@@ -62,12 +62,12 @@ discard block |
||
62 | 62 | protected function __getZappableSleepProps(&$exprops) |
63 | 63 | { |
64 | 64 | parent::__getZappableSleepProps($exprops); |
65 | - if ($this->_flags===0) |
|
66 | - $exprops[] = "\0TFont\0_flags"; |
|
67 | - if ($this->_name==='') |
|
68 | - $exprops[] = "\0TFont\0_name"; |
|
69 | - if ($this->_size==='') |
|
70 | - $exprops[] = "\0TFont\0_size"; |
|
65 | + if($this->_flags===0) |
|
66 | + $exprops[]="\0TFont\0_flags"; |
|
67 | + if($this->_name==='') |
|
68 | + $exprops[]="\0TFont\0_name"; |
|
69 | + if($this->_size==='') |
|
70 | + $exprops[]="\0TFont\0_size"; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -83,11 +83,11 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function setBold($value) |
85 | 85 | { |
86 | - $this->_flags |= self::IS_SET_BOLD; |
|
86 | + $this->_flags|=self::IS_SET_BOLD; |
|
87 | 87 | if(TPropertyValue::ensureBoolean($value)) |
88 | - $this->_flags |= self::IS_BOLD; |
|
88 | + $this->_flags|=self::IS_BOLD; |
|
89 | 89 | else |
90 | - $this->_flags &= ~self::IS_BOLD; |
|
90 | + $this->_flags&=~self::IS_BOLD; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function setItalic($value) |
105 | 105 | { |
106 | - $this->_flags |= self::IS_SET_ITALIC; |
|
106 | + $this->_flags|=self::IS_SET_ITALIC; |
|
107 | 107 | if(TPropertyValue::ensureBoolean($value)) |
108 | - $this->_flags |= self::IS_ITALIC; |
|
108 | + $this->_flags|=self::IS_ITALIC; |
|
109 | 109 | else |
110 | - $this->_flags &= ~self::IS_ITALIC; |
|
110 | + $this->_flags&=~self::IS_ITALIC; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function setOverline($value) |
125 | 125 | { |
126 | - $this->_flags |= self::IS_SET_OVERLINE; |
|
126 | + $this->_flags|=self::IS_SET_OVERLINE; |
|
127 | 127 | if(TPropertyValue::ensureBoolean($value)) |
128 | - $this->_flags |= self::IS_OVERLINE; |
|
128 | + $this->_flags|=self::IS_OVERLINE; |
|
129 | 129 | else |
130 | - $this->_flags &= ~self::IS_OVERLINE; |
|
130 | + $this->_flags&=~self::IS_OVERLINE; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function setSize($value) |
145 | 145 | { |
146 | - $this->_flags |= self::IS_SET_SIZE; |
|
146 | + $this->_flags|=self::IS_SET_SIZE; |
|
147 | 147 | $this->_size=$value; |
148 | 148 | } |
149 | 149 | |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function setStrikeout($value) |
162 | 162 | { |
163 | - $this->_flags |= self::IS_SET_STRIKEOUT; |
|
163 | + $this->_flags|=self::IS_SET_STRIKEOUT; |
|
164 | 164 | if(TPropertyValue::ensureBoolean($value)) |
165 | - $this->_flags |= self::IS_STRIKEOUT; |
|
165 | + $this->_flags|=self::IS_STRIKEOUT; |
|
166 | 166 | else |
167 | - $this->_flags &= ~self::IS_STRIKEOUT; |
|
167 | + $this->_flags&=~self::IS_STRIKEOUT; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function setUnderline($value) |
182 | 182 | { |
183 | - $this->_flags |= self::IS_SET_UNDERLINE; |
|
183 | + $this->_flags|=self::IS_SET_UNDERLINE; |
|
184 | 184 | if(TPropertyValue::ensureBoolean($value)) |
185 | - $this->_flags |= self::IS_UNDERLINE; |
|
185 | + $this->_flags|=self::IS_UNDERLINE; |
|
186 | 186 | else |
187 | - $this->_flags &= ~self::IS_UNDERLINE; |
|
187 | + $this->_flags&=~self::IS_UNDERLINE; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | */ |
201 | 201 | public function setName($value) |
202 | 202 | { |
203 | - $this->_flags |= self::IS_SET_NAME; |
|
203 | + $this->_flags|=self::IS_SET_NAME; |
|
204 | 204 | $this->_name=$value; |
205 | 205 | } |
206 | 206 | |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | return ''; |
284 | 284 | $str=''; |
285 | 285 | if($this->_flags & self::IS_SET_BOLD) |
286 | - $str.='font-weight:'.(($this->_flags & self::IS_BOLD)?'bold;':'normal;'); |
|
286 | + $str.='font-weight:'.(($this->_flags & self::IS_BOLD) ? 'bold;' : 'normal;'); |
|
287 | 287 | if($this->_flags & self::IS_SET_ITALIC) |
288 | - $str.='font-style:'.(($this->_flags & self::IS_ITALIC)?'italic;':'normal;'); |
|
288 | + $str.='font-style:'.(($this->_flags & self::IS_ITALIC) ? 'italic;' : 'normal;'); |
|
289 | 289 | $textDec=''; |
290 | 290 | if($this->_flags & self::IS_UNDERLINE) |
291 | 291 | $textDec.='underline'; |
@@ -312,9 +312,9 @@ discard block |
||
312 | 312 | if($this->_flags===0) |
313 | 313 | return; |
314 | 314 | if($this->_flags & self::IS_SET_BOLD) |
315 | - $writer->addStyleAttribute('font-weight',(($this->_flags & self::IS_BOLD)?'bold':'normal')); |
|
315 | + $writer->addStyleAttribute('font-weight', (($this->_flags & self::IS_BOLD) ? 'bold' : 'normal')); |
|
316 | 316 | if($this->_flags & self::IS_SET_ITALIC) |
317 | - $writer->addStyleAttribute('font-style',(($this->_flags & self::IS_ITALIC)?'italic':'normal')); |
|
317 | + $writer->addStyleAttribute('font-style', (($this->_flags & self::IS_ITALIC) ? 'italic' : 'normal')); |
|
318 | 318 | $textDec=''; |
319 | 319 | if($this->_flags & self::IS_UNDERLINE) |
320 | 320 | $textDec.='underline'; |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | $textDec.=' line-through'; |
325 | 325 | $textDec=ltrim($textDec); |
326 | 326 | if($textDec!=='') |
327 | - $writer->addStyleAttribute('text-decoration',$textDec); |
|
327 | + $writer->addStyleAttribute('text-decoration', $textDec); |
|
328 | 328 | if($this->_size!=='') |
329 | - $writer->addStyleAttribute('font-size',$this->_size); |
|
329 | + $writer->addStyleAttribute('font-size', $this->_size); |
|
330 | 330 | if($this->_name!=='') |
331 | - $writer->addStyleAttribute('font-family',$this->_name); |
|
331 | + $writer->addStyleAttribute('font-family', $this->_name); |
|
332 | 332 | } |
333 | 333 | } |
@@ -76,15 +76,15 @@ |
||
76 | 76 | } |
77 | 77 | catch(Exception $e) |
78 | 78 | { |
79 | - throw new TInvalidDataValueException('conditional_condition_invalid',$this->_condition,$e->getMessage()); |
|
79 | + throw new TInvalidDataValueException('conditional_condition_invalid', $this->_condition, $e->getMessage()); |
|
80 | 80 | } |
81 | 81 | if($result) |
82 | 82 | { |
83 | 83 | if($this->_trueTemplate) |
84 | - $this->_trueTemplate->instantiateIn($this->getTemplateControl(),$this); |
|
84 | + $this->_trueTemplate->instantiateIn($this->getTemplateControl(), $this); |
|
85 | 85 | } |
86 | 86 | else if($this->_falseTemplate) |
87 | - $this->_falseTemplate->instantiateIn($this->getTemplateControl(),$this); |
|
87 | + $this->_falseTemplate->instantiateIn($this->getTemplateControl(), $this); |
|
88 | 88 | $this->_creatingChildren=false; |
89 | 89 | } |
90 | 90 |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | { |
54 | 54 | $uniqueID=$this->getUniqueID(); |
55 | 55 | $this->getPage()->ensureRenderInForm($this); |
56 | - $writer->addAttribute('type','hidden'); |
|
56 | + $writer->addAttribute('type', 'hidden'); |
|
57 | 57 | if($uniqueID!=='') |
58 | - $writer->addAttribute('name',$uniqueID); |
|
58 | + $writer->addAttribute('name', $uniqueID); |
|
59 | 59 | if($this->getID()!=='') |
60 | - $writer->addAttribute('id',$this->getClientID()); |
|
60 | + $writer->addAttribute('id', $this->getClientID()); |
|
61 | 61 | if(($value=$this->getValue())!=='') |
62 | - $writer->addAttribute('value',$value); |
|
62 | + $writer->addAttribute('value', $value); |
|
63 | 63 | |
64 | 64 | if($this->getHasAttributes()) |
65 | 65 | { |
66 | 66 | foreach($this->getAttributes() as $name=>$value) |
67 | - $writer->addAttribute($name,$value); |
|
67 | + $writer->addAttribute($name, $value); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | $writer->renderBeginTag('input'); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param array the input data collection |
79 | 79 | * @return boolean whether the data of the component has been changed |
80 | 80 | */ |
81 | - public function loadPostData($key,$values) |
|
81 | + public function loadPostData($key, $values) |
|
82 | 82 | { |
83 | 83 | $value=$values[$key]; |
84 | 84 | if($value===$this->getValue()) |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function onValueChanged($param) |
148 | 148 | { |
149 | - $this->raiseEvent('OnValueChanged',$this,$param); |
|
149 | + $this->raiseEvent('OnValueChanged', $this, $param); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function getValue() |
156 | 156 | { |
157 | - return $this->getViewState('Value',''); |
|
157 | + return $this->getViewState('Value', ''); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | */ |
164 | 164 | public function setValue($value) |
165 | 165 | { |
166 | - $this->setViewState('Value',$value,''); |
|
166 | + $this->setViewState('Value', $value, ''); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function getTagName() |
39 | 39 | { |
40 | - return ($this->_tagName !== null) ? $this->_tagName : ($this->_tagName = $this->getDefaultTagName()); |
|
40 | + return ($this->_tagName!==null) ? $this->_tagName : ($this->_tagName=$this->getDefaultTagName()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -61,6 +61,6 @@ discard block |
||
61 | 61 | * @return boolean true if TagName has deviated from the default. |
62 | 62 | */ |
63 | 63 | public function getIsMutated() { |
64 | - return $this->_tagName !== null && $this->_tagName != $this->getDefaultTagName(); |
|
64 | + return $this->_tagName!==null && $this->_tagName!=$this->getDefaultTagName(); |
|
65 | 65 | } |
66 | 66 | } |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | * @package System.Web.UI.WebControls.assets |
10 | 10 | */ |
11 | 11 | |
12 | -define('THEME_OPAQUE_BACKGROUND',0x0001); |
|
13 | -define('THEME_NOISY_BACKGROUND',0x0002); |
|
14 | -define('THEME_HAS_GRID',0x0004); |
|
15 | -define('THEME_HAS_SCRIBBLE',0x0008); |
|
16 | -define('THEME_MORPH_BACKGROUND',0x0010); |
|
17 | -define('THEME_SHADOWED_TEXT',0x0020); |
|
12 | +define('THEME_OPAQUE_BACKGROUND', 0x0001); |
|
13 | +define('THEME_NOISY_BACKGROUND', 0x0002); |
|
14 | +define('THEME_HAS_GRID', 0x0004); |
|
15 | +define('THEME_HAS_SCRIBBLE', 0x0008); |
|
16 | +define('THEME_MORPH_BACKGROUND', 0x0010); |
|
17 | +define('THEME_SHADOWED_TEXT', 0x0020); |
|
18 | 18 | |
19 | 19 | require_once(dirname(__FILE__).'/captcha_key.php'); |
20 | 20 | |
@@ -24,10 +24,10 @@ discard block |
||
24 | 24 | if(isset($_GET['options'])) |
25 | 25 | { |
26 | 26 | $str=base64_decode($_GET['options']); |
27 | - if(strlen($str)>32) |
|
27 | + if(strlen($str) > 32) |
|
28 | 28 | { |
29 | - $hash=substr($str,0,32); |
|
30 | - $str=substr($str,32); |
|
29 | + $hash=substr($str, 0, 32); |
|
30 | + $str=substr($str, 32); |
|
31 | 31 | if(md5($privateKey.$str)===$hash) |
32 | 32 | { |
33 | 33 | $options=unserialize($str); |
@@ -37,83 +37,82 @@ discard block |
||
37 | 37 | $alphabet=$options['alphabet']; |
38 | 38 | $fontSize=$options['fontSize']; |
39 | 39 | $theme=$options['theme']; |
40 | - if(($randomSeed=$options['randomSeed'])>0) |
|
40 | + if(($randomSeed=$options['randomSeed']) > 0) |
|
41 | 41 | srand($randomSeed); |
42 | 42 | else |
43 | - srand((int)(microtime()*1000000)); |
|
44 | - $token=generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive); |
|
43 | + srand((int) (microtime() * 1000000)); |
|
44 | + $token=generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | } |
48 | 48 | |
49 | -displayToken($token,$fontSize,$theme); |
|
49 | +displayToken($token, $fontSize, $theme); |
|
50 | 50 | |
51 | -function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive) |
|
51 | +function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive) |
|
52 | 52 | { |
53 | - $token=substr(hash2string(md5($publicKey.$privateKey),$alphabet).hash2string(md5($privateKey.$publicKey),$alphabet),0,$tokenLength); |
|
54 | - return $caseSensitive?$token:strtoupper($token); |
|
53 | + $token=substr(hash2string(md5($publicKey.$privateKey), $alphabet).hash2string(md5($privateKey.$publicKey), $alphabet), 0, $tokenLength); |
|
54 | + return $caseSensitive ? $token : strtoupper($token); |
|
55 | 55 | } |
56 | 56 | |
57 | -function hash2string($hex,$alphabet) |
|
57 | +function hash2string($hex, $alphabet) |
|
58 | 58 | { |
59 | - if(strlen($alphabet)<2) |
|
59 | + if(strlen($alphabet) < 2) |
|
60 | 60 | $alphabet='234578adefhijmnrtABDEFGHJLMNRT'; |
61 | 61 | $hexLength=strlen($hex); |
62 | 62 | $base=strlen($alphabet); |
63 | 63 | $result=''; |
64 | - for($i=0;$i<$hexLength;$i+=6) |
|
64 | + for($i=0; $i < $hexLength; $i+=6) |
|
65 | 65 | { |
66 | - $number=hexdec(substr($hex,$i,6)); |
|
66 | + $number=hexdec(substr($hex, $i, 6)); |
|
67 | 67 | while($number) |
68 | 68 | { |
69 | - $result.=$alphabet[$number%$base]; |
|
70 | - $number=floor($number/$base); |
|
69 | + $result.=$alphabet[$number % $base]; |
|
70 | + $number=floor($number / $base); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | return $result; |
74 | 74 | } |
75 | 75 | |
76 | -function displayToken($token,$fontSize,$theme) |
|
76 | +function displayToken($token, $fontSize, $theme) |
|
77 | 77 | { |
78 | - if(($fontSize=(int)$fontSize)<22) |
|
78 | + if(($fontSize=(int) $fontSize) < 22) |
|
79 | 79 | $fontSize=22; |
80 | - if($fontSize>100) |
|
80 | + if($fontSize > 100) |
|
81 | 81 | $fontSize=100; |
82 | 82 | $length=strlen($token); |
83 | 83 | $padding=10; |
84 | 84 | $fontWidth=$fontSize; |
85 | - $fontHeight=floor($fontWidth*1.5); |
|
86 | - $width=$fontWidth*$length+$padding*2; |
|
85 | + $fontHeight=floor($fontWidth * 1.5); |
|
86 | + $width=$fontWidth * $length + $padding * 2; |
|
87 | 87 | $height=$fontHeight; |
88 | - $image=imagecreatetruecolor($width,$height); |
|
88 | + $image=imagecreatetruecolor($width, $height); |
|
89 | 89 | |
90 | - addBackground |
|
91 | - ( |
|
90 | + addBackground( |
|
92 | 91 | $image, $width, $height, |
93 | - $theme&THEME_OPAQUE_BACKGROUND, |
|
94 | - $theme&THEME_NOISY_BACKGROUND, |
|
95 | - $theme&THEME_HAS_GRID, |
|
96 | - $theme&THEME_HAS_SCRIBBLE, |
|
97 | - $theme&THEME_MORPH_BACKGROUND |
|
92 | + $theme & THEME_OPAQUE_BACKGROUND, |
|
93 | + $theme & THEME_NOISY_BACKGROUND, |
|
94 | + $theme & THEME_HAS_GRID, |
|
95 | + $theme & THEME_HAS_SCRIBBLE, |
|
96 | + $theme & THEME_MORPH_BACKGROUND |
|
98 | 97 | ); |
99 | 98 | |
100 | 99 | $font=dirname(__FILE__).DIRECTORY_SEPARATOR.'verase.ttf'; |
101 | 100 | |
102 | 101 | if(function_exists('imagefilter')) |
103 | - imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR); |
|
102 | + imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR); |
|
104 | 103 | |
105 | - $hasShadow=($theme&THEME_SHADOWED_TEXT); |
|
106 | - for($i=0;$i<$length;$i++) |
|
104 | + $hasShadow=($theme & THEME_SHADOWED_TEXT); |
|
105 | + for($i=0; $i < $length; $i++) |
|
107 | 106 | { |
108 | - $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); |
|
109 | - $size=rand($fontWidth-10,$fontWidth); |
|
110 | - $angle=rand(-30,30); |
|
111 | - $x=$padding+$i*$fontWidth; |
|
112 | - $y=rand($fontHeight-15,$fontHeight-10); |
|
113 | - imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]); |
|
107 | + $color=imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220)); |
|
108 | + $size=rand($fontWidth - 10, $fontWidth); |
|
109 | + $angle=rand(-30, 30); |
|
110 | + $x=$padding + $i * $fontWidth; |
|
111 | + $y=rand($fontHeight - 15, $fontHeight - 10); |
|
112 | + imagettftext($image, $size, $angle, $x, $y, $color, $font, $token[$i]); |
|
114 | 113 | if($hasShadow) |
115 | - imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]); |
|
116 | - imagecolordeallocate($image,$color); |
|
114 | + imagettftext($image, $size, $angle, $x + 2, $y + 2, $color, $font, $token[$i]); |
|
115 | + imagecolordeallocate($image, $color); |
|
117 | 116 | } |
118 | 117 | |
119 | 118 | header('Content-Type: image/png'); |
@@ -121,103 +120,103 @@ discard block |
||
121 | 120 | imagedestroy($image); |
122 | 121 | } |
123 | 122 | |
124 | -function addBackground($image,$width,$height,$opaque,$noisy,$hasGrid,$hasScribble,$morph) |
|
123 | +function addBackground($image, $width, $height, $opaque, $noisy, $hasGrid, $hasScribble, $morph) |
|
125 | 124 | { |
126 | - $background=imagecreatetruecolor($width*2,$height*2); |
|
127 | - $white=imagecolorallocate($background,255,255,255); |
|
128 | - imagefill($background,0,0,$white); |
|
125 | + $background=imagecreatetruecolor($width * 2, $height * 2); |
|
126 | + $white=imagecolorallocate($background, 255, 255, 255); |
|
127 | + imagefill($background, 0, 0, $white); |
|
129 | 128 | |
130 | 129 | if($opaque) |
131 | - imagefill($background,0,0,imagecolorallocate($background,100,100,100)); |
|
130 | + imagefill($background, 0, 0, imagecolorallocate($background, 100, 100, 100)); |
|
132 | 131 | |
133 | 132 | if($noisy) |
134 | - addNoise($background,$width*2,$height*2); |
|
133 | + addNoise($background, $width * 2, $height * 2); |
|
135 | 134 | |
136 | 135 | if($hasGrid) |
137 | - addGrid($background,$width*2,$height*2); |
|
136 | + addGrid($background, $width * 2, $height * 2); |
|
138 | 137 | |
139 | 138 | if($hasScribble) |
140 | - addScribble($background,$width*2,$height*2); |
|
139 | + addScribble($background, $width * 2, $height * 2); |
|
141 | 140 | |
142 | 141 | if($morph) |
143 | - morphImage($background,$width*2,$height*2); |
|
142 | + morphImage($background, $width * 2, $height * 2); |
|
144 | 143 | |
145 | - imagecopy($image,$background,0,0,30,30,$width,$height); |
|
144 | + imagecopy($image, $background, 0, 0, 30, 30, $width, $height); |
|
146 | 145 | |
147 | 146 | if(!$opaque) |
148 | - imagecolortransparent($image,$white); |
|
147 | + imagecolortransparent($image, $white); |
|
149 | 148 | } |
150 | 149 | |
151 | -function addNoise($image,$width,$height) |
|
150 | +function addNoise($image, $width, $height) |
|
152 | 151 | { |
153 | - for($x=0;$x<$width;++$x) |
|
152 | + for($x=0; $x < $width; ++$x) |
|
154 | 153 | { |
155 | - for($y=0;$y<$height;++$y) |
|
154 | + for($y=0; $y < $height; ++$y) |
|
156 | 155 | { |
157 | - if(rand(0,100)<25) |
|
156 | + if(rand(0, 100) < 25) |
|
158 | 157 | { |
159 | - $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); |
|
160 | - imagesetpixel($image,$x,$y,$color); |
|
161 | - imagecolordeallocate($image,$color); |
|
158 | + $color=imagecolorallocate($image, rand(150, 220), rand(150, 220), rand(150, 220)); |
|
159 | + imagesetpixel($image, $x, $y, $color); |
|
160 | + imagecolordeallocate($image, $color); |
|
162 | 161 | } |
163 | 162 | } |
164 | 163 | } |
165 | 164 | } |
166 | 165 | |
167 | -function addGrid($image,$width,$height) |
|
166 | +function addGrid($image, $width, $height) |
|
168 | 167 | { |
169 | - for($i=0;$i<$width;$i+=rand(15,25)) |
|
168 | + for($i=0; $i < $width; $i+=rand(15, 25)) |
|
170 | 169 | { |
171 | - imagesetthickness($image,rand(2,6)); |
|
172 | - $color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180)); |
|
173 | - imageline($image,$i+rand(-10,20),0,$i+rand(-10,20),$height,$color); |
|
174 | - imagecolordeallocate($image,$color); |
|
170 | + imagesetthickness($image, rand(2, 6)); |
|
171 | + $color=imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
|
172 | + imageline($image, $i + rand(-10, 20), 0, $i + rand(-10, 20), $height, $color); |
|
173 | + imagecolordeallocate($image, $color); |
|
175 | 174 | } |
176 | - for($i=0;$i<$height;$i+=rand(15,25)) |
|
175 | + for($i=0; $i < $height; $i+=rand(15, 25)) |
|
177 | 176 | { |
178 | - imagesetthickness($image,rand(2,6)); |
|
179 | - $color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180)); |
|
180 | - imageline($image,0,$i+rand(-10,20),$width,$i+rand(-10,20),$color); |
|
181 | - imagecolordeallocate($image,$color); |
|
177 | + imagesetthickness($image, rand(2, 6)); |
|
178 | + $color=imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
|
179 | + imageline($image, 0, $i + rand(-10, 20), $width, $i + rand(-10, 20), $color); |
|
180 | + imagecolordeallocate($image, $color); |
|
182 | 181 | } |
183 | 182 | } |
184 | 183 | |
185 | -function addScribble($image,$width,$height) |
|
184 | +function addScribble($image, $width, $height) |
|
186 | 185 | { |
187 | - for($i=0;$i<8;$i++) |
|
186 | + for($i=0; $i < 8; $i++) |
|
188 | 187 | { |
189 | - $color=imagecolorallocate($image,rand(100,180),rand(100,180),rand(100,180)); |
|
188 | + $color=imagecolorallocate($image, rand(100, 180), rand(100, 180), rand(100, 180)); |
|
190 | 189 | $points=array(); |
191 | - for($j=1;$j<rand(5,10);$j++) |
|
190 | + for($j=1; $j < rand(5, 10); $j++) |
|
192 | 191 | { |
193 | - $points[]=rand(2*(20*($i+1)),2*(50*($i+1))); |
|
194 | - $points[]=rand(30,$height+30); |
|
192 | + $points[]=rand(2 * (20 * ($i + 1)), 2 * (50 * ($i + 1))); |
|
193 | + $points[]=rand(30, $height + 30); |
|
195 | 194 | } |
196 | - imagesetthickness($image,rand(2,6)); |
|
197 | - imagepolygon($image,$points,intval(sizeof($points)/2),$color); |
|
198 | - imagecolordeallocate($image,$color); |
|
195 | + imagesetthickness($image, rand(2, 6)); |
|
196 | + imagepolygon($image, $points, intval(sizeof($points) / 2), $color); |
|
197 | + imagecolordeallocate($image, $color); |
|
199 | 198 | } |
200 | 199 | } |
201 | 200 | |
202 | -function morphImage($image,$width,$height) |
|
201 | +function morphImage($image, $width, $height) |
|
203 | 202 | { |
204 | - $tempImage=imagecreatetruecolor($width,$height); |
|
205 | - $chunk=rand(1,5); |
|
206 | - for($x=$y=0;$x<$width;$x+=$chunk) |
|
203 | + $tempImage=imagecreatetruecolor($width, $height); |
|
204 | + $chunk=rand(1, 5); |
|
205 | + for($x=$y=0; $x < $width; $x+=$chunk) |
|
207 | 206 | { |
208 | - $chunk=rand(1,5); |
|
209 | - $y+=rand(-1,1); |
|
210 | - if($y>=$height) $y=$height-5; |
|
211 | - if($y<0) $y=5; |
|
212 | - imagecopy($tempImage,$image,$x,0,$x,$y,$chunk,$height); |
|
207 | + $chunk=rand(1, 5); |
|
208 | + $y+=rand(-1, 1); |
|
209 | + if($y >= $height) $y=$height - 5; |
|
210 | + if($y < 0) $y=5; |
|
211 | + imagecopy($tempImage, $image, $x, 0, $x, $y, $chunk, $height); |
|
213 | 212 | } |
214 | - for($x=$y=0;$y<$height;$y+=$chunk) |
|
213 | + for($x=$y=0; $y < $height; $y+=$chunk) |
|
215 | 214 | { |
216 | - $chunk=rand(1,5); |
|
217 | - $x+=rand(-1,1); |
|
218 | - if($x>=$width) $x=$width-5; |
|
219 | - if($x<0) $x=5; |
|
220 | - imagecopy($image,$tempImage,$x,$y,0,$y,$width,$chunk); |
|
215 | + $chunk=rand(1, 5); |
|
216 | + $x+=rand(-1, 1); |
|
217 | + if($x >= $width) $x=$width - 5; |
|
218 | + if($x < 0) $x=5; |
|
219 | + imagecopy($image, $tempImage, $x, $y, 0, $y, $width, $chunk); |
|
221 | 220 | } |
222 | 221 | } |
223 | 222 |
@@ -39,7 +39,7 @@ |
||
39 | 39 | { |
40 | 40 | if(($id=$this->getID())==='') |
41 | 41 | throw new TConfigurationException('contentplaceholder_id_required'); |
42 | - $this->getTemplateControl()->registerContentPlaceHolder($id,$this); |
|
42 | + $this->getTemplateControl()->registerContentPlaceHolder($id, $this); |
|
43 | 43 | $parent->getControls()->add($this); |
44 | 44 | } |
45 | 45 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | public function addParsedObject($object) |
44 | 44 | { |
45 | 45 | if(is_string($object)) |
46 | - $object=html_entity_decode($object,ENT_QUOTES,'UTF-8'); |
|
46 | + $object=html_entity_decode($object, ENT_QUOTES, 'UTF-8'); |
|
47 | 47 | parent::addParsedObject($object); |
48 | 48 | } |
49 | 49 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getText() |
54 | 54 | { |
55 | - return $this->getViewState('Text',''); |
|
55 | + return $this->getViewState('Text', ''); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function setText($value) |
62 | 62 | { |
63 | - $this->setViewState('Text',$value); |
|
63 | + $this->setViewState('Text', $value); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | if(($text=$this->getText())==='' && $this->getHasControls()) |
75 | 75 | { |
76 | - $htmlWriter = Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
76 | + $htmlWriter=Prado::createComponent($this->GetResponse()->getHtmlWriterType(), new TTextWriter()); |
|
77 | 77 | parent::renderContents($htmlWriter); |
78 | 78 | $text=$htmlWriter->flush(); |
79 | 79 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function getDataField() |
40 | 40 | { |
41 | - return $this->getViewState('DataField',''); |
|
41 | + return $this->getViewState('DataField', ''); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public function setDataField($value) |
48 | 48 | { |
49 | - $this->setViewState('DataField',$value,''); |
|
49 | + $this->setViewState('DataField', $value, ''); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function getDataFormatString() |
56 | 56 | { |
57 | - return $this->getViewState('DataFormatString',''); |
|
57 | + return $this->getViewState('DataFormatString', ''); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function setDataFormatString($value) |
64 | 64 | { |
65 | - $this->setViewState('DataFormatString',$value,''); |
|
65 | + $this->setViewState('DataFormatString', $value, ''); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function getText() |
72 | 72 | { |
73 | - return $this->getViewState('Text',''); |
|
73 | + return $this->getViewState('Text', ''); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function setText($value) |
80 | 80 | { |
81 | - $this->setViewState('Text',$value,''); |
|
81 | + $this->setViewState('Text', $value, ''); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | public function getEncode() |
88 | 88 | { |
89 | - return $this->getViewState('Encode',false); |
|
89 | + return $this->getViewState('Encode', false); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function setEncode($value) |
96 | 96 | { |
97 | - $this->setViewState('Encode',TPropertyValue::ensureBoolean($value),false); |
|
97 | + $this->setViewState('Encode', TPropertyValue::ensureBoolean($value), false); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | * @param integer the index to the Columns property that the cell resides in. |
105 | 105 | * @param string the type of cell (Header,Footer,Item,AlternatingItem,EditItem,SelectedItem) |
106 | 106 | */ |
107 | - public function initializeCell($cell,$columnIndex,$itemType) |
|
107 | + public function initializeCell($cell, $columnIndex, $itemType) |
|
108 | 108 | { |
109 | 109 | if($itemType===TListItemType::Item || $itemType===TListItemType::AlternatingItem || $itemType===TListItemType::EditItem || $itemType===TListItemType::SelectedItem) |
110 | 110 | { |
111 | 111 | if($this->getDataField()!=='') |
112 | 112 | { |
113 | - $cell->attachEventHandler('OnDataBinding',array($this,'dataBindColumn')); |
|
113 | + $cell->attachEventHandler('OnDataBinding', array($this, 'dataBindColumn')); |
|
114 | 114 | } else { |
115 | 115 | $text=$this->getText(); |
116 | 116 | if($this->getEncode()) |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | } |
121 | 121 | else |
122 | - parent::initializeCell($cell,$columnIndex,$itemType); |
|
122 | + parent::initializeCell($cell, $columnIndex, $itemType); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | * This method is invoked when datagrid performs databinding. |
128 | 128 | * It populates the content of the cell with the relevant data from data source. |
129 | 129 | */ |
130 | - public function dataBindColumn($sender,$param) |
|
130 | + public function dataBindColumn($sender, $param) |
|
131 | 131 | { |
132 | 132 | $item=$sender->getNamingContainer(); |
133 | 133 | $data=$item->getData(); |
134 | 134 | $formatString=$this->getDataFormatString(); |
135 | 135 | if(($field=$this->getDataField())!=='') |
136 | - $value=$this->formatDataValue($formatString,$this->getDataFieldValue($data,$field)); |
|
136 | + $value=$this->formatDataValue($formatString, $this->getDataFieldValue($data, $field)); |
|
137 | 137 | else |
138 | - $value=$this->formatDataValue($formatString,$data); |
|
138 | + $value=$this->formatDataValue($formatString, $data); |
|
139 | 139 | if($sender instanceof TTableCell) |
140 | 140 | { |
141 | 141 | if($this->getEncode()) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public function getTokenImageTheme() |
73 | 73 | { |
74 | - return $this->getViewState('TokenImageTheme',0); |
|
74 | + return $this->getViewState('TokenImageTheme', 0); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | public function setTokenImageTheme($value) |
91 | 91 | { |
92 | 92 | $value=TPropertyValue::ensureInteger($value); |
93 | - if($value>=0 && $value<=63) |
|
94 | - $this->setViewState('TokenImageTheme',$value,0); |
|
93 | + if($value >= 0 && $value <= 63) |
|
94 | + $this->setViewState('TokenImageTheme', $value, 0); |
|
95 | 95 | else |
96 | - throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63); |
|
96 | + throw new TConfigurationException('captcha_tokenimagetheme_invalid', 0, 63); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function getTokenFontSize() |
103 | 103 | { |
104 | - return $this->getViewState('TokenFontSize',30); |
|
104 | + return $this->getViewState('TokenFontSize', 30); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | public function setTokenFontSize($value) |
114 | 114 | { |
115 | 115 | $value=TPropertyValue::ensureInteger($value); |
116 | - if($value>=20 && $value<=100) |
|
117 | - $this->setViewState('TokenFontSize',$value,30); |
|
116 | + if($value >= 20 && $value <= 100) |
|
117 | + $this->setViewState('TokenFontSize', $value, 30); |
|
118 | 118 | else |
119 | - throw new TConfigurationException('captcha_tokenfontsize_invalid',20,100); |
|
119 | + throw new TConfigurationException('captcha_tokenfontsize_invalid', 20, 100); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function getMinTokenLength() |
126 | 126 | { |
127 | - return $this->getViewState('MinTokenLength',4); |
|
127 | + return $this->getViewState('MinTokenLength', 4); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | public function setMinTokenLength($value) |
134 | 134 | { |
135 | 135 | $length=TPropertyValue::ensureInteger($value); |
136 | - if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) |
|
137 | - $this->setViewState('MinTokenLength',$length,4); |
|
136 | + if($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) |
|
137 | + $this->setViewState('MinTokenLength', $length, 4); |
|
138 | 138 | else |
139 | - throw new TConfigurationException('captcha_mintokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH); |
|
139 | + throw new TConfigurationException('captcha_mintokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function getMaxTokenLength() |
146 | 146 | { |
147 | - return $this->getViewState('MaxTokenLength',6); |
|
147 | + return $this->getViewState('MaxTokenLength', 6); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -153,10 +153,10 @@ discard block |
||
153 | 153 | public function setMaxTokenLength($value) |
154 | 154 | { |
155 | 155 | $length=TPropertyValue::ensureInteger($value); |
156 | - if($length>=self::MIN_TOKEN_LENGTH && $length<=self::MAX_TOKEN_LENGTH) |
|
157 | - $this->setViewState('MaxTokenLength',$length,6); |
|
156 | + if($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) |
|
157 | + $this->setViewState('MaxTokenLength', $length, 6); |
|
158 | 158 | else |
159 | - throw new TConfigurationException('captcha_maxtokenlength_invalid',self::MIN_TOKEN_LENGTH,self::MAX_TOKEN_LENGTH); |
|
159 | + throw new TConfigurationException('captcha_maxtokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function getCaseSensitive() |
166 | 166 | { |
167 | - return $this->getViewState('CaseSensitive',true); |
|
167 | + return $this->getViewState('CaseSensitive', true); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function setCaseSensitive($value) |
174 | 174 | { |
175 | - $this->setViewState('CaseSensitive',TPropertyValue::ensureBoolean($value),true); |
|
175 | + $this->setViewState('CaseSensitive', TPropertyValue::ensureBoolean($value), true); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function getTokenAlphabet() |
182 | 182 | { |
183 | - return $this->getViewState('TokenAlphabet','234578adefhijmnrtABDEFGHJLMNRT'); |
|
183 | + return $this->getViewState('TokenAlphabet', '234578adefhijmnrtABDEFGHJLMNRT'); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -188,9 +188,9 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public function setTokenAlphabet($value) |
190 | 190 | { |
191 | - if(strlen($value)<2) |
|
191 | + if(strlen($value) < 2) |
|
192 | 192 | throw new TConfigurationException('captcha_tokenalphabet_invalid'); |
193 | - $this->setViewState('TokenAlphabet',$value,'234578adefhijmnrtABDEFGHJLMNRT'); |
|
193 | + $this->setViewState('TokenAlphabet', $value, '234578adefhijmnrtABDEFGHJLMNRT'); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function getTokenExpiry() |
200 | 200 | { |
201 | - return $this->getViewState('TokenExpiry',600); |
|
201 | + return $this->getViewState('TokenExpiry', 600); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | */ |
207 | 207 | public function setTokenExpiry($value) |
208 | 208 | { |
209 | - $this->setViewState('TokenExpiry',TPropertyValue::ensureInteger($value),600); |
|
209 | + $this->setViewState('TokenExpiry', TPropertyValue::ensureInteger($value), 600); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public function getChangingTokenBackground() |
216 | 216 | { |
217 | - return $this->getViewState('ChangingTokenBackground',false); |
|
217 | + return $this->getViewState('ChangingTokenBackground', false); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function setChangingTokenBackground($value) |
224 | 224 | { |
225 | - $this->setViewState('ChangingTokenBackground',TPropertyValue::ensureBoolean($value),false); |
|
225 | + $this->setViewState('ChangingTokenBackground', TPropertyValue::ensureBoolean($value), false); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | public function getTestLimit() |
232 | 232 | { |
233 | - return $this->getViewState('TestLimit',5); |
|
233 | + return $this->getViewState('TestLimit', 5); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function setTestLimit($value) |
240 | 240 | { |
241 | - $this->setViewState('TestLimit',TPropertyValue::ensureInteger($value),5); |
|
241 | + $this->setViewState('TestLimit', TPropertyValue::ensureInteger($value), 5); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function getIsTokenExpired() |
248 | 248 | { |
249 | - if(($expiry=$this->getTokenExpiry())>0 && ($start=$this->getViewState('TokenGenerated',0))>0) |
|
250 | - return $expiry+$start<time(); |
|
249 | + if(($expiry=$this->getTokenExpiry()) > 0 && ($start=$this->getViewState('TokenGenerated', 0)) > 0) |
|
250 | + return $expiry + $start < time(); |
|
251 | 251 | else |
252 | 252 | return false; |
253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | */ |
258 | 258 | public function getPublicKey() |
259 | 259 | { |
260 | - if(($publicKey=$this->getViewState('PublicKey',''))==='') |
|
260 | + if(($publicKey=$this->getViewState('PublicKey', ''))==='') |
|
261 | 261 | { |
262 | 262 | $publicKey=$this->generateRandomKey(); |
263 | 263 | $this->setPublicKey($publicKey); |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | */ |
271 | 271 | public function setPublicKey($value) |
272 | 272 | { |
273 | - $this->setViewState('PublicKey',$value,''); |
|
273 | + $this->setViewState('PublicKey', $value, ''); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | public function getToken() |
280 | 280 | { |
281 | - return $this->generateToken($this->getPublicKey(),$this->getPrivateKey(),$this->getTokenAlphabet(),$this->getTokenLength(),$this->getCaseSensitive()); |
|
281 | + return $this->generateToken($this->getPublicKey(), $this->getPrivateKey(), $this->getTokenAlphabet(), $this->getTokenLength(), $this->getCaseSensitive()); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | { |
291 | 291 | $minLength=$this->getMinTokenLength(); |
292 | 292 | $maxLength=$this->getMaxTokenLength(); |
293 | - if($minLength>$maxLength) |
|
294 | - $tokenLength=rand($maxLength,$minLength); |
|
295 | - else if($minLength<$maxLength) |
|
296 | - $tokenLength=rand($minLength,$maxLength); |
|
293 | + if($minLength > $maxLength) |
|
294 | + $tokenLength=rand($maxLength, $minLength); |
|
295 | + else if($minLength < $maxLength) |
|
296 | + $tokenLength=rand($minLength, $maxLength); |
|
297 | 297 | else |
298 | 298 | $tokenLength=$minLength; |
299 | - $this->setViewState('TokenLength',$tokenLength); |
|
299 | + $this->setViewState('TokenLength', $tokenLength); |
|
300 | 300 | } |
301 | 301 | return $tokenLength; |
302 | 302 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | $fileName=$this->generatePrivateKeyFile(); |
312 | 312 | $content=file_get_contents($fileName); |
313 | 313 | $matches=array(); |
314 | - if(preg_match("/privateKey='(.*?)'/ms",$content,$matches)>0) |
|
314 | + if(preg_match("/privateKey='(.*?)'/ms", $content, $matches) > 0) |
|
315 | 315 | $this->_privateKey=$matches[1]; |
316 | 316 | else |
317 | 317 | throw new TConfigurationException('captcha_privatekey_unknown'); |
@@ -326,18 +326,18 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function validate($input) |
328 | 328 | { |
329 | - $number=$this->getViewState('TestNumber',0); |
|
329 | + $number=$this->getViewState('TestNumber', 0); |
|
330 | 330 | if(!$this->_validated) |
331 | 331 | { |
332 | - $this->setViewState('TestNumber',++$number); |
|
332 | + $this->setViewState('TestNumber', ++$number); |
|
333 | 333 | $this->_validated=true; |
334 | 334 | } |
335 | - if($this->getIsTokenExpired() || (($limit=$this->getTestLimit())>0 && $number>$limit)) |
|
335 | + if($this->getIsTokenExpired() || (($limit=$this->getTestLimit()) > 0 && $number > $limit)) |
|
336 | 336 | { |
337 | 337 | $this->regenerateToken(); |
338 | 338 | return false; |
339 | 339 | } |
340 | - return ($this->getToken()===($this->getCaseSensitive()?$input:strtoupper($input))); |
|
340 | + return ($this->getToken()===($this->getCaseSensitive() ? $input : strtoupper($input))); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | $this->setPublicKey(''); |
352 | 352 | $this->clearViewState('TokenGenerated'); |
353 | 353 | $this->clearViewState('RandomSeed'); |
354 | - $this->clearViewState('TestNumber',0); |
|
354 | + $this->clearViewState('TestNumber', 0); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | parent::onPreRender($param); |
364 | 364 | if(!self::checkRequirements()) |
365 | 365 | throw new TConfigurationException('captcha_imagettftext_required'); |
366 | - if(!$this->getViewState('TokenGenerated',0)) |
|
366 | + if(!$this->getViewState('TokenGenerated', 0)) |
|
367 | 367 | { |
368 | 368 | $manager=$this->getApplication()->getAssetManager(); |
369 | 369 | $manager->publishFilePath($this->getFontFile()); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | $url.='?options='.urlencode($this->getTokenImageOptions()); |
372 | 372 | $this->setImageUrl($url); |
373 | 373 | |
374 | - $this->setViewState('TokenGenerated',time()); |
|
374 | + $this->setViewState('TokenGenerated', time()); |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | protected function getTokenImageOptions() |
382 | 382 | { |
383 | - $privateKey=$this->getPrivateKey(); // call this method to ensure private key is generated |
|
383 | + $privateKey=$this->getPrivateKey(); // call this method to ensure private key is generated |
|
384 | 384 | $token=$this->getToken(); |
385 | 385 | $options=array(); |
386 | 386 | $options['publicKey']=$this->getPublicKey(); |
@@ -389,12 +389,12 @@ discard block |
||
389 | 389 | $options['alphabet']=$this->getTokenAlphabet(); |
390 | 390 | $options['fontSize']=$this->getTokenFontSize(); |
391 | 391 | $options['theme']=$this->getTokenImageTheme(); |
392 | - if(($randomSeed=$this->getViewState('RandomSeed',0))===0) |
|
392 | + if(($randomSeed=$this->getViewState('RandomSeed', 0))===0) |
|
393 | 393 | { |
394 | - $randomSeed=(int)(microtime()*1000000); |
|
395 | - $this->setViewState('RandomSeed',$randomSeed); |
|
394 | + $randomSeed=(int) (microtime() * 1000000); |
|
395 | + $this->setViewState('RandomSeed', $randomSeed); |
|
396 | 396 | } |
397 | - $options['randomSeed']=$this->getChangingTokenBackground()?0:$randomSeed; |
|
397 | + $options['randomSeed']=$this->getChangingTokenBackground() ? 0 : $randomSeed; |
|
398 | 398 | $str=serialize($options); |
399 | 399 | return base64_encode(md5($privateKey.$str).$str); |
400 | 400 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | $content="<?php |
429 | 429 | \$privateKey='$key'; |
430 | 430 | ?>"; |
431 | - file_put_contents($fileName,$content); |
|
431 | + file_put_contents($fileName, $content); |
|
432 | 432 | } |
433 | 433 | return $fileName; |
434 | 434 | } |
@@ -449,10 +449,10 @@ discard block |
||
449 | 449 | * @param boolean whether the token is case sensitive |
450 | 450 | * @return string the token generated. |
451 | 451 | */ |
452 | - protected function generateToken($publicKey,$privateKey,$alphabet,$tokenLength,$caseSensitive) |
|
452 | + protected function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive) |
|
453 | 453 | { |
454 | - $token=substr($this->hash2string(md5($publicKey.$privateKey),$alphabet).$this->hash2string(md5($privateKey.$publicKey),$alphabet),0,$tokenLength); |
|
455 | - return $caseSensitive?$token:strtoupper($token); |
|
454 | + $token=substr($this->hash2string(md5($publicKey.$privateKey), $alphabet).$this->hash2string(md5($privateKey.$publicKey), $alphabet), 0, $tokenLength); |
|
455 | + return $caseSensitive ? $token : strtoupper($token); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -461,20 +461,20 @@ discard block |
||
461 | 461 | * @param string the alphabet used to represent the converted string. If empty, it means '234578adefhijmnrtwyABDEFGHIJLMNQRTWY', which excludes those confusing characters. |
462 | 462 | * @return string the converted string |
463 | 463 | */ |
464 | - protected function hash2string($hex,$alphabet='') |
|
464 | + protected function hash2string($hex, $alphabet='') |
|
465 | 465 | { |
466 | - if(strlen($alphabet)<2) |
|
466 | + if(strlen($alphabet) < 2) |
|
467 | 467 | $alphabet='234578adefhijmnrtABDEFGHJLMNQRT'; |
468 | 468 | $hexLength=strlen($hex); |
469 | 469 | $base=strlen($alphabet); |
470 | 470 | $result=''; |
471 | - for($i=0;$i<$hexLength;$i+=6) |
|
471 | + for($i=0; $i < $hexLength; $i+=6) |
|
472 | 472 | { |
473 | - $number=hexdec(substr($hex,$i,6)); |
|
473 | + $number=hexdec(substr($hex, $i, 6)); |
|
474 | 474 | while($number) |
475 | 475 | { |
476 | - $result.=$alphabet[$number%$base]; |
|
477 | - $number=floor($number/$base); |
|
476 | + $result.=$alphabet[$number % $base]; |
|
477 | + $number=floor($number / $base); |
|
478 | 478 | } |
479 | 479 | } |
480 | 480 | return $result; |