Download cap_form.php
Read cap_form.php
- <?php
- /*
- * Notice the image src that is a php image generator.
- * That's all ...
- */
- ?>
- <div class="box">
- <h2>Post your comment</h2>
- <div class="commentform">
- <form method="post" action="cap_postdata.php">
- <input type="hidden" name="formId" value="comment:<?=$postId?>" />
- <span>Type the number below:</span><img width=120 height=30 src="cap_button.php" alt="random number" border="1" />
- <br />
- <input maxlength=5 size=5 name="audit" type="text" value="" />
- <input type="submit" value="Add comment" class="btn" />
- </form>
- </div>
- </div>
Download cap_postdata.php
Read cap_postdata.php
- <?
- require 'cap_audit.php';
- if(audit()) {
- /* echo put your code on successful captcha here */
- } else {
- /* echo put your code on failed captcha here */
- }
- ?>
Download cap_audit.php
Read cap_audit.php
- <?php
- function audit() {
- /* session_start(); */
- $digit = $_SESSION['digit'];
- $userdigit = $_POST['audit'];
- if (($digit == $userdigit) && ($digit > 1)) {
- return true;
- } else {
- return false;
- }
- }
- ?>
Download cap_button.php
Read cap_button.php
- <?php
- $image = imagecreate(120, 30);
- $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
- $gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0);
- $darkgray = imagecolorallocate($image, 0x50, 0x50, 0x50);
- for ($i = 0; $i < 30; $i++) {
- imageline($image, $x1, $y1, $x2, $y2 , $gray);
- }
- for ($i = 0; $i < 5; $i++) {
- }
- $x = 0;
- for ($i = 0; $i < 5; $i++) {
- imagestring($image, $fnt, $x, $y, $cnum[$i] , $darkgray);
- }
- $digit = "$cnum[0]$cnum[1]$cnum[2]$cnum[3]$cnum[4]";
- $_SESSION['digit'] = $digit;
- imagepng($image);
- imagedestroy($image);
- ?>