wcypierre

tbd shoutbox

Oct 15th, 2011
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <?php
  2.  
  3. set_time_limit(0);
  4. ini_set('memory_limit','128M');
  5. ini_set('xdebug.max_nesting_level', 0);
  6.  
  7. function listen($host, $port, $data_arr) {
  8.     //ob_start();
  9.     $header = array(
  10.         //"User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0\r\n",
  11.         //"Accept:    text/plain, */*; q=0.01\r\n",
  12.         //"Accept-Language:    en-us,en;q=0.5\r\n",
  13.         //"Accept-Encoding: gzip, deflate\r\n",
  14.         //"Accept-Charset:    ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n",
  15.         "Connection:keep-alive\r\n",
  16.         "X-Requested-With:XMLHttpRequest\r\n",
  17.         "If-None-Match:0\r\n",
  18.         "If-Modified-Since:".gmdate("r", time())."\r\n\r\n");      
  19.        
  20.     $url = $host . "/sub?id=tbdshout&a=d4257aa2d6c95fca201b173a7c35d87e26aeeaae";
  21.        
  22.     $opts = array(
  23.     CURLOPT_URL => $url,
  24.     CURLOPT_RETURNTRANSFER => true,
  25.     CURLOPT_FOLLOWLOCATION => false,
  26.     //CURLOPT_USERAGENT => $useragent,
  27.     /*CURLOPT_PROXY => "",
  28.     CURLOPT_PROXYPORT => 8080,*/
  29.     CURLOPT_HEADER => false,
  30.     CURLOPT_PORT => $port,
  31.     CURLOPT_HTTPHEADER => $header,
  32.     //CURLOPT_POSTFIELDS => 'A',
  33.     CURLOPT_SSL_VERIFYPEER => false,
  34.     CURLOPT_SSL_VERIFYHOST => 2,
  35.     CURLOPT_HTTPAUTH => CURLAUTH_ANY);
  36.  
  37.     $init = curl_init();
  38.     curl_setopt_array($init,$opts);
  39.    
  40.     $exec = curl_exec($init);
  41.    
  42.     $data = json_decode($exec);
  43.     var_dump($data);
  44.    
  45.     /*
  46.     if(isset($data_arr))
  47.     {
  48.         $count = count($data_arr);
  49.         var_dump($count);  
  50.        
  51.         if($count == 0 or $count == 1){
  52.             echo "<b>". $count . "</b>";
  53.             if($data_arr[$count-1] == null){
  54.                 $data_arr[$count-1] = $data->shout_msg;
  55.                 echo $data_arr[$count-1];
  56.                 ob_flush();
  57.                 flush();
  58.             }
  59.         }
  60.         else if(isset($data_arr[$count]) != isset($data_arr[$count+1])){
  61.                 $data_arr[$count] = $data->shout_msg;
  62.                 echo $data_arr[$count]. "<br />";
  63.                 //var_dump($data_arr);
  64.            
  65.                 ob_flush();
  66.                 flush();               
  67.         }
  68.     }
  69.     */
  70.     //echo $data->uname . " -> " . $data->shout_msg . "<br />";
  71.    
  72.     curl_close($init);
  73.    
  74.     //sleep(5);
  75.     unset($host, $port, $header, $opts, $init, $exec);
  76.     //ob_end_flush();
  77.     listen($_GET['host'],"8080",$data_arr);
  78.    
  79.     //http://w3.tbd.my/xmlhttp.php?action=show_shouts_json&jsoncallback=?
  80. }
  81. $_GET['host'] = "s.tbd.my";
  82. $lhost = $_GET['host'];
  83.  
  84. listen($lhost,"8080",'');
  85.    
  86. ?>
  87.  
Advertisement
Add Comment
Please, Sign In to add comment