Changeset 12617


Ignore:
Timestamp:
Nov 13, 2011, 12:34:07 AM (12 years ago)
Author:
mistic100
Message:

rewrite some prefilters, replace CryptograPHP by Securimage (not abandoned project!)

Location:
extensions/CryptograPHP
Files:
45 added
3 deleted
22 edited

Legend:

Unmodified
Added
Removed
  • extensions/CryptograPHP/admin.php

    r11316 r12617  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33
     4$conf['cryptographp'] = unserialize($conf['cryptographp']);
    45load_language('plugin.lang', CRYPTO_PATH);
    5 $conf['cryptographp_theme'] = explode(',', $conf['cryptographp_theme']);
    66
    77if ( isset($_POST['submit']))
    88{
    9   $conf['cryptographp_theme'] = array(
    10     $_POST['cryptographp_theme'],
    11     $_POST['comments_action'],
     9  $conf['cryptographp'] = array(
     10    'comments_action' => $_POST['comments_action'],
     11    'theme'           => $_POST['theme'],
     12    'captcha_type'    => $_POST['captcha_type'],
     13    'case_sensitive'  => $conf['cryptographp']['case_sensitive'], //not used, problem with some fonts
     14    'width'           => (int)$_POST['width'],
     15    'height'          => (int)$_POST['height'],
     16    'perturbation'    => (float)$_POST['perturbation'],
     17    'image_bg_color'  => $_POST['image_bg_color'],
     18    'code_length'     => (int)$_POST['code_length'],
     19    'text_color'      => $_POST['text_color'],
     20    'num_lines'       => (float)$_POST['num_lines'],
     21    'line_color'      => $_POST['line_color'],
     22    'noise_level'     => (float)$_POST['noise_level'],
     23    'noise_color'     => $_POST['noise_color'],
     24    'ttf_file'        => $_POST['ttf_file'],
    1225    );
    13   conf_update_param('cryptographp_theme', implode(',', $conf['cryptographp_theme']));
     26 
     27  conf_update_param('cryptographp', serialize($conf['cryptographp']));
    1428  array_push($page['infos'], l10n('Information data registered in database'));
    1529}
    1630
    17 $template->set_filename('plugin_admin_content', dirname(__FILE__).'/admin.tpl');
     31$presets = array(
     32  'bluenoise' => array('perturbation'=>0.25, 'image_bg_color'=>'ffffff', 'text_color'=>'0000ff', 'num_lines'=>2, 'line_color'=>'0000ff', 'noise_level'=>2, 'noise_color'=>'0000ff', 'ttf_file'=>'AlteHassGroteskB'),
     33  'gray' => array('perturbation'=>1, 'image_bg_color'=>'ffffff', 'text_color'=>'8a8a8a', 'num_lines'=>2, 'line_color'=>'8a8a8a', 'noise_level'=>0.1, 'noise_color'=>'8a8a8a', 'ttf_file'=>'TopSecret'),
     34  'xcolor' => array('perturbation'=>0.5, 'image_bg_color'=>'ffffff', 'text_color'=>'random', 'num_lines'=>1, 'line_color'=>'ffffff', 'noise_level'=>2, 'noise_color'=>'ffffff', 'ttf_file'=>'Dread'),
     35  'pencil' => array('perturbation'=>0.8, 'image_bg_color'=>'9e9e9e', 'text_color'=>'363636', 'num_lines'=>0, 'line_color'=>'ffffff', 'noise_level'=>0, 'noise_color'=>'ffffff', 'ttf_file'=>'AllStar'),
     36  );
     37 
     38function list_fonts($dir)
     39{
     40  $dir = rtrim($dir, '/');
     41  $dh = opendir($dir);
     42  $fonts = array();
     43 
     44  while (($file = readdir($dh)) !== false )
     45  {
     46    if ($file !== '.' && $file !== '..') $fonts[] = str_replace('.ttf', null, $file);
     47  }
     48 
     49  closedir($dh);
     50  return $fonts;
     51}
     52
     53function presets_to_js($presets)
     54{
     55  $out = null;
     56 
     57  foreach ($presets as $name => $param)
     58  {
     59    $out.= '
     60function apply_'.$name.'() {
     61  $("input[name=perturbation]").val("'.$param['perturbation'].'");
     62  $("input[name=image_bg_color]").val("'.$param['image_bg_color'].'");
     63  $("input[name=text_color]").val("'.$param['text_color'].'");
     64  $("input[name=num_lines]").val("'.$param['num_lines'].'");
     65  $("input[name=line_color]").val("'.$param['line_color'].'");
     66  $("input[name=noise_level]").val("'.$param['noise_level'].'");
     67  $("input[name=noise_color]").val("'.$param['noise_color'].'");
     68  $("input[name=ttf_file]").val(["'.$param['ttf_file'].'"]);
     69
     70}';
     71  }
     72   
     73  return $out;
     74}
     75
     76$template->set_filename('plugin_admin_content', dirname(__FILE__).'/template/admin.tpl');
    1877
    1978$template->assign(array(
    20   'cryptographp_theme' => $conf['cryptographp_theme'][0],
    21   'comments_action' => $conf['cryptographp_theme'][1],
    22   'available_themes' => array('cryptographp', 'bluenoise', 'gray', 'pencil', 'xcolor'),
     79  'crypto' => $conf['cryptographp'],
     80  'fonts' => list_fonts(CRYPTO_PATH.'securimage/fonts'),
     81  'presets' => array_keys($presets),
     82  'PRESETS_FUNC' => presets_to_js($presets),
    2383  'CRYPTO_PATH' => CRYPTO_PATH,
    24   )
    25 );
     84  ));
    2685
    2786$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
  • extensions/CryptograPHP/include/category.inc.php

    r11370 r12617  
    11<?php
    2 
    32if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 
    5 $cryptinstall = CRYPTO_PATH.'cryptographp/cryptographp.fct.php';
    6 include($cryptinstall);
    73
    84add_event_handler('loc_begin_index', 'add_crypto');
     
    117function add_crypto()
    128{
    13   global $template, $conf;
     9  global $template;
    1410 
    1511  if (!is_a_guest()) return;
    1612 
    1713  $template->set_prefilter('comments_on_albums', 'prefilter_crypto');
    18   $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'][0].'.cfg.php',1));
    1914}
    2015
    2116function prefilter_crypto($content, $smarty)
    2217{
    23   load_language('plugin.lang', CRYPTO_PATH);
     18  global $conf;
    2419 
    2520  $search = '<input type="hidden" name="key" value="{$comment_add.KEY}">';
    2621  $replace = $search.'
    27   <label>{$CAPTCHA}<input type="text" name="code"></label>';
     22  <label>
     23    <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
     24    <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
     25      <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
     26    <br>{\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} :
     27    <input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" />
     28   
     29  </label>';
    2830
    2931  return str_replace($search, $replace, $content);
     
    3234function check_crypto($action, $comment)
    3335{
    34   global $conf, $user;
     36  global $conf;
    3537 
    36   $my_action = ($conf['cryptographp_theme'][1] == 'reject') ? 'reject':'moderate';
     38  include_once(CRYPTO_PATH.'securimage/securimage.php');
     39  $securimage = new Securimage();
    3740
    38   if ($action == 'reject' OR $action == $my_action OR !is_a_guest())
     41  if ( $action == 'reject' or $action == $conf['cryptographp']['comments_action'] or !is_a_guest() )
    3942  {
    4043    return $action;
    4144  }
    4245
    43   if (!chk_crypt($_POST['code']))
     46  if ($securimage->check($_POST['captcha_code']) == false)
    4447  {
    45     return $my_action;
     48    return $conf['cryptographp']['comments_action'];
    4649  }
    47   else
    48   {
    49     return $action;
    50   }
     50
     51  return $action;
    5152}
    5253
  • extensions/CryptograPHP/include/contactform.inc.php

    r11370 r12617  
    11<?php
    2 
    32if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 
    5 $cryptinstall = CRYPTO_PATH.'cryptographp/cryptographp.fct.php';
    6 include($cryptinstall);
    73
    84add_event_handler('display_contactform', 'add_crypto');
     
    117function add_crypto()
    128{
    13   global $template, $conf;
     9  global $template;
    1410
    1511  if (!is_a_guest()) return;
    1612
    1713  $template->set_prefilter('cf_form', 'prefilter_crypto');
    18   $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'][0].'.cfg.php',1));
    1914}
    2015
    2116function prefilter_crypto($content, $smarty)
    2217{
     18  global $conf;
     19 
    2320  $search = '
    2421      <tr>
     
    2623        <td class="contact-form-right"><input class="submit" type="submit" value="{\'cf_submit\'|@translate}"></td>
    2724      </tr>';
    28   $replace = '
     25  $replace = '     
    2926    <tr>
    30       <td class="contact-form-left" style="vertical-align:top;">{\'Antibot test\'|@translate}</td>
    31       <td class="contact-form-right"><input type="text" name="code"> <span style="vertical-align:top;">{$CAPTCHA}</span></td>
     27      <td class="contact-form-left" style="vertical-align:top;">
     28        {\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate}
     29        <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
     30      </td>
     31      <td class="contact-form-right"><input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" />
     32        <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
     33          <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
     34      </td>
    3235    </tr>'
    3336  ."\n".$search;
     
    3942{
    4043  if (!is_a_guest()) return $infos;
    41 
    42   if (!chk_crypt($_POST['code']))
     44 
     45  include_once(CRYPTO_PATH.'securimage/securimage.php');
     46  $securimage = new Securimage();
     47 
     48  if ($securimage->check($_POST['captcha_code']) == false)
    4349  {
    44     load_language('plugin.lang', CRYPTO_PATH);
    4550    array_push($infos['errors'], l10n('Invalid Captcha'));
    4651  }
  • extensions/CryptograPHP/include/picture.inc.php

    r11370 r12617  
    11<?php
    2 
    32if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    43
    5 $cryptinstall = CRYPTO_PATH.'cryptographp/cryptographp.fct.php';
    6 include($cryptinstall);
    7 
    8 add_event_handler('loc_begin_picture', 'add_crypto');
     4add_event_handler('loc_end_picture', 'add_crypto');
    95add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);
    106
    117function add_crypto()
    128{
    13   global $template, $conf;
     9  global $template;
    1410 
    1511  if (!is_a_guest()) return;
    1612 
    1713  $template->set_prefilter('picture', 'prefilter_crypto');
    18   $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'][0].'.cfg.php',1));
    1914}
    2015
    2116function prefilter_crypto($content, $smarty)
    2217{
    23   load_language('plugin.lang', CRYPTO_PATH);
     18  global $conf;
    2419 
    2520  $search = '<input type="hidden" name="key" value="{$comment_add.KEY}">';
    2621  $replace = $search.'
    27   <label>{$CAPTCHA}<input type="text" name="code"></label>';
     22  <label>
     23    <img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image">
     24    <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
     25      <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
     26    <br>{\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} :
     27    <input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" />
     28   
     29  </label>';
    2830
    2931  return str_replace($search, $replace, $content);
     
    3234function check_crypto($action, $comment)
    3335{
    34   global $conf, $user;
     36  global $conf;
    3537 
    36   $my_action = ($conf['cryptographp_theme'][1] == 'reject') ? 'reject':'moderate';
     38  include_once(CRYPTO_PATH.'securimage/securimage.php');
     39  $securimage = new Securimage();
    3740
    38   if ($action == 'reject' OR $action == $my_action OR !is_a_guest())
     41  if ( $action == 'reject' or $action == $conf['cryptographp']['comments_action'] or !is_a_guest() )
    3942  {
    4043    return $action;
    4144  }
    4245
    43   if (!chk_crypt($_POST['code']))
     46  if ($securimage->check($_POST['captcha_code']) == false)
    4447  {
    45     return $my_action;
     48    return $conf['cryptographp']['comments_action'];
    4649  }
    47   else
    48   {
    49     return $action;
    50   }
     50
     51  return $action;
    5152}
    5253
  • extensions/CryptograPHP/include/register.inc.php

    r11370 r12617  
    11<?php
    2 
    32if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    4 
    5 $cryptinstall = CRYPTO_PATH.'cryptographp/cryptographp.fct.php';
    6 include($cryptinstall);
    73
    84add_event_handler('loc_end_page_header', 'add_crypto');
     
    117function add_crypto()
    128{
    13   global $template, $conf;
     9  global $template;
    1410
    1511  $template->set_prefilter('register', 'prefilter_crypto');
    16   $template->assign('CAPTCHA', dsp_crypt($conf['cryptographp_theme'][0].'.cfg.php',1));
    1712}
    1813
    1914function prefilter_crypto($content, $smarty)
    2015{
    21   load_language('plugin.lang', CRYPTO_PATH);
     16  global $conf;
    2217 
    23   $search = '<p class="bottomButtons">';
     18  $search = '#\<\/ul\>(.{0,10})\<\/fieldset\>(.{0,10})\<p class\=\"bottomButtons\"\>#is';
    2419  $replace = '
    25   <fieldset>
    26     <legend>{\'Antibot test\'|@translate}</legend>
    27     <ul>
    2820      <li>
    2921        <span class="property">
    30           <label>{$CAPTCHA}</label>
     22          <label><img id="captcha" src="'.CRYPTO_PATH.'securimage/securimage_show.php" alt="CAPTCHA Image"></label>
    3123        </span>
    32         <input type="text" name="code">
     24        <b>{\''.($conf['cryptographp']['captcha_type']=='string'?'Enter code':'Solve equation').'\'|@translate} :</b><br>
     25        <input type="text" name="captcha_code" size="'.($conf['cryptographp']['code_length']+1).'" maxlength="'.$conf['cryptographp']['code_length'].'" />
     26        <a href="#" onclick="document.getElementById(\'captcha\').src = \''.CRYPTO_PATH.'securimage/securimage_show.php?\' + Math.random(); return false">
     27          <img src="'.CRYPTO_PATH.'template/refresh.png"></a>
    3328      </li>
    34     </ul>
    35   </fieldset>'
    36 ."\n".$search;
     29  </ul>
    3730
    38   return str_replace($search, $replace, $content);
     31  </fieldset>
     32
     33  <p class="bottomButtons">';
     34
     35  return preg_replace($search, $replace, $content);
    3936}
    4037
    4138function check_crypto($errors)
    4239{
    43   if (!chk_crypt($_POST['code']))
     40  include_once(CRYPTO_PATH.'securimage/securimage.php');
     41  $securimage = new Securimage();
     42 
     43  if ($securimage->check($_POST['captcha_code']) == false)
    4444  {
    45     load_language('plugin.lang', CRYPTO_PATH);
    4645    array_push($errors, l10n('Invalid Captcha'));
    4746  }
  • extensions/CryptograPHP/language/cs_CZ/description.txt

    r11142 r12617  
    1 Vloží CryptograPHP captcha ověření pro registrační stránku a kontaktní formulář (thanks to P@t)
     1Vloží captcha ověření pro registrační stránku a kontaktní formulář (thanks to P@t)
  • extensions/CryptograPHP/language/cs_CZ/plugin.lang.php

    r11734 r12617  
    66$lang['Moderate'] = 'Moderovat';
    77$lang['No captcha'] = 'Bez captcha kódu';
    8 $lang['Antibot test'] = 'Antirobot test';
    98
    109?>
  • extensions/CryptograPHP/language/el_GR/description.txt

    r11672 r12617  
    1 Πρόσθεσε ένα CryptograPHP captcha για εγγραφή, σχόλιο και  φόρμα επικοινωνίας
     1Πρόσθεσε ένα captcha για εγγραφή, σχόλιο και  φόρμα επικοινωνίας
  • extensions/CryptograPHP/language/el_GR/plugin.lang.php

    r11672 r12617  
    33$lang['Invalid Captcha'] = 'Άκυρο Captcha';
    44$lang['Captcha theme'] = 'Θέμα Captcha';
    5 $lang['Antibot test'] = 'Δοκιμή Antibot';
    65$lang['Comments action'] = 'Ενέργεια σχολίου';
    76$lang['Moderate'] = 'Μέτριο';
  • extensions/CryptograPHP/language/en_UK/description.txt

    r11375 r12617  
    1 Add a CryptograPHP captcha to register, comment and ContactForm pages (thanks to P@t)
     1Add a captcha to register, comment and ContactForm pages (thanks to P@t)
  • extensions/CryptograPHP/language/en_UK/plugin.lang.php

    r11316 r12617  
    22
    33$lang['Invalid Captcha'] = 'Invalid Captcha';
    4 $lang['Captcha theme'] = 'Captcha theme';
    5 $lang['Antibot test'] = 'Antibot test';
     4$lang['Enter code'] = 'Enter code';
     5$lang['Solve equation'] = 'Solve equation';
     6
    67$lang['Comments action'] = 'Comments action';
    78$lang['Moderate'] = 'Moderate';
    89$lang['No captcha'] = 'No captcha';
     10$lang['Captcha type'] = 'Captcha type';
     11$lang['Random string'] = 'Random string';
     12$lang['Simple equation'] = 'Simple equation';
     13$lang['Case sensitive'] = 'Case sensitive';
     14$lang['Code lenght'] = 'Code lenght';
     15$lang['good value:'] = 'good value:';
     16$lang['Captcha theme'] = 'Captcha theme';
     17
     18$lang['Perturbation'] = 'Perturbation';
     19$lang['range:'] = 'range:';
     20$lang['Background color'] = 'Background color';
     21$lang['Text color'] = 'Text color';
     22$lang['Lines density'] = 'Lines density';
     23$lang['Lines color'] = 'Lines color';
     24$lang['Noise level'] = 'Noise level';
     25$lang['Noise color'] = 'Noise color';
     26$lang['Font'] = 'Font';
     27$lang['Preview'] = 'Preview';
     28$lang['Tip: type "random" on a color field to have a random color'] = 'Tip: type "random" on a color field to have a random color';
    929
    1030?>
  • extensions/CryptograPHP/language/es_ES/description.txt

    r11405 r12617  
    1 Añade un captcha CryptograPHP a la página de registro y en la página de ContactForm (gracias a P@t)
     1Añade un captcha a la página de registro y en la página de ContactForm (gracias a P@t)
  • extensions/CryptograPHP/language/es_ES/plugin.lang.php

    r11405 r12617  
    33$lang['Invalid Captcha'] = 'Captcha no valido';
    44$lang['Captcha theme'] = 'Tema del captcha';
    5 $lang['Antibot test'] = 'Test anti-bots';
    65$lang['Comments action'] = 'Acción para los Comentario';
    76$lang['Moderate'] = 'Moderar';
  • extensions/CryptograPHP/language/fr_FR/description.txt

    r11375 r12617  
    1 Ajoute un captcha CryptograPHP à la page d'enregistrement, au formulaire de commentaire et sur la page de ContactForm (merci à P@t)
     1Ajoute un captcha à la page d'enregistrement, au formulaire de commentaire et sur la page de ContactForm (merci à P@t)
  • extensions/CryptograPHP/language/fr_FR/plugin.lang.php

    r11316 r12617  
    22
    33$lang['Invalid Captcha'] = 'Captcha non valide';
    4 $lang['Captcha theme'] = 'Thème du captcha';
    5 $lang['Antibot test'] = 'Test anti-bots';
     4$lang['Enter code'] = 'Entrez le code';
     5$lang['Solve equation'] = 'Resolvez l\'équation';
     6
    67$lang['Comments action'] = 'Action pour les commentaires';
    78$lang['Moderate'] = 'Modérer';
    89$lang['No captcha'] = 'Pas de captcha';
     10$lang['Captcha type'] = 'Type de captcha';
     11$lang['Random string'] = 'Code aléatoire';
     12$lang['Simple equation'] = 'Equation simple';
     13$lang['Case sensitive'] = 'Sensibilité à la case';
     14$lang['Code lenght'] = 'Longueur du code';
     15$lang['good value:'] = 'conseillé:';
     16$lang['Captcha theme'] = 'Thème du captcha';
     17
     18$lang['Perturbation'] = 'Perturbation';
     19$lang['range:'] = 'plage:';
     20$lang['Background color'] = 'Couleur de fond';
     21$lang['Text color'] = 'Couleur du texte';
     22$lang['Lines density'] = 'Nombre de lignes';
     23$lang['Lines color'] = 'Couleur des lignes';
     24$lang['Noise level'] = 'Quantité de bruit';
     25$lang['Noise color'] = 'Couleur du bruit';
     26$lang['Font'] = 'Police';
     27$lang['Preview'] = 'Prévisualisation';
     28$lang['Tip: type "random" on a color field to have a random color'] = 'Astuce: inscrivez "random" dans un champs de couleur pour avoir une couleur aléatoire';
    929
    1030?>
  • extensions/CryptograPHP/language/hu_HU/description.txt

    r11666 r12617  
    1 CryptograPHP captcha hozzáadása a regisztrációs, komment és KapcsolatŰrlap oldalakhoz.
     1Captcha hozzáadása a regisztrációs, komment és KapcsolatŰrlap oldalakhoz.
  • extensions/CryptograPHP/language/hu_HU/plugin.lang.php

    r11663 r12617  
    33$lang['Invalid Captcha'] = 'Érvénytelen Captcha';
    44$lang['Captcha theme'] = 'Captcha téma';
    5 $lang['Antibot test'] = 'Antibot teszt';
    65$lang['Comments action'] = 'Hozzászólás műveletek';
    76$lang['Moderate'] = 'Moderálás';
  • extensions/CryptograPHP/language/it_IT/description.txt

    r11391 r12617  
    1 Aggiunge un captcha CryptograPHP sulla pagina di iscrizione, sul modulo dei commenti e sulla pagina di ContactForm (grazie a P@t)
     1Aggiunge un captcha sulla pagina di iscrizione, sul modulo dei commenti e sulla pagina di ContactForm (grazie a P@t)
  • extensions/CryptograPHP/language/it_IT/plugin.lang.php

    r11400 r12617  
    33$lang['Invalid Captcha'] = 'Captcha non valido';
    44$lang['Captcha theme'] = 'Tema del captcha';
    5 $lang['Antibot test'] = 'Test Antibot';
    65$lang['Comments action'] = 'Azione per i commenti';
    76$lang['Moderate'] = 'Moderare';
  • extensions/CryptograPHP/language/pl_PL/plugin.lang.php

    r12084 r12617  
    11<?php
    2 // +-----------------------------------------------------------------------+
    3 // | Piwigo - a PHP based photo gallery                                    |
    4 // +-----------------------------------------------------------------------+
    5 // | Copyright(C) 2008-2009 Piwigo Team                  http://piwigo.org |
    6 // | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
    7 // | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
    8 // +-----------------------------------------------------------------------+
    9 // | This program is free software; you can redistribute it and/or modify  |
    10 // | it under the terms of the GNU General Public License as published by  |
    11 // | the Free Software Foundation                                          |
    12 // |                                                                       |
    13 // | This program is distributed in the hope that it will be useful, but   |
    14 // | WITHOUT ANY WARRANTY; without even the implied warranty of            |
    15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
    16 // | General Public License for more details.                              |
    17 // |                                                                       |
    18 // | You should have received a copy of the GNU General Public License     |
    19 // | along with this program; if not, write to the Free Software           |
    20 // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
    21 // | USA.                                                                  |
    22 // +-----------------------------------------------------------------------+
    23 $lang['Antibot test'] = 'Test antybotowy';
     2
    243$lang['Captcha theme'] = 'Wygląd captcha';
    254$lang['Comments action'] = 'Akcja wykonywana dla komentarzy';
     
    276$lang['Moderate'] = 'Średni';
    287$lang['No captcha'] = 'Brak captcha';
     8
    299?>
  • extensions/CryptograPHP/main.inc.php

    r11375 r12617  
    33Plugin Name: Crypto Captcha
    44Version: auto
    5 Description: Add a CryptograPHP captcha to register, comment and ContactForm pages (thanks to P@t)
     5Description: Add a captcha to register, comment and ContactForm pages (thanks to P@t)
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535
    77Author: Mistic
    88Author URI: http://www.strangeplanet.fr
     9*/
     10
     11## TODO : add customization of background image
     12
     13/*
     14Author note :
     15Le plugin était appellé à l'origine CryptograPHP et utilisait la librairie CryptograPHP
     16Puis il a été renommé Crypto Captcha pour plus de clareté
     17La version actuelle s'appelle toujours Crypto Captcha mais utilise la librairie Securimage
    918*/
    1019
     
    1726{
    1827  global $conf, $pwg_loaded_plugins, $page;
    19   $conf['cryptographp_theme'] = explode(',', $conf['cryptographp_theme']);
     28 
     29  $conf['cryptographp'] = unserialize($conf['cryptographp']);
     30  load_language('plugin.lang', CRYPTO_PATH);
    2031 
    2132  if (script_basename() == 'register')
     
    2334    include(CRYPTO_PATH.'include/register.inc.php');
    2435  }
    25   else if (script_basename() == 'picture' AND $conf['cryptographp_theme'][1] != 'inactive')
     36  else if (script_basename() == 'picture' and $conf['cryptographp']['comments_action'] != 'inactive')
    2637  {
    2738    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');
    3539  }
    3640  else if (isset($_GET['/contact']))
    3741  {
    3842    include(CRYPTO_PATH.'include/contactform.inc.php');
     43  }
     44  else if (
     45    script_basename() == 'index' and $conf['cryptographp']['comments_action'] != 'inactive' and
     46    isset($pwg_loaded_plugins['Comments_on_Albums']) and isset($page['section']) and
     47    $page['section'] == 'categories' and isset($page['category'])
     48    )
     49  {
     50    include(CRYPTO_PATH.'include/category.inc.php');
    3951  }
    4052}
     
    4658  function crypto_plugin_admin_menu($menu)
    4759  {
    48     global $page,$conf;
    49 
    50     array_push(
    51       $menu,
    52       array(
    53         'NAME' => 'CryptograPHP',
    54         'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
    55         )
    56       );
     60    array_push($menu, array(
     61      'NAME' => 'Crypto Captcha',
     62      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
     63      ));
    5764    return $menu;
    5865  }
  • extensions/CryptograPHP/maintain.inc.php

    r11316 r12617  
    11<?php
     2define('default_config', serialize(array(
     3  'comments_action' => 'reject',
     4  'theme'           => 'gray',
     5  'captcha_type'    => 'string',
     6  'case_sensitive'  => 'false',
     7  'code_length'     => 6,
     8  'width'           => 120,
     9  'height'          => 40,
     10  'perturbation'    => 1,
     11  'image_bg_color'  => 'ffffff',
     12  'text_color'      => '8a8a8a',
     13  'num_lines'       => 2,
     14  'line_color'      => '8a8a8a',
     15  'noise_level'     => 0.1,
     16  'noise_color'     => '8a8a8a',
     17  'ttf_file'        => 'TopSecret',
     18)));
     19
    220function plugin_install()
    321{
    422  global $conf;
    523 
    6   if (!isset($conf['cryptographp_theme']))
     24  if (!isset($conf['cryptographp']))
    725  {
    8     pwg_query('INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("cryptographp_theme","cryptographp,reject","CryptograPHP config");');
     26    pwg_query('INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("cryptographp",\''.default_config.'\',"CryptograPHP config");');
    927  }
    1028}
     
    1331{
    1432  global $conf;
    15   $conf['cryptographp_theme'] = explode(',', $conf['cryptographp_theme']);
    1633 
    17   if(count($conf['cryptographp_theme']) == 1)
     34  if (isset($conf['cryptograph_theme']))
    1835  {
    19     pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.$conf['cryptographp_theme'][0].',reject" WHERE param = "cryptographp_theme";');
     36    pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param="cryptographp_theme" LIMIT 1');
     37  }
     38 
     39  if (!isset($conf['cryptograph']))
     40  {
     41    pwg_query('INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("cryptographp",\''.default_config.'\',"CryptograPHP config");');
    2042  }
    2143}
    2244function plugin_uninstall()
    2345{
    24   pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param="cryptographp_theme" LIMIT 1');
     46  pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param="cryptographp" LIMIT 1');
    2547}
    2648
Note: See TracChangeset for help on using the changeset viewer.