Changeset 3080 for trunk/application
- Timestamp:
- 07/11/2008 01:30:46 PM (5 months ago)
- Files:
-
- 1 modified
-
trunk/application/controllers/examples.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/application/controllers/examples.php
r3047 r3080 175 175 public function captcha() 176 176 { 177 // Look at the counters in the Session Profiler 177 // Look at the counters for valid and invalid 178 // responses in the Session Profiler. 178 179 new Profiler; 179 180 180 // Load Captcha library 181 // Load Captcha library, you can supply the name 182 // of the config group you would like to use. 181 183 $captcha = new Captcha; 182 184 183 // Ban bots (that accept session cookies) after 50 invalid responses 185 // Ban bots (that accept session cookies) after 50 invalid responses. 184 186 // Be careful not to ban real people though! Set the threshold high enough. 185 187 if ($captcha->invalid_count() > 49) … … 189 191 if ($_POST) 190 192 { 191 // User has not given three valid responses yet192 if ( $captcha->valid_count() < 3)193 // Captcha::valid() is a static method that can be used as a Validation rule also. 194 if (Captcha::valid($this->input->post('captcha_response'))) 193 195 { 194 // Captcha::valid() is a static method that can be used as a Validation rule also 195 if (Captcha::valid($this->input->post('captcha_response'))) 196 { 197 echo '<p style="color:green">Good answer!</p>'; 198 } 199 else 200 { 201 echo '<p style="color:red">Wrong answer!</p>'; 202 } 196 echo '<p style="color:green">Good answer!</p>'; 203 197 } 198 else 199 { 200 echo '<p style="color:red">Wrong answer!</p>'; 201 } 204 202 205 203 // Validate other fields here 206 204 } 207 205 208 // Openform206 // Show form 209 207 echo form::open(); 210 208 echo '<p>Other form fields here...</p>'; 211 209 212 // Don't show Captcha anymore after three or more valid responses 213 if ($captcha->valid_count() < 3) 210 // Don't show Captcha anymore after the user has given enough valid 211 // responses. The "enough" count is set in the captcha config. 212 if ( ! $captcha->promoted()) 214 213 { 215 214 echo '<p>'; … … 217 216 echo '</p>'; 218 217 echo form::input('captcha_response'); 218 } 219 else 220 { 221 echo '<p>You have been promoted to human.</p>'; 219 222 } 220 223
