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

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

try to simplify integration of captchas

File size: 2.8 KB
RevLine 
[10837]1<?php
2/*
[11375]3Plugin Name: Crypto Captcha
[10837]4Version: auto
[20189]5Description: Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t)
[24143]6Plugin URI: auto
[10837]7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
[12617]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
[10837]18if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
19
[21209]20if (mobile_theme())
21{
22  return;
23}
24
[26041]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');
[20189]29
30
[12619]31add_event_handler('init', 'crypto_init');
[10837]32
[20189]33if (defined('IN_ADMIN'))
34{
35  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
36}
37else
38{
[26041]39  add_event_handler('loc_end_section_init', 'crypto_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
[26072]40  add_event_handler('loc_begin_register', 'crypto_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
[20189]41}
42
43
44// plugin init
[10837]45function crypto_init()
46{
[26041]47  global $conf;
[11316]48 
[26041]49  include_once(CRYPTO_PATH . 'maintain.inc.php');
50  $maintain = new CryptograPHP_maintain(CRYPTO_ID);
51  $maintain->autoUpdate(CRYPTO_VERSION, 'install');
[20189]52 
[26041]53  load_language('plugin.lang', CRYPTO_PATH);
[19428]54  $conf['cryptographp'] = unserialize($conf['cryptographp']);
[20189]55}
56
57
[26041]58// modules
[20189]59function crypto_document_init()
60{
[26067]61  global $conf, $pwg_loaded_plugins, $page;
[19428]62 
[26041]63  if (!is_a_guest())
64  {
65    return;
66  }
[26072]67
68  if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
[11316]69  {
[26041]70    include(CRYPTO_PATH . 'include/picture.inc.php');
[11316]71  }
[26041]72  else if (isset($page['section']))
[12617]73  {
[26041]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    }
[12617]91  }
[10837]92}
[26072]93function crypto_register_init()
94{
95  global $conf;
96 
97  if (!is_a_guest())
98  {
99    return;
100  }
[10837]101
[26072]102  if ($conf['cryptographp']['activate_on']['register'])
103  {
104    include(CRYPTO_PATH . 'include/register.inc.php');
105  }
106}
[20189]107
[26072]108
[20189]109// admin
110function crypto_plugin_admin_menu($menu)
[11316]111{
[26041]112  $menu[] = array(
[20189]113    'NAME' => 'Crypto Captcha',
114    'URL' => CRYPTO_ADMIN,
[26041]115    );
[20189]116  return $menu;
[26041]117}
Note: See TracBrowser for help on using the repository browser.