Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Gotowy skrypt ale nie działa
Forum PHP.pl > Forum > Gotowe rozwiązania
plusz01
No to tak w pliku shoucast.class mam taki kod:

  1. <? 
  2. class ShoutCAST { 
  3. var $host, $port, $pass, $dane, $values, $indexes;
  4. function connect() { 
  5. $fp = fsockopen($this->host, $this->port, $errno, $errstr, 10); 
  6. if (!$fp) { return false; 
  7. } else { 
  8. fputs($fp, "GET /admin.cgi?pass=".$this->pass."&mode=viewxml HTTP/1.0rn"); 
  9. fputs($fp, "User-Agent: Mozillarnrn"); 
  10. while (!feof($fp)) { 
  11. $this->dane .= fgets($fp, 512); 
  12. } 
  13. fclose($fp); 
  14. if (stristr($this->dane, "HTTP/1.0 200 OK") != true) return false; 
  15. $code_xml = xml_parser_create(); 
  16. if (!xml_parse_into_struct($code_xml, $this->dane, $this->values, $this->indexes)) return false; 
  17. xml_parser_free($code_xml); 
  18. return true; 
  19. } 
  20. }
  21. function showValue($which) { 
  22. return($this->values[$this->indexes[$which][0]]["value"]); 
  23. }
  24. } 
  25. ?>

