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

Last change on this file since 28431 was 28344, checked in by mistic100, 11 years ago

add 'guest_only' option

File size: 2.8 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
11/*
12Author note :
13Le plugin était appellé à l'origine CryptograPHP et utilisait la librairie CryptograPHP
14Puis il a été renommé Crypto Captcha pour plus de clareté
15La version actuelle s'appelle toujours Crypto Captcha mais utilise la librairie Securimage
16*/
17
18if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
19
20if (mobile_theme())
21{
22  return;
23}
24
25define('CRYPTO_ID',       basename(dirname(__FILE__)));
26define('CRYPTO_PATH' ,    PHPWG_PLUGINS_PATH . CRYPTO_ID . '/');
27define('CRYPTO_ADMIN',    get_root_url() . 'admin.php?page=plugin-' . CRYPTO_ID);
28define('CRYPTO_VERSION',  'auto');
29
30
31add_event_handler('init', 'crypto_init');
32
33if (defined('IN_ADMIN'))
34{
35  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
36}
37else
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
45function 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
59function 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}
93function 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
105function crypto_plugin_admin_menu($menu)
106{
107  $menu[] = array(
108    'NAME' => 'Crypto Captcha',
109    'URL' => CRYPTO_ADMIN,
110    );
111  return $menu;
112}
Note: See TracBrowser for help on using the repository browser.