source: extensions/CryptograPHP/main.inc.php @ 28838

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

use new maintain class

File size: 2.4 KB
Line 
1<?php
2/*
3Plugin Name: Crypto Captcha
4Version: auto
5Description: Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t)
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('CRYPTO_ID',       basename(dirname(__FILE__)));
20define('CRYPTO_PATH' ,    PHPWG_PLUGINS_PATH . CRYPTO_ID . '/');
21define('CRYPTO_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . CRYPTO_ID);
22
23
24add_event_handler('init', 'crypto_init');
25
26if (defined('IN_ADMIN'))
27{
28  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
29}
30else
31{
32  add_event_handler('loc_end_section_init', 'crypto_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
33  add_event_handler('loc_begin_register', 'crypto_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
34}
35
36
37// plugin init
38function crypto_init()
39{
40  global $conf;
41  $conf['cryptographp'] = safe_unserialize($conf['cryptographp']);
42 
43  load_language('plugin.lang', CRYPTO_PATH);
44}
45
46
47// modules
48function crypto_document_init()
49{
50  global $conf, $pwg_loaded_plugins, $page;
51 
52  if (!is_a_guest() && $conf['cryptographp']['guest_only'])
53  {
54    return;
55  }
56
57  if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
58  {
59    include(CRYPTO_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['cryptographp']['activate_on']['category']
68      )
69    {
70      include(CRYPTO_PATH . 'include/category.inc.php');
71    }
72    else if ($page['section'] == 'contact' && $conf['cryptographp']['activate_on']['contactform'])
73    {
74      include(CRYPTO_PATH . 'include/contactform.inc.php');
75    }
76    else if ($page['section'] == 'guestbook' && $conf['cryptographp']['activate_on']['guestbook'])
77    {
78      include(CRYPTO_PATH . 'include/guestbook.inc.php');
79    }
80  }
81}
82function crypto_register_init()
83{
84  global $conf;
85
86  if ($conf['cryptographp']['activate_on']['register'])
87  {
88    include(CRYPTO_PATH . 'include/register.inc.php');
89  }
90}
91
92
93// admin
94function crypto_plugin_admin_menu($menu)
95{
96  $menu[] = array(
97    'NAME' => 'Crypto Captcha',
98    'URL' => CRYPTO_ADMIN,
99    );
100  return $menu;
101}
Note: See TracBrowser for help on using the repository browser.