summaryrefslogtreecommitdiffstats
path: root/pages/admin.php
blob: 2109f7c430f47fa3d6340be71e88f551da38eb13 (plain)
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
<?php
htmlHeader();
?>

<body>
<?php
topbar($Links);

include_once('./includes/datas.php');
include_once('./includes/maps.php');
include_once('./includes/mapoftheday.php');
include_once('./includes/sqli.php');
include_once('./includes/playerStats.php');

if ($_GET['applyall'] == 'true') {
	echo "Apply-All command heard. Executing...";
	
	$x = 0;
	while ($x <= 200) {
		$x++;
		$i = 0;
		while ($i <= 4) {
			$i++;
			applyAchievements($x, $i);
		}	
	}
	
	echo "Execution complete!";
}
else if ($_GET['recalcStats'] == 'true') {
	echo "Recalculating all player stats...";
	flush(); //This sends the above echo
	recalculateStatsForAllPlayers();
	echo "Complete!";
}
else if ($_GET['deleteErrors'] == 'true') {
	echo "Deleting error log...";
	flush(); //This sends the above echo
	$today = date("Y-m-d H:i:s");
	file_put_contents("includes/errorlogs.txt", "LOG START $today \n");
	
	echo "Log restarted!";
}
else if ($_POST['muteUser'] == 'true') {

	muteUser($_POST['muteUserID'], $_POST['muteHours']);
	echo "User ID ".$_POST['muteUserID']." muted for ".$_POST['muteHours']." hours";
}

function muteUser($userID, $numHours) {
	global $mysqli;
	$stmt = $mysqli->prepare("UPDATE `users` 
	SET `dateChatGaggedUntil` = ADDDATE(CURDATE(), INTERVAL ? HOUR) 
	WHERE `ID` = ?");
	$stmt->bind_param('ii', $numHours, $userID);
	$stmt->execute();
	return;
}




$sql = "SELECT `ID`, `displayName`, `dateJoined`, `dateLogin`, `email`, `isAdmin` FROM `users`";
$result = mysql_query($sql);

?>

<center>
<h3>Administrators Page</h3>
<p>News:</p>
<p>Buttons:<br />
	<input type="button" value="Apply all achievements" onClick="parent.location=\'admin?applyall=true\'">
	<input type="button" value="Recalculate all player stats" onClick="parent.location=\'admin?recalcStats=true\'">
	<input type="button" value="Delete Errorlog" onClick="parent.location=\'admin?deleteErrors=true\'">
</p>
<p>Links: <a href="errorlogs">View Errorlog.txt</a></p>

	<form action="admin" method="post" id='muteOptions'>
		<input type="hidden" name="muteUser" value="true">
		<input type="submit" value='MUTE USER'>
		USERID:<input type="text" name="muteUserID" id="muteUserID" value="" maxlength="20" autocomplete="off" >
		LENGTH IN HOURS:<input type="text" name="muteHours" id="muteHours" value="" maxlength="20" autocomplete="off" >
	</form>

</center>
<table style="padding-left:20px;">
<tr>
<th>ID</th><th>Display name:</th><th>Joined On:</th><th>Last Logon</th><th>Email</th><th>Administrator</th>
</tr>


<?

while (list($CUID, $CUsername, $Joined, $LastLogon, $email, $isAdmin) = mysql_fetch_row($result)) {

   //$Joined = Date("d/m/y - g:ia", $Joined);
	$Joined = strtotime($Joined);
   //$Joined = relative_date($Joined);
   $Joined = date("Y-m-d", $Joined);

	$LastLogon = strtotime($LastLogon);
   //$LastLogon = relative_date($LastLogon);
   $LastLogon = date("Y-m-d", $LastLogon);

	if ($isAdmin == 1)
		$isAdmin = "Yes";
	else
		$isAdmin = "No";
   

   Echo "<tr>
<td>$CUID</td>
<td><a href='javascript:;'>$CUsername</a></td>
<td>$Joined</td>
<td>$LastLogon</td>
<td>$email</td>
<td>$isAdmin</td>
</tr>";

}

Echo "
         </table>
      <br />
      <br />
      </td>
   </tr>
</table>
";



htmlFooter();
?>