[10837] | 1 | <?php |
---|
| 2 | /* |
---|
[11375] | 3 | Plugin Name: Crypto Captcha |
---|
[10837] | 4 | Version: auto |
---|
[20189] | 5 | Description: Add a captcha to register, comment, GuestBook and ContactForm pages (thanks to P@t) |
---|
[10839] | 6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=535 |
---|
[10837] | 7 | Author: Mistic |
---|
| 8 | Author URI: http://www.strangeplanet.fr |
---|
| 9 | */ |
---|
| 10 | |
---|
[12617] | 11 | ## TODO : add customization of background image |
---|
| 12 | |
---|
| 13 | /* |
---|
| 14 | Author note : |
---|
| 15 | Le plugin était appellé à l'origine CryptograPHP et utilisait la librairie CryptograPHP |
---|
| 16 | Puis il a été renommé Crypto Captcha pour plus de clareté |
---|
| 17 | La version actuelle s'appelle toujours Crypto Captcha mais utilise la librairie Securimage |
---|
| 18 | */ |
---|
| 19 | |
---|
[10837] | 20 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 21 | |
---|
[20189] | 22 | defined('CRYPTO_ID') or define('CRYPTO_ID', basename(dirname(__FILE__))); |
---|
| 23 | define('CRYPTO_PATH' , PHPWG_PLUGINS_PATH . CRYPTO_ID . '/'); |
---|
| 24 | define('CRYPTO_ADMIN', get_root_url() . 'admin.php?page=plugin-' . CRYPTO_ID); |
---|
| 25 | define('CRYPTO_VERSION', 'auto'); |
---|
| 26 | |
---|
| 27 | |
---|
[12619] | 28 | add_event_handler('init', 'crypto_init'); |
---|
[10837] | 29 | |
---|
[20189] | 30 | if (defined('IN_ADMIN')) |
---|
| 31 | { |
---|
| 32 | add_event_handler('get_admin_plugin_menu_links', 'crypto_plugin_admin_menu'); |
---|
| 33 | } |
---|
| 34 | else |
---|
| 35 | { |
---|
| 36 | add_event_handler('init', 'crypto_document_init'); |
---|
| 37 | add_event_handler('loc_end_section_init', 'crypto_section_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | // plugin init |
---|
[10837] | 42 | function crypto_init() |
---|
| 43 | { |
---|
[20189] | 44 | global $conf, $pwg_loaded_plugins; |
---|
[11316] | 45 | |
---|
[20189] | 46 | if ( |
---|
| 47 | CRYPTO_VERSION == 'auto' or |
---|
| 48 | $pwg_loaded_plugins[CRYPTO_ID]['version'] == 'auto' or |
---|
| 49 | version_compare($pwg_loaded_plugins[CRYPTO_ID]['version'], CRYPTO_VERSION, '<') |
---|
| 50 | ) |
---|
| 51 | { |
---|
| 52 | include_once(CRYPTO_PATH . 'include/install.inc.php'); |
---|
| 53 | crypto_install(); |
---|
| 54 | |
---|
| 55 | if ( $pwg_loaded_plugins[CRYPTO_ID]['version'] != 'auto' and CRYPTO_VERSION != 'auto' ) |
---|
| 56 | { |
---|
| 57 | $query = ' |
---|
| 58 | UPDATE '. PLUGINS_TABLE .' |
---|
| 59 | SET version = "'. CRYPTO_VERSION .'" |
---|
| 60 | WHERE id = "'. CRYPTO_ID .'"'; |
---|
| 61 | pwg_query($query); |
---|
| 62 | |
---|
| 63 | $pwg_loaded_plugins[CRYPTO_ID]['version'] = CRYPTO_VERSION; |
---|
| 64 | |
---|
| 65 | if (defined('IN_ADMIN')) |
---|
| 66 | { |
---|
| 67 | $_SESSION['page_infos'][] = 'Crypto Captcha updated to version '. CRYPTO_VERSION; |
---|
| 68 | } |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | |
---|
[19428] | 72 | $conf['cryptographp'] = unserialize($conf['cryptographp']); |
---|
[20189] | 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | // modules : picture comment & register |
---|
| 77 | function crypto_document_init() |
---|
| 78 | { |
---|
| 79 | global $conf, $user; |
---|
[19428] | 80 | |
---|
| 81 | if (!is_a_guest()) return; |
---|
[14527] | 82 | if ($user['theme'] == 'smartpocket') return; |
---|
| 83 | |
---|
[20189] | 84 | if ( script_basename() == 'register' and $conf['cryptographp']['activate_on']['register'] ) |
---|
[11316] | 85 | { |
---|
[19428] | 86 | $conf['cryptographp']['template'] = 'register'; |
---|
[11316] | 87 | include(CRYPTO_PATH.'include/register.inc.php'); |
---|
| 88 | } |
---|
[20189] | 89 | else if ( script_basename() == 'picture' and $conf['cryptographp']['activate_on']['picture'] ) |
---|
[11316] | 90 | { |
---|
[19428] | 91 | $conf['cryptographp']['template'] = 'comment'; |
---|
[11316] | 92 | include(CRYPTO_PATH.'include/picture.inc.php'); |
---|
| 93 | } |
---|
[17319] | 94 | |
---|
[12619] | 95 | } |
---|
| 96 | |
---|
[20189] | 97 | // modules : album comment & contact & guestbook |
---|
[12619] | 98 | function crypto_section_init() |
---|
| 99 | { |
---|
[15996] | 100 | global $conf, $pwg_loaded_plugins, $page, $user; |
---|
[12619] | 101 | |
---|
[19428] | 102 | if (!is_a_guest()) return; |
---|
[15996] | 103 | if ($user['theme'] == 'smartpocket') return; |
---|
| 104 | |
---|
[12619] | 105 | if ( |
---|
[15996] | 106 | script_basename() == 'index' and $conf['cryptographp']['activate_on']['category'] and |
---|
[12617] | 107 | isset($pwg_loaded_plugins['Comments_on_Albums']) and isset($page['section']) and |
---|
| 108 | $page['section'] == 'categories' and isset($page['category']) |
---|
| 109 | ) |
---|
| 110 | { |
---|
[19428] | 111 | $conf['cryptographp']['template'] = 'comment'; |
---|
[12617] | 112 | include(CRYPTO_PATH.'include/category.inc.php'); |
---|
| 113 | } |
---|
[20189] | 114 | else if ( isset($page['section']) and $page['section'] == 'contact' and $conf['cryptographp']['activate_on']['contactform'] ) |
---|
[17319] | 115 | { |
---|
[19428] | 116 | $conf['cryptographp']['template'] = 'contactform'; |
---|
[17319] | 117 | include(CRYPTO_PATH.'include/contactform.inc.php'); |
---|
| 118 | } |
---|
[20189] | 119 | else if ( isset($page['section']) and $page['section'] == 'guestbook' and $conf['cryptographp']['activate_on']['guestbook'] ) |
---|
[17319] | 120 | { |
---|
[20189] | 121 | $conf['cryptographp']['template'] = 'guestbook'; |
---|
[17319] | 122 | include(CRYPTO_PATH.'include/guestbook.inc.php'); |
---|
| 123 | } |
---|
[10837] | 124 | } |
---|
| 125 | |
---|
[20189] | 126 | |
---|
| 127 | // admin |
---|
| 128 | function crypto_plugin_admin_menu($menu) |
---|
[11316] | 129 | { |
---|
[20189] | 130 | array_push($menu, array( |
---|
| 131 | 'NAME' => 'Crypto Captcha', |
---|
| 132 | 'URL' => CRYPTO_ADMIN, |
---|
| 133 | )); |
---|
| 134 | return $menu; |
---|
[10837] | 135 | } |
---|
| 136 | |
---|
| 137 | ?> |
---|