Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. <?php
  2. function writeCache($content, $filename) {
  3. $fp = fopen('./tmp/cache/ban-acc/' . $filename, 'w');
  4. fwrite($fp, $content);
  5. fclose($fp);}
  6. function readCache($filename, $expiry) {
  7. if (file_exists('./tmp/cache/ban-acc/' . $filename)) {
  8. if ((time() - $expiry) > filemtime('./tmp/cache/ban-acc/' . $filename))
  9. return FALSE;
  10. $cache = file('./tmp/cache/ban-acc/' . $filename);
  11. return implode('', $cache);}
  12. return FALSE;}
  13. ob_start();
  14. ?>
  15. <cached>
  16. <?php
  17. if (!$cached = readCache('ban_acc.cache', 700)) {
  18. ?>
  19. <?php
  20. $host = 'localhost';
  21. $user = 'root';
  22. $pass = '';
  23. $rdb = 'blizz';
  24.  
  25. $connect = mysql_connect($host,$user,$pass) or die('Нет подключения к базе данных');
  26. mysql_select_db ($rdb, $connect) or die(mysql_error());
  27. $ban_account = mysql_query('SET NAMES utf8');
  28. $ban_account = mysql_query("SELECT * FROM `account_banned` WHERE `active` = 1 ORDER BY `bandate` DESC LIMIT 35000", $connect) or die(mysql_error());
  29.  
  30. $id = 1;
  31. while ($result_account = mysql_fetch_array($ban_account)){
  32. $accout_id = $result_account['id'];
  33. $username_sql = mysql_query("SELECT * FROM `account` WHERE `id` = $accout_id LIMIT 1", $connect) or die(mysql_error());
  34. $result_username = mysql_fetch_array($username_sql);
  35. $account = $result_username['username'];
  36. $bandate = date("H:i:s d.m.Y", $result_account['bandate']);
  37. $bannedby = $result_account['bannedby'];
  38. $banreason = $result_account['banreason'];
  39.  
  40. if ($result_account['bandate'] == $result_account['unbandate'])
  41. $unbandate = '<center>Навсегда</center>';
  42. else
  43. $unbandate = date("H:i:s d.m.Y", $result_account['unbandate']);
  44.  
  45. if ($result_account['bannedby'] == '')
  46. $bannedby = 'Консоль';
  47.  
  48.  
  49. print "
  50. <tr class=\"dissing-col\">
  51. <th class=\"hoge-bane-page-st\"scope=\"row\">$id</th>
  52. <th class=\"hoge-bane-page-st\">$account</th>
  53. <th class=\"hoge-bane-page-st\">$bandate</th>
  54. <th class=\"hoge-bane-page-st\">$bannedby</th>
  55. <th class=\"hoge-bane-page-st\">$banreason</th>
  56. <th class=\"hoge-bane-page-st\">$unbandate</th>
  57. </tr>
  58. ";
  59. $id++;
  60. }
  61. mysql_close($connect);
  62. ?>
  63. </cached>
  64. <?php
  65. $cached = ob_get_contents();
  66. ob_clean();
  67. writeCache($cached, 'ban_acc.cache');
  68. }
  69. ob_end_clean();
  70. echo $cached;
  71. $cachefile = 'cached-files/'.date('M-d-Y').'.php';
  72. $cachetime = 18000;
  73. if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
  74. include($cachefile);
  75. exit;
  76. }
  77. ob_start();
  78.  
  79. $fp = fopen($cachefile, 'w');
  80. fwrite($fp, ob_get_contents());
  81. fclose($fp);
  82. ob_end_flush();
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement