forked from rica-carv/epm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe_module.php
More file actions
86 lines (78 loc) · 2.36 KB
/
Copy pathe_module.php
File metadata and controls
86 lines (78 loc) · 2.36 KB
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
<?php
// Esta treta dos menus activos não funciona, não sei porquê....
//var_dump ($eMenuActive);
//echo "----------------------";
//e107::getMessage()->addError(var_dump ($eMenuActive), 'default', true);
/*
+---------------------------------------------------------------+
| Another Profiles Plugin v0.9.6
| Copyright © 2008 Istvan Csonka
| http://freedigital.hu
| support@freedigital.hu
|
| For the e107 website system
| ©Steve Dunstan
| http://e107.org
| jalist@e107.org
|
| (The original program is Alternate Profiles v2.0
| boreded.co.uk)
|
| Another Profiles Plugin comes with
| ABSOLUTELY NO WARRANTY
| Released under the terms and conditions of the
| GNU General Public License (http://gnu.org).
+---------------------------------------------------------------+
*/
//var_dump (defined('e107_INIT'));
if (!defined('e107_INIT') || !e107::isInstalled('pm')) { exit; }
/**
* epm e_module.php - safe redirect from pm.php -> epm/epm.php
* Works very early in bootstrap and avoids using REPORTS or other undefined symbols.
*/
/* --- simple, safe logger (remove when done) --- */
$epm_log_file = __DIR__ . '/epm_module_load.log';
function _epm_log($msg)
{
global $epm_log_file;
@file_put_contents($epm_log_file, date('[Y-m-d H:i:s] ') . $msg . PHP_EOL, FILE_APPEND);
}
/* --- determine request info safely --- */
$reqUri = $_SERVER['REQUEST_URI'] ?? '';
$phpSelf = $_SERVER['PHP_SELF'] ?? '';
$path = parse_url($reqUri, PHP_URL_PATH) ?: $phpSelf;
$page = basename($path);
/* optional debug */
//_epm_log("e_module loaded; REQUEST_URI={$reqUri} PHP_SELF={$phpSelf} page={$page}");
/* avoid CLI or admin-CLI context */
/*
if (php_sapi_name() === 'cli') {
_epm_log("running in CLI - skipping");
return;
}
*/
/* only act when page is pm.php (robust check) */
if ($page === 'pm' || $page === 'pm.php')
{
$query = $_SERVER['QUERY_STRING'] ?? '';
/* avoid redirect loop: skip if we are already inside /epm/ or epm.php */
if (strpos($reqUri, '/epm/') === false && basename($path) !== 'epm.php' && strpos($phpSelf, '/epm/') === false)
{
$dest = e_PLUGIN . 'epm/epm.php' . ($query ? '?' . $query : '');
// _epm_log("redirecting to: {$dest}");
e107::redirect($dest);
exit;
}
/*
else
{
_epm_log("already in epm, skipping redirect");
}
*/
}
/*
else
{
_epm_log("not pm.php - nothing to do");
}
*/