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

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

use new maintain class

File size: 2.4 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
[28838]11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
[12617]12
[28838]13// TODO : captcha on mobile
[21209]14if (mobile_theme())
15{
16  return;
17}
18
[26041]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);
[20189]22
23
[12619]24add_event_handler('init', 'crypto_init');
[10837]25
[20189]26if (defined('IN_ADMIN'))
27{
28  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
29}
30else
31{
[26041]32  add_event_handler('loc_end_section_init', 'crypto_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
[26072]33  add_event_handler('loc_begin_register', 'crypto_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
[20189]34}
35
36
37// plugin init
[10837]38function crypto_init()
39{
[26041]40  global $conf;
[28838]41  $conf['cryptographp'] = safe_unserialize($conf['cryptographp']);
[11316]42 
[26041]43  load_language('plugin.lang', CRYPTO_PATH);
[20189]44}
45
46
[26041]47// modules
[20189]48function crypto_document_init()
49{
[26067]50  global $conf, $pwg_loaded_plugins, $page;
[19428]51 
[28344]52  if (!is_a_guest() && $conf['cryptographp']['guest_only'])
[26041]53  {
54    return;
55  }
[26072]56
57  if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
[11316]58  {
[26041]59    include(CRYPTO_PATH . 'include/picture.inc.php');
[11316]60  }
[26041]61  else if (isset($page['section']))
[12617]62  {
[26041]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    }
[12617]80  }
[10837]81}
[26072]82function crypto_register_init()
83{
84  global $conf;
[10837]85
[26072]86  if ($conf['cryptographp']['activate_on']['register'])
87  {
88    include(CRYPTO_PATH . 'include/register.inc.php');
89  }
90}
[20189]91
[26072]92
[20189]93// admin
94function crypto_plugin_admin_menu($menu)
[11316]95{
[26041]96  $menu[] = array(
[20189]97    'NAME' => 'Crypto Captcha',
98    'URL' => CRYPTO_ADMIN,
[26041]99    );
[20189]100  return $menu;
[26041]101}
Note: See TracBrowser for help on using the repository browser.