/
index.php
132 lines (116 loc) · 3.71 KB
/
index.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
125
126
127
128
129
130
131
132
<?php
/**
* Zenbership Admin Control Panel
*
* Zenbership Membership Software
* Copyright (C) 2013-2016 Castlamp, LLC
*
* 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/>.
*
* @author Castlamp
* @link http://www.castlamp.com/
* @link http://www.zenbership.com/
* @copyright (c) 2013-2016 Castlamp
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
* @project Zenbership Membership Software
*/
/* -- Load Functions -- */
require "sd-system/config.php";
$admin = new admin;
/* -- Admin Session -- */
$employee = $admin->check_employee('', '0');
/* -- IP LOCK -- */
include "sd-system/ip_whitelist.php";
if (! empty($whitelist_ips)) {
if (! in_array(get_ip(), $whitelist_ips)) {
echo "You are not permitted to access this location.";
exit;
}
}
/* -- Correct URL format? -- */
if (strpos(PP_ADMIN, 'https://') !== false) {
if ($db->check_ssl() != '1') {
// Some servers cause a redirect loop if
// there is no trailing forward slash "/"
// at the end of the URL. So we make sure
// we add one here.
$use = rtrim(PP_ADMIN, '/');
header('Location: ' . $use . '/');
exit;
}
}
/* -- Generate Page -- */
ob_start();
$extension = false;
// Redirect to the control panel
if (empty($_GET['l'])) {
$lit = PP_ADMINPATH . "/cp-includes/home.php";
$_GET['l'] = 'home';
}
// If no location was submitted, redirect
// to the control panel homepage.
else {
if (! empty($_GET['plugin'])) {
$lit = PP_PATH . "/custom/plugins/" . htmlentities($_GET['plugin']) . "/admin/views/" . htmlentities($_GET['l']) . ".php";
if (! file_exists($lit)) {
$lit = PP_ADMINPATH . "/cp-includes/error.php";
$_GET['l'] = 'error';
} else {
$ae = new admin_extensions($_GET['l'], $employee, $_GET['plugin']);
$content = $ae->runTask($_GET['l']);
if (empty($content)) {
$lit = PP_ADMINPATH . "/cp-includes/error.php";
$_GET['l'] = 'error';
} else {
$extension = true;
}
}
} else {
$lit = PP_ADMINPATH . "/cp-includes/" . $_GET['l'] . ".php";
if (! file_exists($lit)) {
$lit = PP_ADMINPATH . "/cp-includes/error.php";
$_GET['l'] = 'error';
}
}
}
// Print
if (! empty($_GET['print'])) {
$printing = '1';
$header = 'header-print';
$footer = 'footer-print';
} else {
if (! check_mobile()) {
$printing = '0';
$header = 'header';
$footer = 'footer';
//$header = 'header-mobile';
//$footer = 'footer-mobile';
} else {
$printing = '0';
$header = 'header-mobile';
$footer = 'footer-mobile';
}
}
// Continue
$task_id = $db->start_task('load_page', 'staff', $_GET['l'], $employee['username']);
if (! $extension) {
include($lit);
$content = ob_get_contents();
}
ob_end_clean();
$task = $db->end_task($task_id, '1');
include PP_ADMINPATH . "/cp-includes/" . $header . ".php";
echo $content;
include PP_ADMINPATH . "/cp-includes/" . $footer . ".php";
exit;