Changeset 26072


Ignore:
Timestamp:
Dec 21, 2013, 6:39:06 PM (7 years ago)
Author:
mistic100
Message:

try to simplify integration of captchas

Location:
extensions/CryptograPHP
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/CryptograPHP/admin.php

    r26041 r26072  
    2020 
    2121  $conf['cryptographp'] = array(
    22     'activate_on'     => array(
     22    'activate_on' => array(
    2323      'picture'     => in_array('picture', $_POST['activate_on']),
    2424      'category'    => in_array('category', $_POST['activate_on']) || !$loaded['category'],
  • extensions/CryptograPHP/include/category.inc.php

    r26041 r26072  
    22defined('CRYPTO_ID') or die('Hacking attempt!');
    33
     4$conf['cryptographp']['template'] = 'comment';
    45include(CRYPTO_PATH.'include/common.inc.php');
     6
    57add_event_handler('loc_begin_index', 'add_crypto');
    68add_event_handler('user_comment_check_albums', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     
    1517{
    1618  $search = '{$comment_add.CONTENT}</textarea></p>';
    17   return str_replace($search, $search."\n{\$CRYPTOGRAPHP}", $content);
     19  return str_replace($search, $search."\n{\$CRYPTO.parsed_content}", $content);
    1820}
    1921
  • extensions/CryptograPHP/include/common.inc.php

    r26041 r26072  
    1515  'CRYPTO_PATH' => get_absolute_root_url().CRYPTO_PATH,
    1616  ));
    17  
     17
    1818$template->set_filename('cryptographp', realpath(CRYPTO_PATH.'template/'.$conf['cryptographp']['template'].'.tpl'));
    19 $template->assign_var_from_handle('CRYPTOGRAPHP', 'cryptographp');
     19$template->append('CRYPTO', array('parsed_content' => $template->parse('cryptographp', true)), true);
  • extensions/CryptograPHP/include/contactform.inc.php

    r26066 r26072  
    22defined('CRYPTO_ID') or die('Hacking attempt!');
    33
     4$conf['cryptographp']['template'] = 'contactform';
    45include(CRYPTO_PATH.'include/common.inc.php');
    5 add_event_handler('loc_begin_index', 'add_crypto');
     6
    67add_event_handler('contact_form_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    7 
    8 function add_crypto()
    9 {
    10   global $template;
    11   $template->set_prefilter('contactform', 'prefilter_crypto');
    12 }
    13 
    14 function prefilter_crypto($content, $smarty)
    15 {
    16   $search = '{$contact.content}</textarea></td>';
    17   return str_replace($search, $search."\n{\$CRYPTOGRAPHP}", $content);
    18 }
    198
    209function check_crypto($action, $comment)
  • extensions/CryptograPHP/include/guestbook.inc.php

    r26066 r26072  
    22defined('CRYPTO_ID') or die('Hacking attempt!');
    33
     4$conf['cryptographp']['template'] = 'guestbook';
    45include(CRYPTO_PATH.'include/common.inc.php');
    5 add_event_handler('loc_begin_index', 'add_crypto');
     6
    67add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    7 
    8 function add_crypto()
    9 {
    10   global $template;
    11   $template->set_prefilter('guestbook', 'prefilter_crypto');
    12 }
    13 
    14 function prefilter_crypto($content, $smarty)
    15 {
    16   $search = '{$comment_add.CONTENT}</textarea>';
    17   return str_replace($search, $search."\n{\$CRYPTOGRAPHP}", $content);
    18 }
    198
    209function check_crypto($action, $comment)
  • extensions/CryptograPHP/include/picture.inc.php

    r26041 r26072  
    22defined('CRYPTO_ID') or die('Hacking attempt!');
    33
     4$conf['cryptographp']['template'] = 'comment';
    45include(CRYPTO_PATH.'include/common.inc.php');
     6
    57add_event_handler('loc_end_picture', 'add_crypto');
    68add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
     
    1517{
    1618  $search = '{$comment_add.CONTENT}</textarea></p>';
    17   return str_replace($search, $search."\n{\$CRYPTOGRAPHP}", $content);
     19  return str_replace($search, $search."\n{\$CRYPTO.parsed_content}", $content);
    1820}
    1921
  • extensions/CryptograPHP/include/register.inc.php

    r26041 r26072  
    22defined('CRYPTO_ID') or die('Hacking attempt!');
    33
     4$conf['cryptographp']['template'] = 'register';
    45include(CRYPTO_PATH.'include/common.inc.php');
     6
    57add_event_handler('loc_end_page_header', 'add_crypto');
    68add_event_handler('register_user_check', 'check_crypto');
     
    1416function prefilter_crypto($content, $smarty)
    1517{
    16   $search = '#\(\{\'useful when password forgotten\'\|@translate\}\)(\s*)((\{/if\})?)#i';
    17   $replace = '({\'useful when password forgotten\'|@translate})$1$2'."\n".'{\$CRYPTOGRAPHP}';
     18  $search = '#\(\{\'useful when password forgotten\'\|(@?)translate\}\)(\s*)((?:\{/if\})?)#i';
     19  $replace = '({\'useful when password forgotten\'|$1translate})$2$3'."\n".'{\$CRYPTO.parsed_content}';
    1820  return preg_replace($search, $replace, $content);
    1921}
  • extensions/CryptograPHP/main.inc.php

    r26067 r26072  
    3838{
    3939  add_event_handler('loc_end_section_init', 'crypto_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
     40  add_event_handler('loc_begin_register', 'crypto_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
    4041}
    4142
     
    6465    return;
    6566  }
    66  
    67   if (script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'])
     67
     68  if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
    6869  {
    69     $conf['cryptographp']['template'] = 'register';
    70     include(CRYPTO_PATH . 'include/register.inc.php');
    71   }
    72   else if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
    73   {
    74     $conf['cryptographp']['template'] = 'comment';
    7570    include(CRYPTO_PATH . 'include/picture.inc.php');
    7671  }
     
    8479      )
    8580    {
    86       $conf['cryptographp']['template'] = 'comment';
    8781      include(CRYPTO_PATH . 'include/category.inc.php');
    8882    }
    8983    else if ($page['section'] == 'contact' && $conf['cryptographp']['activate_on']['contactform'])
    9084    {
    91       $conf['cryptographp']['template'] = 'contactform';
    9285      include(CRYPTO_PATH . 'include/contactform.inc.php');
    9386    }
    9487    else if ($page['section'] == 'guestbook' && $conf['cryptographp']['activate_on']['guestbook'])
    9588    {
    96       $conf['cryptographp']['template'] = 'guestbook';
    9789      include(CRYPTO_PATH . 'include/guestbook.inc.php');
    9890    }
     91  }
     92}
     93function crypto_register_init()
     94{
     95  global $conf;
     96 
     97  if (!is_a_guest())
     98  {
     99    return;
     100  }
     101
     102  if ($conf['cryptographp']['activate_on']['register'])
     103  {
     104    include(CRYPTO_PATH . 'include/register.inc.php');
    99105  }
    100106}
  • extensions/CryptograPHP/maintain.inc.php

    r26041 r26072  
    88  function install($plugin_version, &$errors=array())
    99  {
     10    global $conf;
     11   
    1012    if (isset($conf['cryptograph_theme']))
    1113    {
  • extensions/CryptograPHP/template/contactform.tpl

    r26041 r26072  
    1 </tr>     
    21<tr>
    32  <td class="title">
     
    1110  </td>
    1211
    13 {footer_script}
    14 var captcha_code = new LiveValidation("captcha_code", {ldelim} onlyOnSubmit: true, insertAfterWhatNode: "captcha_refresh" });
    15 captcha_code.add(Validate.Presence, {ldelim} failureMessage: "{'Invalid Captcha'|translate}" });
    16 {/footer_script}
     12  {footer_script}
     13  var captcha_code = new LiveValidation("captcha_code", {ldelim} onlyOnSubmit: true, insertAfterWhatNode: "captcha_refresh" });
     14  captcha_code.add(Validate.Presence, {ldelim} failureMessage: "{'Invalid Captcha'|translate}" });
     15  {/footer_script}
     16</tr>
  • extensions/CryptograPHP/template/guestbook.tpl

    r26041 r26072  
    1   </td>
    2 </tr>
    31<tr>
    42  <td>
     
    108    <a href="#" id="captcha_refresh" onclick="document.getElementById('captcha').src = '{$CRYPTO_PATH}securimage/securimage_show.php?'+Math.random(); return false;">
    119      <img src="{$CRYPTO_PATH}template/refresh_{$CRYPTO.button_color}.png" style="vertical-align:bottom;"></a>
     10  </td>
    1211
    13 {footer_script}
    14 var captcha_code = new LiveValidation("captcha_code", {ldelim} onlyOnSubmit: true });
    15 captcha_code.add(Validate.Presence, {ldelim} failureMessage: "{'Invalid Captcha'|translate}" });
    16 {/footer_script}
     12  {footer_script}
     13  var captcha_code = new LiveValidation("captcha_code", {ldelim} onlyOnSubmit: true });
     14  captcha_code.add(Validate.Presence, {ldelim} failureMessage: "{'Invalid Captcha'|translate}" });
     15  {/footer_script}
     16</tr>
Note: See TracChangeset for help on using the changeset viewer.