PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/html/pages/admin/recalcranking.php

https://github.com/graywh/utstats
PHP | 77 lines | 66 code | 10 blank | 1 comment | 7 complexity | 7aed797f4797d1a999e931f5aa99c437 MD5 | raw file
  1. <?php
  2. if (empty($import_adminkey) or isset($_REQUEST['import_adminkey']) or $import_adminkey != $adminkey) die('bla');
  3. $options['title'] = 'Recalculate Rankings';
  4. $options['requireconfirmation'] = false;
  5. $i = 0;
  6. $options['vars'][$i]['name'] = 'start';
  7. $options['vars'][$i]['type'] = 'static';
  8. $options['vars'][$i]['options'] = 'No|Yes';
  9. $options['vars'][$i]['exitif'] = 'No';
  10. $options['vars'][$i]['prompt'] = 'Are you sure';
  11. $options['vars'][$i]['caption'] = 'Sure:';
  12. $i++;
  13. $results = adminselect($options);
  14. if ($results['start'] != 'Yes') {
  15. include('pages/admin/main.php');
  16. exit;
  17. }
  18. @ignore_user_abort(true);
  19. @set_time_limit(0);
  20. echo'<br><table border="0" cellpadding="1" cellspacing="2" width="600">
  21. <tr>
  22. <td class="smheading" align="center" colspan="2">Recalculating Rankings</td>
  23. </tr>';
  24. echo'<tr>
  25. <td class="smheading" align="left" width="200">Deleting rankings</td>';
  26. mysql_query("TRUNCATE uts_rank") or die(mysql_error());
  27. echo'<td class="grey" align="left" width="400">Done</td>';
  28. echo'</tr>
  29. <tr>
  30. <td class="smheading" align="left">Recalculating Rankings:</td>';
  31. echo'<td class="grey" align="left">';
  32. $playerbanned = false;
  33. $q_pm = mysql_query( " SELECT p.id,
  34. p.matchid,
  35. p.pid,
  36. p.gid,
  37. m.gamename
  38. FROM uts_player p,
  39. uts_pinfo pi,
  40. uts_match m
  41. WHERE pi.id = p.pid
  42. AND pi.banned <> 'Y'
  43. AND m.id = p.matchid
  44. ORDER BY p.matchid ASC,
  45. p.playerid ASC");
  46. $i = 0;
  47. while ($r_pm = mysql_fetch_array($q_pm)) {
  48. $i++;
  49. if ($i%50 == 0) {
  50. echo '. ';
  51. flush();
  52. }
  53. $playerecordid = $r_pm['id'];
  54. $matchid = $r_pm['matchid'];
  55. $pid = $r_pm['pid'];
  56. $gid = $r_pm['gid'];
  57. $gamename = $r_pm['gamename'];
  58. // echo "$pid|$gid|$matchid<br>";
  59. include('import/import_ranking.php');
  60. }
  61. echo 'Done</td>
  62. </tr>
  63. <tr>
  64. <td class="smheading" align="center" colspan="2">Rankings recalculated - <a href="./admin.php?key='.$_REQUEST[key].'">Go Back To Admin Page</a></td>
  65. </tr></table>';
  66. ?>