Advertisement
Guest User

Untitled

a guest
Aug 8th, 2012
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function encurta($str, $tam)
  3. {
  4.     $num_car = $tam;
  5.     $palavra = strlen($str);
  6.     $nova_palavra = substr($str, 0, $num_car);
  7.     if($palavra > $num_car)
  8.     {
  9.         return $nova_palavra.'...';
  10.     }
  11.     else
  12.     {
  13.         return $str;
  14.     }
  15. }
  16. $host = "184.82.172.42";
  17. $port = "8688";
  18. $fp = fsockopen($host, $port, &$errno, &$errstr, 30);
  19. if(!$fp)
  20. {
  21.     $success = 2;
  22. }
  23. if($success != 2)
  24. {
  25.     fputs($fp,"GET /index.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //get 7.html
  26.     while(!feof($fp))
  27.     {
  28.         $pg .= fgets($fp, 1000);
  29.     }
  30.     fclose($fp);
  31.    
  32.     // locutor
  33.     $paage = ereg_replace(".*<font class=default>Stream Title: </font></td><td><font class=default><b>", "", $pg);
  34.     $paage = ereg_replace("</b></td></tr><tr><td width=100 nowrap>.*", "", $paage);
  35.    
  36.     // programa
  37.     $pge = ereg_replace(".*<font class=default>Stream Genre: </font></td><td><font class=default><b>", "", $pg);
  38.     $pge = ereg_replace("</b></td></tr><tr><td width=100 nowrap>.*", "", $pge);
  39.    
  40.     /*
  41.     $pe = ereg_replace(".*<font class=default>Stream Genre: </font></td><td><font class=default><b>", "", $pg);
  42.     $pe = ereg_replace("</b></td></tr><tr><td width=100 nowrap>.*", "", $pe);
  43.     */
  44.    
  45.     // musica
  46.     $musica = ereg_replace(".*<font class=default>Current Song: </font></td><td><font class=default><b>", "", $pg);
  47.     $musica = ereg_replace("</b></td></tr></table>.*", "", $musica);
  48.     $numbers = explode(",",$paage);
  49.     $servertitle = $numbers[0];
  50.     $connected = $numbers[1];
  51. }
  52.  
  53. $fp2 = fsockopen("$host", $port, &$errno, &$errstr, 30);
  54. if(!$fp2)
  55. {
  56.     $success2 = 2;
  57. }
  58. if($success2 != 2)
  59. {
  60.     fputs($fp2,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
  61.     while(!feof($fp2))
  62.     {
  63.         $pg2 .= fgets($fp2, 1000);
  64.     }
  65.    
  66.     fclose($fp2);
  67.     $pag = ereg_replace(".*<body>", "", $pg2);
  68.     $pag = ereg_replace("</body>.*", ",", $pag);
  69.     $numbers = explode(",",$pag);
  70.    
  71.     // ouvintes
  72.     $currentlisteners = $numbers[0];
  73. }
  74.  
  75. // $tipo = post('tipo');
  76. $tipo = $_POST['tipo'];
  77.  
  78.     $json_return = array(
  79.     "locutor" => utf8_encode(encurta($paage, '35')),
  80.     "programa" => utf8_encode(encurta($pge, '35')),
  81.     "ouvintes" => utf8_encode(encurta($currentlisteners, '35')),
  82.     );
  83.    
  84.     echo json_encode($json_return);
  85. ?>
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement