You are not logged in.

  • Login

1

Monday, November 6th 2006, 5:49pm

Php shoutcast auslesen STREAMTITEL

so ja ähm hab nen script mit kollegen geschrieben vor monaten, was ich jetzt wieder brauche aber mir Probleme macht.

PHP Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
## shoutcast by Pr3mu on ##
$server = "88.198.7.243"; //hier deinen server eintragen z.b. musik.de oder 213.61.885.8
$port = 8000; //hier den port eintragen (ist standard (autom.korrigiert) 8000)
    $fp = @fsockopen($server, $port, $errno, $errstr, 30);
 
    if ($fp) {
        fputs($fp, "GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
        while(!feof($fp))
            $page .= fgets($fp, 1000);
        fclose($fp);
        $page = ereg_replace(".*<body>", "", $page);
        $page = ereg_replace("</body>.*", ",", $page);
        $numbers = explode(",", $page);
        $shoutcast_currentlisteners = $numbers[0]; //variable ueber die aktuelle anzahl der zuhoerer
        $connected = $numbers[1]; //variable zum anzeigen ob ein sender verbunden sind
        if($connected == 1) {
            $radio_status = 1; //variable zum anzeigen ob radio an ist oder nicht
            $wordconnected = "yes"; //zusaetzliche variable die ich brauchte ;)
        }
        else
            $wordconnected = "no"; //zusaetzliche variable die ich brauchte
        $shoutcast_peaklisteners = $numbers[2]; //variable die die anzahl der peaks angiebt
        $shoutcast_maxlisteners = $numbers[3]; //variable ueber die maximal moegliche anzahl der zuhoerer
        $shoutcast_reportedlisteners = $numbers[4]; //
        $shoutcast_bitrate = $numbers[5]; //bitrate ;)
        $shoutcast_cursong = $numbers[6]; //aktueller song 
        $shoutcast_curbwidth = $shoutcast_bitrate * $shoutcast_currentlisteners; //gesamtbandbreite
        $shoutcast_peakbwidth = $shoutcast_bitrate * $shoutcast_peaklisteners; //gesamtpeakbandbreite
    }
 
## output on ##    
echo '<html><title>Shoutcast by Pr3mu</title><body>';
if ($radio_status == 1) {
    echo 'Anzahl der hoerer: ' . $shoutcast_currentlisteners . '<br />';
    echo 'Gesamtbandbreite: ' . $shoutcast_curbwidth . ' kb/s<br />';
    echo 'Bitrate: ' . $shoutcast_bitrate .' kb/s <br />';
    echo 'Zuhoerer Peak: ' . $shoutcast_peaklisteners . '<br />';
    echo 'Bandbreite Peak: ' . $shoutcast_peakbwidth . ' kb/s<br />';
    echo 'Max. moegliche Zuhoerer: ' . $shoutcast_maxlisteners . '<br />';
    echo 'Aktueller Song: >>' . $shoutcast_cursong . '<< <br />';
}    
    else {
        echo '<h1>Sorry aber das radio ist zur zeit offline!</h1>';
}
echo '</body></html>';
## output off ##
## shoutcast by Pr3mu off ##
?>


und zwar will ich dass er den Streamtitel ausliest, weis aber ned welchen command , habs probiert mit $shoutcast_streamtitle und $shoutcast_servertitle , aber vergebens, ich weis auch nicht ob das script soweit kommt bis zum Server/Streamtitle.... bitte um hilfe, verzweifel langsam, ich komm ned drauf oder muss ich das wieder alles mit nem sockopen machen !?

btw bräuchte auch ein script was alle x min nen link öffnet, so kann man shoutcast bescheissen , in dem link kann man den currentsong setzten zb als nen Punkt, wenn das script dann zb jede 2 mins nen punkt setzt hat man schön den stationname und kein zurückgebliebenes vom letzten DJ oder Playliste

MFG
Pr3mu

2

Monday, November 6th 2006, 6:18pm

oder kann mir jmd das script so herschneiden, dass ich nur die aller erste Zeile habe ? http://88.198.7.243/dj/streamst.php

PHP Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
 
/*******************************************************************
* shoutcast.class.php
* Version: 0.1
* Author: Henrik Malmberg
* Copyright (C) 2002, Henrik Malmberg
* henrik@ih.nut
* http://yoda.ih.nu/
*
*******************************************************************
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
 
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*******************************************************************/
 
class ShoutCast {
    // Public
    var $host;
    var $port;
    var $passwd;
 
    //Private
    var $_xml;
    var $_error;
 
    function openstats() {
        $fp = fsockopen($this->host, $this->port, $errno, $errstr, 10);
        If (!$fp) {
            $this->_error = "$errstr ($errno)";
            return(0);
        } else {
            fputs($fp, "GET /admin.cgi?pass=".$this->passwd."&mode=viewxml HTTP/1.0\r\n");
            fputs($fp, "User-Agent: Mozilla\r\n\r\n");
            while (!feof($fp)) {
                    $this->_xml .= fgets($fp, 512);
            }
            fclose($fp);
 
            if (stristr($this->_xml, "HTTP/1.0 200 OK") == true) {
                // <-H> Thanks to Blaster for this fix.. trim();
                $this->_xml = trim(substr($this->_xml, 42));
            } else {
                $this->_error = "Bad login";
                return(0);
            }
 
            $xmlparser = xml_parser_create();
            if (!xml_parse_into_struct($xmlparser, $this->_xml, $this->_values, $this->_indexes)) {
                $this->_error = "Unparsable XML";
                return(0);
            }
 
            xml_parser_free($xmlparser);
 
            return(1);
        }
    }
 
    function GetCurrentListenersCount() {
        return($this->_values[$this->_indexes["CURRENTLISTENERS"][0]]["value"]);
    }
 
    function GetPeakListenersCount() {
        return($this->_values[$this->_indexes["PEAKLISTENERS"][0]]["value"]);
    }
 
    function GetMaxListenersCount() {
        return($this->_values[$this->_indexes["MAXLISTENERS"][0]]["value"]);
    }
 
    function GetReportedListenersCount() {
        return($this->_values[$this->_indexes["REPORTEDLISTENERS"][0]]["value"]);
    }
 
    function GetAverageListenTime() {
        return($this->_values[$this->_indexes["AVERAGETIME"][0]]["value"]);
    }
 
    function GetServerGenre() {
        return($this->_values[$this->_indexes["SERVERGENRE"][0]]["value"]);
    }
 
    function GetServerURL() {
        return($this->_values[$this->_indexes["SERVERURL"][0]]["value"]);
    }
 
    function GetServerTitle() {
        return($this->_values[$this->_indexes["SERVERTITLE"][0]]["value"]);
    }
 
    function GetCurrentSongTitle() {
        return($this->_values[$this->_indexes["SONGTITLE"][0]]["value"]);
    }
 
    function GetIRC() {
        return($this->_values[$this->_indexes["IRC"][0]]["value"]);
    }
 
    function GetAIM() {
        return($this->_values[$this->_indexes["AIM"][0]]["value"]);
    }
 
    function GetICQ() {
        return($this->_values[$this->_indexes["ICQ"][0]]["value"]);
    }
 
    function GetWebHitsCount() {
        return($this->_values[$this->_indexes["WEBHITS"][0]]["value"]);
    }
 
    function GetStreamHitsCount() {
        return($this->_values[$this->_indexes["STREAMHITS"][0]]["value"]);
    }
 
    function GetStreamStatus() {
        return($this->_values[$this->_indexes["STREAMSTATUS"][0]]["value"]);
    }
 
    function GetBitRate() {
        return($this->_values[$this->_indexes["BITRATE"][0]]["value"]);
    }
 
    function GetSongHistory() {
        for($i=1;$i<sizeof($this->_indexes['TITLE']);$i++) {
            $arrhistory[$i-1] = array(
                                    "playedat"=>$this->_values[$this->_indexes['PLAYEDAT'][$i]]['value'],
                                    "title"=>$this->_values[$this->_indexes['TITLE'][$i]]['value']
                                );
        }
 
        return($arrhistory);
    }
 
    function GetListeners() {
        for($i=0;$i<sizeof($this->_indexes['USERAGENT']);$i++) {
            $arrlisteners[$i] = array(
                                    "hostname"=>$this->_values[$this->_indexes['HOSTNAME'][$i]]['value'],
                                    "useragent"=>$this->_values[$this->_indexes['USERAGENT'][$i]]['value'],
                                    "underruns"=>$this->_values[$this->_indexes['UNDERRUNS'][$i]]['value'],
                                    "connecttime"=>$this->_values[$this->_indexes['CONNECTTIME'][$i]]['value'],
                                    "pointer"=>$this->_values[$this->_indexes['POINTER'][$i]]['value'],
                                    "uid"=>$this->_values[$this->_indexes['UID'][$i]]['value'],
                                );
        }
 
        return($arrlisteners);
    }
 
    function geterror() { return($this->_error); }
}
 
?>



PHP Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
include("shoutcast.class.php");
 
function ConvertSeconds($seconds) {
    $tmpseconds = substr("00".$seconds % 60, -2);
    if ($seconds > 59) {
        if ($seconds > 3599) {
            $tmphours = substr("0".intval($seconds / 3600), -2);
            $tmpminutes = substr("0".intval($seconds / 60 - (60 * $tmphours)), -2);
 
            return ($tmphours.":".$tmpminutes.":".$tmpseconds);
        } else {
            return ("00:".substr("0".intval($seconds / 60), -2).":".$tmpseconds);
        }
    } else {
        return ("00:00:".$tmpseconds);
    }
}
 
$shoutcast = new ShoutCast();
$shoutcast->host = "localhost";
$shoutcast->port = "8000";
$shoutcast->passwd = "****";
 
if ($shoutcast->openstats()) {
    // We got the XML, gogogo!..
    if ($shoutcast->GetStreamStatus()) {
        echo "<b>".$shoutcast->GetServerTitle()."</b> (".$shoutcast->GetCurrentListenersCount()." of 
 
".$shoutcast->GetMaxListenersCount()." listeners, peak: ".$shoutcast->GetPeakListenersCount().")<p>\n\n";
 
        echo "<table border=0 cellpadding=0 cellspacing=0>\n";
        echo "<tr><td width=\"180\"><b>Server Genre: 
 
</b></td><td>".$shoutcast->GetServerGenre()."</td></tr>\n";
        echo "<tr><td><b>Server URL: </b></td><td><a 
 
href=\"".$shoutcast->GetServerURL()."\">".$shoutcast->GetServerURL()."</a></td></tr>\n";
        echo "<tr><td><b>Server Title: </b></td><td>".$shoutcast->GetServerTitle()."</td></tr><tr><td 
 
colspan=2>&nbsp;</td></tr>\n";
 
        echo "<tr><td><b>Current Song: </b></td><td>".$shoutcast->GetCurrentSongTitle()."</td></tr>\n";
        echo "<tr><td><b>BitRate: </b></td><td>".$shoutcast->GetBitRate()."</td></tr><tr><td 
 
colspan=2>&nbsp;</td></tr>\n";
 
        echo "<tr><td><b>Average listen time: 
 
</b></td><td>".ConvertSeconds($shoutcast->GetAverageListenTime())."</td></tr><tr><td 
 
colspan=2>&nbsp;</td></tr>\n";
 
        echo "<tr><td><b>IRC: </b></td><td>".$shoutcast->GetIRC()."</td></tr>\n";
        echo "<tr><td><b>AIM: </b></td><td>".$shoutcast->GetAIM()."</td></tr>\n";
        echo "<tr><td><b>ICQ: </b></td><td>".$shoutcast->GetICQ()."</td></tr><tr><td 
 
colspan=2>&nbsp;</td></tr>\n";
 
        echo "<tr><td><b>WebHits Count: </b></td><td>".$shoutcast->GetWebHitsCount()."</td></tr>\n";
        echo "<tr><td><b>StreamHits Count: </b></td><td>".$shoutcast->GetStreamHitsCount()."</td></tr>\n";
        echo "</table><p>";
 
        echo "<b>Song history;</b><br>\n";
        $history = $shoutcast->GetSongHistory();
        if (is_array($history)) {
            for ($i=0;$i<sizeof($history);$i++) {
                echo "[".$history[$i]["playedat"]."] - ".$history[$i]["title"]."<br>\n";
            }
        } else {
            echo "No song history available..";
        }
        echo "<p>";
 
        echo "<b>Listeners;</b><br>\n";
        $listeners = $shoutcast->GetListeners();
        if (is_array($listeners)) {
            for ($i=0;$i<sizeof($listeners);$i++) {
                echo "[".$listeners[$i]["uid"]."] - ".$listeners[$i]["hostname"]." using 
 
".$listeners[$i]["useragent"].", connected for ".ConvertSeconds($listeners[$i]["connecttime"])."<br>\n";
            }
        } else {
            echo "Noone listens right now..";
        }
    } else {
        echo "Server is up, but no stream available..";
    }
} else {
    // Ohhh, damnit..
    echo $shoutcast->geterror();
}
?>


