예제 #1
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;
 }