Changeset 2184
- Timestamp:
- 08/30/2007 11:18:16 AM (17 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
demos/quickstart/protected/pages/Controls/Captcha.page (modified) (1 diff)
-
demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php (modified) (1 diff)
-
framework/Web/UI/WebControls/TCaptcha.php (modified) (2 diffs)
-
framework/Web/UI/WebControls/assets/captcha.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/demos/quickstart/protected/pages/Controls/Captcha.page
r2182 r2184 21 21 22 22 <p> 23 To specify the appearance of the generated token image, set <tt>TokenImageTheme</tt> to be an integer between 0 and 31. You may try the following example to see how this value affects the generated token image. The size of the generated token image is determined by <tt>TokenFontSize</tt>. In particular, the image width is proportional to the font size. You may also set <tt>Width</tt> to scale the generated image to your desired size, but the scaled image may not look good. By setting <tt>ChangingTokenBackground</tt> to true, the image background of the token will be variating even though the token is the same during postbacks.23 To specify the appearance of the generated token image, set <tt>TokenImageTheme</tt> to be an integer between 0 and 63. You may try the following example to see how this value affects the generated token image. The size of the generated token image is determined by <tt>TokenFontSize</tt>. In particular, the image width is proportional to the font size. You may also set <tt>Width</tt> to scale the generated image to your desired size, but the scaled image may not look good. By setting <tt>ChangingTokenBackground</tt> to true, the image background of the token will be variating even though the token is the same during postbacks. 24 24 </p> 25 25 -
trunk/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php
r2175 r2184 7 7 if(!$this->IsPostBack) 8 8 { 9 $this->CaptchaList->DataSource=range(0, 31);9 $this->CaptchaList->DataSource=range(0,63); 10 10 $this->CaptchaList->dataBind(); 11 11 } -
trunk/framework/Web/UI/WebControls/TCaptcha.php
r2182 r2184 33 33 * 34 34 * To specify the appearance of the generated token image, set {@link setTokenImageTheme TokenImageTheme} 35 * to be an integer between 0 and 31. And to adjust the generated image size, set {@link setTokenFontSize TokenFontSize}35 * to be an integer between 0 and 63. And to adjust the generated image size, set {@link setTokenFontSize TokenFontSize} 36 36 * (you may also set {@link TWebControl::setWidth Width}, but the scaled image may not look good.) 37 37 * By setting {@link setChangingTokenBackground ChangingTokenBackground} to true, the image background … … 92 92 * Bit 3: whether we should add some scribbles to the image (1) or not (0). 93 93 * Bit 4: whether the image background should be morphed (1) or not (0). 94 * @param integer the theme of the token image. It must be an integer between 0 and 31. 94 * Bit 5: whether the token text should cast a shadow (1) or not (0). 95 * @param integer the theme of the token image. It must be an integer between 0 and 63. 95 96 */ 96 97 public function setTokenImageTheme($value) 97 98 { 98 99 $value=TPropertyValue::ensureInteger($value); 99 if($value>=0 && $value<= 31)100 if($value>=0 && $value<=63) 100 101 $this->setViewState('TokenImageTheme',$value,0); 101 102 else 102 throw new TConfigurationException('captcha_tokenimagetheme_invalid',0, 31);103 throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63); 103 104 } 104 105 -
trunk/framework/Web/UI/WebControls/assets/captcha.php
r2182 r2184 16 16 define('THEME_HAS_SCRIBBLE',0x0008); 17 17 define('THEME_MORPH_BACKGROUND',0x0010); 18 define('THEME_SHADOWED_TEXT',0x0020); 18 19 19 20 require_once(dirname(__FILE__).'/captcha_key.php'); … … 103 104 imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR); 104 105 106 $hasShadow=($theme&THEME_SHADOWED_TEXT); 105 107 for($i=0;$i<$length;$i++) 106 108 { 107 109 $color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220)); 108 imagettftext($image,rand($fontWidth-10,$fontWidth),rand(-30, 30),$padding+$i*$fontWidth,rand($fontHeight-15,$fontHeight-10),$color,$font,$token[$i]); 110 $size=rand($fontWidth-10,$fontWidth); 111 $angle=rand(-30,30); 112 $x=$padding+$i*$fontWidth; 113 $y=rand($fontHeight-15,$fontHeight-10); 114 imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]); 115 if($hasShadow) 116 imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]); 109 117 imagecolordeallocate($image,$color); 110 118 }