a w pliki shoutcast.php taki:
  1. <? 
  2. include(&#8216;shoutcast.class’);
  3. $shoutcast = new ShoutCAST(); 
  4. $shoutcast->host = "192.189.45.3"; // adres IP serwera 
  5. $shoutcast->port = 8000; // port serwera 
  6. $shoutcast->passwd = "haslo"; // hasło do serwera 
  7. if ($shoutcast->connect()) { 
  8. if ($shoutcast->showValue(&#8216;STREAMSTATUS’)) { 
  9. print &#8220;Nazwa serwera:”.$shoutcast->showValue(‘SERVERTITLE’)).”<br>”; 
  10. print &#8220;Ilość słuchaczy:”.$shoutcast->showValue(‘CURRENTLISTENERS’)).”<br>”; 
  11. print &#8220;Limit słuchaczy:”.$shoutcast->showValue(‘MAXLISTENERS’)).”<br>”; 
  12. print &#8220;Rekord słuchaczy:”.$shoutcast->showValue(‘PEAKLISTENERS’)).”<br>”; 
  13. print &#8220;Rodzaj serwera:”.$shoutcast->showValue(‘SERVERGENRE’)).”<br>”; 
  14. print &#8220;URL serwera:”.$shoutcast->showValue(‘SERVERURL’)).”<br>”; 
  15. print &#8220;Nazwa piosenki:”.$shoutcast->showValue(‘SONGTITLE’)).”<br>”; 
  16. print &#8220;Jakość nadawania:”.$shoutcast->showValue(‘BITRATE’)).”<br>”; 
  17. print &#8220;IRC:”.$shoutcast->showValue(‘IRC’)).”<br>”; 
  18. print &#8220;AIM:”.$shoutcast->showValue(‘AIM’)).”<br>”; 
  19. print &#8220;ICQ:”.$shoutcast->showValue(‘ICQ’)).”<br>”;
  20. } else { 
  21. print "Serwer jest włączony, ale aktualnie nie ma żadnej audycji."; 
  22. } 
  23. } else { 
  24. print &#8220;Serwer jest wyłączony.”; 
  25. } 
  26. ?> 

oczywiscie dane serwera są przykładowe w pliku mam prawidłowe biggrin.gif i wyskakuje mi taki błąd Parse error: syntax error, unexpected T_STRING in F:\Programy\WebServ\httpd\stat\shoutcast.php on line 9


Tym razem poprawiłe ale w kolejnych postach proszę używać odpowiedniego bbCode.
~mike_mech
strife
Witam,

Na pierwszy rzut oka myślę że chodzi o nawiasy...
  1. <?php
  2.  
  3. $shoutcast->showValue("SERVERTITLE")); // powinno sie zamykac w jeden.
  4.  
  5. ?>

W tych dalszych to samo...

Pozdrawiam!
plusz01
no to tak zrobiłem jak kazałeś kod wygląda tak:
  1. <? 
  2. include(&#8216;shoutcast.class’);
  3. $shoutcast = new ShoutCAST();
  4. $shoutcast->host = "192.189.45.3"; // adres IP serwera
  5. $shoutcast->port = 8000; // port serwera
  6. $shoutcast->passwd = "haslo"; // hasło do serwera
  7. if ($shoutcast->connect()) {
  8. if ($shoutcast->showValue(&#8216;STREAMSTATUS’)) {
  9. print &#8220;Nazwa serwera:”.$shoutcast->showValue(‘SERVERTITLE’).”<br>”;
  10. print &#8220;Ilość słuchaczy:”.$shoutcast->showValue(‘CURRENTLISTENERS’).”<br>”;
  11. print &#8220;Limit słuchaczy:”.$shoutcast->showValue(‘MAXLISTENERS’).”<br>”;
  12. print &#8220;Rekord słuchaczy:”.$shoutcast->showValue(‘PEAKLISTENERS’).”<br>”;
  13. print &#8220;Rodzaj serwera:”.$shoutcast->showValue(‘SERVERGENRE’).”<br>”;
  14. print &#8220;URL serwera:”.$shoutcast->showValue(‘SERVERURL’).”<br>”;
  15. print &#8220;Nazwa piosenki:”.$shoutcast->showValue(‘SONGTITLE’).”<br>”;
  16. print &#8220;Jakość nadawania:”.$shoutcast->showValue(‘BITRATE’).”<br>”;
  17. print &#8220;IRC:”.$shoutcast->showValue(‘IRC’).”<br>”;
  18. print &#8220;AIM:”.$shoutcast->showValue(‘AIM’).”<br>”;
  19. print &#8220;ICQ:”.$shoutcast->showValue(‘ICQ’).”<br>”;
  20. } else {
  21. print "Serwer jest włączony, ale aktualnie nie ma żadnej audycji.";
  22. }
  23. } else {
  24. print &#8220;Serwer jest wyłączony.”;
  25. }
  26. ?>

i dalej pisze ten sam błąd w lini 9
strife
Używaj poprawnego bbCode do umieszczania kodu. Nie poprawiłeś wszystkiego:
  1. <?php
  2.  
  3. if ($shoutcast->connect()) { // tutaj tez usuń
  4. if ($shoutcast->showValue("STREAMSTATUS")) { // i tu tez...
  5.  
  6. ?>


Jakby kod był pokolorowany lepiej by się go czytało...

Zobacz teraz...
plusz01
Na początku chciałem przeprosic moderatorów za mój wczesniejszy topic nie przeczytałem że go edytowaliscie przepraszam ale mam juz inną sprawę doszedłem do takiego momentu że juz nie mam zadnego błędu tylko pisze mi że serwer jest wyłączony a ja podaje prawidłowe dane do połączenia sie a tu nic wszystkiego juz próbowałem oto kody moich plików oto pierwszy plik odpowiedzialny za połączenie a jego nazwa to shoutclass.class a oto kod
  1. <? 
  2. class ShoutCAST { 
  3. var $host, $port, $pass, $dane, $values, $indexes; 
  4. function connect() { 
  5. $fp = fsockopen($this->host, $this->port, $errno, $errstr, 10); 
  6. if (!$fp) { return false; 
  7. } else { 
  8. fputs($fp, "GET /admin.cgi?pass=".$this->pass."&mode=viewxml HTTP/1.0rn"); 
  9. fputs($fp, "User-Agent: Mozillarnrn"); 
  10. while (!feof($fp)) { 
  11. $this->dane .= fgets($fp, 512); 
  12. } 
  13. fclose($fp); 
  14. if (stristr($this->dane, "HTTP/1.0 200 OK") != true) return false; 
  15. $code_xml = xml_parser_create(); 
  16. if (!xml_parse_into_struct($code_xml, $this->dane, $this->values, $this->indexes)) return false; 
  17. xml_parser_free($code_xml); 
  18. return true; 
  19. } 
  20. } 
  21. function showValue($which) { 
  22. return($this->values[$this->indexes[$which][0]]["value"]); 
  23. } 
  24. } 
  25. ?>

i jest jeszcze drugi plik pod nazwą shoutcast.php który ma za zadanie wyswietlic pobrane dane i pokazać je na stronie jednak tak nie jest pisze że serwer wyłączony i nic więcej a serwer chodzi cały czas bez zadnych przerw jest audycja dane do serwera które tu podam są przykadowe nie prawidłowe więc prawidłowe mam w soich plikach
  1. <? 
  2. include('shoutclass.class');
  3. $shoutcast = new ShoutCAST();
  4. $shoutcast->host = '217.75.59.156'; // adres IP serwera
  5. $shoutcast->port = '8000'; // port serwera
  6. $shoutcast->passwd = 'lol'; // hasło do serwera
  7. if ($shoutcast->connect()) {
  8. if ($shoutcast->showValue('STREAMSTATUS')) {
  9. print 'SŁUCHA NAS - '.$shoutcast->showValue('(CURRENTLISTENERS)');'<html>/</html>'.$shoutcast->showValue('(MAXLISTENERS)').'<br>';
  10. print 'JAKOŚĆ - '.$shoutcast->showValue('BITRATE').' kbps<br>';
  11. print 'REKORD - '.$shoutcast->showValue('PEAKLISTENERS').'<br>';
  12. print 'GRA - '.$shoutcast->showValue('SERVERGENRE').'<br>';
  13. print 'GG - '.$shoutcast->showValue('AIM').'<br>';
  14. print 'PIOSENKA - '.$shoutcast->showValue('SONGTITLE').'<br>';
  15. } else {
  16. print 'Serwer wyłączony!';
  17. }
  18. } else {
  19. print 'Serwer wyłączony.';
  20. }
  21. ?>

z tego co mi wiadomo poprawiłem wszystkie polskie znaczki gdyby były problemy z kodowaniem np literkę ą zastąpiłem kodem ą i juz po problemie po drugie przerobiłem troszkę skrypt tak aby wyswietlał następujące dane:

SŁUCHA NAS - (5)/(100)
JAOKŚĆ - 32 kbps
REKORD - 50
GRA - dj_plusz
GG - 5948929
PIOSENKA - aktualna piosenka

te dane oczywiscie są przykladowe i zmieniałyby sie w zależnosci od ustawien serwera i ustawien pluginu shoutcast ale nurci mnie tylko to dlaczego nonsotp pokazuje że serwer wyłączony nawet jak jest włączony! proszę o pomoc
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.