diff options
Diffstat (limited to 'demos/quickstart/protected')
5 files changed, 103 insertions, 1 deletions
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 @@ +<com:TContent ID="body" >
+
+<h1>TCaptcha</h1>
+<com:DocLink ClassPath="System.Web.UI.WebControls.TCaptcha" />
+
+<p>
+<tt>TCaptcha</tt> displays a <a href="http://en.wikipedia.org/wiki/Captcha">CAPTCHA</a> that can be used to determine if the input is entered by a real user instead of some program. <tt>TCaptcha</tt> 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.
+</p>
+
+<p>
+To use <tt>TCaptcha</tt>, you must enable the PHP GD2 extension with TrueType font support. Unlike other CAPTCHA scripts, <tt>TCaptcha</tt> does not need session or cookie.
+</p>
+
+<p>
+The token generated by <tt>TCaptcha</tt> can be configured in several ways. To specify the length of characters in the token, set <tt>MinTokenLength</tt> and <tt>MaxTokenLength</tt>. To use case-insensitive token comparison and generate upper-case-only token, set <tt>CaseSensitive</tt> to false. More advanced users can try to set <tt>TokenAlphabet</tt> to specify which characters may appear in the generated tokens.
+</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.
+</p>
+
+<p>
+Upon postback, user input can be validated by calling the method <tt>TCaptcha.validate()</tt>. More easily, you can use a <tt>TCaptchaValidator</tt> to automate the validation work for you. The <tt>TCaptchaValidator</tt> 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 <tt>TCaptcha.regenerateToken()</tt> manually.
+</p>
+
+<p>
+The following template shows a typical use of the <tt>TCaptcha</tt> control:
+</p>
+<com:TTextHighlighter Language="prado" CssClass="source">
+<com:TCaptcha ID="Captcha" />
+<com:TTextBox ID="Input" />
+<com:TCaptchaValidator CaptchaControl="Captcha"
+ ControlToValidate="Input"
+ ErrorMessage="You are challenged!" />
+</com:TTextHighlighter>
+
+<com:RunBar PagePath="Controls.Samples.TCaptcha.Home" />
+
+<div class="last-modified">$Id$</div></com:TContent>
\ 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 @@ +<com:TContent ID="body">
+<h1>TCaptcha Samples</h1>
+
+<h2>Validating CAPTCHA</h2>
+<com:TCaptcha ID="Captcha" TokenImageTheme="5"/>
+<com:TTextBox ID="Input" />
+<com:TButton Text="Regenerate" OnClick="regenerateToken" CausesValidation="false" />
+<com:TButton Id="SubmitButton" Text="Submit" OnClick="buttonClicked" />
+<com:TCaptchaValidator CaptchaControl="Captcha" ControlToValidate="Input" Text="error" />
+
+<h2>Different Themes of TCaptcha</h2>
+
+<table border="1">
+<tr>
+<th>Theme</th><th>Image</th>
+</tr>
+<com:TRepeater ID="CaptchaList">
+ <prop:ItemTemplate>
+<tr>
+ <td>
+ <%# $this->Data %>
+ </td>
+ <td>
+ <com:TCaptcha TokenImageTheme="<%# $this->Data %>" MaxTokenLength="5"/>
+ </td>
+</tr>
+ </prop:ItemTemplate>
+</com:TRepeater>
+</table>
+
+<div class="last-modified">$Id$</div>
+</com:TContent>
\ 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 @@ +<?php
+
+class Home extends TPage
+{
+ public function onInit($param)
+ {
+ if(!$this->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 @@ -8,6 +8,10 @@ </li>
<li>
+ <a href="?page=Controls.Captcha">TCaptcha</a> displays a CAPTCHA to keep spammers from signing up for certain accounts online.
+ </li>
+
+ <li>
<a href="?page=Controls.CheckBox">TCheckBox</a> represents a checkbox on a Web page. It can be used to collect two-state user input.
</li>
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 <ul>
<li>Added a new control <a href="?page=Controls.TabPanel">TTabPanel</a> that displays tabbed views.</li>
<li>Added a new control <a href="?page=Controls.Keyboard">TKeyboard</a> that displays a virtual keyboard for text input.</li>
-<li>Added a new module TCacheHttpSession that stores session data using a cache module to improve the session performance.</li>
+<li>Added a new control <a href="?page=Controls.Captcha">TCaptcha</a> that displays a CAPTCHA to keep spammers from signing up for certain accounts online. A related validator <tt>TCaptchaValidator</tt> is also implemented.</li>
<li>Added Oracle DB support to Active Record</li>
</ul>
|