Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [php] błąd w kodzie, tylko gdzie ?
Forum PHP.pl > Forum > Przedszkole
marian2299
Mam 2 pliki:

form.php
  1. <?php
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4.  
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <title>Nazwa radia</title>
  8. </head>
  9.  
  10. <body style="text-align:center">
  11. <div style="width: 500px; margin: 0 auto;">
  12. <form method="get" action="statystyki.php">
  13. <div style="float: left; width:50%; height:30px"><p style="vertical-align:middle">Nazwa radia</p></div>
  14. <div style="float: right; width: 50%; height: 30px;">
  15.        <input name="nazwaradia" type="text" style="width: 100%;margin-top: 4px;"/>
  16. </div>
  17. <div style="width: 500px;">
  18. <div style="float: left; width:50%; height:30px"><p style="vertical-align:middle">
  19.    Adres IP</p></div>
  20. <div style="float: right; width: 50%; height: 30px;">
  21.        <input name="adresip" type="text" style="width: 100%;margin-top: 4px;"/>
  22. </div>
  23. <div style="width: 500px;">
  24. <div style="float: left; width:50%; height:30px"><p style="vertical-align:middle">
  25.    PORT</p></div>
  26. <div style="float: right; width: 50%; height: 30px;" class="style1">
  27.        <input name="port" type="text" style="width: 48%; margin-top: 4px;" maxlength="6"/>
  28. </div>
  29. <div style="width: 500px;">
  30. <div style="float: left; width:50%; height:30px"><p style="vertical-align:middle">
  31.    Styl statystyk</p></div>
  32. <div style="float: right; width: 50%; height: 30px;">
  33.        &nbsp;</div>
  34. <div style="width: 500px;">
  35. <div style="float: left; width:50%; height:30px"><p style="vertical-align:middle">
  36.    Obraz1</p></div>
  37. <div style="float: right; width: 50%; height: 30px;">
  38.        &nbsp;<input name="obraz" value="obraz1" type="radio" checked="checked" /></div>
  39. <div style="width: 500px;">
  40. <div style="float: left; width:50%; height:30px"><p style="vertical-align:middle">
  41.    Obraz2</p></div>
  42. <div style="float: right; width: 50%; height: 30px;">
  43.        &nbsp;<input name="obraz" value="obraz2" type="radio" /></div>
  44. <div style="width: 500px;" class="style1">
  45. <div style="float: left; width:50%; height:30px">
  46.    <p style="vertical-align:middle" class="style2">
  47.    Obraz3</p></div>
  48. <div style="float: right; width: 50%; height: 30px;" class="style2">
  49.        &nbsp;<input name="obraz" value="obraz3" type="radio" /></div>
  50.  
  51. <br />
  52. <input type="submit" value="Wyślij!" />
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </div>
  59. </form>
  60. </div>
  61. </body>
  62.  
  63. </html>
  64. ?>


