From dd02492f08248bf9b53a20b54a3d49a9f78fc0ad Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 29 Aug 2007 19:57:50 +0000 Subject: finished TCaptcha. --- .../protected/pages/Controls/Captcha.page | 39 ++++++++++++++++++++++ .../pages/Controls/Samples/TCaptcha/Home.page | 32 ++++++++++++++++++ .../pages/Controls/Samples/TCaptcha/Home.php | 27 +++++++++++++++ .../protected/pages/Controls/Standard.page | 4 +++ .../pages/GettingStarted/NewFeatures.page | 2 +- 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 demos/quickstart/protected/pages/Controls/Captcha.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.page create mode 100644 demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php (limited to 'demos') diff --git a/demos/quickstart/protected/pages/Controls/Captcha.page b/demos/quickstart/protected/pages/Controls/Captcha.page new file mode 100644 index 00000000..244a3adc --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Captcha.page @@ -0,0 +1,39 @@ + + +

TCaptcha

+ + +

+TCaptcha displays a CAPTCHA that can be used to determine if the input is entered by a real user instead of some program. TCaptcha displays a token (a string consisting of alphanumeric characters) as an image and the user is expected to repeat the token in a text box. The token image is generated in a way such that it can be recognized by a human being, but not a program. +

+ +

+To use TCaptcha, you must enable the PHP GD2 extension with TrueType font support. Unlike other CAPTCHA scripts, TCaptcha does not need session or cookie. +

+ +

+The token generated by TCaptcha can be configured in several ways. To specify the length of characters in the token, set MinTokenLength and MaxTokenLength. To use case-insensitive token comparison and generate upper-case-only token, set CaseSensitive to false. More advanced users can try to set TokenAlphabet to specify which characters may appear in the generated tokens. +

+ +

+To specify the appearance of the generated token image, set TokenImageTheme 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 TokenFontSize. In particular, the image width is proportional to the font size. You may also set Width to scale the generated image to your desired size, but the scaled image may not look good. +

+ +

+Upon postback, user input can be validated by calling the method TCaptcha.validate(). More easily, you can use a TCaptchaValidator to automate the validation work for you. The TCaptchaValidator has the additional benefit of being able to validate the user input on the client-side. By default, a generated token will remain unchanged during postbacks. A new token can be generated by calling TCaptcha.regenerateToken() manually. +

+ +

+The following template shows a typical use of the TCaptcha control: +

+ +<com:TCaptcha ID="Captcha" /> +<com:TTextBox ID="Input" /> +<com:TCaptchaValidator CaptchaControl="Captcha" + ControlToValidate="Input" + ErrorMessage="You are challenged!" /> + + + + +
$Id$
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.page new file mode 100644 index 00000000..f47583e9 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.page @@ -0,0 +1,32 @@ + +

TCaptcha Samples

+ +

Validating CAPTCHA

+ + + + + + +

Different Themes of TCaptcha

+ + + + + + + + + + + + + +
ThemeImage
+ <%# $this->Data %> + + +
+ +
$Id$
+
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php new file mode 100644 index 00000000..4d54ce87 --- /dev/null +++ b/demos/quickstart/protected/pages/Controls/Samples/TCaptcha/Home.php @@ -0,0 +1,27 @@ +IsPostBack) + { + $this->CaptchaList->DataSource=range(0,31); + $this->CaptchaList->dataBind(); + } + } + + public function regenerateToken($sender,$param) + { + $this->Captcha->regenerateToken(); + $this->SubmitButton->Text="Submit"; + } + + public function buttonClicked($sender,$param) + { + if($this->IsValid) + $sender->Text="You passed!"; + } +} + +?> \ No newline at end of file diff --git a/demos/quickstart/protected/pages/Controls/Standard.page b/demos/quickstart/protected/pages/Controls/Standard.page index d481525c..7d961a84 100644 --- a/demos/quickstart/protected/pages/Controls/Standard.page +++ b/demos/quickstart/protected/pages/Controls/Standard.page @@ -7,6 +7,10 @@ TButton represents a click button on a Web page. It is mainly used to trigger page postback. +
  • + TCaptcha displays a CAPTCHA to keep spammers from signing up for certain accounts online. +
  • +
  • TCheckBox represents a checkbox on a Web page. It can be used to collect two-state user input.
  • diff --git a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page index a5136d72..53b516cc 100644 --- a/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page +++ b/demos/quickstart/protected/pages/GettingStarted/NewFeatures.page @@ -10,7 +10,7 @@ This page summarizes the main new features that are introduced in each PRADO rel -- cgit v1.2.3