-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.inc.php
124 lines (103 loc) · 3.32 KB
/
main.inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/*
Version: 1.1.1
Plugin Name: PHP Captcha for Piwigo
Plugin URI: https://piwigo.org/ext/extension_view.php?eid=882
Author: pstimpel
Author URI: https://wp.peters-webcorner.de
Description: PHP Captcha for Piwigo without using any third party content, tracking save and GDPR save replacement for Google Recaptcha and co.
Has Settings: true
*/
/**
Heavily based on work by Mistic and the Plugin Crypto Captcha
Color Picker by Stefan Petre
*/
/**
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// Chech whether we are indeed included by Piwigo.
if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
// Define the path to our plugin.
define('PHPCAPTCHA_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/');
require_once __DIR__ . '/phpcaptchaconfig.php';
add_event_handler('init', 'phpcaptcha_init');
if (defined('IN_ADMIN'))
{
add_event_handler('get_admin_plugin_menu_links', 'phpcaptcha_admin_menu');
}
else
{
add_event_handler('loc_end_section_init', 'phpcaptcha_document_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
add_event_handler('loc_begin_register', 'phpcaptcha_register_init', EVENT_HANDLER_PRIORITY_NEUTRAL+30);
}
//clean the seession directory
PhpCaptchaConfig::cleanSessionDir();
function phpcaptcha_init()
{
load_language('plugin.lang', PHPCAPTCHA_PATH);
}
// modules
function phpcaptcha_document_init()
{
global $pwg_loaded_plugins, $page, $phpcaptcha_config;
$phpcaptcha_config = PhpCaptchaConfig::readConfig();
if (!is_a_guest() && $phpcaptcha_config['guestonly']==true)
{
return;
}
if (script_basename() == 'picture' and $phpcaptcha_config['picture'])
{
include(PHPCAPTCHA_PATH . 'include/picture.inc.php');
}
else if (isset($page['section']))
{
if (
script_basename() == 'index' &&
$page['section'] == 'categories' && isset($page['category']) &&
isset($pwg_loaded_plugins['Comments_on_Albums']) &&
$phpcaptcha_config['category']
)
{
include(PHPCAPTCHA_PATH . 'include/category.inc.php');
}
else if ($page['section'] == 'contact' && $phpcaptcha_config['contactform'])
{
include(PHPCAPTCHA_PATH . 'include/contactform.inc.php');
}
else if ($page['section'] == 'guestbook' && $phpcaptcha_config['guestbook'])
{
include(PHPCAPTCHA_PATH . 'include/guestbook.inc.php');
}
}
}
function phpcaptcha_register_init()
{
global $pwg_loaded_plugins, $page, $phpcaptcha_config;
$phpcaptcha_config = PhpCaptchaConfig::readConfig();
if ($phpcaptcha_config['register'])
{
include(PHPCAPTCHA_PATH . 'include/register.inc.php');
}
}
// Add an entry to the 'Plugins' menu.
function phpcaptcha_admin_menu($menu) {
array_push(
$menu,
array(
'NAME' => l10n('PHP Captcha for Piwigo'),
'URL' => get_root_url() . 'admin.php?page=plugin-phpcaptchapiwigo'
)
);
return $menu;
}