PageRenderTime 75ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/TBDev/installer_v4_1/docleanup.php

https://github.com/cybernet/CyBerFuN-CoDeX
PHP | 154 lines | 132 code | 13 blank | 9 comment | 18 complexity | 8ed63863ac09065c271716a2f632116f MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. require_once("include/bittorrent.php");
  3. require_once "include/user_functions.php";
  4. require_once "include/bbcode_functions.php";
  5. dbconn();
  6. maxcoder();
  7. if (!logged_in()) {
  8. header("HTTP/1.0 404 Not Found");
  9. // moddifed logginorreturn by retro//Remember to change the following line to match your server
  10. print("<html><h1>Not Found</h1><p>The requested URL /{$_SERVER['PHP_SELF']} was not found on this server.</p><hr /><address>Apache/1.1.11 ".$SITENAME." Server at " . $_SERVER['SERVER_NAME'] . " Port 80</address></body></html>\n");
  11. die();
  12. }
  13. if (get_user_class() != UC_CODER)
  14. hacker_dork("DoCleanUp - TuT TuT... Cheating are we ??");
  15. function calctime($val)
  16. {
  17. $days = intval($val / 86400);
  18. $val -= $days * 86400;
  19. $hours = intval($val / 3600);
  20. $val -= $hours * 3600;
  21. $mins = intval($val / 60);
  22. $secs = $val - ($mins * 60);
  23. return $days . " Days, " . $hours . " Hours, " . $mins . " Minutes, " . $secs . " Seconds";
  24. }
  25. if (!function_exists('memory_get_usage')) {
  26. function memory_get_usage()
  27. {
  28. // If its Windows
  29. // Tested on Win XP Pro SP2. Should work on Win 2003 Server too
  30. // Doesn't work for 2000
  31. // If you need it to work for 2000 look at http://us2.php.net/manual/en/function.memo...usage.php#54642
  32. if (substr(PHP_OS, 0, 3) == 'WIN') {
  33. if (substr(PHP_OS, 0, 3) == 'WIN') {
  34. $output = array();
  35. exec('tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output);
  36. return preg_replace('/[\D]/', '', $output[5]) * 1024;
  37. }
  38. } else {
  39. // We now assume the OS is UNIX
  40. // Tested on Mac OS X 10.4.6 and Linux Red Hat Enterprise 4
  41. // This should work on most UNIX systems
  42. $pid = getmypid();
  43. exec("ps -eo%mem,rss,pid | grep $pid", $output);
  44. $output = explode(" ", $output[0]);
  45. // rss is given in 1024 byte units
  46. return $output[1] * 1024;
  47. }
  48. }
  49. }
  50. stdhead("Cleanup Page");
  51. begin_main_frame('Cleanups');
  52. begin_table();
  53. ?><tr><td class="colhead">Cleanup Name</td><td class="colhead">Last Run</td><td class="colhead">Runs every</td><td class="colhead">Scheduled to run</td></tr><?php
  54. $res = mysql_query("SELECT arg, value_u FROM avps");
  55. while ($arr = mysql_fetch_assoc($res)) {
  56. switch ($arr['arg']) {
  57. case 'lastcleantime': $arg = $autoclean_interval;
  58. break;
  59. case 'inactivemail': $arg = $inactivemail_interval;
  60. break;
  61. case 'lastslowcleantime': $arg = $autoslowclean_interval;
  62. break;
  63. case 's2slowcleantime': $arg = $s2autoslowclean_interval;
  64. break;
  65. case 'lotterycleantime': $arg = $autolottery_interval;
  66. break;
  67. case 'lastoptimizedbtime': $arg = $optimizedb_interval;
  68. break;
  69. case 'lastbackupdbtime': $arg = $backupdb_interval;
  70. break;
  71. case 'lastautohitruntime': $arg = $autohitrun_interval;
  72. break;
  73. }
  74. echo'<tr>' . '<td>' . $arr['arg'] . '</td>' . '<td>' . get_date_time($arr['value_u']) . ' (' . get_elapsed_time(sql_timestamp_to_unix_timestamp(get_date_time($arr['value_u']))) . ' ago)</td>' . '<td>' . calctime($arg) . '</td>' . '<td>' . calctime($arr['value_u'] - (gmtime() - $arg)) . '</td>' . '</tr>';
  75. }
  76. end_table();
  77. ?><br><form action="<?=$_SERVER["SCRIPT_NAME"]?>" method="post">
  78. <table align="center"><tr><td class="chs">
  79. <input type="checkbox" name="docleanup">Do Cleanup
  80. &nbsp;&nbsp;&nbsp;&nbsp;
  81. <input type="checkbox" name="doslowcleanup">Do Slow Cleanup
  82. &nbsp;&nbsp;&nbsp;&nbsp;
  83. <input type="checkbox" name="dos2slowcleanup">Do Slow Cleanup2
  84. &nbsp;&nbsp;&nbsp;&nbsp;
  85. <input type="checkbox" name="dolotterycleanup">Do lottery Cleanup
  86. &nbsp;&nbsp;&nbsp;&nbsp;
  87. <input type="checkbox" name="dooptimization">Do Optimization
  88. &nbsp;&nbsp;&nbsp;&nbsp;
  89. <input type="checkbox" name="dobackupdb">Do Auto Back Up
  90. &nbsp;&nbsp;&nbsp;&nbsp;
  91. <input type="checkbox" name="doautohitrun">Do Hit and Run
  92. <br><br><center><input type="submit" value="Submit"></center>
  93. </td></tr></table>
  94. </form><?php
  95. $now = gmtime();
  96. if ($_POST['docleanup']) {
  97. require_once("include/cleanup.php");
  98. sql_query("UPDATE avps SET value_u = " . sqlesc($now) . " WHERE arg = 'lastcleantime'") or sqlerr(__FILE__, __LINE__);
  99. docleanup();
  100. echo "<br><center><h1>Cleanup Done</h1></center>";
  101. }
  102. if ($_POST['doslowcleanup']) {
  103. require_once("include/cleanup.php");
  104. sql_query("UPDATE avps SET value_u = " . sqlesc($now) . " WHERE arg = 'lastslowcleantime'") or sqlerr(__FILE__, __LINE__);
  105. doslowcleanup();
  106. echo "<br><center><h1>Slow Cleanup Done</h1></center>";
  107. }
  108. if ($_POST['dos2slowcleanup']) {
  109. require_once("include/cleanup.php");
  110. sql_query("UPDATE avps SET value_u = " . sqlesc($now) . " WHERE arg = 's2slowcleantime'") or sqlerr(__FILE__, __LINE__);
  111. dos2slowcleanup();
  112. echo "<br><center><h1>Stage 2 Slow Cleanup Done</h1></center>";
  113. }
  114. if ($_POST['dolotterycleanup']) {
  115. require_once("include/cleanup.php");
  116. sql_query("UPDATE avps SET value_u = " . sqlesc($now) . " WHERE arg = 'lotterycleantime'") or sqlerr(__FILE__, __LINE__);
  117. dolotterycleanup();
  118. echo "<br><center><h1>lottery Cleanup Done</h1></center>";
  119. }
  120. if ($_POST['dooptimization']) {
  121. require_once("include/cleanup.php");
  122. sql_query("UPDATE avps SET value_u = " . sqlesc($now) . " WHERE arg = 'lastoptimizedbtime'") or sqlerr(__FILE__, __LINE__);
  123. dooptimizedb();
  124. echo "<br><center><h1>Optimization Done</h1></center>";
  125. }
  126. if ($_POST['dobackupdb']) {
  127. require_once("include/cleanup.php");
  128. sql_query("UPDATE avps SET value_u = '$now' WHERE arg = 'lastbackupdbtime'") or sqlerr(__FILE__, __LINE__);
  129. dobackupdb();
  130. echo "<br><center><h1>Auto Back Up Done</h1></center>";
  131. }
  132. if ($_POST['doautohitrun']) {
  133. require_once("include/cleanup.php");
  134. sql_query("UPDATE avps SET value_u = " . sqlesc($now) . " WHERE arg = 'lastautohitruntime'") or sqlerr(__FILE__, __LINE__);
  135. doautohitrun();
  136. echo "<br><center><h1>Hit and run clean Done</h1></center>";
  137. }
  138. echo("Memory usage:" . memory_get_usage() . "<br /><br />");
  139. end_main_frame();
  140. stdfoot();
  141. ?>