示例#1
0
 public function action_image()
 {
     $token = $this->request->param('id');
     //removig the & we add to refresh the image.
     if (($amp_pos = strpos($token, '&')) > 1) {
         $token = substr($token, 0, $amp_pos);
     }
     $captcha = new captcha();
     die($captcha->image($token));
 }
示例#2
0
    function form($title = "&rarr; retype that here", $more = "<small>Enter the correct letters and numbers from the image into the text box. This small test serves as access restriction against malicious bots. Simply reload the page if this graphic is too hard to read.</small>")
    {
        $pw = captcha::mkpass();
        $hash = captcha::hash($pw);
        $maxsize = strpos("MSIE", $_SERVER["HTTP_USER_AGENT"]) ? 3000 : 6000;
        @header("Vary: User-Agent");
        $img = "data:image/jpeg;base64," . base64_encode(captcha::image($pw, 200, 60, CAPTCHA_INVERSE, $maxsize));
        $alt = htmlentities(captcha::textual_riddle($pw));
        $html = '<table border="0" summary="captcha input"><tr>' . '<td><img name="captcha_image" id="captcha_image" src="' . $img . '" height="60" width="200" alt="' . $alt . '" /></td>' . '<td>' . $title . '<br/><input name="captcha_hash" type="hidden" value="' . $hash . '" />' . '<input name="captcha_input" type="text" size="7" maxlength="16" style="height:46px; font-size:34px; font-weight:450;" />' . '</td><td>' . $more . '</td>' . '</tr></table>';
        $base = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}/" . substr(realpath(__FILE__), strlen($_SERVER["DOCUMENT_ROOT"]));
        $html .= <<<END
<script language="Javascript"><!--
if (/Microsoft/.test(navigator.appName)) {
   var img = document.captcha_image;
   img.src = "{$base}?_ddu=" + img.src.substr(23);
} //--></script>
END;
        $html = "<div class=\"captcha\">{$html}</div>";
        return $html;
    }
示例#3
0
文件: captcha.php 项目: rhertzog/lcs
 function form()
 {
     #-- stop if user already verified
     if (!empty($_COOKIE[CAPTCHA_COOKIE]) && $_COOKIE[CAPTCHA_COOKIE] == (int) (time() / 1000000)) {
         return "";
     }
     $title = translate('Enter Characters Seen in Graphic');
     $more = translate('Enter the correct letters and numbers from the image into the text box...');
     #-- prepare image text
     $pw = captcha::mkpass();
     $hash = captcha::hash($pw);
     //$alt = htmlentities(captcha::textual_riddle($pw));
     $alt = $title;
     #-- image
     $img = captcha::image($pw, 200, 60, CAPTCHA_INVERSE, CAPTCHA_MAXSIZE);
     if (CAPTCHA_DATA_URLS && !strpos('MSIE', $_SERVER['HTTP_USER_AGENT'])) {
         $img_fn = 'data:image/jpeg;base64,' . base64_encode($img);
     } else {
         $img_fn = CAPTCHA_TEMP_DIR . '/' . captcha::store_image($img) . '.jpg';
     }
     //echo $img_fn;
     #-- emit html form
     $html = '
     <div class="captcha">
       <fieldset style="width:420px">
         <legend>' . translate('Challenge/Response') . '</legend>
         <table border="0" summary="captcha input" width="400px"><tr>
           <td colspan="2"><small>' . $more . '</small></td></tr><tr>
           <td><img name="captcha_image" id="captcha_image" src="' . $img_fn . '" height="60" width="200" alt="' . $alt . '" /></td>
           <td>' . $title . '<br /><input name="captcha_hash" type="hidden" value="' . $hash . '" />
             <input name="captcha_input" type="text" size="7" maxlength="16" style="height:46px;font-size:34px; font-weight:bold;" />
           </td></tr></table>
       </fieldset>
     </div>
   ';
     return $html;
 }
示例#4
0
<?php

/*
	[Destoon B2B System] Copyright (c) 2008-2013 Destoon.COM
	This is NOT a freeware, use is subject to license.txt
*/
define('DT_NONUSER', true);
require '../common.inc.php';
check_referer() or exit;
if ($DT_BOT) {
    dhttp(403);
}
$session = new dsession();
require DT_ROOT . '/include/captcha.class.php';
$do = new captcha();
$do->font = DT_ROOT . '/file/font/' . $DT['water_font'];
if ($DT['captcha_cn']) {
    $do->cn = is_file($do->font);
}
$do->ip = $DT_IP;
if ($action == 'question') {
    $id = isset($id) ? trim($id) : 'questionstr';
    $do->question($id);
} else {
    if ($DT['captcha_chars']) {
        $do->chars = trim($DT['captcha_chars']);
    }
    $do->image();
}
示例#5
0
<?php

include 'captcha.php';
captcha::image($_GET['salt']);
示例#6
0
<script>
function refreshCaptcha(target) {

    var req = new XMLHttpRequest();

    req.open("POST", window.location, true);
    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

	
    req.onreadystatechange = function() {
	    if(req.readyState == 4 && req.status == 200) {
			target.src = req.responseText;
	    }
    }

    req.send("rCaptcha=true");
}
</script>

<form method="post" autocomplete="off">
	<fieldset>
		<legend>PHP Captcha</legend>
		
		<input type="text" name="code" placeholder="Captcha Code" /><br/>
		<img src="<?php 
echo captcha::image();
?>
" onclick="refreshCaptcha(this)" title="click to refresh" /><br/>
		<input type="submit" value="Check" /><br/>
	</fieldset>
</form>