Advertisement
bueddl

<3

May 8th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.01 KB | None | 0 0
  1. <?php
  2.  
  3. define('STAT_SERVER_IP'  , '64.22.107.125');
  4. define('STAT_SERVER_HOST', 'dpmaster.deathmask.net');
  5. define('STAT_SERVER_PATH', '?game=warsow&server={IP}:{Port}&xml=1');
  6.  
  7.  
  8. function reqServers($Servers) {
  9.  
  10.     $curly = array();
  11.     $result = array();
  12.     $mh = curl_multi_init();
  13.     foreach ($Servers as $id => $s) {
  14.     $curly[$id] = curl_init();
  15.  
  16.     curl_setopt($curly[$id], CURLOPT_URL,  str_replace(
  17.                                                 array('{IP}', '{Port}'),
  18.                                                 array($s->IP, $s->Port),
  19.                                                 'http://'.STAT_SERVER_IP.'/'.STAT_SERVER_PATH)
  20.                                             );
  21.     curl_setopt($curly[$id], CURLOPT_HEADER,         0);
  22.     curl_setopt($curly[$id], CURLOPT_HTTPHEADER,     array('Host: '.STAT_SERVER_HOST));
  23.     curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
  24.  
  25.     curl_multi_add_handle($mh, $curly[$id]);
  26.     }
  27.  
  28.     $running = null;
  29.     do {
  30.         curl_multi_exec($mh, $running);
  31.     } while($running > 0);
  32.  
  33.     foreach($curly as $id => $c) {
  34.         $result[$id] = curl_multi_getcontent($c);
  35.         curl_multi_remove_handle($mh, $c);
  36.     }
  37.     curl_multi_close($mh);
  38.  
  39.     return $result;
  40. }
  41.  
  42. class Server {
  43.     public $IP, $Port;
  44.    
  45.     public function __construct($IP, $Port)
  46.     {
  47.         $this->IP   = $IP;
  48.         $this->Port = $Port;
  49.     }
  50. }
  51.  
  52. $r = reqServers(array(
  53.     new Server('178.63.89.77', 44410),
  54.     new Server('178.63.89.77', 44420),
  55.     new Server('93.170.105.188', 44410),
  56.     new Server('93.170.105.188', 44420),
  57.     new Server('178.63.89.77', 44410),
  58.     new Server('178.63.89.77', 44420),
  59.     new Server('93.170.105.188', 44410),
  60.     new Server('93.170.105.188', 44420),
  61.     new Server('198.199.125.100', 44400),
  62.     new Server('178.63.69.69', 44401),
  63.     new Server('198.211.116.185', 44410),
  64.     new Server('198.211.116.185', 44420),
  65.     new Server('198.199.125.100', 44400),
  66.     new Server('178.63.69.69', 44401),
  67.     new Server('198.211.116.185', 44410),
  68.     new Server('198.211.116.185', 44420),
  69.     new Server('84.200.14.116', 44410),
  70.     new Server('178.63.89.77', 44430),
  71.     new Server('84.200.14.116', 44410),
  72.     new Server('178.63.89.77', 44430)
  73. ));
  74.  
  75. echo '<pre>';
  76.  
  77. print_r($r);
  78.  
  79. echo '</pre>';
  80.  
  81.  
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement