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

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

index.php was selectable as a font ! fix display of checkboxes with small browser window

File size: 3.7 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)
[10839]6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535
[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
[20189]25defined('CRYPTO_ID') or define('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
[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{
39  add_event_handler('init', 'crypto_document_init');
40  add_event_handler('loc_end_section_init', 'crypto_section_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
41}
42
43
44// plugin init
[10837]45function crypto_init()
46{
[20189]47  global $conf, $pwg_loaded_plugins;
[11316]48 
[20189]49  if (
50    CRYPTO_VERSION == 'auto' or
51    $pwg_loaded_plugins[CRYPTO_ID]['version'] == 'auto' or
52    version_compare($pwg_loaded_plugins[CRYPTO_ID]['version'], CRYPTO_VERSION, '<')
53  )
54  {
55    include_once(CRYPTO_PATH . 'include/install.inc.php');
56    crypto_install();
57   
58    if ( $pwg_loaded_plugins[CRYPTO_ID]['version'] != 'auto' and CRYPTO_VERSION != 'auto' )
59    {
60      $query = '
61UPDATE '. PLUGINS_TABLE .'
62SET version = "'. CRYPTO_VERSION .'"
63WHERE id = "'. CRYPTO_ID .'"';
64      pwg_query($query);
65     
66      $pwg_loaded_plugins[CRYPTO_ID]['version'] = CRYPTO_VERSION;
67     
68      if (defined('IN_ADMIN'))
69      {
70        $_SESSION['page_infos'][] = 'Crypto Captcha updated to version '. CRYPTO_VERSION;
71      }
72    }
73  }
74 
[19428]75  $conf['cryptographp'] = unserialize($conf['cryptographp']);
[20189]76}
77
78
79// modules : picture comment & register
80function crypto_document_init()
81{
82  global $conf, $user;
[19428]83 
84  if (!is_a_guest()) return;
[14527]85 
[20189]86  if ( script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'] )
[11316]87  {
[19428]88    $conf['cryptographp']['template'] = 'register';
[11316]89    include(CRYPTO_PATH.'include/register.inc.php');
90  }
[20189]91  else if ( script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'] )
[11316]92  {
[19428]93    $conf['cryptographp']['template'] = 'comment';
[11316]94    include(CRYPTO_PATH.'include/picture.inc.php');
95  }
[17319]96 
[12619]97}
98
[20189]99// modules : album comment & contact & guestbook
[12619]100function crypto_section_init()
101{
[15996]102  global $conf, $pwg_loaded_plugins, $page, $user;
[12619]103 
[19428]104  if (!is_a_guest()) return;
[15996]105 
[12619]106  if (
[15996]107    script_basename() == 'index' and $conf['cryptographp']['activate_on']['category'] and 
[12617]108    isset($pwg_loaded_plugins['Comments_on_Albums']) and isset($page['section']) and 
109    $page['section'] == 'categories' and isset($page['category'])
110    ) 
111  {
[19428]112    $conf['cryptographp']['template'] = 'comment';
[12617]113    include(CRYPTO_PATH.'include/category.inc.php');
114  }
[20189]115  else if ( isset($page['section']) and $page['section'] == 'contact' and $conf['cryptographp']['activate_on']['contactform'] ) 
[17319]116  {
[19428]117    $conf['cryptographp']['template'] = 'contactform';
[17319]118    include(CRYPTO_PATH.'include/contactform.inc.php');
119  }
[20189]120  else if ( isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook'] ) 
[17319]121  {
[20189]122    $conf['cryptographp']['template'] = 'guestbook';
[17319]123    include(CRYPTO_PATH.'include/guestbook.inc.php');
124  }
[10837]125}
126
[20189]127
128// admin
129function crypto_plugin_admin_menu($menu)
[11316]130{
[20189]131  array_push($menu, array(
132    'NAME' => 'Crypto Captcha',
133    'URL' => CRYPTO_ADMIN,
134    ));
135  return $menu;
[10837]136}
137
138?>
Note: See TracBrowser for help on using the repository browser.