Well, I changed the plug-in code just to use the XML file written by Lynx.
Also, when I remove @fsockopen, It says It cannot connect to the IP specified on port 5555.
fsockopen should be blocked by a Firewall.
Here's the new code for the plugin.
PHP Code:
$scdef = $vbulletin->options['scname_full'];
$scip = $vbulletin->options['scip_full'];
$scport = $vbulletin->options['scport_full'];
$scpass = $vbulletin->options['scpass_full'];
$ircsite = $vbulletin->options['scirc_full'];
$file = $vbulletin->options['scxml_full'];
$cache_tolerance = $vbulletin->options['scupdate_full'];
// Check if Cache needs an update
if (file_exists($file)) {
clearstatcache();
$time_difference = time() - filemtime($file);
} else {
$time_difference = $cache_tolerance; // force update
}
// Outputs the cached file after new data
$xmlcache = fopen($file,"r");
$page = '';
if($xmlcache){
while (!feof($xmlcache)) {
$page .= fread($xmlcache, 8192);
}
fclose($xmlcache);
}
else{
// outputs the cached file
$xmlcache = fopen($file,"r");
$page = '';
if($xmlcache){
while (!feof($xmlcache)) {
$page .= fread($xmlcache, 8192);
}
fclose($xmlcache);
}
}
//define xml elements
$loop = array("AVERAGETIME", "CURRENTLISTENERS", "PEAKLISTENERS", "MAXLISTENERS", "SERVERGENRE", "SERVERURL", "SERVERTITLE", "SONGTITLE", "SONGURL", "IRC", "ICQ" ,"AIM", "WEBHITS", "STREAMHITS", "LISTEN", "STREAMSTATUS", "BITRATE", "CONTENT");
$y=0;
while($loop[$y]!=''){
$pageed = ereg_replace(".*<$loop[$y]>", "", $page);
$scphp = strtolower($loop[$y]);
$$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE)
$$scphp = urldecode($$scphp);
;
$y++;
}
//end intro xml elements
//get song info and history
$pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
$pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
$songatime = explode("<SONG>", $pageed);
$r=1;
while($songatime[$r]!=""){
$t=$r-1;
$playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]);
$playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]);
$song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]);
$song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]);
$song[$t] = urldecode($song[$t]);
$dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page);
$dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed);
$r++;
}
$averagemin = round($averagetime/60,2);
$irclink = 'irc://'.$ircsite.'/'.$irc.'';
$listenamp = 'http://'.$scip.':'.$scport.'/listen.pls';
$listenlnk = 'http://'.$scip.':'.$scport.'';
// Player template requests
if ($_REQUEST['do'] == 'mp'){ // MP popup link
eval('print_output("' . fetch_template('forumhome_shoutcast_mp') . '");');
}
if ($_REQUEST['do'] == 'rp'){ // RP popup link
eval('print_output("' . fetch_template('forumhome_shoutcast_rp') . '");');
}
if ($_REQUEST['do'] == 'qt'){ // QT popup link
eval('print_output("' . fetch_template('forumhome_shoutcast_qt') . '");');
}
//display stats
if($time_difference <= $cache_tolerance){
if($streamstatus == "1"){
$search_text = '<!-- end logged-in users -->';
$vbulletin->templatecache['FORUMHOME'] = str_replace($search_text,
$search_text.fetch_template('forumhome_shoutcast'),$vbulletin->templatecache['FORUMHOME']);
} else {
$search_text = '<!-- end logged-in users -->';
$vbulletin->templatecache['FORUMHOME'] = str_replace($search_text,
$search_text.fetch_template('forumhome_shoutcast_off'),$vbulletin->templatecache['FORUMHOME']);
}
}