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: auto |
---|
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 | 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('loc_end_section_init', 'crypto_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30); |
---|
40 | add_event_handler('loc_begin_register', 'crypto_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30); |
---|
41 | } |
---|
42 | |
---|
43 | |
---|
44 | // plugin init |
---|
45 | function crypto_init() |
---|
46 | { |
---|
47 | global $conf; |
---|
48 | |
---|
49 | include_once(CRYPTO_PATH . 'maintain.inc.php'); |
---|
50 | $maintain = new CryptograPHP_maintain(CRYPTO_ID); |
---|
51 | $maintain->autoUpdate(CRYPTO_VERSION, 'install'); |
---|
52 | |
---|
53 | load_language('plugin.lang', CRYPTO_PATH); |
---|
54 | $conf['cryptographp'] = unserialize($conf['cryptographp']); |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | // modules |
---|
59 | function crypto_document_init() |
---|
60 | { |
---|
61 | global $conf, $pwg_loaded_plugins, $page; |
---|
62 | |
---|
63 | if (!is_a_guest() && $conf['cryptographp']['guest_only']) |
---|
64 | { |
---|
65 | return; |
---|
66 | } |
---|
67 | |
---|
68 | if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture']) |
---|
69 | { |
---|
70 | include(CRYPTO_PATH . 'include/picture.inc.php'); |
---|
71 | } |
---|
72 | else if (isset($page['section'])) |
---|
73 | { |
---|
74 | if ( |
---|
75 | script_basename() == 'index' && |
---|
76 | $page['section'] == 'categories' && isset($page['category']) && |
---|
77 | isset($pwg_loaded_plugins['Comments_on_Albums']) && |
---|
78 | $conf['cryptographp']['activate_on']['category'] |
---|
79 | ) |
---|
80 | { |
---|
81 | include(CRYPTO_PATH . 'include/category.inc.php'); |
---|
82 | } |
---|
83 | else if ($page['section'] == 'contact' && $conf['cryptographp']['activate_on']['contactform']) |
---|
84 | { |
---|
85 | include(CRYPTO_PATH . 'include/contactform.inc.php'); |
---|
86 | } |
---|
87 | else if ($page['section'] == 'guestbook' && $conf['cryptographp']['activate_on']['guestbook']) |
---|
88 | { |
---|
89 | include(CRYPTO_PATH . 'include/guestbook.inc.php'); |
---|
90 | } |
---|
91 | } |
---|
92 | } |
---|
93 | function crypto_register_init() |
---|
94 | { |
---|
95 | global $conf; |
---|
96 | |
---|
97 | if ($conf['cryptographp']['activate_on']['register']) |
---|
98 | { |
---|
99 | include(CRYPTO_PATH . 'include/register.inc.php'); |
---|
100 | } |
---|
101 | } |
---|
102 | |
---|
103 | |
---|
104 | // admin |
---|
105 | function crypto_plugin_admin_menu($menu) |
---|
106 | { |
---|
107 | $menu[] = array( |
---|
108 | 'NAME' => 'Crypto Captcha', |
---|
109 | 'URL' => CRYPTO_ADMIN, |
---|
110 | ); |
---|
111 | return $menu; |
---|
112 | } |
---|