Ignore:
Timestamp:
Aug 9, 2012, 12:11:10 PM (12 years ago)
Author:
mistic100
Message:

update for the new Contact Form

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/CryptograPHP/include/contactform.inc.php

    r17319 r17484  
    33
    44load_language('plugin.lang', CRYPTO_PATH);
    5 add_event_handler('display_contactform', 'add_crypto');
    6 add_event_handler('check_contactform_params', 'check_crypto');
     5add_event_handler('loc_begin_index', 'add_crypto');
     6add_event_handler('contact_form_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    77
    88function add_crypto()
     
    1212  if (!is_a_guest()) return;
    1313
    14   $template->set_prefilter('cf_form', 'prefilter_crypto');
     14  $template->set_prefilter('index', 'prefilter_crypto');
    1515}
    1616
     
    1919  global $conf;
    2020 
    21   $search = '<td class="contact-form-right"><textarea name="cf_message" id="cf_message" rows="10" cols="40">{$CF.MESSAGE}</textarea></td>';
     21  $search = '{$contact.content}</textarea></td>';
    2222  $replace = $search.'
    2323      </tr>     
    2424      <tr>
    25         <td class="contact-form-left" style="vertical-align:top;">
     25        <td class="title">
    2626          {\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate}
    27           <img id="captcha" src="{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
    28           <a href="#" onclick="document.getElementById(\'captcha\').src = \'{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
    29             <img src="{$ROOT_URL}'.CRYPTO_PATH.'template/refresh.png"></a>
    3027        </td>
    31         <td class="contact-form-right"><input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" /></td>';
     28        <td>
     29          <input type="text" name="captcha_code" id="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" />
     30          <img id="captcha" src="{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image" style="vertical-align:top;">
     31          <a href="#" id="captcha_refresh" onclick="document.getElementById(\'captcha\').src = \'{$ROOT_URL}'.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
     32            <img src="{$ROOT_URL}'.CRYPTO_PATH.'template/refresh.png" style="vertical-align:bottom;"></a>
     33        </td>
     34       
     35{footer_script}
     36var captcha_code = new LiveValidation("captcha_code", {ldelim} onlyOnSubmit: true, insertAfterWhatNode: "captcha_refresh" });
     37captcha_code.add(Validate.Presence, {ldelim} failureMessage: "{\'Invalid Captcha\'|@translate}" });
     38{/footer_script}';
    3239 
    3340  return str_replace($search, $replace, $content);
    3441}
    3542
    36 function check_crypto($infos)
     43function check_crypto($action, $comment)
    3744{
    38   if (!is_a_guest()) return $infos;
     45  global $conf, $page;
    3946 
    4047  include_once(CRYPTO_PATH.'securimage/securimage.php');
    4148  $securimage = new Securimage();
    42  
     49
     50  if (!is_a_guest()) return $action;
     51
    4352  if ($securimage->check($_POST['captcha_code']) == false)
    4453  {
    45     array_push($infos['errors'], l10n('Invalid Captcha'));
     54    array_push($page['errors'], l10n('Invalid Captcha'));
     55    return 'reject';
    4656  }
    4757
    48   return $infos;
     58  return $action;
    4959}
    5060
Note: See TracChangeset for help on using the changeset viewer.