1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Crypto Captcha |
---|
4 | Version: auto |
---|
5 | Description: Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t) |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535 |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | /* |
---|
12 | Author note : |
---|
13 | Le plugin était appellé à l'origine CryptograPHP et utilisait la librairie CryptograPHP |
---|
14 | Puis il a été renommé Crypto Captcha pour plus de clareté |
---|
15 | La version actuelle s'appelle toujours Crypto Captcha mais utilise la librairie Securimage |
---|
16 | */ |
---|
17 | |
---|
18 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
19 | |
---|
20 | if (mobile_theme()) |
---|
21 | { |
---|
22 | return; |
---|
23 | } |
---|
24 | |
---|
25 | defined('CRYPTO_ID') or define('CRYPTO_ID', basename(dirname(__FILE__))); |
---|
26 | define('CRYPTO_PATH' , PHPWG_PLUGINS_PATH . CRYPTO_ID . '/'); |
---|
27 | define('CRYPTO_ADMIN', get_root_url() . 'admin.php?page=plugin-' . CRYPTO_ID); |
---|
28 | define('CRYPTO_VERSION', 'auto'); |
---|
29 | |
---|
30 | |
---|
31 | add_event_handler('init', 'crypto_init'); |
---|
32 | |
---|
33 | if (defined('IN_ADMIN')) |
---|
34 | { |
---|
35 | add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu'); |
---|
36 | } |
---|
37 | else |
---|
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 |
---|
45 | function 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 = ' |
---|
61 | UPDATE '. PLUGINS_TABLE .' |
---|
62 | SET version = "'. CRYPTO_VERSION .'" |
---|
63 | WHERE 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 |
---|
80 | function 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 |
---|
101 | function 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 |
---|
131 | function 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 | ?> |
---|