-
Notifications
You must be signed in to change notification settings - Fork 67
/
main.php
179 lines (179 loc) · 5.72 KB
/
main.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
if(basename($_SERVER["PHP_SELF"]) == "main.php") {
die("403 - Access Forbidden");
}
if(isset($_SESSION['id']) && isset($_SESSION['admin'])) {
if(empty($admin)) {
$getcomments = $mysqli->query("SELECT author, feedback, date, comment FROM ".$prefix."bcomments UNION ALL SELECT author, feedback, date, comment FROM ".$prefix."ncomments UNION ALL SELECT author, feedback, date, comment FROM ".$prefix."ecomments");
$gettime = $mysqli->query("SELECT githubapi FROM ".$prefix."properties")->fetch_assoc();
$time = time();
if(empty($gettime['githubapi']) || $gettime['githubapi'] >= $time+21600) {
$time = $time + 21600;
if (extension_loaded('openssl')) {
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"User-Agent: maplebit"
)
);
$context = stream_context_create($opts);
$current_tags = file_get_contents("https://api.github.com/repos/greenelfx/maplebit/tags", false, $context);
if ($current_tags) {
$tags = json_decode($current_tags);
$ref_tag = "v1.20";
$current_tag = $tags[0]->name;
if ($current_tag == $ref_tag) {
$alert_class = "success";
$version_message = "<b>MapleBit is up to date.</b>";
$status = 0;
} else {
$alert_class = "info";
$version_message = "<a href=\"https://github.com/greenelfx/MapleBit\" class=\"alert-link\">Update Available »</a>";
$status = 1;
}
} else {
$alert_class = "danger";
$version_message = "Can't get MapleBit update status.";
$status = 2;
}
} else {
$alert_class = "danger";
$version_message = "Enable openssl by right clicking wamp, then PHP, and then scroll down to php_openssl";
$status = 2;
}
$mysqli->query("UPDATE ".$prefix."properties SET status = '".$status."', githubapi = '". $time ."'");
} else {
$getstatus = $mysqli->query("SELECT status FROM ".$prefix."properties")->fetch_assoc();
if($getstatus['status'] == 0) {
$alert_class = "success";
$version_message = "<b>MapleBit is up to date.</b>";
}
elseif($getstatus['status'] == 1) {
$alert_class = "info";
$version_message = "<a href=\"https://github.com/greenelfx/MapleBit\" class=\"alert-link\">Update Available »</a>";
}
elseif($getstatus['status'] == 2) {
$alert_class = "danger";
$version_message = "Can't get MapleBit update status.";
}
else {
$alert_class = "danger";
$version_message = "Enable openssl by right clicking wamp, then PHP, and then scroll down to php_openssl";
}
}
require_once 'assets/libs/HTMLPurifier.standalone.php';
$commentconfig = HTMLPurifier_Config::createDefault();
$commentconfig->set('HTML.Allowed', '');
$commentpurifier = new HTMLPurifier($commentconfig);
?>
<h2 class="text-left">Admin Home</h2>
<hr>
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-8">
<div class="jumbotron">
<h1>Welcome Back!</h1>
<p>Hey there, <?php echo $_SESSION['name']; ?>! You can use the links below to manage your website configuration, users, reports, and more!</p>
</div>
</div>
<div class="col-md-4">
<div class="alert alert-<?php echo $alert_class; ?>">
<h2 class="text-center" style="margin: 0px;">Status</h2><hr/>
<?php echo $version_message; ?>
</div>
</div>
</div>
<hr/>
<h2 class="text-left">Recent Comments</h2><br/>
<?php
if($getcomments->num_rows) {
echo '<ul class="list-group">';
while($comments = $getcomments->fetch_assoc()) {
$clean_comment = $commentpurifier->purify($comments['comment']);
$clean_comment = (strlen($clean_comment) > 50) ? substr($clean_comment,0,50).'...' : $clean_comment;
if($comments['feedback'] == 0) {
$feedback = "<span class=\"positive_comment\">Positive</span>";
}
elseif($comments['feedback'] == 1) {
$feedback = "<span class=\"neutral_comment\">Neutral</span>";
}
if($comments['feedback'] == 2) {
$feedback = "<span class=\"negative_comment\">Negative</span>";
}
echo "
<li class=\"list-group-item\">
<a href=\"?base=main&page=members&name=" . $comments['author'] . "\">" . $comments['author'] . "</a> - ".$feedback." - Posted ".ago($comments['date']).".<br/>
".$clean_comment."
</li>
";
}
echo "</ul>";
}
else {
echo '<div class="alert alert-info">No comments yet!</div>';
}
?>
<hr/>
</div>
</div>
</div></div></div>
<?php
}
elseif($admin === "voteconfig") {
include('sources/admin/voteconfig.php');
}
elseif($admin === "gmlog") {
include('sources/admin/gmlog.php');
}
elseif($admin === "manevent") {
include('sources/admin/manage-event.php');
}
elseif($admin === "mannews") {
include('sources/admin/manage-news.php');
}
elseif($admin === "muteuser") {
include('sources/admin/mute-user.php');
}
elseif($admin === "unmuteuser") {
include('sources/admin/unmute-user.php');
}
elseif($admin === "properties") {
include('sources/admin/properties.php');
}
elseif($admin === "banned") {
include('sources/admin/banned.php');
}
elseif($admin === "nxpacks") {
include('sources/admin/nxpacks.php');
}
elseif($admin === "theme") {
include('sources/admin/theme.php');
}
elseif($admin === "banner") {
include('sources/admin/banner.php');
}
elseif($admin === "background") {
include('sources/admin/background.php');
}
elseif($admin === "pages") {
include('sources/admin/pages.php');
}
elseif($admin === "homeconfig") {
include('sources/admin/homeconfig.php');
}
elseif($admin === "bannedmaps") {
include('sources/admin/bannedmaps.php');
}
elseif($admin === "manageaccounts") {
include('sources/admin/manage-accounts.php');
}
else {
redirect("?base=admin");
}
if(!empty($admin)) {
include("sources/structure/admin/footer.php");
}
} else {
redirect("?base=main");
}