Pomoc - Szukaj - U¿ytkownicy - Kalendarz
Pe³na wersja: Xsl Parser potrzebuje help
Forum PHP.pl > Forum > Gotowe rozwi±zania
bumfank
witam znalazlem dobry parser do XSL, dkadniej statystyki Serwera Icecast, na tym serwerze mam kilkanascie mointpoint ale interesuje mnie tylko jeden ten ktory sobie wybiore, a mam parserek ktory wybiera ten na samej gorze, prosilbym bardzo o poprawienie kodu tego parsera aby moc wybierac mointpoint, adres do XSL: http://strumyczek.man.olsztyn.pl:8000/status2.xsl
skrypt tak pokazuje http://www.infoparty.pl/status/ice2_status.php
KOD:

  1. <?php
  2. $ip = "strumyczek.man.olsztyn.pl";  //your server address in the form of mydomain.com or 192.161.1.1
  3. $port = "8000";  //the port of your server
  4. $ice2_station = "Radio Raveshow";  // your station or stream name
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. ////////////////start the parsin action
  12. //opening socket
  13. $fp = fsockopen("$ip", $port, &$errno, &$errstr, 30); //open connection
  14. if(!$fp) {
  15. $success=2; //set if no connection
  16.  
  17.  
  18.  
  19. //edit html to fit your stations site, this display is for offline status
  20. echo'<table>
  21.  <tr>
  22. <td width="100%" colspan="2">
  23. <img border="0" src="images/offline.gif" width="22" height="22">
  24. <b><font face="Arial" size="2" color="#FF0000">'.$ice2_station.' is currently offline</font></b></td>
  25. </tr>
  26. </table>';
  27. }
  28.  
  29.  
  30.  
  31.  
  32. if($success!=2){ //if connection
  33.  fputs($fp,"GET /status2.xsl HTTP/1.0rnUser-Agent: Icecast2 XSL Parser (Mozilla Compatible)rnrn"); //get status2.xsl
  34.  while(!feof($fp)) {
  35. $page .= fgets($fp, 1000);
  36.  }
  37.  fclose($fp); //close connection
  38.  $page = ereg_replace(".*<pre>", "", $page); //extract data
  39.  $page = ereg_replace("</pre>.*", ",", $page); //extract data
  40.  
  41.  $numbers = explode(",",$page); //bomb it and extract data
  42.  $mount = $numbers[0];
  43.  $connections = $numbers[1];
  44.  $stream_n = $numbers[2];
  45.  $listeners = $numbers[3];
  46.  $desc = $numbers[4];
  47.  $cur_song = $numbers[5];
  48.  $str_url = $numbers[6];
  49.  $client_info = $numbers[7];
  50.  $test1 = $numbers[8];  //set vars that where empty and still dont know what the heck those values are ;-)
  51.  $test2 = $numbers[9]; //set vars that where empty and still dont know what the heck those values are ;-)
  52.  $test3 = $numbers[10];  //set vars that where empty and still dont know what the heck those values are ;-)
  53.  $mount = $numbers[11];
  54.  $connections = $numbers[12];
  55.  $station =$numbers[13];
  56.  $listeners = $numbers[14];
  57.  $description = $numbers[15];
  58.  $cur_song = $numbers[16];
  59.  $www_url = $numbers[17];
  60.  
  61.  
  62. //edit html to fit your stations site, this display is for online status
  63. <table width="100%" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
  64. <tr>
  65.  <td width="100%"><b><font face="Arial" size="2">
  66. <img border="0" src="images/ice2_status/icecast.gif" width="22" height="22">
  67. Powered By Icecast2</font></b></td>
  68. </tr>
  69. <tr>
  70. <td width="100%"><b><font face="Arial" size="1"><a href="'.$www_url.'">
  71. '.$station.'</a> - '.$description.'</font></b></td>
  72. </tr>
  73. <tr>
  74. <td width="100%"><b><font face="Arial" size="1">
  75. <img border="0" src="images/ice2_status/listeners.gif" width="22" height="18">
  76. Listeners: '.$listeners.'</font></b></td>
  77. </tr>
  78. <tr>
  79. <td width="100%"><b><font face="Arial" size="1">
  80. <img border="0" src="images/ice2_status/tunes.gif" width="21" height="21">
  81. Now Playing: '.$cur_song.'</font></b></td>
  82. </tr>
  83. <tr>
  84. <td width="100%"><b><font face="Arial" size="2">
  85. <img border="0" src="images/ice2_status/play.gif" width="15" height="15">
  86. <a target="_blank" href="http://'.$ip.':'.$port.''.$mount.'.m3u">Listen Now</a></font></b></td>
  87. </tr>
  88.  </table>';
  89. }
  90.  
  91. ?>
dr_bonzo
xsl to XSL
a twoje xsl to CSV (coma separated values)

http://pl.php.net/manual/en/function.fgetcsv.php
tym pooperujesz sobie na liniach w pliku.
bumfank
gdybym to umial........;(

edit zreszta ten skrypt jest dobry tylko nie ma tej opcji wyboru mintpoints
To jest wersja lo-fi g³ównej zawarto¶ci. Aby zobaczyæ pe³n± wersjê z wiêksz± zawarto¶ci±, obrazkami i formatowaniem proszê kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.