source: extensions/CryptograPHP/main.inc.php @ 21466

Last change on this file since 21466 was 21209, checked in by mistic100, 12 years ago

inactive with mobile_theme

File size: 3.8 KB
RevLine 
[10837]1<?php
2/*
[11375]3Plugin Name: Crypto Captcha
[10837]4Version: auto
[20189]5Description: Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t)
[10839]6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535
[10837]7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
[12617]11/*
12Author note :
13Le plugin était appellé à l'origine CryptograPHP et utilisait la librairie CryptograPHP
14Puis il a été renommé Crypto Captcha pour plus de clareté
15La version actuelle s'appelle toujours Crypto Captcha mais utilise la librairie Securimage
16*/
17
[10837]18if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
19
[21209]20if (mobile_theme())
21{
22  return;
23}
24
[20189]25defined('CRYPTO_ID') or define('CRYPTO_ID', basename(dirname(__FILE__)));
26define('CRYPTO_PATH' , PHPWG_PLUGINS_PATH . CRYPTO_ID . '/');
27define('CRYPTO_ADMIN', get_root_url() . 'admin.php?page=plugin-' . CRYPTO_ID);
28define('CRYPTO_VERSION', 'auto');
29
30
[12619]31add_event_handler('init', 'crypto_init');
[10837]32
[20189]33if (defined('IN_ADMIN'))
34{
35  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
36}
37else
38{
39  add_event_handler('init', 'crypto_document_init');
40  add_event_handler('loc_end_section_init', 'crypto_section_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
41}
42
43
44// plugin init
[10837]45function crypto_init()
46{
[20189]47  global $conf, $pwg_loaded_plugins;
[11316]48 
[20189]49  if (
50    CRYPTO_VERSION == 'auto' or
51    $pwg_loaded_plugins[CRYPTO_ID]['version'] == 'auto' or
52    version_compare($pwg_loaded_plugins[CRYPTO_ID]['version'], CRYPTO_VERSION, '<')
53  )
54  {
55    include_once(CRYPTO_PATH . 'include/install.inc.php');
56    crypto_install();
57   
58    if ( $pwg_loaded_plugins[CRYPTO_ID]['version'] != 'auto' and CRYPTO_VERSION != 'auto' )
59    {
60      $query = '
61UPDATE '. PLUGINS_TABLE .'
62SET version = "'. CRYPTO_VERSION .'"
63WHERE id = "'. CRYPTO_ID .'"';
64      pwg_query($query);
65     
66      $pwg_loaded_plugins[CRYPTO_ID]['version'] = CRYPTO_VERSION;
67     
68      if (defined('IN_ADMIN'))
69      {
70        $_SESSION['page_infos'][] = 'Crypto Captcha updated to version '. CRYPTO_VERSION;
71      }
72    }
73  }
74 
[19428]75  $conf['cryptographp'] = unserialize($conf['cryptographp']);
[20189]76}
77
78
79// modules : picture comment & register
80function crypto_document_init()
81{
82  global $conf, $user;
[19428]83 
84  if (!is_a_guest()) return;
[14527]85  if ($user['theme'] == 'smartpocket') return;
86 
[20189]87  if ( script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'] )
[11316]88  {
[19428]89    $conf['cryptographp']['template'] = 'register';
[11316]90    include(CRYPTO_PATH.'include/register.inc.php');
91  }
[20189]92  else if ( script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'] )
[11316]93  {
[19428]94    $conf['cryptographp']['template'] = 'comment';
[11316]95    include(CRYPTO_PATH.'include/picture.inc.php');
96  }
[17319]97 
[12619]98}
99
[20189]100// modules : album comment & contact & guestbook
[12619]101function crypto_section_init()
102{
[15996]103  global $conf, $pwg_loaded_plugins, $page, $user;
[12619]104 
[19428]105  if (!is_a_guest()) return;
[15996]106  if ($user['theme'] == 'smartpocket') return;
107 
[12619]108  if (
[15996]109    script_basename() == 'index' and $conf['cryptographp']['activate_on']['category'] and 
[12617]110    isset($pwg_loaded_plugins['Comments_on_Albums']) and isset($page['section']) and 
111    $page['section'] == 'categories' and isset($page['category'])
112    ) 
113  {
[19428]114    $conf['cryptographp']['template'] = 'comment';
[12617]115    include(CRYPTO_PATH.'include/category.inc.php');
116  }
[20189]117  else if ( isset($page['section']) and $page['section'] == 'contact' and $conf['cryptographp']['activate_on']['contactform'] ) 
[17319]118  {
[19428]119    $conf['cryptographp']['template'] = 'contactform';
[17319]120    include(CRYPTO_PATH.'include/contactform.inc.php');
121  }
[20189]122  else if ( isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook'] ) 
[17319]123  {
[20189]124    $conf['cryptographp']['template'] = 'guestbook';
[17319]125    include(CRYPTO_PATH.'include/guestbook.inc.php');
126  }
[10837]127}
128
[20189]129
130// admin
131function crypto_plugin_admin_menu($menu)
[11316]132{
[20189]133  array_push($menu, array(
134    'NAME' => 'Crypto Captcha',
135    'URL' => CRYPTO_ADMIN,
136    ));
137  return $menu;
[10837]138}
139
140?>
Note: See TracBrowser for help on using the repository browser.