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

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

use new maintain class

File size: 2.5 KB
RevLine 
[24215]1<?php
2/*
3Plugin Name: Easy Captcha
4Version: auto
[24233]5Description: A fun antibot system for comments, registration, ContactForm and GuestBook.
[24215]6Plugin URI: auto
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
12
[26025]13// TODO : captcha on mobile
[24215]14if (mobile_theme())
15{
16  return;
17}
18
[26025]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);
[24215]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{
[24234]32  add_event_handler('loc_end_section_init', 'easycaptcha_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
[26069]33  add_event_handler('loc_begin_register', 'easycaptcha_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
[24215]34}
35
36
37// plugin init
38function easycaptcha_init()
39{
[28840]40  global $conf;
41  $conf['EasyCaptcha'] = safe_unserialize($conf['EasyCaptcha']);
[24215]42
43  load_language('plugin.lang', EASYCAPTCHA_PATH);
44}
45
46
[24234]47// modules
[24215]48function easycaptcha_document_init()
49{
[24234]50  global $conf, $pwg_loaded_plugins, $page;
[24215]51
[28592]52  if (!is_a_guest() && $conf['EasyCaptcha']['guest_only'])
[26025]53  {
54    return;
55  }
[24215]56
[26069]57  if (script_basename() == 'picture' && $conf['EasyCaptcha']['activate_on']['picture'])
[24215]58  {
59    include(EASYCAPTCHA_PATH . 'include/picture.inc.php');
60  }
[24234]61  else if (isset($page['section']))
[24215]62  {
[24234]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    }
[26025]72    else if ($page['section'] == 'contact' && $conf['EasyCaptcha']['activate_on']['contactform'])
[24234]73    {
74      include(EASYCAPTCHA_PATH . 'include/contactform.inc.php');
75    }
[26025]76    else if ($page['section'] == 'guestbook' && $conf['EasyCaptcha']['activate_on']['guestbook'])
[24234]77    {
78      include(EASYCAPTCHA_PATH . 'include/guestbook.inc.php');
79    }
[24215]80  }
81}
[26069]82function easycaptcha_register_init()
83{
84  global $conf;
[24215]85
[26069]86  if ($conf['EasyCaptcha']['activate_on']['register'])
87  {
88    include(EASYCAPTCHA_PATH . 'include/register.inc.php');
89  }
90}
91
92
[24215]93// admin
94function easycaptcha_plugin_admin_menu($menu)
95{
[26025]96  $menu[] = array(
[24215]97    'NAME' => 'Easy Captcha',
98    'URL' => EASYCAPTCHA_ADMIN,
[26025]99    );
[24215]100  return $menu;
101}
Note: See TracBrowser for help on using the repository browser.