oraz statystyki.php
  1. <?
  2.  
  3.   $obraz          =   $_GET['obraz'];
  4.   $sc[ip]         = ".'$_GET[adresip]'."; //Ip serwera shoutcast
  5.   $sc[port]      =   ".'$_GET[port]'."; //Port serwera shoutcast
  6.   $sc[czas]     =   "60"; //Czas odświeżania statywu
  7.  
  8. // Tutaj nic nie ruszać!
  9.   $sc[table1]   =   "<b>[dj]</b>";
  10.   $sc[table2]   =   "<b>[audycja]</b>";
  11.   $sc[table3]   =   "<b>[ile]</b>";
  12.  
  13. if($fp = fsockopen($sc[ip] , $sc[port]))
  14. {
  15. fputs($fp,"GET /index.html HTTP/1.0r\nUser-Agent: XML Getter (Mozilla Compatible)r\nr\n");
  16. fgets($fp);fgets($fp);fgets($fp);
  17.       while(!feof($fp)) $in.=strip_tags(fgets($fp));
  18. fclose($fp);
  19.  # echo $in;
  20.  
  21. //  [status]
  22.   $m[0]="Server is currently";
  23.   $m[1]="";
  24.   $mp[0]=strpos($in,$m[0]);
  25.   $mp[1]=@strpos($in,$m[1]);
  26.   $ml[0]=strlen($m[0]);
  27.   $ml[1]=strlen($m[1]);
  28.  
  29.   $tmp[1]=explode( " " , trim( substr( $in , $mp[0] + $ml[0] , 5 ) ) );
  30.  
  31.   if( $tmp[1][0] == "up" )
  32.       $dat[status] = "";
  33.   elseif( $tmp[1][0] == "down" )
  34.       $dat[status] = "Aktualnie nie nadajemy";
  35.   else
  36.       $dat[status] = "Radio Party-Net Zapraszamy!!!";
  37.  
  38.   if($dat[status]=="")
  39.   {
  40.  
  41. //  [audycja]
  42.       $m[0]="Stream Title:";
  43.       $m[1]="Content Type:";
  44.       $mp[0]=strpos($in,$m[0]);
  45.       $mp[1]=strpos($in,$m[1]);
  46.       $ml[0]=strlen($m[0]);
  47.       $ml[1]=strlen($m[1]);
  48.  
  49.       $tmp[1]=trim( substr( $in , $mp[0] + $ml[0] , $mp[1]-$mp[0]-$ml[1] ) );
  50.  
  51.       if( $tmp[1] ) $dat[audycja] = $tmp[1];
  52.       else $dat[audycja] = "Radio Party-Net Zapraszamy!!!";
  53.  
  54.   //  [dj]
  55.       $m[0]="Stream Genre:";
  56.       $m[1]="Stream URL:";
  57.       $mp[0]=strpos($in,$m[0]);
  58.       $mp[1]=strpos($in,$m[1]);
  59.       $ml[0]=strlen($m[0]);
  60.       $ml[1]=strlen($m[1]);
  61.  
  62.       $tmp[1]=trim( substr( $in , $mp[0] + $ml[0] , $mp[1]-$mp[0]-$ml[1]-2 ) );
  63.  
  64.       if( $tmp[1] ) $dat[dj] = $tmp[1];
  65.       else $dat[dj] = "Radio Party-Net Zapraszamy!!!";
  66.  
  67.   //  [statyw]
  68.       $m[0]="Stream AIM:";
  69.       $m[1]="Stream IRC:";
  70.       $mp[0]=strpos($in,$m[0]);
  71.       $mp[1]=strpos($in,$m[1]);
  72.       $ml[0]=strlen($m[0]);
  73.       $ml[1]=strlen($m[1]);
  74.  
  75.       $tmp[1]=trim( substr( $in , $mp[0] + $ml[0] , $mp[1]-$mp[0]-$ml[1] ) );
  76.  
  77.       if( $tmp[1] ) $dat[statyw] = $tmp[1];
  78.       else $dat[statyw] = "autopilot";
  79.  
  80.   //  [gg]
  81.       $m[0]="Stream ICQ:";
  82.       $m[1]="Stream AIM:";
  83.       $mp[0]=strpos($in,$m[0]);
  84.       $mp[1]=strpos($in,$m[1]);
  85.       $ml[0]=strlen($m[0]);
  86.       $ml[1]=strlen($m[1]);
  87.  
  88.       $tmp[1]=trim( substr( $in , $mp[0] + $ml[0] , $mp[1]-$mp[0]-$ml[1] ) );
  89.  
  90.       if( $tmp[1] ) $dat[gg] = $tmp[1];
  91.       else $dat[gg] = "Radio Party-Net Zapraszamy!!!";
  92.  
  93.   //  [ile]
  94.       $m[0]="kbps with";
  95.       $m[1]="listeners";
  96.       $mp[0]=strpos($in,$m[0]);
  97.       $mp[1]=strpos($in,$m[1]);
  98.       $ml[0]=strlen($m[0]);
  99.       $ml[1]=strlen($m[1]);
  100.  
  101.       $tmp[1]=explode( " " , trim( substr( $in , $mp[0] + $ml[0] , $mp[1]-$mp[0]-$ml[1]-2 ) ) );
  102.  
  103.       if( $tmp[1] ) $dat[ile] = $tmp[1][0];
  104.       else $dat[ile] = "Radio Party-Net Zapraszamy!!!";
  105.  
  106.     //  [peak]
  107.       $m[0]="Listener Peak:";
  108.       $m[1]="Average";
  109.       $mp[0]=strpos($in,$m[0]);
  110.       $mp[1]=strpos($in,$m[1]);
  111.       $ml[0]=strlen($m[0]);
  112.       $ml[1]=strlen($m[1]);
  113.  
  114.       $tmp[1]=trim( substr( $in , $mp[0] + $ml[0] , $mp[1]-$mp[0]-$ml[1]-7) );
  115.  
  116.       if( $tmp[1] ) $dat[peak] = $tmp[1];
  117.       else $dat[peak] = "Radio Party-Net Zapraszamy!!!";
  118.  
  119. //  [nuta]
  120.       $m[0]="Current Song:";
  121.       $m[1]="Written by Ste";
  122.       $mp[0]=strpos($in,$m[0]);
  123.       $mp[1]=strpos($in,$m[1]);
  124.       $ml[0]=strlen($m[0]);
  125.       $ml[1]=strlen($m[1]);
  126.  
  127.       $tmp[1]=trim( substr( $in , $mp[0] + $ml[0] , $mp[1]-$mp[0]-$ml[1] ) );
  128.  
  129.       if( $tmp[1] ) $dat[nuta] = $tmp[1];
  130.       else $dat[nuta] = "Radio Party-Net Zapraszamy!!!";
  131.  
  132.   }
  133. }
  134. else
  135. {
  136.   $dat=array();
  137.   $dat[status]="err";
  138. }
  139.  
  140. $co             =   array('[status]','[audycja]','[dj]','[statyw]','[gg]','[ile]','[peak]','[nuta]');
  141. $naco           =   array($dat[status],$dat[audycja],$dat[dj],$dat[statyw],$dat[gg],$dat[ile],$dat[peak],$dat[nuta]);
  142. $sc[table1]   =   str_replace($co,$naco,$sc[table1]);
  143. $sc[table2]   =   str_replace($co,$naco,$sc[table2]);
  144. $sc[table3]   =   str_replace($co,$naco,$sc[table3]);
  145. ?>
  146. <body style="text-align:center">
  147. <div align="center" style="margin: 0 auto;">
  148.  <table border="0" style="margin: 0 auto;" cellpadding="0" cellspacing="0" bgcolor="#393939" background="<? echo $obraz ?>.jpg">
  149.    <tr>
  150.      <td width="120" height="190" background="1.jpg">
  151.      <div style="position: absolute; width:89px; height: 15px; left: 586px; top: 56px;"><marquee><? echo $sc[table1]; ?></marquee></div>
  152.    <div style="position: absolute; width:89px; height: 15px; left: 582px; top: 92px;"><marquee><? echo $sc[table2]; ?></marquee></div>
  153.       <div style="position: absolute; width:54px; height: 20px; left: 622px; top: 126px;"><marquee><? echo $sc[table3]; ?></marquee></div>
  154.  </td></tr></table>
  155.          </div>
  156.          </body>


Zadaniem tego ma być wstawianie na stronę statystyk shoutcast za pomocą iframe z mojej strony, nawet gdy nie mamy fopen.
Jednak skrypt nie działa prawidłowo.
Powinien wyświetlić dane, chociażby z :http://sc2.supercast.pl:8510.
Adres musi być w "cudzysłowie".
Nie wiem, czy na cba jest fopen, ale nie ma błędu, więc sądzę że jest.
Proszę nie pisać w sprawie walidacji kodu, tym zajmę się gdy zrobię skrypt.
Z góry thx.


PS: Pomógł `rozdaje` zawsze, kiedy rozwiąże CAŁY problem.
patryczakowy
Na pewno tu masz błąd
  1. <?php
  2. $sc[ip]         = ".'$_GET[adresip]'."; //Ip serwera shoutcast
  3.   $sc[port]      =   ".'$_GET[port]'."; //Port serwera shoutcast
  4. ?>
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.