function scan_dir($dir, $no_dots = FALSE) { $files = array(); $dh = @opendir($dir); if ($dh != FALSE) { while (false !== ($filename = readdir($dh))) { $files[] = $filename; } if ($no_dots) { while (($ix = array_search('.', $files)) > -1) { unset($files[$ix]); } while (($ix = array_search('..', $files)) > -1) { unset($files[$ix]); } } sort($files); } return $files; } session_start(); $spe = scan_dir('inc/ttf/', true); foreach ($spe as $value) { if (strpos($value, '.ttf')) { $fonts[] = $value; } } $array = array('tempfolder' => 'uploads/', 'TTF_folder' => 'inc/ttf/', 'TTF_RANGE' => $fonts, 'chars' => ((int) $_GET['chars'] > 8 or (int) $_GET['chars'] < 1) ? 5 : (int) $_GET['chars'], 'minsize' => ((int) $_GET['minsize'] > 30 or (int) $_GET['minsize'] < 8) ? 8 : (int) $_GET['minsize'], 'maxsize' => ((int) $_GET['maxsize'] > 60 or (int) $_GET['maxsize'] < 14) ? 14 : (int) $_GET['maxsize'], 'captcha_mode' => (isset($_GET['mode']) and $_GET['mode'] == 'mini') ? 'captcha_mini' : 'captcha'); $captcha = new hn_captcha($array, false); $captcha->display_form();
<h3>This is a demo of hn_captcha.class.php with a Standalone-Form:</h3> <?php $captcha = new hn_captcha($CAPTCHA_INIT, TRUE); //$captcha =& new hn_captcha($CAPTCHA_INIT); switch ($captcha->validate_submit()) { // was submitted and has valid keys case 1: // PUT IN ALL YOUR STUFF HERE // echo "<p><br>Congratulation. You will get the resource now."; echo "<br><br><a href=\"" . $_SERVER['PHP_SELF'] . "?download=yes&id=1234\">New DEMO</a></p>"; break; // was submitted with no matching keys, but has not reached the maximum try's // was submitted with no matching keys, but has not reached the maximum try's case 2: echo $captcha->display_form(); break; // was submitted, has bad keys and also reached the maximum try's // was submitted, has bad keys and also reached the maximum try's case 3: //if(!headers_sent() && isset($captcha->badguys_url)) header('location: '.$captcha->badguys_url); echo "<p><br>Reached the maximum try's of " . $captcha->maxtry . " without success!"; echo "<br><br><a href=\"" . $_SERVER['PHP_SELF'] . "?download=yes&id=1234\">New DEMO</a></p>"; break; // was not submitted, first entry // was not submitted, first entry default: echo $captcha->display_form(); break; } ?>