1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Easy Captcha |
---|
4 | Version: auto |
---|
5 | Description: A fun antibot system for comments, registration, ContactForm and GuestBook. |
---|
6 | Plugin URI: auto |
---|
7 | Author: Mistic |
---|
8 | Author URI: http://www.strangeplanet.fr |
---|
9 | */ |
---|
10 | |
---|
11 | defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); |
---|
12 | |
---|
13 | // TODO : captcha on mobile |
---|
14 | if (mobile_theme()) |
---|
15 | { |
---|
16 | return; |
---|
17 | } |
---|
18 | |
---|
19 | define('EASYCAPTCHA_ID', basename(dirname(__FILE__))); |
---|
20 | define('EASYCAPTCHA_PATH' , PHPWG_PLUGINS_PATH . EASYCAPTCHA_ID . '/'); |
---|
21 | define('EASYCAPTCHA_ADMIN', get_root_url() . 'admin.php?page=plugin-' . EASYCAPTCHA_ID); |
---|
22 | |
---|
23 | |
---|
24 | add_event_handler('init', 'easycaptcha_init'); |
---|
25 | |
---|
26 | if (defined('IN_ADMIN')) |
---|
27 | { |
---|
28 | add_event_handler('get_admin_plugin_menu_links', 'easycaptcha_plugin_admin_menu'); |
---|
29 | } |
---|
30 | else |
---|
31 | { |
---|
32 | add_event_handler('loc_end_section_init', 'easycaptcha_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30); |
---|
33 | add_event_handler('loc_begin_register', 'easycaptcha_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30); |
---|
34 | } |
---|
35 | |
---|
36 | |
---|
37 | // plugin init |
---|
38 | function easycaptcha_init() |
---|
39 | { |
---|
40 | global $conf; |
---|
41 | $conf['EasyCaptcha'] = safe_unserialize($conf['EasyCaptcha']); |
---|
42 | |
---|
43 | load_language('plugin.lang', EASYCAPTCHA_PATH); |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | // modules |
---|
48 | function easycaptcha_document_init() |
---|
49 | { |
---|
50 | global $conf, $pwg_loaded_plugins, $page; |
---|
51 | |
---|
52 | if (!is_a_guest() && $conf['EasyCaptcha']['guest_only']) |
---|
53 | { |
---|
54 | return; |
---|
55 | } |
---|
56 | |
---|
57 | if (script_basename() == 'picture' && $conf['EasyCaptcha']['activate_on']['picture']) |
---|
58 | { |
---|
59 | include(EASYCAPTCHA_PATH . 'include/picture.inc.php'); |
---|
60 | } |
---|
61 | else if (isset($page['section'])) |
---|
62 | { |
---|
63 | if ( |
---|
64 | script_basename() == 'index' && |
---|
65 | $page['section'] == 'categories' && isset($page['category']) && |
---|
66 | isset($pwg_loaded_plugins['Comments_on_Albums']) && |
---|
67 | $conf['EasyCaptcha']['activate_on']['category'] |
---|
68 | ) |
---|
69 | { |
---|
70 | include(EASYCAPTCHA_PATH . 'include/category.inc.php'); |
---|
71 | } |
---|
72 | else if ($page['section'] == 'contact' && $conf['EasyCaptcha']['activate_on']['contactform']) |
---|
73 | { |
---|
74 | include(EASYCAPTCHA_PATH . 'include/contactform.inc.php'); |
---|
75 | } |
---|
76 | else if ($page['section'] == 'guestbook' && $conf['EasyCaptcha']['activate_on']['guestbook']) |
---|
77 | { |
---|
78 | include(EASYCAPTCHA_PATH . 'include/guestbook.inc.php'); |
---|
79 | } |
---|
80 | } |
---|
81 | } |
---|
82 | function easycaptcha_register_init() |
---|
83 | { |
---|
84 | global $conf; |
---|
85 | |
---|
86 | if ($conf['EasyCaptcha']['activate_on']['register']) |
---|
87 | { |
---|
88 | include(EASYCAPTCHA_PATH . 'include/register.inc.php'); |
---|
89 | } |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | // admin |
---|
94 | function easycaptcha_plugin_admin_menu($menu) |
---|
95 | { |
---|
96 | $menu[] = array( |
---|
97 | 'NAME' => 'Easy Captcha', |
---|
98 | 'URL' => EASYCAPTCHA_ADMIN, |
---|
99 | ); |
---|
100 | return $menu; |
---|
101 | } |
---|