source: extensions/EasyCaptcha/main.inc.php @ 30946

Last change on this file since 30946 was 28840, checked in by mistic100, 10 years ago

use new maintain class

File size: 2.5 KB
Line 
1<?php
2/*
3Plugin Name: Easy Captcha
4Version: auto
5Description: A fun antibot system for comments, registration, ContactForm and GuestBook.
6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
12
13// TODO : captcha on mobile
14if (mobile_theme())
15{
16  return;
17}
18
19define('EASYCAPTCHA_ID',      basename(dirname(__FILE__)));
20define('EASYCAPTCHA_PATH' ,   PHPWG_PLUGINS_PATH . EASYCAPTCHA_ID . '/');
21define('EASYCAPTCHA_ADMIN',   get_root_url() . 'admin.php?page=plugin-' . EASYCAPTCHA_ID);
22
23
24add_event_handler('init', 'easycaptcha_init');
25
26if (defined('IN_ADMIN'))
27{
28  add_event_handler('get_admin_plugin_menu_links', 'easycaptcha_plugin_admin_menu');
29}
30else
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
38function 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
48function 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}
82function 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
94function easycaptcha_plugin_admin_menu($menu)
95{
96  $menu[] = array(
97    'NAME' => 'Easy Captcha',
98    'URL' => EASYCAPTCHA_ADMIN,
99    );
100  return $menu;
101}
Note: See TracBrowser for help on using the repository browser.