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

Last change on this file since 22725 was 22725, checked in by mistic100, 11 years ago

index.php was selectable as a font ! fix display of checkboxes with small browser window

File size: 3.7 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 
86  if ( script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'] )
87  {
88    $conf['cryptographp']['template'] = 'register';
89    include(CRYPTO_PATH.'include/register.inc.php');
90  }
91  else if ( script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'] )
92  {
93    $conf['cryptographp']['template'] = 'comment';
94    include(CRYPTO_PATH.'include/picture.inc.php');
95  }
96 
97}
98
99// modules : album comment & contact & guestbook
100function crypto_section_init()
101{
102  global $conf, $pwg_loaded_plugins, $page, $user;
103 
104  if (!is_a_guest()) return;
105 
106  if (
107    script_basename() == 'index' and $conf['cryptographp']['activate_on']['category'] and 
108    isset($pwg_loaded_plugins['Comments_on_Albums']) and isset($page['section']) and 
109    $page['section'] == 'categories' and isset($page['category'])
110    ) 
111  {
112    $conf['cryptographp']['template'] = 'comment';
113    include(CRYPTO_PATH.'include/category.inc.php');
114  }
115  else if ( isset($page['section']) and $page['section'] == 'contact' and $conf['cryptographp']['activate_on']['contactform'] ) 
116  {
117    $conf['cryptographp']['template'] = 'contactform';
118    include(CRYPTO_PATH.'include/contactform.inc.php');
119  }
120  else if ( isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook'] ) 
121  {
122    $conf['cryptographp']['template'] = 'guestbook';
123    include(CRYPTO_PATH.'include/guestbook.inc.php');
124  }
125}
126
127
128// admin
129function crypto_plugin_admin_menu($menu)
130{
131  array_push($menu, array(
132    'NAME' => 'Crypto Captcha',
133    'URL' => CRYPTO_ADMIN,
134    ));
135  return $menu;
136}
137
138?>
Note: See TracBrowser for help on using the repository browser.