Changeset 20189


Ignore:
Timestamp:
Jan 16, 2013, 3:10:31 PM (11 years ago)
Author:
mistic100
Message:

fix for new guestbook template + code cleaning

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

Legend:

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

    r19428 r20189  
    1616  ));
    1717 
    18 $template->set_filename('cryptographp', realpath(CRYPTO_PATH.'include/'.$conf['cryptographp']['template'].'.tpl'));
     18$template->set_filename('cryptographp', realpath(CRYPTO_PATH.'template/'.$conf['cryptographp']['template'].'.tpl'));
    1919$template->assign_var_from_handle('CRYPTOGRAPHP', 'cryptographp');
    2020
  • extensions/CryptograPHP/include/guestbook.inc.php

    r19428 r20189  
    1414function prefilter_crypto($content, $smarty)
    1515{
    16   $search = '{$comment_add.CONTENT}</textarea></p>';
     16  $search = '{$comment_add.CONTENT}</textarea>';
    1717  return str_replace($search, $search."\n{\$CRYPTOGRAPHP}", $content);
    1818}
  • extensions/CryptograPHP/language/en_UK/description.txt

    r12617 r20189  
    1 Add a captcha to register, comment and ContactForm pages (thanks to P@t)
     1Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t)
  • extensions/CryptograPHP/language/fr_FR/description.txt

    r12617 r20189  
    1 Ajoute un captcha à la page d'enregistrement, au formulaire de commentaire et sur la page de ContactForm (merci à P@t)
     1Ajoute un captcha à la page d'enregistrement, aux formulaires de commentaire et sur les pages de ContactForm and GuestBook (merci à P@t)
  • extensions/CryptograPHP/main.inc.php

    r19428 r20189  
    33Plugin Name: Crypto Captcha
    44Version: auto
    5 Description: Add a captcha to register, comment and ContactForm pages (thanks to P@t)
     5Description: Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t)
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535
    77Author: Mistic
     
    1919
    2020if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    21 define('CRYPTO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
     21
     22defined('CRYPTO_ID') or define('CRYPTO_ID', basename(dirname(__FILE__)));
     23define('CRYPTO_PATH' , PHPWG_PLUGINS_PATH . CRYPTO_ID . '/');
     24define('CRYPTO_ADMIN', get_root_url() . 'admin.php?page=plugin-' . CRYPTO_ID);
     25define('CRYPTO_VERSION', 'auto');
     26
    2227
    2328add_event_handler('init', 'crypto_init');
    24 add_event_handler('loc_end_section_init', 'crypto_section_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
    2529
     30if (defined('IN_ADMIN'))
     31{
     32  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
     33}
     34else
     35{
     36  add_event_handler('init', 'crypto_document_init');
     37  add_event_handler('loc_end_section_init', 'crypto_section_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
     38}
     39
     40
     41// plugin init
    2642function crypto_init()
    2743{
    28   global $conf, $user;
     44  global $conf, $pwg_loaded_plugins;
     45 
     46  if (
     47    CRYPTO_VERSION == 'auto' or
     48    $pwg_loaded_plugins[CRYPTO_ID]['version'] == 'auto' or
     49    version_compare($pwg_loaded_plugins[CRYPTO_ID]['version'], CRYPTO_VERSION, '<')
     50  )
     51  {
     52    include_once(CRYPTO_PATH . 'include/install.inc.php');
     53    crypto_install();
     54   
     55    if ( $pwg_loaded_plugins[CRYPTO_ID]['version'] != 'auto' and CRYPTO_VERSION != 'auto' )
     56    {
     57      $query = '
     58UPDATE '. PLUGINS_TABLE .'
     59SET version = "'. CRYPTO_VERSION .'"
     60WHERE id = "'. CRYPTO_ID .'"';
     61      pwg_query($query);
     62     
     63      $pwg_loaded_plugins[CRYPTO_ID]['version'] = CRYPTO_VERSION;
     64     
     65      if (defined('IN_ADMIN'))
     66      {
     67        $_SESSION['page_infos'][] = 'Crypto Captcha updated to version '. CRYPTO_VERSION;
     68      }
     69    }
     70  }
    2971 
    3072  $conf['cryptographp'] = unserialize($conf['cryptographp']);
     73}
     74
     75
     76// modules : picture comment & register
     77function crypto_document_init()
     78{
     79  global $conf, $user;
    3180 
    3281  if (!is_a_guest()) return;
    3382  if ($user['theme'] == 'smartpocket') return;
    3483 
    35   if (script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'])
     84  if ( script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'] )
    3685  {
    3786    $conf['cryptographp']['template'] = 'register';
    3887    include(CRYPTO_PATH.'include/register.inc.php');
    3988  }
    40   else if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
     89  else if ( script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'] )
    4190  {
    4291    $conf['cryptographp']['template'] = 'comment';
     
    4695}
    4796
     97// modules : album comment & contact & guestbook
    4898function crypto_section_init()
    4999{
     
    62112    include(CRYPTO_PATH.'include/category.inc.php');
    63113  }
    64   else if ( preg_match('#contact/?$#', $_SERVER['REQUEST_URI']) and $conf['cryptographp']['activate_on']['contactform'])
     114  else if ( isset($page['section']) and $page['section'] == 'contact' and $conf['cryptographp']['activate_on']['contactform'] )
    65115  {
    66116    $conf['cryptographp']['template'] = 'contactform';
    67117    include(CRYPTO_PATH.'include/contactform.inc.php');
    68118  }
    69   else if (isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook'])
     119  else if ( isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook'] )
    70120  {
    71     $conf['cryptographp']['template'] = 'comment';
     121    $conf['cryptographp']['template'] = 'guestbook';
    72122    include(CRYPTO_PATH.'include/guestbook.inc.php');
    73123  }
    74124}
    75125
    76 if (script_basename() == 'admin')
     126
     127// admin
     128function crypto_plugin_admin_menu($menu)
    77129{
    78   add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
    79 
    80   function crypto_plugin_admin_menu($menu)
    81   {
    82     array_push($menu, array(
    83       'NAME' => 'Crypto Captcha',
    84       'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
    85       ));
    86     return $menu;
    87   }
     130  array_push($menu, array(
     131    'NAME' => 'Crypto Captcha',
     132    'URL' => CRYPTO_ADMIN,
     133    ));
     134  return $menu;
    88135}
    89136
  • extensions/CryptograPHP/maintain.inc.php

    r19428 r20189  
    11<?php
    2 define('crypto_default_config', serialize(array(
    3   'activate_on'     => array(
    4         'picture'     => true,
    5         'category'    => true,
    6         'register'    => true,
    7         'contactform' => true,
    8         'guestbook'   => true,
    9         ),
    10   'comments_action' => 'reject',
    11   'theme'           => 'gray',
    12   'captcha_type'    => 'string',
    13   'case_sensitive'  => 'false',
    14   'code_length'     => 6,
    15   'width'           => 180,
    16   'height'          => 70,
    17   'perturbation'    => 1,
    18   'image_bg_color'  => 'ffffff',
    19   'text_color'      => '8a8a8a',
    20   'num_lines'       => 2,
    21   'line_color'      => '8a8a8a',
    22   'noise_level'     => 0.1,
    23   'noise_color'     => '8a8a8a',
    24   'ttf_file'        => 'TopSecret',
    25   'button_color'    => 'dark',
    26 )));
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
    273
    28 function plugin_install()
     4defined('CRYPTO_ID') or define('CRYPTO_ID', basename(dirname(__FILE__)));
     5include_once(PHPWG_PLUGINS_PATH . CRYPTO_ID . '/include/install.inc.php');
     6
     7function plugin_install()
    298{
    30   global $conf;
    31  
    32   conf_update_param('cryptographp', crypto_default_config);
     9  crypto_install();
     10  define('crypto_installed', true);
    3311}
    3412
    3513function plugin_activate()
    3614{
    37   global $conf;
    38  
    39   if (isset($conf['cryptograph_theme']))
     15  if (!defined('crypto_installed'))
    4016  {
    41     pwg_query('DELETE FROM '.CONFIG_TABLE.' WHERE param="cryptographp_theme" LIMIT 1;');
    42   }
    43  
    44   if (!isset($conf['cryptographp']))
    45   {
    46     conf_update_param('cryptographp', crypto_default_config);
    47   }
    48   else
    49   {
    50     $conf['cryptographp'] = unserialize($conf['cryptographp']);
    51     if (!isset($conf['cryptographp']['activate_on']))
    52     {
    53       $conf['cryptographp']['activate_on'] = array(
    54         'picture'     => $conf['cryptographp']['comments_action'] != 'inactive',
    55         'category'    => $conf['cryptographp']['comments_action'] != 'inactive',
    56         'register'    => true,
    57         'contactform' => true,
    58         'guestbook'   => true,
    59         );
    60       conf_update_param('cryptographp', serialize($conf['cryptographp']));
    61     }
    62     if (!isset($conf['cryptographp']['button_color']))
    63     {
    64       $conf['cryptographp']['button_color'] = 'dark';
    65       conf_update_param('cryptographp', serialize($conf['cryptographp']));
    66     }
     17    crypto_install();
    6718  }
    6819}
Note: See TracChangeset for help on using the changeset viewer.