TYPO3
7.6
Users
bogdan
Projects
Kapeli
Resources
Dash
Docsets
TYPO3
src
vendor
swiftmailer
swiftmailer
lib
classes
Swift
Plugins
AntiFloodPlugin.php
Go to the documentation of this file.
1
<?php
2
3
/*
4
* This file is part of SwiftMailer.
5
* (c) 2004-2009 Chris Corbyn
6
*
7
* For the full copyright and license information, please view the LICENSE
8
* file that was distributed with this source code.
9
*/
10
16
class
Swift_Plugins_AntiFloodPlugin
implements
Swift_Events_SendListener
,
Swift_Plugins_Sleeper
17
{
23
private
$_threshold
;
24
30
private
$_sleep
;
31
37
private
$_counter
= 0;
38
44
private
$_sleeper
;
45
53
public
function
__construct
($threshold = 99, $sleep = 0,
Swift_Plugins_Sleeper
$sleeper = null)
54
{
55
$this->
setThreshold
($threshold);
56
$this->
setSleepTime
($sleep);
57
$this->_sleeper = $sleeper;
58
}
59
65
public
function
setThreshold
($threshold)
66
{
67
$this->_threshold = $threshold;
68
}
69
75
public
function
getThreshold
()
76
{
77
return
$this->_threshold
;
78
}
79
85
public
function
setSleepTime
($sleep)
86
{
87
$this->_sleep = $sleep;
88
}
89
95
public
function
getSleepTime
()
96
{
97
return
$this->_sleep
;
98
}
99
105
public
function
beforeSendPerformed
(
Swift_Events_SendEvent
$evt)
106
{
107
}
108
114
public
function
sendPerformed
(
Swift_Events_SendEvent
$evt)
115
{
116
++
$this->_counter
;
117
if
($this->_counter >= $this->_threshold) {
118
$transport = $evt->
getTransport
();
119
$transport->stop();
120
if
($this->_sleep) {
121
$this->
sleep
($this->_sleep);
122
}
123
$transport->start();
124
$this->_counter = 0;
125
}
126
}
127
133
public
function
sleep
($seconds)
134
{
135
if
(isset($this->_sleeper)) {
136
$this->_sleeper->sleep($seconds);
137
}
else
{
138
sleep
($seconds);
139
}
140
}
141
}
Generated on Wed Nov 11 2015 01:51:50 for TYPO3 by
1.8.3