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

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

include_once('./includes/datas.php');
include_once('./includes/maps.php');
include_once('./includes/mapoftheday.php');
include_once('./includes/sqlEmbedded.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!";
}


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

echo '
<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>

<p>Hello admins, this is our current userlist.</p>
</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();
?>