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
Line 
1<?php
2/*
3Plugin Name: Crypto Captcha
4Version: auto
5Description: Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t)
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
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
18if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
19
20if (mobile_theme())
21{
22  return;
23}
24
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
31add_event_handler('init', 'crypto_init');
32
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
45function crypto_init()
46{
47  global $conf, $pwg_loaded_plugins;
48 
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 
75  $conf['cryptographp'] = unserialize($conf['cryptographp']);
76}
77
78
79// modules : picture comment & register
80function crypto_document_init()
81{
82  global $conf, $user;
83 
84  if (!is_a_guest()) return;
85  if ($user['theme'] == 'smartpocket') return;
86 
87  if ( script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'] )
88  {
89    $conf['cryptographp']['template'] = 'register';
90    include(CRYPTO_PATH.'include/register.inc.php');
91  }
92  else if ( script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'] )
93  {
94    $conf['cryptographp']['template'] = 'comment';
95    include(CRYPTO_PATH.'include/picture.inc.php');
96  }
97 
98}
99
100// modules : album comment & contact & guestbook
101function crypto_section_init()
102{
103  global $conf, $pwg_loaded_plugins, $page, $user;
104 
105  if (!is_a_guest()) return;
106  if ($user['theme'] == 'smartpocket') return;
107 
108  if (
109    script_basename() == 'index' and $conf['cryptographp']['activate_on']['category'] and 
110    isset($pwg_loaded_plugins['Comments_on_Albums']) and isset($page['section']) and 
111    $page['section'] == 'categories' and isset($page['category'])
112    ) 
113  {
114    $conf['cryptographp']['template'] = 'comment';
115    include(CRYPTO_PATH.'include/category.inc.php');
116  }
117  else if ( isset($page['section']) and $page['section'] == 'contact' and $conf['cryptographp']['activate_on']['contactform'] ) 
118  {
119    $conf['cryptographp']['template'] = 'contactform';
120    include(CRYPTO_PATH.'include/contactform.inc.php');
121  }
122  else if ( isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook'] ) 
123  {
124    $conf['cryptographp']['template'] = 'guestbook';
125    include(CRYPTO_PATH.'include/guestbook.inc.php');
126  }
127}
128
129
130// admin
131function crypto_plugin_admin_menu($menu)
132{
133  array_push($menu, array(
134    'NAME' => 'Crypto Captcha',
135    'URL' => CRYPTO_ADMIN,
136    ));
137  return $menu;
138}
139
140?>
Note: See TracBrowser for help on using the repository browser.