PageRenderTime 52ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/html/pages/admin/main.php

https://github.com/graywh/utstats
PHP | 113 lines | 98 code | 14 blank | 1 comment | 17 complexity | a0fcc4918eaeeae00cb0ef049281d5b9 MD5 | raw file
  1. <?php
  2. if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
  3. if (isset($_REQUEST['droptable'])) {
  4. $droptable = my_addslashes($_REQUEST['droptable']);
  5. if (substr($droptable, 0, 9) == 'uts_temp_' and strlen($droptable) == 17) {
  6. mysql_query("DROP TABLE $droptable;") or die(mysql_error());
  7. } else {
  8. die('NO!');
  9. }
  10. }
  11. // Graph width
  12. $max_width = 150;
  13. function nf($number) {
  14. return(number_format($number));
  15. }
  16. echo'<table border="0" cellpadding="1" cellspacing="2" width="600">
  17. <tr>
  18. <td class="smheading" align="center" height="25" colspan="4">Database Statistics</td>
  19. </tr>';
  20. $q_dbsize = mysql_query("SHOW table STATUS") or die(mysql_error());
  21. $tot_size = 0;
  22. $tot_rows = 0;
  23. $max_size = 0;
  24. while ($r_dbsize = mysql_fetch_array($q_dbsize)) {
  25. if (substr($r_dbsize['Name'], 0, 4) != 'uts_') continue;
  26. $size = $r_dbsize['Data_length'] + $r_dbsize['Index_length'];
  27. $rows = $r_dbsize['Rows'];
  28. $tables[] = array (
  29. 'name' => $r_dbsize['Name'],
  30. 'size' => $size,
  31. 'rows' => $rows
  32. );
  33. $tot_size += $size;
  34. $tot_rows += $rows;
  35. if ($max_size < $size) $max_size = $size;
  36. }
  37. $i = 0;
  38. foreach($tables as $table) {
  39. $i++;
  40. $class = ($i%2) ? 'grey' : 'grey2';
  41. $d_size = file_size_info($table['size']);
  42. $title = get_dp($table['size'] / $tot_size * 100) .' %';
  43. echo'<tr>
  44. <td class="smheading" align="left" width="200">';
  45. if (substr($table['name'], 0, 9) == 'uts_temp_' and strlen($table['name']) == 17) {
  46. 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>';
  47. } else {
  48. echo $table['name'];
  49. }
  50. echo '</td>
  51. <td class="'.$class.'" align="right">'.nf($table['rows']).' rows</td>
  52. <td class="'.$class.'" align="right">'.$d_size['size'] .' '. $d_size['type'].'</td>
  53. <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>
  54. </tr>';
  55. }
  56. $d_size = file_size_info($tot_size);
  57. echo'<tr>
  58. <td class="smheading" align="left" width="200">Total Database Size</td>
  59. <td class="darkgrey" align="right">'.nf($tot_rows).' rows</td>
  60. <td class="darkgrey" align="right">'.$d_size['size'] .' '. $d_size['type'].'</td>
  61. <td class="darkgrey" >&nbsp;</td>
  62. </tr>
  63. </table><br>';
  64. echo'<table border="0" cellpadding="1" cellspacing="2" width="600">
  65. <tr><td width="100%">';
  66. echo '
  67. <ul>';
  68. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=mplayers">Merge Players</a></li>';
  69. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=mservers">Merge Servers</a></li>';
  70. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=plm">Merge IPs with more than 1 Player</a></li>';
  71. echo '<br>';
  72. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=dmatch">Delete Match</a></li>';
  73. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=dpmatch">Delete Player From Match</a></li>';
  74. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=dplayer">Delete Player</a></li>';
  75. echo '<br>';
  76. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=pban&amp;saction=ban">Ban Player</a></li>';
  77. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=pban&amp;saction=unban">Unban Player</a></li>';
  78. echo '<br>';
  79. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=pinfo">Extended Player Info</a></li>';
  80. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=ipsearch">Search IP</a></li>';
  81. if ($import_utdc_download_enable) {
  82. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=utdclog">View UTDC logs</a></li>';
  83. }
  84. if ($import_ac_download_enable) {
  85. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=aclog">View AnthChecker logs</a></li>';
  86. }
  87. echo '<br>';
  88. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=editweapons">Edit Weapons</a></li>';
  89. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=editgames">Add/Edit Game Names</a></li>';
  90. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=editgamestype">Add/Edit Game Types</a></li>';
  91. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=recalcranking">Recalculate Rankings</a></li>';
  92. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=recalcflags">Recalculate Countryflags</a></li>';
  93. echo '<br>';
  94. echo '<li><a href="admin.php?key='. urlencode($adminkey) .'&amp;action=emptydb">Empty the database</a></li>';
  95. echo '
  96. </ul>
  97. ';
  98. echo'</td></tr></table>';
  99. ?>