summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/quickstart/protected/pages/Controls/Captcha.page2
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php2
-rw-r--r--framework/Web/UI/WebControls/TCaptcha.php9
-rw-r--r--framework/Web/UI/WebControls/assets/captcha.php10
4 files changed, 16 insertions, 7 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Captcha.page b/demos/quickstart/protected/pages/Controls/Captcha.page
index a0af13e5..8a6e8a81 100644
--- a/demos/quickstart/protected/pages/Controls/Captcha.page
+++ b/demos/quickstart/protected/pages/Controls/Captcha.page
@@ -20,7 +20,7 @@ The validation of the token is related with two properties: <tt>TestLimit</tt> (
</p>
<p>
-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.
+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.
</p>
<p>
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php
index 4d54ce87..6965bbbd 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php
+++ b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php
@@ -6,7 +6,7 @@ class Home extends TPage
{
if(!$this->IsPostBack)
{
- $this->CaptchaList->DataSource=range(0,31);
+ $this->CaptchaList->DataSource=range(0,63);
$this->CaptchaList->dataBind();
}
}
diff --git a/framework/Web/UI/WebControls/TCaptcha.php b/framework/Web/UI/WebControls/TCaptcha.php
index 48e57b9e..55cbc940 100644
--- a/framework/Web/UI/WebControls/TCaptcha.php
+++ b/framework/Web/UI/WebControls/TCaptcha.php
@@ -32,7 +32,7 @@ Prado::using('System.Web.UI.WebControls.TImage');
* be tested with on the server side, and the latter says when a generated token will expire.
*
* To specify the appearance of the generated token image, set {@link setTokenImageTheme TokenImageTheme}
- * to be an integer between 0 and 31. And to adjust the generated image size, set {@link setTokenFontSize TokenFontSize}
+ * to be an integer between 0 and 63. And to adjust the generated image size, set {@link setTokenFontSize TokenFontSize}
* (you may also set {@link TWebControl::setWidth Width}, but the scaled image may not look good.)
* By setting {@link setChangingTokenBackground ChangingTokenBackground} to true, the image background
* of the token will be variating even though the token is the same during postbacks.
@@ -91,15 +91,16 @@ class TCaptcha extends TImage
* Bit 2: whether we should add a grid to the image (1) or not (0).
* Bit 3: whether we should add some scribbles to the image (1) or not (0).
* Bit 4: whether the image background should be morphed (1) or not (0).
- * @param integer the theme of the token image. It must be an integer between 0 and 31.
+ * Bit 5: whether the token text should cast a shadow (1) or not (0).
+ * @param integer the theme of the token image. It must be an integer between 0 and 63.
*/
public function setTokenImageTheme($value)
{
$value=TPropertyValue::ensureInteger($value);
- if($value>=0 && $value<=31)
+ if($value>=0 && $value<=63)
$this->setViewState('TokenImageTheme',$value,0);
else
- throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,31);
+ throw new TConfigurationException('captcha_tokenimagetheme_invalid',0,63);
}
/**
diff --git a/framework/Web/UI/WebControls/assets/captcha.php b/framework/Web/UI/WebControls/assets/captcha.php
index 26ed44f4..48c39cb2 100644
--- a/framework/Web/UI/WebControls/assets/captcha.php
+++ b/framework/Web/UI/WebControls/assets/captcha.php
@@ -15,6 +15,7 @@ define('THEME_NOISY_BACKGROUND',0x0002);
define('THEME_HAS_GRID',0x0004);
define('THEME_HAS_SCRIBBLE',0x0008);
define('THEME_MORPH_BACKGROUND',0x0010);
+define('THEME_SHADOWED_TEXT',0x0020);
require_once(dirname(__FILE__).'/captcha_key.php');
@@ -102,10 +103,17 @@ function displayToken($token,$fontSize,$theme)
if(function_exists('imagefilter'))
imagefilter($image,IMG_FILTER_GAUSSIAN_BLUR);
+ $hasShadow=($theme&THEME_SHADOWED_TEXT);
for($i=0;$i<$length;$i++)
{
$color=imagecolorallocate($image,rand(150,220),rand(150,220),rand(150,220));
- imagettftext($image,rand($fontWidth-10,$fontWidth),rand(-30, 30),$padding+$i*$fontWidth,rand($fontHeight-15,$fontHeight-10),$color,$font,$token[$i]);
+ $size=rand($fontWidth-10,$fontWidth);
+ $angle=rand(-30,30);
+ $x=$padding+$i*$fontWidth;
+ $y=rand($fontHeight-15,$fontHeight-10);
+ imagettftext($image,$size,$angle,$x,$y,$color,$font,$token[$i]);
+ if($hasShadow)
+ imagettftext($image,$size,$angle,$x+2,$y+2,$color,$font,$token[$i]);
imagecolordeallocate($image,$color);
}