for those who have problems with the function 'fsockopen', this script (which uses the CURL library) should fix it. The script is part of the plugin "Shout-stream" (author: ..:: deuced:: .. http://deuced.net) for wordpress. Let me know if you work.
Script at work: http://www.djferik.it/example-stats-curl.php
- Code: Select all
<?php
/******* IP or Address (without http) ********/
$mm_ipstream = '123.123.123.123';
/******** Port *******/
$mm_portstream = '123456';
/******** Language options *******/
$mm_text_stat_0 = 'Stream is';
$mm_text_stat_1 = '@';
$mm_text_stat_2 = 'Listeners';
$mm_text_stat_3 = 'of';
$mm_text_stat_4 = 'Peak';
$mm_text_stat_5 = 'Stream Title';
$mm_text_stat_6 = 'Current Song';
$mm_text_stat_7 = 'Stream is currently';
$mm_text_stat_8 = 'UP';
$mm_text_stat_9 = 'DOWN';
$mm_text_stat_12 = 'Average Time';
$mm_text_stat_15 = 'Recent Songs';
$mm_heading = 'h6';
/******** start php CURL (DO NOT EDIT)*******/
$header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
$header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive: 300";
$header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
$header[] = "Accept-Language: en-us,en;q=0.5";
$header[] = "Pragma: "; // browsers keep this blank.
ini_set("display_errors","On");
ini_set("error_reporting",ini_get("error_reporting") & ~E_WARNING);
$CurlURL_stats = 'http://' . $mm_ipstream . ':' . $mm_portstream . '/index.html';
$canale1 = curl_init();
curl_setopt($canale1, CURLOPT_URL, $CurlURL_stats);
curl_setopt($canale1, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($canale1, CURLOPT_HTTPHEADER, $header);
curl_setopt($canale1, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($canale1, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($canale1, CURLOPT_AUTOREFERER, true);
curl_setopt($canale1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($canale1, CURLOPT_HEADER, false);
curl_setopt($canale1, CURLOPT_TIMEOUT, 5); //5 seconds
$CurlURL_history = 'http://' . $mm_ipstream . ':' . $mm_portstream . '/played.html';
$canale2 = curl_init();
curl_setopt($canale2, CURLOPT_URL, $CurlURL_history);
curl_setopt($canale2, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($canale2, CURLOPT_HTTPHEADER, $header);
curl_setopt($canale2, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($canale2, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($canale2, CURLOPT_AUTOREFERER, true);
curl_setopt($canale2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($canale2, CURLOPT_HEADER, false);
curl_setopt($canale2, CURLOPT_TIMEOUT, 5); //5 seconds
$mh = curl_multi_init();
curl_multi_add_handle($mh,$canale1);
curl_multi_add_handle($mh,$canale2);
$running = null;
do { curl_multi_exec($mh,$running); } while ($running > 0);
$mm_read_curl = curl_exec($canale1);
$mm_read_curl_history = curl_exec($canale2);
curl_multi_remove_handle($mh,$canale1);
curl_multi_remove_handle($mh,$canale2);
curl_multi_close($mh);
$search_and_Destroy = array('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\\/\\!]*?[^<>]*?>@si', // Strip out HTML tags
'@<style[^>]*?>.*?</style>@siU', // Strip style tags properly
'@<![\\s\\S]*?--[ \\t\\n\\r]*>@' // Strip multi-line comments including CDATA
);
$mm_Xplain = preg_replace($search_and_Destroy, '|', $mm_read_curl);
$mm_Xplain .= preg_replace($search_and_Destroy, '|', $mm_read_curl_history);
$mm_lessTop = explode('Current Stream Information', $mm_Xplain, 2);
$MMless_Bottom = explode('Nullsoft', $mm_lessTop[1]);
$mm_Page_Stats = $MMless_Bottom[0];
$mm_Page_History = $MMless_Bottom[1];
$mm_Page_Stats = preg_replace('/\s\s+/', '', $mm_Page_Stats);
$mm_Page_History = preg_replace('/\s\s+/', '', $mm_Page_History);
$mm_curl = explode('|||||', $mm_Page_Stats, 12);
$mm_song = explode('Current Song:', $mm_curl[11], 2);
$mm_song = $mm_song[1];
$MMsongname = explode('|||||', $mm_song);
$MMkbps = preg_replace ( '/[^0-9]/', ' ', $mm_curl[4] );
$mm_kbps = explode(' ', $MMkbps, 46);
$MMlessTop_history = explode('Current Song', $mm_Page_History, 2);
$MMlessBottom_history = explode('Nullsoft', $MMlessTop_history[1], 2);
$MMless_history = $MMlessBottom_history[0];
$MMcurl_history = explode('||', $MMless_history);
$MMcurl_history = preg_replace('/\|/', '', $MMcurl_history);
/******** end php CURL (DO NOT EDIT)*******/
/**** PAGINATION ****/
/** Server Status (UP/DOWN) **/
if ($mm_curl[2] == 'Server is currently down.') {
$state = $mm_text_stat_9;
echo '<li><strong><a href="http://' . $mm_ipstream . ':' . $mm_portstream . '/" target="_blank">' . $mm_text_stat_7 . ' ' . $state . '</a></strong></li>';
} else if ($mm_curl[2] == 'Server is currently up and public.' || $mm_curl[2] == 'Server is currently up and private.') {
$state = $mm_text_stat_8;
/** Server Info **/
echo '<li><strong><a href="http://' . $mm_ipstream . ':' . $mm_portstream . '/" target="_blank">' . $mm_text_stat_0 . ' ' . $state . '</a></strong> ' . $mm_text_stat_1 . ' <strong>' . $mm_kbps[16] . '</strong> kbps</li>';
/** Listeners **/
echo '<li>' . $mm_text_stat_2 . ': <strong>' . $mm_kbps[28] . '</strong> ' . $mm_text_stat_3 . ' <strong>' . $mm_kbps[32] . '</strong> (' . $mm_text_stat_4 . ': '.$mm_curl[6].')</li>';
/** Average Time **/
echo '<li>' . $mm_text_stat_12 . ': <strong>'.$mm_curl[8].'</strong></li>';
/** Stream Title **/
echo '<' . $mm_heading . ' style="padding: 10px;">' . $mm_text_stat_5 . '</' . $mm_heading . '>';
$nonengtitle = preg_replace ( '/[^a-zA-Z0-9]/', ' ', $mm_curl[10] );
echo '<li><strong>' . $nonengtitle . '</strong></li>';
/** Current Song **/
echo '<' . $mm_heading . ' style="padding: 10px;">' . $mm_text_stat_6 . '</' . $mm_heading . '>';
$nonengsong = preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMsongname[1] );
echo '<li><strong>' . $nonengsong . '</strong></li>';
/** Songs History **/
echo '<' . $mm_heading . ' style="padding: 10px;">' . $mm_text_stat_15 . '</' . $mm_heading . '>';
if ($MMcurl_history[2] != 0) {
echo '<li>' . $MMcurl_history[2] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[3] ) . '</li>';
}
if ($MMcurl_history[4] != 0) {
echo '<li>' . $MMcurl_history[4] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[5] ) . '</li>';
}
if ($MMcurl_history[6] != 0) {
echo '<li>' . $MMcurl_history[6] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[7] ) . '</li>';
}
if ($MMcurl_history[8] != 0) {
echo '<li>' . $MMcurl_history[8] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[9] ) . '</li>';
}
if ($MMcurl_history[10] != 0) {
echo '<li>' . $MMcurl_history[10] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[11] ) . '</li>';
}
if ($MMcurl_history[12] != 0) {
echo '<li>' . $MMcurl_history[12] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[13] ) . '</li>';
}
if ($MMcurl_history[14] != 0) {
echo '<li>' . $MMcurl_history[14] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[15] ) . '</li>';
}
if ($MMcurl_history[16] != 0) {
echo '<li>' . $MMcurl_history[16] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[17] ) . '</li>';
}
if ($MMcurl_history[18] != 0) {
echo '<li>' . $MMcurl_history[18] . ' : ' . preg_replace ( '/[^a-zA-Z0-9]/', ' ', $MMcurl_history[19] ) . '</li>';
}
} else {
echo '<li><font color="#CC0000"><strong>STREAM CONNECT TO ' . $mm_ipstream . ':' . $mm_portstream . ' FAILED !!!</strong></font></li>';
}
?>
Bye

