-
Notifications
You must be signed in to change notification settings - Fork 11
/
admincp.php
80 lines (67 loc) · 2.02 KB
/
admincp.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
<?php
session_start();
include 'lib.php';
include 'lib_form_helper.php';
$hasError = false;
$errormsg = "";
if (!Player::isLoggedIn() || !Player::getSessionPlayer()->isSuper()) {
redirect("Location: index.php");
}
print_header("Admin Control Panel");
?>
<div class="grid_10 suffix_1 prefix_1">
<div id="gatherling_main" class="box">
<div class="uppertitle"> Admin Control Panel </div>
<center>
<?php do_page(); ?>
</center>
<div class="clear"></div>
</div></div>
<?php print_footer(); ?>
<?php
function do_page() {
handleActions();
printError();
printAddCardSet();
printChangePasswordForm();
}
function printError() {
global $hasError;
global $errormsg;
if ($hasError) {
echo "<div class=\"error\">{$errormsg}</div>";
}
}
function printAddCardSet() {
echo "<form action=\"util/insertcardset.php\" method=\"post\" enctype=\"multipart/form-data\">";
echo "<h3><center>Install New Cardset</center></h3>";
echo "<table class=\"form\" style=\"border-width: 0px\" align=\"center\">";
print_select_input("Set Type", "settype", array("Core" => "Core", "Block" => "Block", "Extra" => "Extra"));
print_file_input("Cardset JSON", "cardsetfile");
print_submit("Install New Cardset");
echo "</table></form>";
}
function printChangePasswordForm() {
echo "<form action=\"admincp.php\" method=\"post\">";
echo "<h3><center>Change User Password</center></h3>";
echo "<table class=\"form\" style=\"border-width: 0px\" align=\"center\">";
print_text_input("Username", "username");
print_text_input("New Password", "new_password");
print_submit("Change Password");
echo "</table> </form>";
}
function handleActions() {
global $hasError;
global $errormsg;
if (!isset($_POST['action'])) {
return;
}
if ($_POST['action'] == "Change Password") {
$player = new Player($_POST['username']);
$player->setPassword($_POST['new_password']);
$result = "Password changed for user {$player->name} to {$_POST['new_password']}";
}
if (isset($result)) {
echo "<div class=\"notice\">{$result}</div>";
}
}