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

Revision 26066, 2.9 KB checked in by mistic100, 6 years ago (diff)

compatibility with contactform and guestbook

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}
41
42
43// plugin init
44function crypto_init()
45{
46  global $conf;
47 
48  include_once(CRYPTO_PATH . 'maintain.inc.php');
49  $maintain = new CryptograPHP_maintain(CRYPTO_ID);
50  $maintain->autoUpdate(CRYPTO_VERSION, 'install');
51 
52  load_language('plugin.lang', CRYPTO_PATH);
53  $conf['cryptographp'] = unserialize($conf['cryptographp']);
54}
55
56
57// modules
58function crypto_document_init()
59{
60  global $conf, $user, $page;
61 
62  if (!is_a_guest())
63  {
64    return;
65  }
66 
67  if (script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'])
68  {
69    $conf['cryptographp']['template'] = 'register';
70    include(CRYPTO_PATH . 'include/register.inc.php');
71  }
72  else if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
73  {
74    $conf['cryptographp']['template'] = 'comment';
75    include(CRYPTO_PATH . 'include/picture.inc.php');
76  }
77  else if (isset($page['section']))
78  {
79    if (
80      script_basename() == 'index' &&
81      $page['section'] == 'categories' && isset($page['category']) &&
82      isset($pwg_loaded_plugins['Comments_on_Albums']) &&
83      $conf['cryptographp']['activate_on']['category']
84      )
85    {
86      $conf['cryptographp']['template'] = 'comment';
87      include(CRYPTO_PATH . 'include/category.inc.php');
88    }
89    else if ($page['section'] == 'contact' && $conf['cryptographp']['activate_on']['contactform'])
90    {
91      $conf['cryptographp']['template'] = 'contactform';
92      include(CRYPTO_PATH . 'include/contactform.inc.php');
93    }
94    else if ($page['section'] == 'guestbook' && $conf['cryptographp']['activate_on']['guestbook'])
95    {
96      $conf['cryptographp']['template'] = 'guestbook';
97      include(CRYPTO_PATH . 'include/guestbook.inc.php');
98    }
99  }
100}
101
102
103// admin
104function crypto_plugin_admin_menu($menu)
105{
106  $menu[] = array(
107    'NAME' => 'Crypto Captcha',
108    'URL' => CRYPTO_ADMIN,
109    );
110  return $menu;
111}
Note: See TracBrowser for help on using the repository browser.