summaryrefslogtreecommitdiff
path: root/html/pages/admin
diff options
context:
space:
mode:
Diffstat (limited to 'html/pages/admin')
-rwxr-xr-xhtml/pages/admin/acelog.php318
-rwxr-xr-xhtml/pages/admin/aclog.php108
-rwxr-xr-xhtml/pages/admin/check.php408
-rwxr-xr-xhtml/pages/admin/dmatch.php105
-rwxr-xr-xhtml/pages/admin/dplayer.php76
-rwxr-xr-xhtml/pages/admin/dpmatch.php106
-rwxr-xr-xhtml/pages/admin/editgames.php74
-rwxr-xr-xhtml/pages/admin/editgamestype.php228
-rwxr-xr-xhtml/pages/admin/editweapons.php58
-rwxr-xr-xhtml/pages/admin/emptydb.php62
-rwxr-xr-xhtml/pages/admin/index.htm0
-rwxr-xr-xhtml/pages/admin/ipsearch.php58
-rwxr-xr-xhtml/pages/admin/main.php117
-rwxr-xr-xhtml/pages/admin/mplayers.php91
-rwxr-xr-xhtml/pages/admin/mservers.php41
-rwxr-xr-xhtml/pages/admin/pban.php74
-rwxr-xr-xhtml/pages/admin/pinfo.php91
-rwxr-xr-xhtml/pages/admin/plm.php329
-rwxr-xr-xhtml/pages/admin/recalcflags.php72
-rwxr-xr-xhtml/pages/admin/recalcranking.php77
-rwxr-xr-xhtml/pages/admin/utdclog.php137
-rwxr-xr-xhtml/pages/admin/utdcshot.php22
22 files changed, 2652 insertions, 0 deletions
diff --git a/html/pages/admin/acelog.php b/html/pages/admin/acelog.php
new file mode 100755
index 0000000..365174a
--- /dev/null
+++ b/html/pages/admin/acelog.php
@@ -0,0 +1,318 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('Access denied');
+
+$filename = (!empty($_REQUEST['filename'])) ? my_stripslashes($_REQUEST['filename']) : '';
+$filename = str_replace(array('..', '/', '\\', '<', ':'), array(), $filename);
+
+function InvertSort($curr_field, $order, $sort) {
+ if ($curr_field != $order) return(($curr_field == "time") ? "DESC" : "ASC");
+ if ($sort == 'ASC') return('DESC');
+ return('ASC');
+}
+
+function SortPic($curr_field, $order, $sort) {
+ if ($curr_field != $order) return;
+ $fname = 'images/s_'. strtolower($sort) .'.png';
+ if (!file_exists($fname)) return;
+ return('&nbsp;<img src="'. $fname .'" border="0" width="11" height="9" alt="" title="('.strtolower($sort).'ending)">');
+}
+
+// Get filter, order and set sorting
+if (isset($_GET[order])) {
+ $order = my_addslashes($_GET[order]);
+ setcookie('uts_ace_order', $_GET['order'], time()+60*60*24*30*365);
+}
+else if (isset($_COOKIE['uts_ace_order'])){
+ $order = $_REQUEST['uts_ace_order'];
+}
+else {
+ $order = "time";
+}
+
+if (isset($_GET[sort])) {
+ $sort = my_addslashes($_GET[sort]);
+ setcookie('uts_ace_sort', $_GET['sort'], time()+60*60*24*30*365);
+}
+else if (isset($_COOKIE['uts_ace_sort'])){
+ $sort = $_REQUEST['uts_ace_sort'];
+}
+else {
+ $sort = ($order == "time") ? "DESC" : "ASC";
+}
+
+if (isset($_GET[timeout])) {
+ $timeout = my_addslashes($_GET[timeout]);
+ setcookie('uts_ace_timeout', $_GET['timeout'], time()+60*60*24*30*365);
+}
+else if (isset($_COOKIE['uts_ace_timeout'])){
+ $timeout = $_REQUEST['uts_ace_timeout'];
+}
+else {
+ $timeout = 0;
+}
+
+if (isset($_GET[show])) {
+ $show = my_addslashes($_GET[show]);
+ setcookie('uts_ace_show', $_GET['show'], time()+60*60*24*30*365);
+}
+else if (isset($_COOKIE['uts_ace_show'])){
+ $show = $_REQUEST['uts_ace_show'];
+}
+else {
+ $show = "week";
+}
+
+if (!empty($filename)) {
+ if (!file_exists('logs/ace/'. $filename) or !is_file('logs/ace/'. $filename)) die('File not found');
+ if (isset($_REQUEST['del'])) {
+ unlink('logs/ace/'. $filename);
+ $filename = '';
+ }
+}
+
+if (empty($filename)) {
+ echo '
+
+ <script language = "javascript">
+
+ function timefilter() {
+ var filter = document.filter.show.value;
+ window.open("admin.php?key='.$adminkey.'&action='.$action.'&show="+filter, "_parent");
+ }
+
+ function toggletimeouts() {
+ if (document.filter.timeouts.checked == true) {
+ window.open("admin.php?key='.$adminkey.'&action='.$action.'&timeout=1", "_parent");
+ }
+ else {
+ window.open("admin.php?key='.$adminkey.'&action='.$action.'&timeout=0", "_parent");
+ }
+ }
+ </script>
+ <form name = "filter">
+ <table class = "box" border="0" cellpadding="1" cellspacing="2" width="720">
+ <tr>
+ <td class="heading" align="center" width="100%" colspan="5">Available ACE Logs:</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="center" width="100%" colspan = "5">Filter:
+ <select onchange = "javascript:timefilter()" name = "show">
+ <option value = "all"'.($show == "all" ? ' selected=selected' : '').'>All</option>
+ <option value = "day"'.($show == "day" ? ' selected=selected' : '').'>Last day</option>
+ <option value = "week"'.($show == "week" ? ' selected=selected' : '').'>Last week</option>
+ <option value = "month"'.($show == "month" ? ' selected=selected' : '').'>Last month</option>
+ </select>
+ <input name = "timeouts" type = "checkbox" value = 1 onchange = "javascript:toggletimeouts()"'.($timeout == 1 ? ' checked="yes"' : '').'> Show timeouts</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="center"><a class="smheading" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;order=time&amp;sort='.InvertSort('time', $order, $sort).'">Time</a>'.SortPic('time', $order, $sort).'</td>
+ <td class="smheading" align="center"><a class="smheading" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;order=name&amp;sort='.InvertSort('name', $order, $sort).'">Player Name</a>'.SortPic('name', $order, $sort).'</td>
+ <td class="smheading" align="center"><a class="smheading" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;order=reason&amp;sort='.InvertSort('reason', $order, $sort).'">Kick Reason</a>'.SortPic('reason', $order, $sort).'</td>
+ <td class="smheading" align="center" colspan = 2></td>
+ </tr>';
+ $logdir = opendir('logs/ace');
+ $logs = array();
+ $sortlogs = array();
+ $i = 0;
+ while (false !== ($filename = readdir($logdir))) {
+ if (!is_file('logs/ace/'. $filename)) continue;
+ if ($filename == '.htaccess' or $filename == 'index.htm') continue;
+
+ preg_match('/\d{4}\.\d{2}.\d{2}.\d{2}.\d{2}.\d{2}/', $filename, &$date);
+ $adate = preg_split('/\./', $date[0]);
+ // filter on days
+ if ($show != "all") {
+ // calculate days
+ $logAgeInDays = abs(strtotime(date("Y/m/d")) - strtotime("$adate[0]/$adate[1]/$adate[2]"))/68400-1;
+ if (($show == "day" and $logAgeInDays > 1)
+ or ($show == "week" and $logAgeInDays > 7)
+ or ($show == "month" and $logAgeInDays > 31)) {
+ continue;
+ }
+ }
+
+ $i++;
+ $TimeStamp = "unknown";
+ $PlayerName = "unknown";
+ $KickReason = "unknown";
+ if (substr($filename, strlen($filename) - strlen($import_ace_screenshot_extension)) == $import_ace_screenshot_extension
+ and substr($filename, 0, strlen($import_ace_screenshot_start)) == $import_ace_screenshot_start) {
+ // Screenshot
+ $TimeStamp = "$adate[2]-$adate[1]-$adate[0] / $adate[3]:$adate[4]:$adate[5]";
+ $PlayerName = "Unknown";
+ $KickReason = "Screenshot";
+ }
+ else {
+ // logfile
+
+ $fp = my_fopen('logs/ace/'.$filename, 'rb', $compression = NULL);
+ if (!$fp) die("Error opening file");
+
+ while (($line = my_fgets($fp, 5000, $compression)) !== FALSE) {
+ $info = preg_split('/\s/', $line, 3);
+ $info[2] = preg_replace('/[\r\n]+/', '', $info[2]);
+ if ($info[1] == "TimeStamp....:") {
+ $TimeStamp = $info[2];
+ }
+ else if ($info[1] == "PlayerName...:") {
+ $PlayerName = $info[2];
+ }
+ else if ($info[1] == "KickReason...:") {
+ $KickReason = $info[2];
+ }
+ else if ($info[1] == "RequestedBy..:") {
+ $KickReason = "Requested Screenshot";
+ }
+ else if ($info[1] == "WARNING:") {
+ $ainfo = preg_split('/\s/', $info[2]);
+ if ($ainfo[5] == "UDP") {
+ $TimeStamp = "$adate[2]-$adate[1]-$adate[0] / $adate[3]:$adate[4]:$adate[5]";
+ $PlayerName = $ainfo[1];
+ $KickReason = "Proxy/Tunnel";
+ }
+ }
+ else if ($info[2] == ": Kicked - [REASON] Timeout during check spawn") {
+ $TimeStamp = "$adate[2]-$adate[1]-$adate[0] / $adate[3]:$adate[4]:$adate[5]";
+ $PlayerName = preg_replace('/[\[\]]/', '', $info[1]);
+ $KickReason = "Timeout during check spawn";
+ }
+ }
+ my_fclose($fp, $compression);
+ }
+
+ // don't show timeout logs?
+ if (($timeout == 0)
+ and (($KickReason == "Timeout during check spawn")
+ or ($KickReason == "Timeout during checks")
+ or ($KickReason == "Timeout during initial check"))) {
+ continue;
+ }
+
+ $logs[$i] = array($filename, $TimeStamp, $PlayerName, $KickReason);
+ $extra = 0;
+ if (substr($filename, -4) == '.bz2') $extra = 4;
+ if (substr($filename, -3) == '.gz') $extra = 3;
+
+ if ($order == "time") {
+ $sortlogs[$i] = $date[0];
+ }
+ else if ($order == "name") {
+ $sortlogs[$i] = strtolower($PlayerName);
+ }
+ else if ($order == "reason") {
+ $sortlogs[$i] = strtolower($KickReason);
+ }
+ }
+ closedir($logdir);
+ if (count($logs) == 0) {
+ echo '<tr><td class="grey" colspan="5">No logs available!</td></tr>';
+ } else {
+ if ($sort == "ASC") {
+ asort($sortlogs);
+ }
+ else {
+ arsort($sortlogs);
+ }
+ $i = 0;
+ foreach($sortlogs as $id => $date) {
+ $log = $logs[$id][0];
+ if (empty($log)) {
+ continue;
+ }
+ $TimeStamp = $logs[$id][1];
+ $PlayerName = $logs[$id][2];
+ $KickReason = $logs[$id][3];
+ $Screenshot = $logs[$id][4];
+ $extra = 0;
+ if (substr($log, -4) == '.bz2') $extra = 4;
+ if (substr($log, -3) == '.gz') $extra = 3;
+
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr><td class="'.$class.'">';
+ $tmp = substr($log, strlen($log) - (23 + $extra), 19);
+ $tmp = str_replace('.', '', $tmp);
+ // $ts = mtimestamp($tmp);
+ echo ' <a class="'.$class.'" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'">'.$TimeStamp.'</a>';
+ echo '</td><td class="'.$class.'">';
+ echo '<a class="'.$class.'" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'">'.$PlayerName.'</a>';
+ echo '</td><td class="'.$class.'">';
+ echo '<a class="'.$class.'" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'">'.$KickReason.'</a>';
+ echo '</td><td class="'.$class.'" align="right">';
+ $d_size = file_size_info(filesize('logs/ace/'. $log));
+ echo $d_size['size'] .' '. $d_size['type'];
+ echo '</td><td class="'.$class.'" align="center">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td></tr>';
+ }
+ }
+ echo '</form>';
+}
+
+
+if (!empty($filename)) {
+ if (!file_exists('logs/ace/'. $filename) or !is_file('logs/ace/'. $filename)) die('File not found (2)');
+ echo'<br><table class = "box" border="0" cellpadding="1" cellspacing="2" width="720">
+ <tr>
+ <td class="smheading" align="center" width="95%" colspan="4">'.$filename.'</td>
+ <td class="smheading" align="center" width="5%" align="right">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($filename).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td>
+ </tr>';
+ if (substr($filename, strlen($filename) - strlen($import_ace_screenshot_extension)) == $import_ace_screenshot_extension
+ and substr($filename, 0, strlen($import_ace_screenshot_start)) == $import_ace_screenshot_start) {
+ // screenshot
+ echo '<tr><td class="grey" colspan="5"><span style="font-family: monospace;">';
+ echo '<a href = "logs/ace/'.preg_replace('/\+/', '%20', urlencode($filename)).'" target = "_blank"><img src = "logs/ace/'.preg_replace('/\+/', '%20', urlencode($filename)).'" width = 100% border = 0></a>';
+ echo '</span></td></tr>';
+ }
+ else {
+ $fp = my_fopen('logs/ace/'.$filename, 'rb', $compression = NULL);
+ if (!$fp) die("Error opening file");
+
+ $i = 0;
+ echo '<tr><td class="grey" colspan="5"><span style="font-family: monospace;">';
+
+ while (($line = my_fgets($fp, 5000, $compression)) !== FALSE) {
+ /*
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr><td class="'.$class.'" colspan="4">';
+ echo '<span style="font-family: monospace;">';
+ echo htmlentities($line);
+ echo '</span>';
+ echo '</td></tr>';
+ */
+ echo wordwrap(htmlentities($line), 80, '<br />', 1) ."<br />";
+ $info = preg_split('/\s/', $line, 3);
+ $info[2] = preg_replace('/[\r\n]/', '', $info[2]);
+ if ($info[1] == "FileName.....:") {
+ $Screenshot = basename($info[2]);
+ }
+
+ }
+ echo '</span></td></tr>';
+ my_fclose($fp, $compression);
+
+ // look for a matching ace screenshot
+ if (isset($Screenshot) and file_exists('logs/ace/' . $Screenshot)) {
+ echo '<tr>
+ <td class="smheading" align="center" width="95%" colspan="4">'.$Screenshot.'</td>
+ <td class="smheading" align="center" width="5%" align="right">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.preg_replace('/\+/', '%20', urlencode($Screenshot)).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td>
+ </tr>';
+
+ echo '<tr><td class="grey" colspan="5"><span style="font-family: monospace;">';
+ echo '<a href = "logs/ace/'.preg_replace('/\+/', '%20', urlencode($Screenshot)).'" target = "_blank"><img src = "logs/ace/'.preg_replace('/\+/', '%20', urlencode($Screenshot)).'" width = 100% border = 0></a>';
+ echo '</span></td></tr>';
+ }
+ }
+}
+
+echo '</tr>';
+if (!empty($filename)) echo'<tr><td class="smheading" align="center" colspan="5"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'&amp;action='.$action.'">Go Back To Logfile Overview</a></td></tr>';
+echo'<tr><td class="smheading" align="center" colspan="5"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td></tr>';
+echo '</table>';
+
+?>
diff --git a/html/pages/admin/aclog.php b/html/pages/admin/aclog.php
new file mode 100755
index 0000000..ada35c8
--- /dev/null
+++ b/html/pages/admin/aclog.php
@@ -0,0 +1,108 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$filename = (!empty($_REQUEST['filename'])) ? my_stripslashes($_REQUEST['filename']) : '';
+$filename = str_replace(array('..', '/', '\\', '<', ':'), array(), $filename);
+
+
+if (!empty($filename)) {
+ if (!file_exists('logs/ac/'. $filename) or !is_file('logs/ac/'. $filename)) die('bla');
+ if (isset($_REQUEST['del'])) {
+ unlink('logs/ac/'. $filename);
+ $filename = '';
+ }
+}
+
+
+
+
+if (empty($filename)) {
+ echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" width="100%" colspan="4">Available AnthChecker Logs:</td>
+ </tr>';
+ $logdir = opendir('logs/ac');
+ $logs = array();
+ $sort = array();
+ $i = 0;
+ while (false !== ($filename = readdir($logdir))) {
+ if (!is_file('logs/ac/'. $filename)) continue;
+ if ($filename == '.htaccess' or $filename == 'index.htm') continue;
+ $i++;
+ $logs[$i] = $filename;
+ $extra = 0;
+ if (substr($filename, -4) == '.bz2') $extra = 4;
+ if (substr($filename, -3) == '.gz') $extra = 3;
+
+ $sort[$i] = substr($filename, strlen($filename) - (23 + $extra), 19);
+ }
+ closedir($logdir);
+ if (count($logs) == 0) {
+ echo '<tr><td class="grey" colspan="4">No logs available!</td></tr>';
+ } else {
+ arsort($sort);
+ $i = 0;
+ foreach($sort as $id => $date) {
+ $log = $logs[$id];
+ $extra = 0;
+ if (substr($log, -4) == '.bz2') $extra = 4;
+ if (substr($log, -3) == '.gz') $extra = 3;
+
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr><td class="'.$class.'">';
+ $tmp = substr($log, strlen($log) - (23 + $extra), 19);
+ $tmp = str_replace('.', '', $tmp);
+ $ts = mtimestamp($tmp);
+ echo ' <a class="'.$class.'" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'">'.date('Y-m-d H:i', $ts).'</a>';
+ echo '</td><td class="'.$class.'">';
+ echo '<a class="'.$class.'" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'">'.substr($log, 6, strlen($log) - 30 - $extra).'</a>';
+ echo '</td><td class="'.$class.'" align="right">';
+ $d_size = file_size_info(filesize('logs/ac/'. $log));
+ echo $d_size['size'] .' '. $d_size['type'];
+ echo '</td><td class="'.$class.'" align="center">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td></tr>';
+ }
+ }
+}
+
+
+if (!empty($filename)) {
+ if (!file_exists('logs/ac/'. $filename) or !is_file('logs/ac/'. $filename)) die('bla');
+ echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" width="95%" colspan="3">'.$filename.'</td>
+ <td class="smheading" align="center" width="5%" align="right">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($filename).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td>
+ </tr>';
+
+ $fp = my_fopen('logs/ac/'.$filename, 'rb', $compression = NULL);
+ if (!$fp) die("Error opening file");
+
+ $i = 0;
+ echo '<tr><td class="grey" colspan="4"><span style="font-family: monospace;">';
+
+ while (($line = my_fgets($fp, 5000, $compression)) !== FALSE) {
+ /*
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr><td class="'.$class.'" colspan="4">';
+ echo '<span style="font-family: monospace;">';
+ echo htmlentities($line);
+ echo '</span>';
+ echo '</td></tr>';
+ */
+ echo wordwrap(htmlentities($line), 80, '<br />', 1) ."<br />";
+ }
+ echo '</span></td></tr>';
+ my_fclose($fp, $compression);
+}
+
+echo '</tr>';
+if (!empty($filename)) echo'<tr><td class="smheading" align="center" colspan="4"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'&amp;action='.$action.'">Go Back To Logfile Overview</a></td></tr>';
+echo'<tr><td class="smheading" align="center" colspan="4"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td></tr>';
+echo '</table>';
+
+?>
diff --git a/html/pages/admin/check.php b/html/pages/admin/check.php
new file mode 100755
index 0000000..a03bf91
--- /dev/null
+++ b/html/pages/admin/check.php
@@ -0,0 +1,408 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+echo '
+ <center>
+ <table class = "box" border="0" cellpadding="1" cellspacing="2" width="720">
+ <tbody><tr>
+ <td class="heading" align="center" colspan="2">Server configuration check</td>
+ </tr></tbody></table><br>';
+
+// Check access rights
+echo '
+ <table class="box" border="0" cellpadding="1" cellspacing="2">
+ <tr>
+ <td class="smheading" align="center" height="25" width="550" colspan="2">Checking access rights</td>
+ </tr>';
+
+// directories
+foreach (array("logs", "logs/ac", "logs/backup", "logs/utdc", "logs/ace") as $dir)
+{
+ echo '
+ <tr>
+ <td class="smheading" align="left" width="350">', $dir, '</td>';
+ if (!file_exists($dir)) {
+ if (mkdir($dir, 0777)) {
+ echo '
+ <td class="warn" align="left" width="200">Created</td></tr>';
+ }
+ else {
+ echo '
+ <td class="warn" align="left" width="200">Not found!</td></tr>';
+ }
+ }
+ else if (!is_dir($dir)) {
+ echo '
+ <td class="warn" align="left" width="200">Not a directory!</td></tr>';
+ }
+ else if (!is_writable($dir)) {
+ if (@chmod($dir, 0777)) {
+ echo '
+ <td class="grey" align="left" width="200">SET</td></tr>';
+ }
+ else {
+ echo '
+ <td class="warn" align="left" width="200">Incorrect access rights: ' , substr(sprintf('%o', fileperms($dir)), -4) , '</td></tr>';
+ }
+ }
+ else {
+ echo '
+ <td class="grey" align="left" width="200">OK</td></tr>';
+ }
+}
+
+// files:
+foreach (array("includes/ftptimestamp.php") as $file)
+{
+ echo '
+ <tr>
+ <td class="smheading" align="left" width="350">', $file, '</td>';
+ if (!file_exists($file)) {
+ echo '
+ <td class="warn" align="left" width="200">Not found!</td></tr>';
+ }
+ else if (!is_file($file)) {
+ echo '
+ <td class="warn" align="left" width="200">Not a file!</td></tr>';
+ }
+ else if (!is_writable($file)) {
+ if (@chmod($file, 0777)) {
+ echo '
+ <td class="grey" align="left" width="200">SET</td></tr>';
+ }
+ else {
+ echo '
+ <td class="warn" align="left" width="200">Incorrect access rights: ' , substr(sprintf('%o', fileperms($file)), -4) , '</td></tr>';
+ }
+ }
+ else {
+ echo '
+ <td class="grey" align="left" width="200">OK</td></tr>';
+ }
+}
+
+echo '
+ </tbody></table>
+<div class="opnote">* Might not work correctly on Windows systems *</div><br>';
+
+
+// connect to the database and check structure
+echo '
+ <table class="box" border="0" cellpadding="1" cellspacing="2">
+ <tr>
+ <td class="smheading" align="center" height="25" width="550" colspan="2">Checking mysql tables</td>
+ </tr>';
+
+// database creation array
+// to add a database simply add $create_table['dbname'] = "database creation sql"
+$create_table['uts_events'] = "
+CREATE TABLE `uts_events` (
+ `id` mediumint(10) NOT NULL auto_increment,
+ `matchid` mediumint(10) NOT NULL default '0',
+ `playerid` tinyint(3) NOT NULL default '0',
+ `col0` varchar(20) NOT NULL default '',
+ `col1` varchar(120) NOT NULL default '',
+ `col2` varchar(120) NOT NULL default '',
+ `col3` varchar(120) NOT NULL default '',
+ `col4` varchar(120) NOT NULL default '',
+ PRIMARY KEY (`id`)
+);
+";
+
+$create_table['uts_games'] = "
+CREATE TABLE `uts_games` (
+ `id` tinyint(3) unsigned NOT NULL auto_increment,
+ `gamename` varchar(100) NOT NULL default '',
+ `name` varchar(100) NOT NULL default '',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT=9 ;
+";
+
+$create_table['uts_gamestype'] = "
+CREATE TABLE `uts_gamestype` (
+ `id` smallint(5) unsigned NOT NULL auto_increment,
+ `serverip` varchar(21) NOT NULL default '',
+ `gamename` varchar(100) NOT NULL default '',
+ `mutator` varchar(100) NOT NULL default '',
+ `gid` tinyint(3) unsigned NOT NULL default '0',
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM;
+";
+
+$create_table['uts_ignoreips'] = "
+CREATE TABLE IF NOT EXISTS `uts_ignoreips` (
+ `ip` bigint(15) NOT NULL default '0',
+ PRIMARY KEY (`ip`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+";
+
+$create_table['uts_killsmatrix'] = "
+CREATE TABLE `uts_killsmatrix` (
+ `matchid` mediumint(8) unsigned NOT NULL default '0',
+ `killer` tinyint(4) NOT NULL default '0',
+ `victim` tinyint(4) NOT NULL default '0',
+ `kills` tinyint(3) unsigned NOT NULL default '0',
+ KEY `matchid` (`matchid`)
+) ENGINE=MyISAM;
+";
+
+$create_table['uts_match'] = "
+CREATE TABLE `uts_match` (
+ `id` mediumint(10) NOT NULL auto_increment,
+ `time` varchar(14) default NULL,
+ `servername` varchar(100) NOT NULL default '',
+ `serverip` varchar(21) NOT NULL default '0',
+ `gamename` varchar(100) NOT NULL default '0',
+ `gid` tinyint(3) unsigned NOT NULL default '0',
+ `gametime` float NOT NULL default '0',
+ `mutators` longtext NOT NULL,
+ `insta` tinyint(1) NOT NULL default '0',
+ `tournament` varchar(5) NOT NULL default '',
+ `teamgame` varchar(5) NOT NULL default '',
+ `mapname` varchar(100) NOT NULL default '',
+ `mapfile` varchar(100) NOT NULL default '',
+ `serverinfo` mediumtext NOT NULL,
+ `gameinfo` mediumtext NOT NULL,
+ `firstblood` int(10) unsigned NOT NULL default '0',
+ `frags` mediumint(5) NOT NULL default '0',
+ `deaths` mediumint(5) NOT NULL default '0',
+ `kills` mediumint(5) NOT NULL default '0',
+ `suicides` mediumint(5) NOT NULL default '0',
+ `teamkills` mediumint(5) NOT NULL default '0',
+ `assaultid` varchar(10) NOT NULL default '',
+ `ass_att` tinyint(1) NOT NULL default '0',
+ `ass_win` tinyint(4) NOT NULL default '0',
+ `t0` tinyint(1) NOT NULL default '0',
+ `t1` tinyint(1) NOT NULL default '0',
+ `t2` tinyint(1) NOT NULL default '0',
+ `t3` tinyint(1) NOT NULL default '0',
+ `t0score` mediumint(5) NOT NULL default '0',
+ `t1score` mediumint(5) NOT NULL default '0',
+ `t2score` mediumint(5) NOT NULL default '0',
+ `t3score` mediumint(5) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `serverip` (`serverip`)
+) ENGINE=MyISAM AUTO_INCREMENT=83 ;
+";
+
+$create_table['uts_pinfo'] = "
+CREATE TABLE `uts_pinfo` (
+ `id` int(10) unsigned NOT NULL auto_increment,
+ `name` varchar(50) NOT NULL default '',
+ `country` char(2) NOT NULL default '',
+ `banned` enum('Y','N') NOT NULL default 'N',
+ PRIMARY KEY (`id`),
+ KEY `name` (`name`(22))
+) ENGINE=MyISAM AUTO_INCREMENT=136 ;
+";
+
+$create_table['uts_player'] = "
+CREATE TABLE `uts_player` (
+ `id` mediumint(10) NOT NULL auto_increment,
+ `matchid` mediumint(10) NOT NULL default '0',
+ `insta` tinyint(1) NOT NULL default '0',
+ `playerid` tinyint(3) NOT NULL default '0',
+ `pid` int(10) unsigned NOT NULL default '0',
+ `team` tinyint(2) unsigned NOT NULL default '0',
+ `isabot` tinyint(1) NOT NULL default '0',
+ `country` char(2) NOT NULL default '',
+ `ip` int(10) unsigned NOT NULL default '0',
+ `gid` tinyint(3) unsigned NOT NULL default '0',
+ `gametime` float NOT NULL default '0',
+ `gamescore` smallint(5) NOT NULL default '0',
+ `lowping` smallint(5) unsigned NOT NULL default '0',
+ `highping` smallint(5) unsigned NOT NULL default '0',
+ `avgping` smallint(5) unsigned NOT NULL default '0',
+ `frags` smallint(5) NOT NULL default '0',
+ `deaths` smallint(5) unsigned NOT NULL default '0',
+ `kills` smallint(5) unsigned NOT NULL default '0',
+ `suicides` smallint(5) unsigned NOT NULL default '0',
+ `teamkills` smallint(5) unsigned NOT NULL default '0',
+ `eff` float NOT NULL default '0',
+ `accuracy` float NOT NULL default '0',
+ `ttl` float NOT NULL default '0',
+ `flag_taken` smallint(5) unsigned NOT NULL default '0',
+ `flag_dropped` smallint(5) unsigned NOT NULL default '0',
+ `flag_return` smallint(5) unsigned NOT NULL default '0',
+ `flag_capture` tinyint(3) unsigned NOT NULL default '0',
+ `flag_cover` smallint(5) unsigned NOT NULL default '0',
+ `flag_seal` smallint(5) unsigned NOT NULL default '0',
+ `flag_assist` smallint(5) unsigned NOT NULL default '0',
+ `flag_kill` mediumint(5) unsigned NOT NULL default '0',
+ `flag_pickedup` smallint(5) unsigned NOT NULL default '0',
+ `dom_cp` smallint(5) unsigned NOT NULL default '0',
+ `ass_obj` smallint(5) unsigned NOT NULL default '0',
+ `spree_double` smallint(5) unsigned NOT NULL default '0',
+ `spree_triple` smallint(5) unsigned NOT NULL default '0',
+ `spree_multi` smallint(5) unsigned NOT NULL default '0',
+ `spree_mega` tinyint(3) unsigned NOT NULL default '0',
+ `spree_ultra` tinyint(3) unsigned NOT NULL default '0',
+ `spree_monster` tinyint(3) unsigned NOT NULL default '0',
+ `spree_kill` smallint(5) unsigned NOT NULL default '0',
+ `spree_rampage` smallint(5) unsigned NOT NULL default '0',
+ `spree_dom` tinyint(3) unsigned NOT NULL default '0',
+ `spree_uns` tinyint(3) unsigned NOT NULL default '0',
+ `spree_god` smallint(5) unsigned NOT NULL default '0',
+ `pu_pads` tinyint(3) unsigned NOT NULL default '0',
+ `pu_armour` tinyint(3) unsigned NOT NULL default '0',
+ `pu_keg` tinyint(3) unsigned NOT NULL default '0',
+ `pu_invis` tinyint(3) unsigned NOT NULL default '0',
+ `pu_belt` tinyint(3) unsigned NOT NULL default '0',
+ `pu_amp` tinyint(3) unsigned NOT NULL default '0',
+ `rank` float NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `matchid` (`matchid`,`team`),
+ KEY `pid` (`pid`),
+ KEY `gid` (`gid`)
+) ENGINE=MyISAM AUTO_INCREMENT=615 ;
+";
+
+$create_table['uts_rank'] = "
+CREATE TABLE `uts_rank` (
+ `id` mediumint(10) NOT NULL auto_increment,
+ `time` float unsigned NOT NULL default '0',
+ `pid` int(10) unsigned NOT NULL default '0',
+ `gid` tinyint(3) unsigned NOT NULL default '0',
+ `rank` float NOT NULL default '0',
+ `prevrank` float NOT NULL default '0',
+ `matches` mediumint(5) NOT NULL default '0',
+ PRIMARY KEY (`id`),
+ KEY `name` (`pid`,`gid`),
+ KEY `rank` (`rank`),
+ KEY `gamename` (`gid`,`rank`)
+) ENGINE=MyISAM AUTO_INCREMENT=173 ;
+";
+
+$create_table['uts_weapons'] = "
+CREATE TABLE `uts_weapons` (
+ `id` tinyint(3) unsigned NOT NULL auto_increment,
+ `name` varchar(100) NOT NULL default '',
+ `image` varchar(50) NOT NULL default '',
+ `sequence` tinyint(3) unsigned NOT NULL default '200',
+ `hide` enum('N','Y') NOT NULL default 'N',
+ PRIMARY KEY (`id`),
+ KEY `name` (`name`(20))
+) ENGINE=MyISAM AUTO_INCREMENT=20 ;
+";
+
+$create_table['uts_weaponstats'] = "
+CREATE TABLE `uts_weaponstats` (
+ `matchid` mediumint(8) unsigned NOT NULL default '0',
+ `pid` int(10) unsigned NOT NULL default '0',
+ `weapon` tinyint(3) unsigned NOT NULL default '0',
+ `kills` mediumint(8) unsigned NOT NULL default '0',
+ `shots` int(10) unsigned NOT NULL default '0',
+ `hits` int(10) unsigned NOT NULL default '0',
+ `damage` int(10) unsigned NOT NULL default '0',
+ `acc` float unsigned NOT NULL default '0',
+ KEY `full` (`matchid`,`pid`)
+) ENGINE=MyISAM;
+";
+
+foreach ($create_table as $table => $query) {
+ echo '
+ <tr>
+ <td class="smheading" align="left" width="350">', $table, '</td>';
+ if (small_count("SHOW TABLES LIKE '$table'") == 1) {
+ // database exists, check columns
+ echo '
+ <td class="grey" align="left" width="200">OK</td></tr>';
+ }
+ else {
+ if (mysql_query($query)) {
+ echo '
+ <td class="grey" align="left" width="200">Created</td></tr>';
+ }
+ else {
+ echo '
+ <td class="warn" align="left" width="200">Not found!</td></tr>';
+ }
+ }
+}
+echo '
+ </tbody></table><br>';
+
+// Check the weapons
+$create_weapon['Translocator'] = "INSERT INTO `uts_weapons` VALUES (1, 'Translocator', 'trans.jpg', 1, 'N');";
+$create_weapon['Impact Hammer'] = "INSERT INTO `uts_weapons` VALUES (2, 'Impact Hammer', 'impact.jpg', 2, 'N');";
+$create_weapon['Enforcer'] = "INSERT INTO `uts_weapons` VALUES (3, 'Enforcer', 'enforcer.jpg', 3, 'N');";
+$create_weapon['Double Enforcer'] = "INSERT INTO `uts_weapons` VALUES (4, 'Double Enforcer', 'enforcer2.jpg', 4, 'N');";
+$create_weapon['GES Bio Rifle'] = "INSERT INTO `uts_weapons` VALUES (5, 'GES Bio Rifle', 'bio.jpg', 5, 'N');";
+$create_weapon['Ripper'] = "INSERT INTO `uts_weapons` VALUES (6, 'Ripper', 'ripper.jpg', 6, 'N');";
+$create_weapon['Shock Rifle'] = "INSERT INTO `uts_weapons` VALUES (7, 'Shock Rifle', 'shock.jpg', 7, 'N');";
+$create_weapon['Enhanced Shock Rifle'] = "INSERT INTO `uts_weapons` VALUES (8, 'Enhanced Shock Rifle', 'ishock.jpg', 8, 'N');";
+$create_weapon['Pulse Gun'] = "INSERT INTO `uts_weapons` VALUES (9, 'Pulse Gun', 'pulse.jpg', 9, 'N');";
+$create_weapon['Minigun'] = "INSERT INTO `uts_weapons` VALUES (10, 'Minigun', 'minigun.jpg', 10, 'N');";
+$create_weapon['Flak Cannon'] = "INSERT INTO `uts_weapons` VALUES (11, 'Flak Cannon', 'flak.jpg', 11, 'N');";
+$create_weapon['Rocket Launcher'] = "INSERT INTO `uts_weapons` VALUES (12, 'Rocket Launcher', 'rockets.jpg', 12, 'N');";
+$create_weapon['Sniper Rifle'] = "INSERT INTO `uts_weapons` VALUES (13, 'Sniper Rifle', 'sniper.jpg', 13, 'N');";
+$create_weapon['Redeemer'] = "INSERT INTO `uts_weapons` VALUES (14, 'Redeemer', 'deemer.jpg', 14, 'N');";
+$create_weapon['None'] = "INSERT INTO `uts_weapons` VALUES (15, 'None', 'blank.jpg', 15, 'N');";
+$create_weapon['Chainsaw'] = "INSERT INTO `uts_weapons` VALUES (16, 'Chainsaw', 'chainsaw.jpg', 16, 'N');";
+
+echo '
+ <table class="box" border="0" cellpadding="1" cellspacing="2">
+ <tr>
+ <td class="smheading" align="center" height="25" width="550" colspan="2">Checking supported weapons</td>
+ </tr>';
+if (small_count("SHOW TABLES LIKE 'uts_weapons'") != 1) {
+ // database exists, check columns
+ echo '
+ <td class="warn" align="left" width="550" colspan = "2">Table uts_weapons does not exist!</td></tr>';
+}
+else {
+ foreach ($create_weapon as $weapon => $query) {
+ echo '
+ <tr>
+ <td class="smheading" align="left" width="350">', $weapon, '</td>';
+ if (small_count("SELECT id FROM uts_weapons WHERE name = '$weapon' LIMIT 0,1") == 1) {
+ // database exists, check columns
+ echo '
+ <td class="grey" align="left" width="200">OK</td></tr>';
+ }
+ else {
+ if (mysql_query($query)) {
+ echo '
+ <td class="grey" align="left" width="200">Added</td></tr>';
+ }
+ else {
+ echo '
+ <td class="warn" align="left" width="200">Not found!</td></tr>';
+ }
+ }
+ }
+}
+echo '
+ </tbody></table><br>';
+
+echo '
+ <table class="box" border="0" cellpadding="1" cellspacing="2">
+ <tr>
+ <td class="smheading" align="center" height="25" width="550" colspan="2">Checking data</td>
+ </tr>';
+
+ echo '
+ <tr>
+ <td class="smheading" align="left" width="350">Fix BT cap times</td>';
+
+ $q = mysql_query("UPDATE uts_events SET col3 = ROUND(CEILING((col3-1)*100/1.1) / 100, 2), col1 = 'btcap' WHERE col1 = 'cap'");
+ $affected = mysql_affected_rows();
+
+ if ($affected == -1) {
+ echo '
+ <td class="error" align="left" width="200">Failed</td></tr>
+ <table>';
+ }
+ else {
+ echo '
+ <td class="grey" align="left" width="200">Updated ' . $affected . ' rows.</td></tr>
+ <table><br>';
+ }
+
+echo '
+ <table class = "box" border="0" cellpadding="1" cellspacing="2" width="720">
+ <tbody>';
+echo '<tr><td class="smheading" align="center" colspan="4"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td></tr>';
+echo '</tbody></table>';
+
+?> \ No newline at end of file
diff --git a/html/pages/admin/dmatch.php b/html/pages/admin/dmatch.php
new file mode 100755
index 0000000..9fed97d
--- /dev/null
+++ b/html/pages/admin/dmatch.php
@@ -0,0 +1,105 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Delete match';
+$i = 0;
+$options['vars'][$i]['name'] = 'server';
+$options['vars'][$i]['type'] = 'server';
+$options['vars'][$i]['prompt'] = 'Choose the server where the match took place:';
+$options['vars'][$i]['caption'] = 'Server:';
+$i++;
+$options['vars'][$i]['name'] = 'mid';
+$options['vars'][$i]['type'] = 'match';
+$options['vars'][$i]['whereserver'] = 'server';
+$options['vars'][$i]['prompt'] = 'Choose the match to delete:';
+$options['vars'][$i]['caption'] = 'Match to delete:';
+$i++;
+
+$results = adminselect($options);
+
+
+$matchid = $results['mid'];
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Deleting Match ID '.$matchid.'</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Adjusting Rankings</td>';
+$sql_radjust = "SELECT pid, gid, rank FROM uts_player WHERE matchid = $matchid";
+$q_radjust = mysql_query($sql_radjust) or die(mysql_error());
+$pids = array();
+while ($r_radjust = mysql_fetch_array($q_radjust)) {
+
+ $pid = $r_radjust[pid];
+ $pids[] = $pid;
+ $gid = $r_radjust[gid];
+ $rank = $r_radjust[rank];
+
+ $sql_crank = small_query("SELECT id, rank, matches FROM uts_rank WHERE pid = $pid AND gid = $gid");
+ if (!$sql_crank) continue;
+
+ $rid = $sql_crank[id];
+ $newrank = $sql_crank[rank]-$rank;
+ $oldrank = $sql_crank[rank];
+ $matchcount = $sql_crank[matches]-1;
+
+ mysql_query("UPDATE uts_rank SET rank = $newrank, prevrank = $oldrank, matches = $matchcount WHERE id = $rid") or die(mysql_error());
+ mysql_query("DELETE FROM uts_rank WHERE matches = 0") or die(mysql_error());
+}
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Match Record:</td>';
+mysql_query("DELETE FROM uts_match WHERE id = $matchid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Player Records:</td>';
+mysql_query("DELETE FROM uts_player WHERE matchid = $matchid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Kill Matrix Entries:</td>';
+mysql_query("DELETE FROM uts_killsmatrix WHERE matchid = $matchid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Weapon Stats:</td>';
+mysql_query("DELETE FROM uts_weaponstats WHERE matchid = $matchid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Amending Player Weapon Stats:</td>';
+foreach($pids as $pid) {
+ mysql_query("DELETE FROM uts_weaponstats WHERE matchid IN ('$matchid','0') AND pid = '$pid'") or die(mysql_error());
+
+ $q_weaponstats = mysql_query("SELECT weapon, SUM(kills) AS kills, SUM(shots) AS shots, SUM(hits) as hits, SUM(damage) as damage, AVG(acc) AS acc FROM uts_weaponstats WHERE pid = '$pid' GROUP BY weapon") or die(mysql_error());
+ while ($r_weaponstats = mysql_fetch_array($q_weaponstats)) {
+ mysql_query("INSERT INTO uts_weaponstats SET matchid='0', pid='$pid', weapon='${r_weaponstats['weapon']}', kills='${r_weaponstats['kills']}', shots='${r_weaponstats['shots']}', hits='${r_weaponstats['hits']}', damage='${r_weaponstats['damage']}', acc='${r_weaponstats['acc']}'") or die(mysql_error());
+ }
+}
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Amending Global Weapon Stats:</td>';
+ mysql_query("DELETE FROM uts_weaponstats WHERE matchid='0' AND pid='0'") or die(mysql_error());
+
+ $q_weaponstats = mysql_query("SELECT weapon, SUM(kills) AS kills, SUM(shots) AS shots, SUM(hits) as hits, SUM(damage) as damage, AVG(acc) AS acc FROM uts_weaponstats WHERE matchid = '0' GROUP BY weapon") or die(mysql_error());
+ while ($r_weaponstats = mysql_fetch_array($q_weaponstats)) {
+ mysql_query("INSERT INTO uts_weaponstats SET matchid='0', pid='0', weapon='${r_weaponstats['weapon']}', kills='${r_weaponstats['kills']}', shots='${r_weaponstats['shots']}', hits='${r_weaponstats['hits']}', damage='${r_weaponstats['damage']}', acc='${r_weaponstats['acc']}'") or die(mysql_error());
+ }
+
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing events:</td>';
+mysql_query("DELETE FROM uts_events WHERE matchid = $matchid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="center" colspan="2">Match Deleted - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+
+
+?>
diff --git a/html/pages/admin/dplayer.php b/html/pages/admin/dplayer.php
new file mode 100755
index 0000000..0239e5d
--- /dev/null
+++ b/html/pages/admin/dplayer.php
@@ -0,0 +1,76 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Delete Player';
+$i = 0;
+$options['vars'][$i]['name'] = 'pid';
+$options['vars'][$i]['type'] = 'player';
+$options['vars'][$i]['prompt'] = 'Choose the player you want to delete:';
+$options['vars'][$i]['caption'] = 'Player to delete:';
+$i++;
+
+$results = adminselect($options);
+
+
+$pid = $results['pid'];
+$playerid = $pid;
+
+echo'<table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Deleting Player</td>
+</tr>
+<tr>
+ <td class="smheading" align="left">Removing Kill Matrix Entries:</td>';
+ $q_match = mysql_query("SELECT matchid, playerid FROM uts_player WHERE pid = '$pid'") or die(mysql_error());
+ while ($r_match = mysql_fetch_array($q_match)) {
+ mysql_query("DELETE FROM uts_killsmatrix WHERE matchid = '${r_match['matchid']}' AND (killer = '${r_match['playerid']}' OR victim = '${r_match['playerid']}')") or die(mysql_error());
+ }
+ echo'<td class="grey" align="left">Done</td>
+</tr>
+
+<tr>
+ <td class="smheading" align="left" width="300">Removing Player Info:</td>';
+$r_pinfo = small_query("SELECT banned FROM uts_pinfo WHERE id = $playerid");
+if ($r_pinfo['banned'] != 'Y') {
+ mysql_query("DELETE FROM uts_pinfo WHERE id = $playerid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="300">Done</td>';
+} else {
+ echo'<td class="grey" align="left" width="300">No (player banned)</td>';
+}
+echo '
+</tr>
+<tr>
+ <td class="smheading" align="left">Removing Player Match Events:</td>';
+mysql_query("DELETE e.* FROM uts_player as p, uts_events as e WHERE p.pid = $playerid AND p.playerid = e.playerid AND p.matchid = e.matchid") or die(mysql_error());
+ echo'<td class="grey" align="left">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left">Removing Player Match Records:</td>';
+mysql_query("DELETE FROM uts_player WHERE pid = $playerid") or die(mysql_error());
+ echo'<td class="grey" align="left">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left">Removing Player Rank:</td>';
+mysql_query("DELETE FROM uts_rank WHERE pid = $playerid") or die(mysql_error());
+ echo'<td class="grey" align="left">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left">Removing Player Weapon Stats:</td>';
+mysql_query("DELETE FROM uts_weaponstats WHERE pid = $playerid") or die(mysql_error());
+ echo'<td class="grey" align="left">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Amending Global Weapon Stats:</td>';
+ mysql_query("DELETE FROM uts_weaponstats WHERE matchid='0' AND pid='0'") or die(mysql_error());
+
+ $q_weaponstats = mysql_query("SELECT weapon, SUM(kills) AS kills, SUM(shots) AS shots, SUM(hits) as hits, SUM(damage) as damage, AVG(acc) AS acc FROM uts_weaponstats WHERE matchid = '0' GROUP BY weapon") or die(mysql_error());
+ while ($r_weaponstats = mysql_fetch_array($q_weaponstats)) {
+ mysql_query("INSERT INTO uts_weaponstats SET matchid='0', pid='0', weapon='${r_weaponstats['weapon']}', kills='${r_weaponstats['kills']}', shots='${r_weaponstats['shots']}', hits='${r_weaponstats['hits']}', damage='${r_weaponstats['damage']}', acc='${r_weaponstats['acc']}'") or die(mysql_error());
+ }
+
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="center" colspan="2">Player Deleted - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+?>
diff --git a/html/pages/admin/dpmatch.php b/html/pages/admin/dpmatch.php
new file mode 100755
index 0000000..b021054
--- /dev/null
+++ b/html/pages/admin/dpmatch.php
@@ -0,0 +1,106 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Delete Player from Match';
+$i = 0;
+$options['vars'][$i]['name'] = 'pid';
+$options['vars'][$i]['type'] = 'player';
+$options['vars'][$i]['prompt'] = 'Choose the player you want to delete from a match:';
+$options['vars'][$i]['caption'] = 'Player to delete:';
+$i++;
+$options['vars'][$i]['name'] = 'mid';
+$options['vars'][$i]['type'] = 'match';
+$options['vars'][$i]['whereplayer'] = 'pid';
+$options['vars'][$i]['prompt'] = 'Choose the match you want to delete the player from:';
+$options['vars'][$i]['caption'] = 'Match:';
+$i++;
+
+$results = adminselect($options);
+
+
+$matchid = $results['mid'];
+$pid = $results['pid'];
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Delete Player From Match ID '.$matchid.'</td>
+</tr>';
+
+echo'<tr>
+ <td class="smheading" align="left" width="200">Amending Players Rank:</td>';
+
+$q_radjust = small_query("SELECT pid, gid, rank FROM uts_player WHERE id = $pid");
+if (!$q_radjust) {
+ $sql_crank = false;
+} else {
+ $rank_pid = $q_radjust[pid];
+ $rank_gid = $q_radjust[gid];
+ $rank = $q_radjust[rank];
+
+ $sql_crank = small_query("SELECT id, rank, matches FROM uts_rank WHERE pid = $rank_pid AND gid = '$rank_gid'");
+}
+if (!$sql_crank) {
+ echo'<td class="grey" align="left" width="400">Player not in rankings</td>';
+} else {
+ $rid = $sql_crank[id];
+ $newrank = $sql_crank[rank]-$rank;
+ $oldrank = $sql_crank[rank];
+ $matchcount = $sql_crank[matches]-1;
+
+ mysql_query("UPDATE uts_rank SET rank = $newrank, prevrank = $oldrank, matches = $matchcount WHERE id = $rid") or die(mysql_error());
+ mysql_query("DELETE FROM uts_rank WHERE matches = 0") or die(mysql_error());
+
+ echo'<td class="grey" align="left" width="400">Done</td>';
+}
+echo'</tr>
+<tr>
+ <td class="smheading" align="left">Removing Kill Matrix Entries:</td>';
+ $q_match = mysql_query("SELECT matchid, playerid FROM uts_player WHERE pid = '$pid' and matchid = '$matchid'") or die(mysql_error());
+ while ($r_match = mysql_fetch_array($q_match)) {
+ mysql_query("DELETE FROM uts_killsmatrix WHERE matchid = '${r_match['matchid']}' AND (killer = '${r_match['playerid']}' OR victim = '${r_match['playerid']}')") or die(mysql_error());
+ }
+ echo'<td class="grey" align="left">Done</td>
+</tr>
+
+
+<tr>
+ <td class="smheading" align="left" width="200">Removing Player Weapon Stats:</td>';
+mysql_query("DELETE FROM uts_weaponstats WHERE matchid = $matchid AND pid = $pid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Player Events:</td>';
+mysql_query("DELETE e.* FROM uts_events as e, uts_player as p WHERE p.pid = '$pid' AND e.matchid = $matchid AND p.playerid = e.playerid AND p.matchid = e.matchid") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Player From Match:</td>';
+mysql_query("DELETE FROM uts_player WHERE matchid IN ('$matchid','0') AND pid = '$pid'") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Amending Player Weapon Stats:</td>';
+mysql_query("DELETE FROM uts_weaponstats WHERE matchid IN ('$matchid','0') AND pid = '$pid'") or die(mysql_error());
+
+$q_weaponstats = mysql_query("SELECT SUM(kills) AS kills, SUM(shots) AS shots, SUM(hits) as hits, SUM(damage) as damage, AVG(acc) AS acc FROM uts_weaponstats WHERE pid = '$pid' GROUP BY weapon") or die(mysql_error());
+while ($r_weaponstats = mysql_fetch_array($q_weaponstats)) {
+ mysql_query("INSERT INTO uts_weaponstats SET matchid='0', pid='$pid', kills='${r_weaponstats['kills']}', shots='${r_weaponstats['shots']}', hits='${r_weaponstats['hits']}', damage='${r_weaponstats['damage']}', acc='${r_weaponstats['acc']}'") or die(mysql_error());
+}
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Amending Global Weapon Stats:</td>';
+ mysql_query("DELETE FROM uts_weaponstats WHERE matchid='0' AND pid='0'") or die(mysql_error());
+
+ $q_weaponstats = mysql_query("SELECT weapon, SUM(kills) AS kills, SUM(shots) AS shots, SUM(hits) as hits, SUM(damage) as damage, AVG(acc) AS acc FROM uts_weaponstats WHERE matchid = '0' GROUP BY weapon") or die(mysql_error());
+ while ($r_weaponstats = mysql_fetch_array($q_weaponstats)) {
+ mysql_query("INSERT INTO uts_weaponstats SET matchid='0', pid='0', weapon='${r_weaponstats['weapon']}', kills='${r_weaponstats['kills']}', shots='${r_weaponstats['shots']}', hits='${r_weaponstats['hits']}', damage='${r_weaponstats['damage']}', acc='${r_weaponstats['acc']}'") or die(mysql_error());
+ }
+
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="center" colspan="2">Match Deleted - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+
+?>
diff --git a/html/pages/admin/editgames.php b/html/pages/admin/editgames.php
new file mode 100755
index 0000000..3f7a542
--- /dev/null
+++ b/html/pages/admin/editgames.php
@@ -0,0 +1,74 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+if (isset($_REQUEST['submit'])) {
+ foreach($_REQUEST['name'] as $id => $bla) {
+ if ($id == 0) {
+ if (empty($_REQUEST['name'][$id])) continue;
+ mysql_query(" INSERT INTO uts_games
+ SET name = '". my_addslashes($_REQUEST['name'][$id]) ."',
+ gamename = '(user defined)';") or die(mysql_error());
+ } else {
+ mysql_query(" UPDATE uts_games
+ SET name = '". my_addslashes($_REQUEST['name'][$id]) ."'
+ WHERE id = '$id';") or die(mysql_error());
+ }
+ }
+}
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="medheading" align="center" colspan="2">Edit games</td>
+</tr>
+<tr>
+ <td class="smheading">GameName</td>
+ <td class="smheading">DisplayName</td>
+</tr>
+<form action="'.$_SERVER['PHP_SELF'].'" method="POST">
+<input type="hidden" name="key" value="'.$adminkey.'">
+<input type="hidden" name="action" value="'.$action.'">
+';
+
+
+$sql_games = "SELECT id, gamename, name FROM uts_games ORDER BY gamename ASC;";
+$q_games = mysql_query($sql_games) or die(mysql_error());
+$i = 0;
+while ($r_games = mysql_fetch_array($q_games)) {
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr>';
+ echo '<td class="'.$class.'">'.htmlentities($r_games['gamename']).'</td>';
+ echo '<td class="'.$class.'"><input class="searchform" type="text" name="name['.$r_games['id'].']" value="'.$r_games['name'].'"></td>';
+ echo '</tr>';
+}
+echo'
+<tr>
+ <td colspan="2">&nbsp;</td>
+</tr>
+<tr>
+ <td class="smheading" colspan="2" align="center">Add new</td>
+</tr>
+<tr>
+ <td class="grey">(n/a)</td>
+ <td class="grey"><input class="searchform" type="text" name="name[0]" value=""></td></td>
+</tr>
+<tr>
+ <td colspan="2">&nbsp;</td>
+</tr>
+<tr>
+ <td class="smheading" colspan="2" align="center">Submit</td>
+</tr>
+';
+
+
+echo '<tr>';
+echo '<td class="darkgrey" colspan="4" align="center"><input class="searchformb" type="Submit" name="submit" value="Save"></td>';
+echo '</tr>';
+
+echo'</form>
+ <tr>
+ <td class="smheading" align="center" colspan="4"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr>
+</table>';
+
+?>
diff --git a/html/pages/admin/editgamestype.php b/html/pages/admin/editgamestype.php
new file mode 100755
index 0000000..d9e4ff1
--- /dev/null
+++ b/html/pages/admin/editgamestype.php
@@ -0,0 +1,228 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$sql_server = "SELECT id, servername, serverip FROM uts_match GROUP BY servername, serverip ORDER BY servername ASC";
+$q_server = mysql_query($sql_server) or die(mysql_error());
+$servernames = array('0' => '');
+$serverips = array('0' => '*');
+while ($r_server = mysql_fetch_array($q_server)) {
+ $servernames[$r_server['id']] = $r_server['servername'];
+ $serverips[$r_server['id']] = $r_server['serverip'];
+}
+
+$sql_games = "SELECT id, gamename, name FROM uts_games ORDER BY gamename ASC";
+$q_games = mysql_query($sql_games) or die(mysql_error());
+$gamedisplaynames = array('0' => '');
+$gamenames = array('0' => '*');
+while ($r_games = mysql_fetch_array($q_games)) {
+ $gamenames[$r_games['id']] = $r_games['gamename'];
+ $gamedisplaynames[$r_games['id']] = $r_games['name'];
+}
+
+
+if (isset($_REQUEST['submit'])) {
+ mysql_query(" INSERT INTO uts_gamestype
+ SET serverip = '". my_addslashes($_REQUEST['serverip']) ."',
+ gamename = '". my_addslashes($_REQUEST['gamename']) ."',
+ mutator = '". my_addslashes($_REQUEST['mutator']) ."',
+ gid = '". my_addslashes($_REQUEST['gid']) ."'
+ ") or die(mysql_error());
+
+ if (isset($_REQUEST['update'])) {
+ echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" colspan="2">Updating...</td>
+ </tr>
+
+
+
+ <tr>
+ <td class="smheading" align="left" width="200">Updating Player Records</td>';
+ $where = 'WHERE 1';
+ if ($_REQUEST['serverip'] != '*') {
+ $where .= " AND m.serverip = '". my_addslashes($_REQUEST['serverip']) ."'";
+ }
+ if ($_REQUEST['gamename'] != '*') {
+ $gids = array_keys($gamenames, my_stripslashes($_REQUEST['gamename']));
+ $where .= " AND m.gid IN (".implode(',', $gids).")";
+ }
+ if ($_REQUEST['mutator'] != '*') {
+ $where .= " AND m.mutators LIKE '%".my_addslashes($_REQUEST['mutator'])."%'";
+ }
+
+ mysql_query("UPDATE uts_player p, uts_match m SET p.gid = '". my_addslashes($_REQUEST['gid']) ."' $where AND m.id = p.matchid;") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done (updated '.mysql_affected_rows().' records)</td>
+ </tr>
+
+
+
+
+ <tr>
+ <td class="smheading" align="left" width="200">Updating Matches</td>';
+ mysql_query("UPDATE uts_match m SET m.gid = '". my_addslashes($_REQUEST['gid']) ."' $where;") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done (updated '.mysql_affected_rows().' matches)</td>
+ </tr>
+
+
+
+
+
+ <tr>
+ <td class="smheading" align="left" width="200">Re-Calcuating Rankings</td>';
+
+ if ($_REQUEST['gamename'] != '*') {
+ $gids[] = $_REQUEST['gid'];
+ $where = "WHERE gid IN (".implode(',', $gids).")";
+ } else {
+ $where = 'WHERE 1';
+ }
+ mysql_query("DELETE FROM uts_rank $where;") or die(mysql_error());
+
+ $sql_nrank = "SELECT SUM(p.gametime) AS time, p.pid, p.gid, SUM(p.rank) AS rank, COUNT(p.matchid) AS matches FROM uts_player p, uts_pinfo pi $where AND pi.id = p.pid AND pi.banned <> 'Y' GROUP BY p.gid, p.pid";
+ $q_nrank = mysql_query($sql_nrank) or die(mysql_error());
+ $num_ranks = 0;
+ while ($r_nrank = mysql_fetch_array($q_nrank)) {
+ mysql_query("INSERT INTO uts_rank SET time = '${r_nrank['time']}', pid = ${r_nrank['pid']}, gid = ${r_nrank['gid']}, rank = '${r_nrank['rank']}', prevrank = '${r_nrank['rank']}', matches = ${r_nrank['matches']}") or die(mysql_error());
+ $num_ranks++;
+ }
+ echo'<td class="grey" align="left" width="400">Done (recalculated '.$num_ranks.' rankings)</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="center" colspan="2">Update finished..</td>
+ </tr>
+ </table>';
+ }
+}
+
+if (isset($_REQUEST['del'])) {
+ mysql_query(" DELETE FROM uts_gamestype
+ WHERE id = '". my_addslashes($_REQUEST['del']) ."'
+ ") or die(mysql_error());
+}
+
+
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="medheading" align="center" colspan="8">Current Mappings</td>
+</tr>
+<tr>
+ <td class="smheading" width="130">&nbsp;Server IP</td>
+ <td class="smheading" width="20"></td>
+ <td class="smheading" width="130">&nbsp;Game Name</td>
+ <td class="smheading" width="20"></td>
+ <td class="smheading" width="130">&nbsp;Mutatorlist contains</td>
+ <td class="smheading" width="20"></td>
+ <td class="smheading" width="130">&nbsp;Game</td>
+ <td class="smheading" width="20"></td>
+</tr>';
+
+
+
+
+
+
+$sql_gamestype = "SELECT id, serverip, gamename, mutator, gid FROM uts_gamestype ORDER BY id ASC;";
+$q_gamestype = mysql_query($sql_gamestype) or die(mysql_error());
+$i = 0;
+while ($r_gamestype = mysql_fetch_array($q_gamestype)) {
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr>';
+ echo '<td class="'.$class.'">&nbsp;'.htmlentities($r_gamestype['serverip']).'</td>';
+ echo '<td class="smheading" align="center">+</td>';
+ echo '<td class="'.$class.'">&nbsp;'.htmlentities($r_gamestype['gamename']).'</td>';
+ echo '<td class="smheading" align="center">+</td>';
+ echo '<td class="'.$class.'">&nbsp;'.htmlentities($r_gamestype['mutator']).'</td>';
+ echo '<td class="smheading" align="center">=</td>';
+ echo '<td class="'.$class.'">&nbsp;'.htmlentities($gamedisplaynames[$r_gamestype['gid']]).'</td>';
+ echo '<td class="'.$class.'" align="center">';
+ echo '<a href="'.$_SERVER['PHP_SELF'].'?action='.$action.'&amp;key='.$adminkey.'&amp;del='.$r_gamestype['id'].'">';
+ echo '<img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" />';
+ echo '</a>';
+ echo '</td>';
+ echo '</tr>';
+}
+
+echo '</tr></table>';
+
+
+
+
+
+
+
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="medheading" align="center" colspan="2">Add new gamestype</td>
+</tr>
+<form action="'.$_SERVER['PHP_SELF'].'" method="POST">
+<input type="hidden" name="key" value="'.$adminkey.'">
+<input type="hidden" name="action" value="'.$action.'">
+';
+
+$class='grey';
+echo '<tr>';
+echo '<td class="smheading" width="170">If server =</td>';
+echo '<td class="'.$class.'">';
+echo '<select class="searchform" name="serverip">';
+foreach($serverips as $id => $bla) {
+ echo '<option value="'.$serverips[$id].'">'. $serverips[$id];
+ if (!empty($servernames[$id])) echo ' ('. $servernames[$id] .')';
+ echo '</option>';
+ }
+echo '</select>';
+echo '</td></tr>';
+
+
+echo '<tr><td class="smheading" nowrap>and gamename =</td>';
+echo '<td class="'.$class.'">';
+
+echo '<select class="searchform" name="gamename">';
+foreach($gamenames as $id => $bla) {
+ if ($gamenames[$id] == '(user defined)') continue;
+ echo '<option value="'.$gamenames[$id].'">'. $gamenames[$id];
+ if (!empty($gamedisplaynames[$id])) echo ' ('. $gamedisplaynames[$id] .')';
+ echo '</option>';
+}
+echo '</select>';
+echo '</td></tr>';
+
+
+echo '<tr><td class="smheading" nowrap>and mutatorlist contains</td>';
+echo '<td class="'.$class.'">';
+echo '<input type="text" class="searchform" name="mutator" value="*"> <span class="text2">(case insensitive substring)</span>';
+echo '</td></tr>';
+
+
+echo '<tr><td class="smheading" nowrap>==&gt; assume gametype:</td>';
+echo '<td class="'.$class.'">';
+
+echo '<select class="searchform" name="gid">';
+foreach($gamenames as $id => $bla) {
+ if ($gamenames[$id] == '*') continue;
+ echo '<option value="'.$id.'">'. $gamenames[$id];
+ if (!empty($gamedisplaynames[$id])) echo ' ['. $gamedisplaynames[$id] .']';
+ echo '</option>';
+}
+echo '</select>';
+echo '</td></tr>';
+
+echo '<tr><td class="smheading">Update existing matches:</td>';
+echo '<td class="'.$class.'">';
+echo '<input type="checkbox" checked name="update"> <span class="text2">(this cannot be undone easily!)</span>';
+echo '</td></tr>';
+
+
+echo '<tr>';
+echo '<td class="'.$class.'" colspan="2" align="center"><input class="searchformb" type="Submit" name="submit" value="Add"></td>';
+echo '</tr>';
+
+echo'</form>
+ <tr>
+ <td class="smheading" align="center" colspan="2"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr>
+</table>';
+
+?>
diff --git a/html/pages/admin/editweapons.php b/html/pages/admin/editweapons.php
new file mode 100755
index 0000000..2baeab9
--- /dev/null
+++ b/html/pages/admin/editweapons.php
@@ -0,0 +1,58 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+if (isset($_REQUEST['submit'])) {
+ foreach($_REQUEST['image'] as $id => $bla) {
+ mysql_query(" UPDATE uts_weapons
+ SET image = '". my_addslashes($_REQUEST['image'][$id]) ."',
+ sequence = '". my_addslashes($_REQUEST['sequence'][$id]) ."',
+ hide = '". (isset($_REQUEST['hide'][$id]) ? 'Y' : 'N') ."'
+ WHERE id = '$id';") or die(mysql_error());
+ }
+}
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="medheading" align="center" colspan="4">Edit weapons</td>
+</tr>
+<tr>
+ <td class="smheading">Name</td>
+ <td class="smheading" align="center" '.OverlibPrintHint('', 'Image to display instead of the weapon\'s name<br>Should exist in images/weapons/<br>Leave empty to display the weapon name').'>Image</td>
+ <td class="smheading" '.OverlibPrintHint('', 'Use this number to set the weapons order to your liking').'>Order</td>
+ <td class="smheading" '.OverlibPrintHint('', 'If checked, this weapon won\'t be shown (including kills, shots, acc, ...)').'>Hide</td>
+</tr>
+<form action="'.$_SERVER['PHP_SELF'].'" method="POST">
+<input type="hidden" name="key" value="'.$adminkey.'">
+<input type="hidden" name="action" value="'.$action.'">
+';
+
+
+$sql_weapons = "SELECT id, name, image, sequence, hide FROM uts_weapons ORDER BY sequence ASC;";
+$q_weapons = mysql_query($sql_weapons) or die(mysql_error());
+$i = 0;
+while ($r_weapons = mysql_fetch_array($q_weapons)) {
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr>';
+ echo '<td class="'.$class.'">'.htmlentities($r_weapons['name']).'</td>';
+ echo '<td class="'.$class.'">';
+ echo '<table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td width="60%">';
+ echo '<input class="searchform" type="text" name="image['.$r_weapons['id'].']" value="'.$r_weapons['image'].'">';
+ echo '</td><td width="40%" align="center">';
+ if (!empty($r_weapons['image'])) echo ' <img src="images/weapons/'. $r_weapons['image'] .'" border="0">';
+ echo' </td></tr></table></td>';
+ echo '<td class="'.$class.'"><input class="searchform" type="text" name="sequence['.$r_weapons['id'].']" value="'.$r_weapons['sequence'].'" size="3" maxlength="3"></td>';
+ echo '<td class="'.$class.'"><input class="searchform" type="checkbox" name="hide['.$r_weapons['id'].']" '.($r_weapons['hide'] == 'Y' ? 'checked' : '').'></td>';
+ echo '</tr>';
+}
+
+echo '<tr>';
+echo '<td class="darkgrey" colspan="4" align="center"><input class="searchformb" type="Submit" name="submit" value="Save"></td>';
+echo '</tr>';
+
+echo'</form>
+ <tr>
+ <td class="smheading" align="center" colspan="4"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+
+?>
diff --git a/html/pages/admin/emptydb.php b/html/pages/admin/emptydb.php
new file mode 100755
index 0000000..9eee7d2
--- /dev/null
+++ b/html/pages/admin/emptydb.php
@@ -0,0 +1,62 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Empty the Database';
+$i = 0;
+$options['vars'][$i]['name'] = 'sure';
+$options['vars'][$i]['type'] = 'static';
+$options['vars'][$i]['options'] = 'No|Yes';
+$options['vars'][$i]['exitif'] = 'No';
+$options['vars'][$i]['prompt'] = 'Are you sure (all data will be lost)?';
+$options['vars'][$i]['caption'] = 'Sure:';
+$i++;
+$options['vars'][$i]['name'] = 'really';
+$options['vars'][$i]['type'] = 'static';
+$options['vars'][$i]['options'] = 'No|Yes';
+$options['vars'][$i]['exitif'] = 'No';
+$options['vars'][$i]['prompt'] = 'Are you really sure (this can NOT be undone)?';
+$options['vars'][$i]['caption'] = 'Really sure (last warning):';
+$i++;
+
+$results = adminselect($options);
+
+
+IF ($results['sure'] == "Yes" and $results['really'] == "Yes") {
+ echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" colspan="2">Empty Database</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="left" width="300">Emptying All Tables but uts_ip2country and uts_weaponstats</td>';
+ mysql_query("TRUNCATE uts_events;") or die(mysql_error());
+ mysql_query("TRUNCATE uts_games;") or die(mysql_error());
+ mysql_query("TRUNCATE uts_gamestype;") or die(mysql_error());
+ mysql_query("TRUNCATE uts_killsmatrix;") or die(mysql_error());
+ mysql_query("TRUNCATE uts_match;") or die(mysql_error());
+ mysql_query("TRUNCATE uts_pinfo;") or die(mysql_error());
+ mysql_query("TRUNCATE uts_player;") or die(mysql_error());
+ mysql_query("TRUNCATE uts_rank;") or die(mysql_error());
+ mysql_query("DELETE FROM uts_weapons WHERE id > 19") or die(mysql_error());
+ mysql_query("ALTER TABLE uts_weapons AUTO_INCREMENT=20") or die(mysql_error());
+ mysql_query("TRUNCATE uts_weaponstats;") or die(mysql_error());
+ echo'<td class="grey" align="left" width="300">Done</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="center" colspan="2">Database Emptied - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+ </tr></table>';
+} else {
+ echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" colspan="2">Empty Database</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="left" width="300">Database Not Emptied</td>
+ <td class="grey" align="left" width="300">Answer Was No</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="center" colspan="2">Database Not Emptied - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+ </tr></table>';
+}
+
+
+?>
diff --git a/html/pages/admin/index.htm b/html/pages/admin/index.htm
new file mode 100755
index 0000000..e69de29
--- /dev/null
+++ b/html/pages/admin/index.htm
diff --git a/html/pages/admin/ipsearch.php b/html/pages/admin/ipsearch.php
new file mode 100755
index 0000000..4ac9731
--- /dev/null
+++ b/html/pages/admin/ipsearch.php
@@ -0,0 +1,58 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['requireconfirmation'] = false;
+$options['title'] = 'IP Search';
+$i = 0;
+$options['vars'][$i]['name'] = 'ip_from';
+$options['vars'][$i]['type'] = 'text';
+$options['vars'][$i]['prompt'] = 'Enter the IP you want to search from:';
+$options['vars'][$i]['caption'] = 'IP from:';
+$i++;
+$options['vars'][$i]['name'] = 'ip_to';
+$options['vars'][$i]['type'] = 'text';
+$options['vars'][$i]['initialvalue'] = 'ip_from';
+$options['vars'][$i]['prompt'] = 'Enter the IP you want to search to:';
+$options['vars'][$i]['caption'] = 'IP to:';
+$i++;
+
+$results = adminselect($options);
+
+
+$ip_from = $results['ip_from'];
+$ip_to = $results['ip_to'];
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Players using IPs '.$ip_from.' - '.$ip_to.' and their last 5 matches using these IPs</td>
+</tr>';
+
+
+$sql_players = "SELECT pi.name, pi.id AS pid FROM uts_player p, uts_pinfo pi WHERE p.pid = pi.id AND p.ip BETWEEN INET_ATON('$ip_from') AND INET_ATON('$ip_to') GROUP BY pid";
+$q_players = mysql_query($sql_players) or die(mysql_error());
+$j = 0;
+while ($r_players = mysql_fetch_array($q_players)) {
+ echo '<tr>';
+ echo '<td class="dark" align="center" valign="top" width="150">';
+ echo '<a class="darkhuman" href="admin.php?action=pinfo&amp;pid='.$r_players['pid'].'">'.$r_players['name'].'</a></td>';
+ $sql_recent = "SELECT m.time AS time, m.id AS mid, INET_NTOA(p.ip) AS ip FROM uts_player p, uts_match m WHERE m.id = p.matchid AND p.pid = '${r_players['pid']}' AND p.ip BETWEEN INET_ATON('$ip_from') AND INET_ATON('$ip_to') ORDER BY m.time DESC LIMIT 0,5";
+ echo '<td class="grey">';
+ echo '<table width="100%" border="0" cellspacing="0" cellpadding="2">';
+ $q_recent= mysql_query($sql_recent) or die(mysql_error());
+ while ($r_recent = mysql_fetch_array($q_recent)) {
+ $j++;
+ $class = ($j%2) ? 'grey' : 'grey2';
+ echo '<tr><td class="'.$class.'" align="center" width="60%">';
+ echo '<a class="'.$class.'" href="./?p=match&amp;mid='.$r_recent['mid'].'">'.mdate($r_recent['time']).'</a>';
+ echo '</td><td class="'.$class.'" align="center">';
+ echo $r_recent['ip'];
+ echo '</td></tr>';
+ }
+ echo '</table></td></tr>';
+}
+
+
+echo'<tr>
+ <td class="smheading" align="center" colspan="2"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+?>
diff --git a/html/pages/admin/main.php b/html/pages/admin/main.php
new file mode 100755
index 0000000..4d60302
--- /dev/null
+++ b/html/pages/admin/main.php
@@ -0,0 +1,117 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+if (isset($_REQUEST['droptable'])) {
+ $droptable = my_addslashes($_REQUEST['droptable']);
+ if (substr($droptable, 0, 9) == 'uts_temp_' and strlen($droptable) == 17) {
+ mysql_query("DROP TABLE $droptable;") or die(mysql_error());
+ } else {
+ die('NO!');
+ }
+}
+
+
+// Graph width
+$max_width = 150;
+function nf($number) {
+ return(number_format($number));
+}
+
+
+echo'<table class = "box" border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" height="25" colspan="4">Database Statistics</td>
+</tr>';
+
+$q_dbsize = mysql_query("SHOW table STATUS") or die(mysql_error());
+$tot_size = 0;
+$tot_rows = 0;
+$max_size = 0;
+while ($r_dbsize = mysql_fetch_array($q_dbsize)) {
+ if (substr($r_dbsize['Name'], 0, 4) != 'uts_') continue;
+ $size = $r_dbsize['Data_length'] + $r_dbsize['Index_length'];
+ $rows = $r_dbsize['Rows'];
+ $tables[] = array (
+ 'name' => $r_dbsize['Name'],
+ 'size' => $size,
+ 'rows' => $rows
+ );
+ $tot_size += $size;
+ $tot_rows += $rows;
+ if ($max_size < $size) $max_size = $size;
+
+}
+
+$i = 0;
+foreach($tables as $table) {
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+
+ $d_size = file_size_info($table['size']);
+ $title = get_dp($table['size'] / $tot_size * 100) .' %';
+ echo'<tr>
+ <td class="smheading" align="left" width="200">';
+ if (substr($table['name'], 0, 9) == 'uts_temp_' and strlen($table['name']) == 17) {
+ echo '<a href="admin.php?key='. urlencode($adminkey) .'&amp;action=main&amp;droptable='.htmlentities($table['name']).'"><img src="images/del.png" border="0" width="16" height="16" title="Click to drop this table" alt="Delete" /></a><em>'.$table['name'].'</em>';
+ } else {
+ echo $table['name'];
+ }
+ echo '</td>
+ <td class="'.$class.'" align="right">'.nf($table['rows']).' rows</td>
+ <td class="'.$class.'" align="right">'.$d_size['size'] .' '. $d_size['type'].'</td>
+ <td class="'.$class.'" width="'.($max_width + 5).'"><img border="0" src="images/bars/h_bar'. ($i % 16 + 1) .'.png" height="10" width="'.(int)($table['size'] / $max_size * $max_width).'" alt="'. $title .'" title="'. $title .'"></td>
+ </tr>';
+}
+
+$d_size = file_size_info($tot_size);
+echo'<tr>
+ <td class="smheading" align="left" width="200">Total Database Size</td>
+ <td class="darkgrey" align="right">'.nf($tot_rows).' rows</td>
+ <td class="darkgrey" align="right">'.$d_size['size'] .' '. $d_size['type'].'</td>
+ <td class="darkgrey" >&nbsp;</td>
+</tr>
+</table><br>';
+
+echo'<table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr><td width="100%">';
+
+echo '
+ <ul>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=mplayers">Merge Players</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=mservers">Merge Servers</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=plm">Merge IPs with more than 1 Player</a></li>';
+ echo '<br>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=dmatch">Delete Match</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=dpmatch">Delete Player From Match</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=dplayer">Delete Player</a></li>';
+ echo '<br>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=pban&amp;saction=ban">Ban Player</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=pban&amp;saction=unban">Unban Player</a></li>';
+ echo '<br>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=pinfo">Extended Player Info</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=ipsearch">Search IP</a></li>';
+ if ($import_utdc_download_enable) {
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=utdclog">View UTDC logs</a></li>';
+ }
+ if ($import_ac_download_enable) {
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=aclog">View AnthChecker logs</a></li>';
+ }
+ if ($import_ace_download_enable) {
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=acelog">View ACE logs</a></li>';
+ }
+ echo '<br>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=editweapons">Edit Weapons</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=editgames">Add/Edit Game Names</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=editgamestype">Add/Edit Game Types</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=recalcranking">Recalculate Rankings</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=recalcflags">Recalculate Countryflags</a></li>';
+ echo '<br>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=check">Check server settings</a></li>';
+ echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=emptydb">Empty the database</a></li>';
+echo '
+</ul>
+';
+
+
+
+echo'</td></tr></table>';
+?>
diff --git a/html/pages/admin/mplayers.php b/html/pages/admin/mplayers.php
new file mode 100755
index 0000000..3754d99
--- /dev/null
+++ b/html/pages/admin/mplayers.php
@@ -0,0 +1,91 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Merge Players';
+$i = 0;
+$options['vars'][$i]['name'] = 'mplayer1';
+$options['vars'][$i]['type'] = 'player';
+$options['vars'][$i]['prompt'] = 'Choose player to merge to:';
+$options['vars'][$i]['caption'] = 'Player to merge to:';
+$i++;
+$options['vars'][$i]['name'] = 'mplayer2';
+$options['vars'][$i]['type'] = 'player';
+$options['vars'][$i]['prompt'] = 'Choose player to merge from:';
+$options['vars'][$i]['caption'] = 'Player to merge from:';
+$options['vars'][$i]['exclude'] = 'mplayer1';
+$i++;
+
+$results = adminselect($options);
+
+
+
+$mplayer1 = $results['mplayer1'];
+$mplayer2 = $results['mplayer2'];
+
+
+$mp1name = small_query("SELECT name FROM uts_pinfo WHERE id = $mplayer1");
+$mp2name = small_query("SELECT name FROM uts_pinfo WHERE id = $mplayer2");
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Merging '.$mp2name[name].' Into '.$mp1name[name].'</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Info Records</td>';
+mysql_query("DELETE FROM uts_pinfo WHERE id = $mplayer2") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Updating Player Records</td>';
+mysql_query("UPDATE uts_player SET pid = $mplayer1 WHERE pid = $mplayer2") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Updating Weapon Records</td>';
+mysql_query("UPDATE uts_weaponstats SET pid = $mplayer1 WHERE pid = $mplayer2") or die(mysql_error());
+mysql_query("DELETE FROM uts_weaponstats WHERE pid = $mplayer2") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Amending Player Weapon Stats:</td>';
+mysql_query("DELETE FROM uts_weaponstats WHERE matchid='0' AND pid = '$mplayer1'") or die(mysql_error());
+
+$q_weaponstats = mysql_query("SELECT weapon, SUM(kills) AS kills, SUM(shots) AS shots, SUM(hits) as hits, SUM(damage) as damage, AVG(acc) AS acc FROM uts_weaponstats WHERE pid = '$mplayer1' GROUP BY weapon") or die(mysql_error());
+while ($r_weaponstats = mysql_fetch_array($q_weaponstats)) {
+ mysql_query("INSERT INTO uts_weaponstats SET matchid='0', pid='$mplayer1', weapon='${r_weaponstats['weapon']}', kills='${r_weaponstats['kills']}', shots='${r_weaponstats['shots']}', hits='${r_weaponstats['hits']}', damage='${r_weaponstats['damage']}', acc='${r_weaponstats['acc']}'") or die(mysql_error());
+}
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Updating First Blood Records</td>';
+mysql_query("UPDATE uts_match SET firstblood = $mplayer1 WHERE firstblood = $mplayer2") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Temporary Rank</td>';
+mysql_query("UPDATE uts_rank SET pid = $mplayer2 WHERE pid= $mplayer1") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Creating New Rank</td>';
+
+$sql_nrank = "SELECT SUM(time) AS time, pid, gid, AVG(rank) AS rank, AVG(prevrank) AS prevrank, SUM(matches) AS matches FROM uts_rank WHERE pid = $mplayer2 GROUP BY pid, gid";
+$q_nrank = mysql_query($sql_nrank) or die(mysql_error());
+while ($r_nrank = mysql_fetch_array($q_nrank)) {
+
+ mysql_query("INSERT INTO uts_rank SET time = '$r_nrank[time]', pid = $mplayer1, gid = $r_nrank[gid], rank = '$r_nrank[rank]', prevrank = '$r_nrank[prevrank]', matches = $r_nrank[matches]") or die(mysql_error());
+}
+
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Removing Old Rank</td>';
+mysql_query("DELETE FROM uts_rank WHERE pid = $mplayer2") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="center" colspan="2">Player Record Merged - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr>
+</table>';
+
+?>
diff --git a/html/pages/admin/mservers.php b/html/pages/admin/mservers.php
new file mode 100755
index 0000000..b52a9d1
--- /dev/null
+++ b/html/pages/admin/mservers.php
@@ -0,0 +1,41 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Merge Servers';
+$i = 0;
+$options['vars'][$i]['name'] = 'mserver1';
+$options['vars'][$i]['type'] = 'server';
+$options['vars'][$i]['prompt'] = 'Choose the server to merge to:';
+$options['vars'][$i]['caption'] = 'Server to merge to:';
+$i++;
+$options['vars'][$i]['name'] = 'mserver2';
+$options['vars'][$i]['type'] = 'server';
+$options['vars'][$i]['prompt'] = 'Choose the server to merge from:';
+$options['vars'][$i]['caption'] = 'Server to merge from:';
+$options['vars'][$i]['exclude'] = 'mserver1';
+$i++;
+
+$results = adminselect($options);
+
+
+$mserver1 = $results[mserver1];
+$mserver2 = $results[mserver2];
+
+$q_myserver1 = small_query("SELECT servername, serverip FROM uts_match WHERE id = $mserver1");
+$q_myserver2 = small_query("SELECT servername, serverip FROM uts_match WHERE id = $mserver2");
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Merging '.$q_myserver2[servername].' ('.$q_myserver2[serverip].')<br>
+ Into '.$q_myserver1[servername].' ('.$q_myserver1[serverip].')</td>
+</tr>
+<tr>
+ <td class="smheading" align="left" width="200">Merging Records</td>';
+mysql_query("UPDATE uts_match SET serverip = '". addslashes($q_myserver1[serverip]) ."', servername = '". addslashes($q_myserver1[servername]) ."' WHERE serverip = '". addslashes($q_myserver2[serverip]) ."' and servername = '". addslashes($q_myserver2[servername]) ."'") or die(mysql_error());
+ echo'<td class="grey" align="left" width="400">Done</td>
+</tr>
+<tr>
+ <td class="smheading" align="center" colspan="2">Server Records Merged - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+
+?>
diff --git a/html/pages/admin/pban.php b/html/pages/admin/pban.php
new file mode 100755
index 0000000..f421ef5
--- /dev/null
+++ b/html/pages/admin/pban.php
@@ -0,0 +1,74 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$ban = ($_REQUEST['saction'] == 'ban') ? true : false;
+
+if ($ban) {
+ $options['title'] = 'Ban Player';
+} else {
+ $options['title'] = 'Unban Player';
+}
+$i = 0;
+$options['vars'][$i]['name'] = 'pid';
+$options['vars'][$i]['type'] = 'player';
+if ($ban) {
+ $options['vars'][$i]['whereisbanned'] = 'N';
+} else {
+ $options['vars'][$i]['whereisbanned'] = 'Y';
+}
+$options['vars'][$i]['prompt'] = 'Player?';
+$options['vars'][$i]['caption'] = 'Player:';
+$i++;
+
+$results = adminselect($options);
+
+
+$pid = $results['pid'];
+
+if ($ban) {
+ echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" colspan="2">Banning Player</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="left">Removing Player Rank:</td>';
+ mysql_query("DELETE FROM uts_rank WHERE pid = $pid") or die(mysql_error());
+ echo'<td class="grey" align="left">Done</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="left">Updating Player Record:</td>';
+ mysql_query("UPDATE uts_pinfo SET banned = 'Y' WHERE id = $pid") or die(mysql_error());
+ echo'<td class="grey" align="left">Done</td>
+ </tr>
+
+ <tr>
+ <td class="smheading" align="center" colspan="2">Player Banned - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+ </tr></table>';
+} else {
+ echo'<table border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" colspan="2">Unbanning Player</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="left">Updating Player Record:</td>';
+ mysql_query("UPDATE uts_pinfo SET banned = 'N' WHERE id = $pid") or die(mysql_error());
+ echo'<td class="grey" align="left">Done</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="left" width="200">Restoring Rankings</td>';
+
+ $sql_nrank = "SELECT SUM(gametime) AS time, pid, gid, SUM(rank) AS rank, COUNT(matchid) AS matches FROM uts_player WHERE pid = $pid GROUP BY pid, gid";
+ $q_nrank = mysql_query($sql_nrank) or die(mysql_error());
+ while ($r_nrank = mysql_fetch_array($q_nrank)) {
+
+ mysql_query("INSERT INTO uts_rank SET time = '$r_nrank[time]', pid = $pid, gid = $r_nrank[gid], rank = '$r_nrank[rank]', prevrank = '$r_nrank[rank]', matches = $r_nrank[matches]") or die(mysql_error());
+ }
+
+ echo'<td class="grey" align="left" width="400">Done</td>
+ </tr>
+ <tr>
+ <td class="smheading" align="center" colspan="2">Player Unbanned - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+ </tr></table>';
+}
+
+?>
diff --git a/html/pages/admin/pinfo.php b/html/pages/admin/pinfo.php
new file mode 100755
index 0000000..7be13ae
--- /dev/null
+++ b/html/pages/admin/pinfo.php
@@ -0,0 +1,91 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Extended Player Info';
+$options['requireconfirmation'] = false;
+$i = 0;
+$options['vars'][$i]['name'] = 'v_pid';
+$options['vars'][$i]['type'] = 'player';
+$options['vars'][$i]['prompt'] = 'Player?';
+$options['vars'][$i]['caption'] = 'Player:';
+$i++;
+
+if (isset($_REQUEST['pid'])) {
+ $pid = $_REQUEST['pid'];
+}else {
+ $results = adminselect($options);
+ $pid = $results['v_pid'];
+}
+
+$is_admin = true;
+include('pages/players_info.php');
+
+echo '<br>';
+
+$sql_ips = "SELECT INET_NTOA(p.ip) AS ip, COUNT(p.id) AS matches, MIN(m.time) AS first, MAX(m.time) AS last FROM uts_player AS p, uts_match AS m WHERE p.pid = ".$pid." AND m.id = p.matchid GROUP BY ip ORDER BY ip";
+$q_ips = mysql_query($sql_ips) or die("Can't get ip's: " . mysql_error());
+echo '
+<table class = "box" border="0" cellpadding="1" cellspacing="2" width="720">
+ <tbody>
+ <tr>
+ <td class="heading" colspan="5" align="center">IP\'s used</td>
+ </tr>
+ <tr>
+ <td class="smheading" width="80" align = "center">IP</td>
+ <td class="smheading" width="180" align = "left">Hostname</td>
+ <td class="smheading" width="60" align = "center">Matches</td>
+ <td class="smheading" width="200" align = "left">First</td>
+ <td class="smheading" width="200" align = "left">Last</td>
+ </tr>';
+
+while ($r_ips = mysql_fetch_assoc($q_ips)) {
+ echo '
+ <tr>
+ <td class="grey" align = "center">'.$r_ips['ip'].'</td>
+ <td class="grey" align = "left">'.gethostbyaddr($r_ips['ip']).'</td>
+ <td class="grey" align = "center">'.$r_ips['matches'].'</td>
+ <td class="grey" align = "left">'.mdate($r_ips['first']).'</td>
+ <td class="grey" align = "left">'.mdate($r_ips['last']).'</td>
+ </tr>';
+}
+
+echo '
+ </tbody>
+</table>
+<div class="opnote">* Hostnames are real time and might have been different at the time of playing. *</div>
+<br>';
+
+mysql_free_result($q_ips);
+
+$sql_fakes = "SELECT INET_NTOA(p1.ip) AS ip, pi.name FROM uts_player AS p1, uts_player AS p2, uts_pinfo AS pi WHERE p1.pid = ".$pid." AND p1.ip = p2.ip AND p1.pid <> p2.pid AND pi.id = p2.pid GROUP BY pi.name";
+$q_fakes = mysql_query($sql_fakes) or die("Can't retrieve fake nicks: " . mysql_error());
+echo '
+<table class = "box" border="0" cellpadding="1" cellspacing="2" width="480">
+ <tbody>
+ <tr>
+ <td class="heading" colspan="2" align="center">Possible aliasses</td>
+ </tr>
+ <tr>
+ <td class="smheading" width="120" align = "center">Nick</td>
+ <td class="smheading" width="360" align = "center">IP</td>
+ </tr>';
+
+if (mysql_num_rows($q_fakes) == 0) {
+ echo '
+ <tr>
+ <td class="grey" align = "center" colspan="2">No other names found</td>
+ </tr>';
+}
+else {
+ while($r_fakes = mysql_fetch_assoc($q_fakes)) {
+ echo '
+ <tr>
+ <td class="grey" align = "center">'.$r_fakes[ip].'</td>
+ <td class="grey" align = "center">'.$r_fakes[name].'</td>
+ </tr>';
+ }
+}
+echo '
+ </tbody>
+</table><br>';
+?>
diff --git a/html/pages/admin/plm.php b/html/pages/admin/plm.php
new file mode 100755
index 0000000..68992e2
--- /dev/null
+++ b/html/pages/admin/plm.php
@@ -0,0 +1,329 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$debug = 0; // This enables debug messages
+
+/*
+** This function merges two playerss
+** @var $mplayer1 : The player to merge to
+** @var $mplayer2 : The player who gets merged into mplayer 1
+** @return null
+*/
+function merge_players($mplayer1, $mplayer2) {
+ $mp1name = small_query("SELECT name FROM uts_pinfo WHERE id = $mplayer1");
+ $mp2name = small_query("SELECT name FROM uts_pinfo WHERE id = $mplayer2");
+
+ mysql_query("DELETE FROM uts_pinfo WHERE id = $mplayer2") or die(mysql_error());
+ mysql_query("UPDATE uts_player SET pid = $mplayer1 WHERE pid = $mplayer2") or die(mysql_error());
+ mysql_query("UPDATE uts_weaponstats SET pid = $mplayer1 WHERE pid = $mplayer2") or die(mysql_error());
+ mysql_query("DELETE FROM uts_weaponstats WHERE pid = $mplayer2") or die(mysql_error());
+ mysql_query("DELETE FROM uts_weaponstats WHERE matchid='0' AND pid = '$mplayer1'") or die(mysql_error());
+
+ $q_weaponstats = mysql_query("SELECT weapon, SUM(kills) AS kills, SUM(shots) AS shots, SUM(hits) as hits, SUM(damage) as damage, AVG(acc) AS acc FROM uts_weaponstats WHERE pid = '$mplayer1' GROUP BY weapon") or die(mysql_error());
+ while ($r_weaponstats = mysql_fetch_array($q_weaponstats)) {
+ mysql_query("INSERT INTO uts_weaponstats SET matchid='0', pid='$mplayer1', weapon='${r_weaponstats['weapon']}', kills='${r_weaponstats['kills']}', shots='${r_weaponstats['shots']}', hits='${r_weaponstats['hits']}', damage='${r_weaponstats['damage']}', acc='${r_weaponstats['acc']}'") or die(mysql_error());
+ }
+ mysql_query("UPDATE uts_match SET firstblood = $mplayer1 WHERE firstblood = $mplayer2") or die(mysql_error());
+ mysql_query("UPDATE uts_rank SET pid = $mplayer2 WHERE pid= $mplayer1") or die(mysql_error());
+ $sql_nrank = "SELECT SUM(time) AS time, pid, gid, AVG(rank) AS rank, AVG(prevrank) AS prevrank, SUM(matches) AS matches FROM uts_rank WHERE pid = $mplayer2 GROUP BY pid, gid";
+ $q_nrank = mysql_query($sql_nrank) or die(mysql_error());
+ while ($r_nrank = mysql_fetch_array($q_nrank)) {
+
+ mysql_query("INSERT INTO uts_rank SET time = '$r_nrank[time]', pid = $mplayer1, gid = $r_nrank[gid], rank = '$r_nrank[rank]', prevrank = '$r_nrank[prevrank]', matches = $r_nrank[matches]") or die(mysql_error());
+ }
+ mysql_query("DELETE FROM uts_rank WHERE pid = $mplayer2") or die(mysql_error());
+}
+
+// If debugmode is on, get start time
+if($debug) {
+ $time = microtime();
+ $time = explode(' ', $time);
+ $time = $time[1] + $time[0];
+ $begintime = $time;
+}
+
+// Print header & links
+echo '<P><B>Player merging tool</B></P>';
+echo "<P><A href=admin.php?key=".$adminkey."&action=plm>Merge ip's</A> - <A href=admin.php?key=".$adminkey."&action=plm&onlyrange=true>Merge ip's, limited on range</A> - <A href=admin.php?key=".$adminkey."&action=plm&manignore=true>Manage ignored ip's</A> - <A href=admin.php?key=".$adminkey."&action=plm&manignore=true&onlyrange=true>Manage ignored ip's - only range</A><BR><BR></P>";
+
+// CASE: MANAGE IGNORED IPS
+if($_GET['manignore'] == "true") {
+ if($_POST['submit'] == "Remove from ignored list") {
+ echo "<P><B>Stopped ignore ip's</B></P>";
+ foreach($_POST as $key=>$value) {
+ if($key !='submit') {
+ $key = mysql_real_escape_string(str_replace("_",".",$key));
+ $query = "DELETE FROM uts_ignoreips WHERE ip = (INET_ATON('".$key."'))";
+ mysql_query($query) or die(mysql_error());
+ echo "<br>$key";
+ }
+ }
+ } else if($_GET['onlyrange'] == "true") {
+ if($_POST['submit'] == "Confirm") {
+ echo '<P><B>Ignored ip\'s in range '.htmlentities($_POST['from']).' to '.htmlentities($_POST['to']).'</B><br><I>If you want to stop ignoring some ip\'s, because for example you accidently ignored these, check these and press the button at the lower end to confirm this</I></P>';
+ echo '<FORM METHOD="POST" ACTION="admin.php?key='.$adminkey.'&action=plm&manignore=true" target="_blank">';
+
+ $from = mysql_real_escape_string($_POST['from']);
+ $to = mysql_real_escape_string($_POST['to']);
+
+ $ignore_ips = mysql_query("SELECT ip FROM uts_ignoreips WHERE ip >= INET_ATON('$from') AND ip <= INET_ATON('$to') ORDER BY ip ASC");
+
+ if(mysql_num_rows($ignore_ips) > 0) {
+ while ($r_pipcheck = mysql_fetch_array($ignore_ips)) {
+
+ $playerip = $r_pipcheck[ip];
+ $trueplayerip = long2ip($playerip);
+ $pidcount = $r_pipcheck[pidcount];
+
+ echo "<br><input type=checkbox name=$trueplayerip> <b>$trueplayerip</b>";
+
+ // Query for player names and ids associated to that ip during the cycle
+ $sql_pcheck = "SELECT pi.id, pi.name, pi.country, p.pid, p.ip FROM uts_pinfo AS pi, uts_player AS p WHERE pi.id = p.pid AND p.ip = $playerip GROUP BY pi.id, pi.name, p.pid, p.ip, pi.country";
+ $q_pcheck = mysql_query($sql_pcheck) or die(mysql_error());
+ while ($r_pcheck = mysql_fetch_array($q_pcheck)) {
+ echo '<br><a class="darkhuman" href="admin.php?key='.$adminkey.'&amp;action=pinfo&amp;pid='.$r_pcheck[pid].'">'.FormatPlayerName($r_pcheck[country], $r_pcheck['pid'], $r_pcheck['name']).'</a> ';
+ }
+ echo '<br />';
+ }
+ echo '<BR><INPUT TYPE="SUBMIT" VALUE="Remove from ignored list" NAME="submit"></FORM>';
+ } else {
+ echo "<BR><P>No ignored ip's found</P>";
+ }
+ } else {
+ echo "<P><B>Ignored ip's in range: Enter range to filter on</B></P>";
+ echo '<FORM METHOD="POST" ACTION="admin.php?key='.$adminkey.'&action=plm&manignore=true&onlyrange=true">';
+ echo '<BR>Ranging from <INPUT TYPE="TEXT" NAME="from" SIZE="20" VALUE="0.0.0.0"> to <INPUT TYPE="TEXT" NAME="to" SIZE="20" VALUE="255.255.255.255">';
+ echo '<BR><BR><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Confirm"></FORM>';
+ }
+ } else {
+ echo '<P><B>Ignored ip\'s</B><br><I>If you want to stop ignoring some ip\'s, because for example you accidently ignored these, check these and press the button at the lower end to confirm this</I></P>';
+ echo '<FORM METHOD="POST" ACTION="admin.php?key='.$adminkey.'&action=plm&manignore=true" target="_blank">';
+
+ $ignore_ips = mysql_query("SELECT ip FROM uts_ignoreips ORDER BY ip ASC");
+ if(mysql_num_rows($ignore_ips) > 0) {
+ while ($r_pipcheck = mysql_fetch_array($ignore_ips)) {
+
+ $playerip = $r_pipcheck[ip];
+ $trueplayerip = long2ip($playerip);
+ $pidcount = $r_pipcheck[pidcount];
+
+ echo "<br><input type=checkbox name=$trueplayerip> <b>$trueplayerip</b>";
+
+ // Query for player names and ids associated to that ip during the cycle
+ $sql_pcheck = "SELECT pi.id, pi.name, pi.country, p.pid, p.ip FROM uts_pinfo AS pi, uts_player AS p WHERE pi.id = p.pid AND p.ip = $playerip GROUP BY pi.id, pi.name, p.pid, p.ip, pi.country";
+ $q_pcheck = mysql_query($sql_pcheck) or die(mysql_error());
+ while ($r_pcheck = mysql_fetch_array($q_pcheck)) {
+ echo '<br><a class="darkhuman" href="admin.php?key='.$adminkey.'&amp;action=pinfo&amp;pid='.$r_pcheck[pid].'">'.FormatPlayerName($r_pcheck[country], $r_pcheck['pid'], $r_pcheck['name']).'</a> ';
+ }
+ echo '<br />';
+ }
+ echo '<BR><INPUT TYPE="SUBMIT" VALUE="Remove from ignored list" NAME="submit"></FORM>';
+ } else {
+ echo "<BR><P>No ignored ip's found</P>";
+ }
+ }
+
+// CASE: IGNORE SUBMITTED IP'S
+} else if($_POST['submit'] == "ignore") {
+ echo "<P><B>Ignored ips</B></P>";
+ foreach($_POST as $key=>$value) {
+ if($key !='submit') {
+ $key = mysql_real_escape_string(str_replace("_",".",$key));
+ $query = "INSERT INTO uts_ignoreips (ip) VALUES (INET_ATON('".$key."'))";
+ mysql_query($query) or die(mysql_error());
+ echo "<br>$key";
+ }
+ }
+ echo "<br>";
+
+// CASE: SHOW NICKS WITH GIVEN SHARED IP
+} else if(substr($_POST['submit'],0,8) == "merge - ") {
+ echo "<P><B>Merge nicks with shared ip</B></P>";
+
+ $ip = mysql_real_escape_string(str_replace("_",".",substr($_POST['submit'],8)));
+ $sql_pipcheck = "SELECT ip, COUNT(DISTINCT pid) AS pidcount FROM uts_player WHERE ip = INET_ATON('$ip') GROUP BY ip ORDER BY ip ASC";
+ $q_pipcheck = mysql_query($sql_pipcheck) or die(mysql_error());
+ while ($r_pipcheck = mysql_fetch_array($q_pipcheck)) {
+
+ $playerip = $r_pipcheck[ip];
+ $trueplayerip = long2ip($playerip);
+ $pidcount = $r_pipcheck[pidcount];
+
+ // If there is more than one pid associated to an IP ...
+ IF ($pidcount > 1 ) {
+ echo '<FORM METHOD="POST" ACTION="admin.php?key='.$adminkey.'&action=plm">';
+ echo "<br><b>$trueplayerip</b>";
+
+ // Query for player names and ids associated to that ip during the cycle
+ $sql_pcheck = "SELECT pi.id, pi.name, pi.country, p.pid, p.ip FROM uts_pinfo AS pi, uts_player AS p WHERE pi.id = p.pid AND p.ip = $playerip GROUP BY pi.id, pi.name, p.pid, p.ip, pi.country";
+
+ $q_pcheck = mysql_query($sql_pcheck) or die(mysql_error());
+ while ($r_pcheck = mysql_fetch_array($q_pcheck)) {
+ echo '<br><a class="darkhuman" href="./?p=pinfo&amp;pid='.$r_pcheck[pid].'">'.FormatPlayerName($r_pcheck[country], $r_pcheck['pid'], $r_pcheck['name']).'</a> ';
+ $options .= '<OPTION value="'.$r_pcheck[pid].'">'.$r_pcheck['name'].'</OPTION>';
+ }
+ echo '<br><br>Merge to: <SELECT NAME="merge_to">'.$options.'</SELECT>';
+ echo "<br><INPUT TYPE=\"hidden\" NAME=\"ip\" VALUE=\"$ip\"><INPUT TYPE=\"SUBMIT\" VALUE=\"Player merge\" NAME=\"submit\"></FORM>";
+ echo '<br />';
+ }
+ }
+
+// CASE: MERGE NICKS WITH SHARED IP
+} else if($_POST['submit'] == "Player merge") {
+ echo "<P><B>Merging nicks with shared ip</B></P>";
+
+ $ip = mysql_real_escape_string(str_replace("_",".",$_POST['ip']));
+ $merge_to_pid = mysql_real_escape_string($_POST['merge_to']);
+ $sql_pipcheck = "SELECT ip, COUNT(DISTINCT pid) AS pidcount FROM uts_player WHERE ip = INET_ATON('$ip') GROUP BY ip ORDER BY ip ASC";
+ $q_pipcheck = mysql_query($sql_pipcheck) or die(mysql_error());
+ while ($r_pipcheck = mysql_fetch_array($q_pipcheck)) {
+
+ $playerip = $r_pipcheck[ip];
+ $trueplayerip = long2ip($playerip);
+ $pidcount = $r_pipcheck[pidcount];
+
+ // If there is more than one pid associated to an IP ...
+ IF ($pidcount > 1 ) {
+ echo "<b>$trueplayerip</b><br><br>merge:<br>";
+
+ // Query for player names and ids associated to that ip during the cycle
+ $sql_pcheck = "SELECT p.pid FROM uts_pinfo AS pi, uts_player AS p WHERE pi.id = p.pid AND p.ip = $playerip GROUP BY pi.id, pi.name, p.pid, p.ip, pi.country";
+
+ $q_pcheck = mysql_query($sql_pcheck) or die(mysql_error());
+ $i=0;
+ while ($r_pcheck = mysql_fetch_array($q_pcheck)) {
+ if($r_pcheck['pid'] != $merge_to_pid) {
+ $pid_from[$i] = $r_pcheck['pid'];
+ echo $pid_from[$i].'<br>';
+ $i++;
+ }
+ }
+ echo '<br />merge to: '.$merge_to_pid;
+ }
+ }
+ if($debug) echo "<br> -- started merging";
+ for($j=0;$j<count($pid_from);$j++) {
+ merge_players($merge_to_pid, $pid_from[$j]);
+ }
+ if($debug) echo "<br> -- merging ended";
+
+// CASE: SHOW ALL IP'S LINKED TO MORE THAN ONE NICK - ONLY RANGE
+} else if($_GET['onlyrange'] == "true") {
+ if($_POST['submit'] == "Confirm") {
+ echo "<P><B>Showing all ip's in range ".htmlentities($_POST['from'])." to ".htmlentities($_POST['to'])."</B><br><I>If you want to ignore some ip's, because for example different but unrelated nicks are associated with it, check these and press the button at the lower end to confirm this</I></P>";
+ $from = mysql_real_escape_string($_POST['from']);
+ $to = mysql_real_escape_string($_POST['to']);
+
+ $ignore_ips = mysql_query("SELECT ip FROM uts_ignoreips WHERE ip >= INET_ATON('$from') AND ip <= INET_ATON('$to')");
+ $extended_query = "WHERE ip >= INET_ATON('$from') AND ip <= INET_ATON('$to')";
+ $i=0;
+ while($ignore_ips_array = mysql_fetch_array($ignore_ips)) {
+ $ip = $ignore_ips_array[0];
+ $extended_query .= " AND ";
+ $extended_query .= "ip <> '".$ip."'";
+ $i++;
+ }
+
+ echo '<FORM METHOD="POST" ACTION="admin.php?key='.$adminkey.'&action=plm" target="_blank">';
+
+
+ // Query for list of unique ips and player ids
+ $sql_pipcheck = "SELECT ip, COUNT(DISTINCT pid) AS pidcount FROM uts_player ".$extended_query." GROUP BY ip ORDER BY ip ASC";
+ $q_pipcheck = mysql_query($sql_pipcheck) or die(mysql_error());
+ if(mysql_num_rows($q_pipcheck) > 0) {
+ while ($r_pipcheck = mysql_fetch_array($q_pipcheck)) {
+
+ $playerip = $r_pipcheck[ip];
+ $trueplayerip = long2ip($playerip);
+ $pidcount = $r_pipcheck[pidcount];
+
+ // If there is more than one pid associated to an IP ...
+ IF ($pidcount > 1 ) {
+
+ echo "<br><input type=checkbox name=$trueplayerip> <b>$trueplayerip</b>";
+
+ // Query for player names and ids associated to that ip during the cycle
+ $sql_pcheck = "SELECT pi.id, pi.name, pi.country, p.pid, p.ip FROM uts_pinfo AS pi, uts_player AS p WHERE pi.id = p.pid AND p.ip = $playerip GROUP BY pi.id, pi.name, p.pid, p.ip, pi.country";
+ $q_pcheck = mysql_query($sql_pcheck) or die(mysql_error());
+ while ($r_pcheck = mysql_fetch_array($q_pcheck)) {
+ echo '<br><a class="darkhuman" href="admin.php?key='.$adminkey.'&amp;action=pinfo&amp;pid='.$r_pcheck[pid].'">'.FormatPlayerName($r_pcheck[country], $r_pcheck['pid'], $r_pcheck['name']).'</a> ';
+ }
+ echo "<br><INPUT TYPE=\"SUBMIT\" VALUE=\"merge - $trueplayerip\" NAME=\"submit\">";
+ echo '<br />';
+ }
+ }
+
+
+ echo '<BR><INPUT TYPE="SUBMIT" VALUE="ignore" NAME="submit"></FORM>';
+ } else {
+ echo "<P><BR>No ip's found with more than one nick linked to it and which are not ignored and are in this range</P>";
+ }
+
+ } else {
+ echo "<P><B>Showing all ip's in range - Enter range to filter on</B></P>";
+ echo '<FORM METHOD="POST" ACTION="admin.php?key='.$adminkey.'&action=plm&onlyrange=true">';
+ echo '<BR>Ranging from <INPUT TYPE="TEXT" NAME="from" SIZE="20" VALUE="0.0.0.0"> to <INPUT TYPE="TEXT" NAME="to" SIZE="20" VALUE="255.255.255.255">';
+ echo '<BR><BR><INPUT TYPE="SUBMIT" NAME="submit" VALUE="Confirm"></FORM>';
+ }
+
+// CASE: SHOW ALL IP'S LINKED TO MORE THAN ONE NICK
+} else {
+ echo "<P><B>IP's linked with more than one nick</B><br><I>If you want to ignore some ip's, because for example different but unrelated nicks are associated with it, check these and press the button at the lower end to confirm this</I></P>";
+
+ $ignore_ips = mysql_query("SELECT ip FROM uts_ignoreips");
+ $extended_query = "";
+ $i=0;
+ while($ignore_ips_array = mysql_fetch_array($ignore_ips)) {
+ $ip = $ignore_ips_array[0];
+ if($i==0)
+ $extended_query = " WHERE ";
+ else
+ $extended_query .= " AND ";
+ $extended_query .= "ip <> '".$ip."'";
+ $i++;
+ }
+
+ echo '<FORM METHOD="POST" ACTION="admin.php?key='.$adminkey.'&action=plm" target="_blank">';
+
+
+ // Query for list of unique ips and player ids
+ $sql_pipcheck = "SELECT ip, COUNT(DISTINCT pid) AS pidcount FROM uts_player ".$extended_query." GROUP BY ip ORDER BY ip ASC";
+ $q_pipcheck = mysql_query($sql_pipcheck) or die(mysql_error());
+ if(mysql_num_rows($q_pipcheck) > 0) {
+ while ($r_pipcheck = mysql_fetch_array($q_pipcheck)) {
+
+ $playerip = $r_pipcheck[ip];
+ $trueplayerip = long2ip($playerip);
+ $pidcount = $r_pipcheck[pidcount];
+
+ // If there is more than one pid associated to an IP ...
+ IF ($pidcount > 1 ) {
+
+ echo "<br><input type=checkbox name=$trueplayerip> <b>$trueplayerip</b>";
+
+ // Query for player names and ids associated to that ip during the cycle
+ $sql_pcheck = "SELECT pi.id, pi.name, pi.country, p.pid, p.ip FROM uts_pinfo AS pi, uts_player AS p WHERE pi.id = p.pid AND p.ip = $playerip GROUP BY pi.id, pi.name, p.pid, p.ip, pi.country";
+ $q_pcheck = mysql_query($sql_pcheck) or die(mysql_error());
+ while ($r_pcheck = mysql_fetch_array($q_pcheck)) {
+ echo '<br><a class="darkhuman" href="admin.php?key='.$adminkey.'&amp;action=pinfo&amp;pid='.$r_pcheck[pid].'">'.FormatPlayerName($r_pcheck[country], $r_pcheck['pid'], $r_pcheck['name']).'</a> ';
+ }
+ echo "<br><INPUT TYPE=\"SUBMIT\" VALUE=\"merge - $trueplayerip\" NAME=\"submit\">";
+ echo '<br />';
+ }
+ }
+ echo '<BR><INPUT TYPE="SUBMIT" VALUE="ignore" NAME="submit"></FORM>';
+ } else {
+ echo "<P><BR>No ip's found with more than one nick linked to it and which are not ignored</P>";
+ }
+}
+
+// If debugmode is on, determine end time & output execution time
+if($debug) {
+ $time = microtime();
+ $time = explode(" ", $time);
+ $time = $time[1] + $time[0];
+ $endtime = $time;
+ $totaltime = ($endtime - $begintime);
+ echo "<br>execution time: $totaltime";
+}
+?> \ No newline at end of file
diff --git a/html/pages/admin/recalcflags.php b/html/pages/admin/recalcflags.php
new file mode 100755
index 0000000..073e648
--- /dev/null
+++ b/html/pages/admin/recalcflags.php
@@ -0,0 +1,72 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Recalculate Countryflags';
+$options['requireconfirmation'] = false;
+$i = 0;
+$options['vars'][$i]['name'] = 'start';
+$options['vars'][$i]['type'] = 'static';
+$options['vars'][$i]['options'] = 'No|Yes';
+$options['vars'][$i]['exitif'] = 'No';
+$options['vars'][$i]['prompt'] = 'Are you sure';
+$options['vars'][$i]['caption'] = 'Sure:';
+$i++;
+
+$results = adminselect($options);
+
+if ($results['start'] != 'Yes') {
+ include('pages/admin/main.php');
+ exit;
+}
+@ignore_user_abort(true);
+@set_time_limit(0);
+
+include("includes/geoip.inc");
+
+/* Opens the database file */
+$gi = geoip_open("GeoIP.dat",GEOIP_STANDARD);
+
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Recalculating Countryflags</td>
+</tr>';
+
+echo'</tr>
+<tr>
+ <td class="smheading" align="left">Recalculating Rankings:</td>';
+ echo'<td class="grey" align="left">';
+
+ echo'Recalculating pinfo table...<br>';
+ /* update pinfo table */
+ $sql_pids = mysql_query("SELECT uts_pinfo.id as pid, uts_pinfo.country as country, uts_player.ip as ip FROM uts_pinfo, uts_player WHERE uts_pinfo.id = uts_player.pid GROUP BY uts_player.pid;") or die(mysql_error());
+ while($sql_pid = mysql_fetch_array($sql_pids))
+ {
+ $playercountry = strtolower(geoip_country_code_by_addr($gi,long2ip($sql_pid['ip'])));
+
+ if ($playercountry != $sql_pid['country'] )
+ {
+ mysql_query("UPDATE uts_pinfo SET country = '$playercountry' WHERE id = '".$sql_pid['pid']."'") or die(mysql_error());
+ }
+ }
+
+ echo'Recalculating player table...<br>';
+ /* update player table */
+ $sql_pids = mysql_query("SELECT pid, ip, country FROM uts_player");
+ while ($sql_pid = mysql_fetch_array($sql_pids))
+ {
+ $playercountry = strtolower(geoip_country_code_by_addr($gi,long2ip($sql_pid['ip'])));
+
+ if ($playercountry != $sql_pid['country'])
+ {
+ mysql_query("UPDATE uts_player SET country = '$playercountry' WHERE pid = '".$sql_pid['pid']."'") or die(mysql_error());
+ }
+ }
+ echo 'Done</td>
+</tr>
+
+<tr>
+ <td class="smheading" align="center" colspan="2">Countryflags recalculated - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+
+?>
diff --git a/html/pages/admin/recalcranking.php b/html/pages/admin/recalcranking.php
new file mode 100755
index 0000000..1cbc865
--- /dev/null
+++ b/html/pages/admin/recalcranking.php
@@ -0,0 +1,77 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$options['title'] = 'Recalculate Rankings';
+$options['requireconfirmation'] = false;
+$i = 0;
+$options['vars'][$i]['name'] = 'start';
+$options['vars'][$i]['type'] = 'static';
+$options['vars'][$i]['options'] = 'No|Yes';
+$options['vars'][$i]['exitif'] = 'No';
+$options['vars'][$i]['prompt'] = 'Are you sure';
+$options['vars'][$i]['caption'] = 'Sure:';
+$i++;
+
+$results = adminselect($options);
+
+if ($results['start'] != 'Yes') {
+ include('pages/admin/main.php');
+ exit;
+}
+@ignore_user_abort(true);
+@set_time_limit(0);
+
+
+echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
+<tr>
+ <td class="smheading" align="center" colspan="2">Recalculating Rankings</td>
+</tr>';
+
+echo'<tr>
+ <td class="smheading" align="left" width="200">Deleting rankings</td>';
+
+ mysql_query("TRUNCATE uts_rank") or die(mysql_error());
+
+ echo'<td class="grey" align="left" width="400">Done</td>';
+
+echo'</tr>
+<tr>
+ <td class="smheading" align="left">Recalculating Rankings:</td>';
+ echo'<td class="grey" align="left">';
+ $playerbanned = false;
+ $q_pm = mysql_query( " SELECT p.id,
+ p.matchid,
+ p.pid,
+ p.gid,
+ m.gamename
+ FROM uts_player p,
+ uts_pinfo pi,
+ uts_match m
+ WHERE pi.id = p.pid
+ AND pi.banned <> 'Y'
+ AND m.id = p.matchid
+ ORDER BY p.matchid ASC,
+ p.playerid ASC");
+ $i = 0;
+ while ($r_pm = mysql_fetch_array($q_pm)) {
+ $i++;
+ if ($i%50 == 0) {
+ echo '. ';
+ flush();
+ }
+ $playerecordid = $r_pm['id'];
+ $matchid = $r_pm['matchid'];
+ $pid = $r_pm['pid'];
+ $gid = $r_pm['gid'];
+ $gamename = $r_pm['gamename'];
+// echo "$pid|$gid|$matchid<br>";
+ include('import/import_ranking.php');
+ }
+ echo 'Done</td>
+</tr>
+
+<tr>
+ <td class="smheading" align="center" colspan="2">Rankings recalculated - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
+</tr></table>';
+
+?>
diff --git a/html/pages/admin/utdclog.php b/html/pages/admin/utdclog.php
new file mode 100755
index 0000000..b22bfd7
--- /dev/null
+++ b/html/pages/admin/utdclog.php
@@ -0,0 +1,137 @@
+<?php
+if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
+
+$filename = (!empty($_REQUEST['filename'])) ? my_stripslashes($_REQUEST['filename']) : '';
+$filename = str_replace(array('..', '/', '\\', '<', ':'), array(), $filename);
+
+
+if (!empty($filename)) {
+ if (!file_exists('logs/utdc/'. $filename) or !is_file('logs/utdc/'. $filename)) die('bla');
+ if (isset($_REQUEST['del'])) {
+ unlink('logs/utdc/'. $filename);
+ $filename = '';
+ }
+}
+
+
+
+
+if (empty($filename)) {
+ echo'<br><table class = "box" border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" width="100%" colspan="4">Available UTDC Logs:</td>
+ </tr>';
+ $logdir = opendir('logs/utdc');
+ $logs = array();
+ $sort = array();
+ $i = 0;
+ while (false !== ($filename = readdir($logdir))) {
+ if (!is_file('logs/utdc/'. $filename)) continue;
+ if ($filename == '.htaccess' or $filename == 'index.htm') continue;
+ $i++;
+ $logs[$i] = $filename;
+ $extra = 0;
+ if (substr($filename, -4) == '.bz2') $extra = 4;
+ if (substr($filename, -3) == '.gz') $extra = 3;
+
+ $sort[$i] = substr($filename, strlen($filename) - (23 + $extra), 19);
+ }
+ closedir($logdir);
+ if (count($logs) == 0) {
+ echo '<tr><td class="grey" colspan="4">No logs available!</td></tr>';
+ } else {
+ arsort($sort);
+ $i = 0;
+ foreach($sort as $id => $date) {
+ $log = $logs[$id];
+ $extra = 0;
+ if (substr($log, -4) == '.bz2') $extra = 4;
+ if (substr($log, -3) == '.gz') $extra = 3;
+
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr><td class="'.$class.'">';
+ $tmp = substr($log, strlen($log) - (23 + $extra), 19);
+ $tmp = str_replace('.', '', $tmp);
+ $ts = mtimestamp($tmp);
+ echo ' <a class="'.$class.'" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'">'.date('Y-m-d H:i', $ts).'</a>';
+ echo '</td><td class="'.$class.'">';
+ echo '<a class="'.$class.'" href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'">'.substr($log, 6, strlen($log) - 30 - $extra).'</a>';
+ echo '</td><td class="'.$class.'" align="right">';
+ $d_size = file_size_info(filesize('logs/utdc/'. $log));
+ echo $d_size['size'] .' '. $d_size['type'];
+ echo '</td><td class="'.$class.'" align="center">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($log).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td></tr>';
+ }
+ }
+}
+
+
+if (!empty($filename)) {
+ if (!file_exists('logs/utdc/'. $filename) or !is_file('logs/utdc/'. $filename)) die('bla');
+ echo'<br><table class = "box" border="0" cellpadding="1" cellspacing="2" width="600">
+ <tr>
+ <td class="smheading" align="center" width="95%" colspan="3">'.$filename.'</td>
+ <td class="smheading" align="center" width="5%" align="right">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($filename).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td>
+ </tr>';
+ if (substr($filename, -4) == '.enc') {
+ echo '<tr><td class="grey" colspan="4"><span style="font-family: monospace;">';
+ echo '<a href = "pages/admin/utdcshot.php?filename='.urlencode($filename).'" target = "_blank"><img src = "pages/admin/utdcshot.php?filename='.urlencode($filename).'" width = 100% border = 0></a>';
+ echo '</span></td></tr>';
+ }
+ else {
+ $fp = my_fopen('logs/utdc/'.$filename, 'rb', $compression = NULL);
+ if (!$fp) die("Error opening file");
+
+ $i = 0;
+ echo '<tr><td class="grey" colspan="4"><span style="font-family: monospace;">';
+
+ while (($line = my_fgets($fp, 5000, $compression)) !== FALSE) {
+ /*
+ $i++;
+ $class = ($i%2) ? 'grey' : 'grey2';
+ echo '<tr><td class="'.$class.'" colspan="4">';
+ echo '<span style="font-family: monospace;">';
+ echo htmlentities($line);
+ echo '</span>';
+ echo '</td></tr>';
+ */
+ echo wordwrap(htmlentities($line), 80, '<br />', 1) ."<br />";
+ }
+ echo '</span></td></tr>';
+ my_fclose($fp, $compression);
+
+ // look for a matching utdc screenshot
+ $logdir = opendir('logs/utdc');
+ if (substr($filename, -4) == '.bz2') $extra = 4;
+ if (substr($filename, -3) == '.gz') $extra = 3;
+ while (false !== ($file = readdir($logdir))) {
+ if (!is_file('logs/utdc/'. $filename)) continue;
+ if ($filename == '.htaccess' or $filename == 'index.htm') continue;
+ if ((substr($file, -4) == '.enc') and
+ ((substr($filename, strlen($filename)-(23 + $extra), 19) == substr($file, strlen($file)-23, 19)) or ((substr($filename, strlen($filename)-(23 + $extra), 17) == substr($file, strlen($file)-23, 17)) and (abs(intval(substr($file, strlen($file)- 6, 2)) - intval(substr($filename, strlen($filename)-(6 + $extra), 17))) <=3)))) {
+ echo '<tr>
+ <td class="smheading" align="center" width="95%" colspan="3">'.$file.'</td>
+ <td class="smheading" align="center" width="5%" align="right">';
+ echo '<a href="admin.php?key='.$adminkey.'&amp;action='.$action.'&amp;filename='.urlencode($file).'&amp;del=1"><img src="images/del.png" border="0" width="16" height="16" title="Delete" alt="Delete" /></a>';
+ echo '</td>
+ </tr>';
+
+ echo '<tr><td class="grey" colspan="4"><span style="font-family: monospace;">';
+ echo '<a href = "pages/admin/utdcshot.php?filename='.urlencode($file).'" target = "_blank"><img src = "pages/admin/utdcshot.php?filename='.urlencode($file).'" width = 100% border = 0></a>';
+ echo '</span></td></tr>';
+ }
+ }
+ closedir($logdir);
+ }
+}
+
+echo '</tr>';
+if (!empty($filename)) echo'<tr><td class="smheading" align="center" colspan="4"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'&amp;action='.$action.'">Go Back To Logfile Overview</a></td></tr>';
+echo'<tr><td class="smheading" align="center" colspan="4"><a class="grey" href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td></tr>';
+echo '</table>';
+
+?>
diff --git a/html/pages/admin/utdcshot.php b/html/pages/admin/utdcshot.php
new file mode 100755
index 0000000..24b21f7
--- /dev/null
+++ b/html/pages/admin/utdcshot.php
@@ -0,0 +1,22 @@
+<?php
+$filename = (!empty($_REQUEST['filename'])) ? stripslashes($_REQUEST['filename']) : '';
+$filename = str_replace(array('..', '/', '\\', '<', ':'), array(), $filename);
+
+
+if (!empty($filename)) {
+ if (!file_exists('../../logs/utdc/'. $filename) or !is_file('../../logs/utdc/'. $filename)) die('bla ' . $filename);
+
+ header("Content-type: image/jpg");
+
+ $fp_in = fopen('../../logs/utdc/'. $filename, 'rb') or die("Can't open file");
+ $blocksize = 1024;
+ while (!feof($fp_in)) {
+ $buffer .= @fread($fp_in, $blocksize);
+ if ($buffer === false) return(false);
+ if ($bytes === false) return(false);
+ }
+
+ $buffer = preg_replace('[\x00]', '', $buffer);
+ echo base64_decode($buffer);
+}
+?> \ No newline at end of file