WÄre echt super nett ich dreh jetzt dann allmälich druch mit dem ganzen ^^

3

Monday, November 6th 2006, 8:50pm

Re: Php shoutcast auslesen STREAMTITEL

also das script aus post1 ist von dir...
aber diese variablen "$shoutcast_streamtitle und $shoutcast_servertitle" - wo stehen die denn?

so wie ich das sehe, stehen alle verwendbaren informationen im array $numbers
mach doch mal ein explode($numbers)

wenn du scripts in gewissen zeitabständen ausführen willst, informier dich zum thema cronjobs
falls dein anbieter keine unterstützt gibt es dazu auch externe dienstleister

zu deinem 2ten post
in welchem zusammenhang steht denn das script mit dem angegebenen link?

wenn du den text von der url laden willst, dann kannst du das mit

PHP Quellcode

1
$text = strip_tags(file_get_contents('http://88.198.7.243/dj/streamst.php'));


ist ja auch nur eine zeile...

4

Tuesday, November 7th 2006, 5:10pm

joar wie gesagt es gibt ne winamplin http://admin:pass:8000uswswsw=TITEL , das titel kann man durch verschienden sachen ersetzten wie zb http://admin:pass:8000uswswsw=playlist, oder http://admin:pass:8000uswswsw?=.

ich will das das script jede 2 mins den link öffnet, und den punkt setzt, was ja der link macht .

MFG
Pr3mu


//UND HIER GEHTS WEITER
http://www.easy-coding.de/script-soll-stream-oeffnen-hillfeee-t2114.html

nebelwelten

Unregistered

5

Tuesday, June 26th 2007, 12:00am

DJ bild anzeige

hi kann mir jemand einen script machen wo man denn DJ anzeigen kann also wer grad sendet bei uns im radio hat jeder seinen namen hinter den radio namen also wenn es möglich wer würde ich mich mega doll freunen ich such schon monate danach

LG Mario
:wink:

Social bookmarks