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

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

change reload icon with color choice (dark or light), separate HTML and PHP

File size: 2.8 KB
Line 
1<?php
2/*
3Plugin Name: Crypto Captcha
4Version: auto
5Description: Add a captcha to register, comment and ContactForm pages (thanks to P@t)
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535
7Author: Mistic
8Author URI: http://www.strangeplanet.fr
9*/
10
11## TODO : add customization of background image
12
13/*
14Author note :
15Le plugin était appellé à l'origine CryptograPHP et utilisait la librairie CryptograPHP
16Puis il a été renommé Crypto Captcha pour plus de clareté
17La version actuelle s'appelle toujours Crypto Captcha mais utilise la librairie Securimage
18*/
19
20if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
21define('CRYPTO_PATH' , PHPWG_PLUGINS_PATH . basename(dirname(__FILE__)) . '/');
22
23add_event_handler('init', 'crypto_init');
24add_event_handler('loc_end_section_init', 'crypto_section_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
25
26function crypto_init()
27{
28  global $conf, $user;
29 
30  $conf['cryptographp'] = unserialize($conf['cryptographp']);
31 
32  if (!is_a_guest()) return;
33  if ($user['theme'] == 'smartpocket') return;
34 
35  if (script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'])
36  {
37    $conf['cryptographp']['template'] = 'register';
38    include(CRYPTO_PATH.'include/register.inc.php');
39  }
40  else if (script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'])
41  {
42    $conf['cryptographp']['template'] = 'comment';
43    include(CRYPTO_PATH.'include/picture.inc.php');
44  }
45 
46}
47
48function crypto_section_init()
49{
50  global $conf, $pwg_loaded_plugins, $page, $user;
51 
52  if (!is_a_guest()) return;
53  if ($user['theme'] == 'smartpocket') return;
54 
55  if (
56    script_basename() == 'index' and $conf['cryptographp']['activate_on']['category'] and 
57    isset($pwg_loaded_plugins['Comments_on_Albums']) and isset($page['section']) and 
58    $page['section'] == 'categories' and isset($page['category'])
59    ) 
60  {
61    $conf['cryptographp']['template'] = 'comment';
62    include(CRYPTO_PATH.'include/category.inc.php');
63  }
64  else if ( preg_match('#contact/?$#', $_SERVER['REQUEST_URI']) and $conf['cryptographp']['activate_on']['contactform']) 
65  {
66    $conf['cryptographp']['template'] = 'contactform';
67    include(CRYPTO_PATH.'include/contactform.inc.php');
68  }
69  else if (isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook']) 
70  {
71    $conf['cryptographp']['template'] = 'comment';
72    include(CRYPTO_PATH.'include/guestbook.inc.php');
73  }
74}
75
76if (script_basename() == 'admin')
77{
78  add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu');
79
80  function crypto_plugin_admin_menu($menu)
81  {
82    array_push($menu, array(
83      'NAME' => 'Crypto Captcha',
84      'URL' => get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__))
85      ));
86    return $menu;
87  }
88}
89
90?>
Note: See TracBrowser for help on using the repository browser.