Changeset 11316


Ignore:
Timestamp:
Jun 11, 2011, 3:01:45 PM (13 years ago)
Author:
mistic100
Message:

activate captcha on comment form

Location:
extensions/CryptograPHP
Files:
3 added
6 edited
2 moved

Legend:

Unmodified
Added
Removed
  • extensions/CryptograPHP/admin.php

    r10837 r11316  
    33
    44load_language('plugin.lang', CRYPTO_PATH);
     5$conf['cryptographp_theme'] = explode(',', $conf['cryptographp_theme']);
    56
    67if ( isset($_POST['submit']))
    78{
    8   $conf['cryptographp_theme'] = trim($_POST['cryptographp_theme']);
    9 
    10   $query = '
    11 UPDATE '.CONFIG_TABLE.'
    12   SET value="'.$conf['cryptographp_theme'].'"
    13   WHERE param="cryptographp_theme"
    14   LIMIT 1';
    15   pwg_query($query);
    16 
     9  $conf['cryptographp_theme'] = array(
     10    $_POST['cryptographp_theme'],
     11    $_POST['comments_action'],
     12    );
     13  conf_update_param('cryptographp_theme', implode(',', $conf['cryptographp_theme']));
    1714  array_push($page['infos'], l10n('Information data registered in database'));
    1815}
     
    2118
    2219$template->assign(array(
    23   'cryptographp_theme' => $conf['cryptographp_theme'],
     20  'cryptographp_theme' => $conf['cryptographp_theme'][0],
     21  'comments_action' => $conf['cryptographp_theme'][1],
    2422  'available_themes' => array('cryptographp', 'bluenoise', 'gray', 'pencil', 'xcolor'),
    2523  'CRYPTO_PATH' => CRYPTO_PATH,
     
    2725);
    2826
    29 $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content');
     27$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    3028
    3129?>
  • extensions/CryptograPHP/admin.tpl

    r11023 r11316  
    55<form method="post" class="properties">
    66<fieldset>
    7   <legend>{'Captcha theme'|@translate}</legend>
     7  <legend>{'Configuration'|@translate}</legend>
    88 
    9   {foreach from=$available_themes item=theme}
    10   <div style="display:inline-block;margin-top:5px;">
    11    <label for="{$theme}-example"><img src="{$CRYPTO_PATH}cryptographp/images/{$theme}.png" alt="{$theme}"/></label> <br/>
    12     <input type="radio" name="cryptographp_theme" id="{$theme}-example" value="{$theme}" {if $theme == $cryptographp_theme}checked="checked"{/if}/>
    13   </div>
    14   {/foreach}
     9  <ul>                 
     10    <li style="text-align:center;">
     11      <b>{'Captcha theme'|@translate}</b><br/>
     12      {foreach from=$available_themes item=theme}
     13      <div style="display:inline-block;margin-top:5px;">
     14       <label for="{$theme}-example"><img src="{$CRYPTO_PATH}cryptographp/images/{$theme}.png" alt="{$theme}"/></label> <br/>
     15        <input type="radio" name="cryptographp_theme" id="{$theme}-example" value="{$theme}" {if $theme == $cryptographp_theme}checked="checked"{/if}/>
     16      </div>
     17      {/foreach}
     18    </li>
     19
     20    <li>
     21      <span class="property">{'Comments action'|@translate}</span>
     22      <label><input type="radio" name="comments_action" value="inactive" {if $comments_action == 'inactive'}checked="checked"{/if}/> {'No captcha'|@translate}</label>
     23      <label><input type="radio" name="comments_action" value="reject" {if $comments_action == 'reject'}checked="checked"{/if}/> {'Reject'|@translate}</label>
     24      <label><input type="radio" name="comments_action" value="moderate" {if $comments_action == 'moderate'}checked="checked"{/if}/> {'Moderate'|@translate}</label>
     25    </li>
     26  </ul>
    1527 
    1628  <p class="bottomButtons">
  • extensions/CryptograPHP/include/contactform.inc.php

    r11249 r11316  
    1313  global $template, $conf;
    1414
    15   // if (!is_a_guest()) return;
     15  if (!is_a_guest()) return;
    1616
    1717  $template->set_prefilter('cf_form', 'captcha_prefilter');
    18   $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'].'.cfg.php',1));
     18  $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'][0].'.cfg.php',1));
    1919}
    2020
     
    3838function check_captcha($infos)
    3939{
    40   global $conf;
    41 
    4240  if (!is_a_guest()) return $infos;
    4341
  • extensions/CryptograPHP/include/register.inc.php

    r11249 r11316  
    1414
    1515  $template->set_prefilter('register', 'captcha_prefilter');
    16   $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'].'.cfg.php',1));
     16  $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'][0].'.cfg.php',1));
    1717}
    1818
     
    4141function check_captcha($errors)
    4242{
    43   global $conf;
    44 
    4543  if (!chk_crypt($_POST['code']))
    4644  {
  • extensions/CryptograPHP/language/en_UK/plugin.lang.php

    r10837 r11316  
    44$lang['Captcha theme'] = 'Captcha theme';
    55$lang['Antibot test'] = 'Antibot test';
     6$lang['Comments action'] = 'Comments action';
     7$lang['Moderate'] = 'Moderate';
     8$lang['No captcha'] = 'No captcha';
    69
    710?>
  • extensions/CryptograPHP/language/fr_FR/plugin.lang.php

    r10837 r11316  
    44$lang['Captcha theme'] = 'Thème du captcha';
    55$lang['Antibot test'] = 'Test anti-bots';
     6$lang['Comments action'] = 'Action pour les commentaires';
     7$lang['Moderate'] = 'Modérer';
     8$lang['No captcha'] = 'Pas de captcha';
    69
    710?>
  • extensions/CryptograPHP/main.inc.php

    r10839 r11316  
    1212define('CRYPTO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
    1313
    14 global $conf;
    15 
    16 add_event_handler('init', 'crypto_init');
     14add_event_handler('loc_end_section_init', 'crypto_init');
    1715
    1816function crypto_init()
    1917{
    20   if (script_basename() == 'register')
    21     include('register.inc.php');
    22   elseif (isset($_GET['/contact']))
    23     include('contactform.inc.php');
    24   else if (script_basename() == 'admin')
    25     add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu' );
     18  global $conf, $pwg_loaded_plugins, $page;
     19  $conf['cryptographp_theme'] = explode(',', $conf['cryptographp_theme']);
     20 
     21  if (script_basename() == 'register')
     22  {
     23    include(CRYPTO_PATH.'include/register.inc.php');
     24  }
     25  else if (script_basename() == 'picture' AND $conf['cryptographp_theme'][1] != 'inactive')
     26  {
     27    include(CRYPTO_PATH.'include/picture.inc.php');
     28  }
     29  else if (
     30    script_basename() == 'index' AND $conf['cryptographp_theme'][1] != 'inactive' AND
     31    isset($pwg_loaded_plugins['Comments_on_Albums']) AND
     32    $page['section'] == 'categories' AND isset($page['category'])
     33  ) {
     34    include(CRYPTO_PATH.'include/category.inc.php');
     35  }
     36  else if (isset($_GET['/contact']))
     37  {
     38    include(CRYPTO_PATH.'include/contactform.inc.php');
     39  }
     40}
     41
     42if (script_basename() == 'admin')
     43{
     44  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu' );
    2645}
    2746
     
    3049        global $page,$conf;
    3150
    32         array_push($menu,
    33                         array(
    34                                 'NAME' => 'CryptograPHP',
    35                                 'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
    36                         )
     51        array_push(
     52    $menu,
     53    array(
     54      'NAME' => 'CryptograPHP',
     55      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
     56      )
    3757                );
    3858        return $menu;
  • extensions/CryptograPHP/maintain.inc.php

    r10841 r11316  
    66  if (!isset($conf['cryptographp_theme']))
    77  {
    8     pwg_query('INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("cryptographp_theme","cryptographp","CryptograPHP theme");');
     8    pwg_query('INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("cryptographp_theme","cryptographp,reject","CryptograPHP config");');
    99  }
    1010}
    1111
     12function plugin_activate()
     13{
     14  global $conf;
     15  $conf['cryptographp_theme'] = explode(',', $conf['cryptographp_theme']);
     16 
     17  if(count($conf['cryptographp_theme']) == 1)
     18  {
     19    pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.$conf['cryptographp_theme'][0].',reject" WHERE param = "cryptographp_theme";');
     20  }
     21}
    1222function plugin_uninstall()
    1323{
Note: See TracChangeset for help on using the changeset viewer.