Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. <?php
  2. include "ctracker.php";
  3. error_reporting( E_ERROR ^ E_WARNING );
  4. require_once('Connections/b3connect.php');
  5.  
  6. $currentPage = $_SERVER["PHP_SELF"];
  7.  
  8. $AserverBanInfos = array();
  9. foreach($config['servers'] as $serverConfig) {
  10. if ($serverConfig['include_in_banlist']!==1) continue;
  11. array_push( $AserverBanInfos, new ServerBanInfo($serverConfig) );
  12. }
  13.  
  14.  
  15. $nbBan = 0;
  16. foreach ($AserverBanInfos as $serverBanInfo) $nbBan += $serverBanInfo->banCount;
  17.  
  18. header("Content-type: text/plain");
  19. header("Cache-Control: no-store, no-cache");
  20. /*echo "\n";
  21. echo "//------------------------------------------------------\n";
  22. echo "// " . $config['clanname'] . " BAN LIST\n";
  23. echo "//------------------------------------------------------\n";
  24. echo "// IP count : " . $nbBan . " ban\n";
  25. echo "// Generated : " . date(DATE_ATOM, time()) . "\n";
  26. echo "//------------------------------------------------------\n";
  27. echo "//\n";
  28. echo "// Cut & paste into your banlist.txt or save it to use it directly. \n";
  29. echo "// The -1 places the ban forever.\n";
  30. echo "// The 0 in IPs prevents IP changing : the ban is made for all the IP mask ( from 0 to 255 ).\n";
  31. echo "// You need to set g_filterban to 1 on your server ( add g_filterban 1 to your cfg )\n";
  32. echo "//\n";
  33. echo "//------------------------------------------------------\n";
  34. echo "\n";*/
  35. foreach ($AserverBanInfos as $serverBanInfo) $serverBanInfo->writeBans();
  36.  
  37.  
  38.  
  39. class ServerBanInfo {
  40.  
  41. private $serverConfig;
  42. private $Aban;
  43.  
  44. public $banCount;
  45.  
  46. function __construct($serverConfig) {
  47. $this->serverConfig = $serverConfig;
  48. $this->Aban = $this->getBanFromBDD();
  49. $this->banCount = sizeof($this->Aban);
  50. }
  51.  
  52. private function getBanFromBDD() {
  53. global $database_b3connect, $b3connect;
  54. loadGameConfig($this->serverConfig);
  55.  
  56. mysql_select_db($database_b3connect, $b3connect);
  57. $query_rs_activebans = sprintf("SELECT penalties.id, penalties.type, penalties.time_add, penalties.time_expire, penalties.reason, penalties.inactive, penalties.duration, penalties.admin_id, target.id as target_id, target.name as target_name, target.ip as target_ip FROM penalties, clients as target WHERE penalties.type != 'Warning' AND penalties.type != 'Notice' AND inactive = 0 AND penalties.client_id = target.id AND ( penalties.time_expire = -1 OR penalties.time_expire > UNIX_TIMESTAMP(NOW())) ORDER BY penalties.id DESC");
  58.  
  59. $rs_activebans = mysql_query($query_rs_activebans, $b3connect) or die(mysql_error());
  60.  
  61. $Aban = array();
  62. while ($row = mysql_fetch_assoc($rs_activebans)) array_push($Aban, $row);
  63. mysql_free_result($rs_activebans);
  64. return $Aban;
  65. }
  66.  
  67. public function writeBans() {
  68. /* echo "\n";
  69. echo "// permanent bans from " . $this->serverConfig['name'] . " \n";*/
  70. $player = trim(strtoupper(stripslashes($_GET['player'])));
  71. foreach ($this->Aban as $ban) {
  72. $show = true;
  73. if ($player != "") {
  74. if ($player != strtoupper($ban['target_name'])) {
  75. $show = false;
  76. }
  77. }
  78. if ($show) {
  79. $text = "IP: ";
  80. $text = preg_replace('/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.\d{1,3}/', '$1.$2.$3.0', $ban['target_ip']) . " - Name: ";// . ':-1 // ';
  81. $text .= $ban['target_name'] . " - Date: ";
  82. $text .= date('d/m/Y (H:i)', $ban['time_add']) . " - Ban Type: ";
  83. if ($ban['time_expire'] == -1) {
  84. $text .= "PERMANENT - ";
  85. } else {
  86. $text .= date('d/m/Y (H:i)', $ban['time_expire']) . " - ";
  87. }
  88. $text .= $ban['reason'];
  89. echo $text . "\n";
  90. }
  91. }
  92. }
  93.  
  94. }
  95. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement