cyberlooser |
06-01-2010 06:30 AM |
Quote:
Originally Posted by Zachariah
(Post 2046210)
Almost done with a VBA block.
|
hi Zachariah,
how?
that's your code for the position for the module:
PHP Code:
// Connect to the server switch ($placecast) { case 2 : $placecast = 'forumhome_above_forums'; break; case 3 : $placecast = 'forumhome_below_forums'; break; case 4 : $placecast = 'forumhome_wgo_pos1'; break; case 5 : $placecast = 'forumhome_wgo_pos2'; break; case 6 : $placecast = 'forumhome_wgo_pos3'; break; case 7 : $placecast = 'forumhome_wgo_pos4'; break; case 8 : $placecast = 'forumhome_wgo_pos5'; break; case 9 : $placecast = '9'; break; default : $placecast = 'forumhome_wgo_pos2'; }
there is no option for the VGA Block :(
can't find the option 2 select where i want 2 located this Modul.
so i modified your scast.php file a little bit.
in this way it is posible to install as a Modules.
here is the code:
this code should be cleaned up...i'll do this later. while some variables doesn't in use but i forgotten which one was it :D
PHP Code:
<?php /* -----------------05/28/2010----------------- This is a Nice hack to add Shoutcast VBA block Modules on your VB4 Forum Home. Hope it helps !!!
Original by Zachariah
modified by cyberlooser/h?r
HowTo Install
Install first the Shoutcast Status 3 (VB4) !
1. save this PHP file with this code as radio.php in your ../forum / modules folder :
2.Create a new PHP module with the following values: Module Title = "Radio" File To Include = radio.php Identifier = radio
playlist link is implemented the playlist link for the players like QT / RP and MediaPlayer need to be reaktivated in this Module
======================================================= Tested On:
vBulletin 4.0 SHOUTcast Server v1.9.5
======================================================= */
$scgroups = explode(',', $vbulletin->options['scgrp_full']);
//if (is_member_of($vbulletin->userinfo, $scgroups) OR $scgroups[0] == 0) { // ##### VBOPTION SETTINGS $scdef = $vbulletin->options['scname_full']; $scip = $vbulletin->options['scip_full']; $scport = $vbulletin->options['scport_full']; $scpass = $vbulletin->options['scpass_full']; $file = $vbulletin->options['scxml_full']; $cache_tolerance = $vbulletin->options['scupdate_full']; $placecast = $vbulletin->options['scplace_full']; $scoff = $vbulletin->options['scoff_full']; // ##### VBOPTION SETTINGS END
$pfad = './images/misc/';
// Check if Cache File needs updated or not if (!is_writable($file)) { @ chmod($folderstring, 0777); } // Check if Cache needs an update if (file_exists($file)) { clearstatcache(); // filemtime info gets cached so we must ensure that the cache is empty $time_difference = time() - filemtime($file); // echo "$file was last modified: " . date ("F d Y H:i:s.", filemtime($file)) . "( " . $time_difference . " seconds ago) <br>" . "The cache is set to update every " . $cache_tolerance . " seconds.<br>"; } else { $time_difference = $cache_tolerance; // force update }
// Parses shoutcasts xml to make an effective stats thing for any website $scfp = @ fsockopen($scip, $scport, $errno, $errstr, 2);
// If server is off line if (!$scfp) { if ($scoff == 1) {
echo" <html>
<head> <title>$scdef</title> </head>
<body > <table width=100%> <tr> <td> <img border=0 src=$pfad/shoutcast_off.gif alt=''> <br><b>$scdef ist derzeit leider</b></br> <img src= $pfad/offline.gif /> </td> <tr><td colspan=2>Sorry, but at moment the radio is offline. </td></tr> </tr> </table> </body> </html> "; } } else { // ############ Shoutcast server is online ####################### if ($time_difference >= $cache_tolerance) { // update the cache if need be // Get XML feed from server if ($scsuccs != 1) { if ($scpass) { fputs($scfp, "GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n"); } else { fputs($scfp, "GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); } while (!feof($scfp)) { $xmlfeed .= fgets($scfp, 8192); } fclose($scfp); } // Output to cache file $tmpfile = fopen($file, "w+"); $fp = fwrite($tmpfile, $xmlfeed); fclose($tmpfile); flush(); // 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); } } } if ($scpass) { // ######### There is a Admin password ############### //define xml elements $loop = array("AVERAGETIME", "CURRENTLISTENERS", "PEAKLISTENERS", "MAXLISTENERS", "SERVERGENRE", "SERVERURL", "SERVERTITLE", "SONGTITLE", "SONGURL", "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++; } //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 = ""; $hours = intval(intval($averagetime) / 3600); $averagemin .= ($padHours) ? str_pad($hours, 2, "0", STR_PAD_LEFT) : $hours . 'h '; $minutes = intval(($averagetime / 60) % 60); $averagemin .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . 'm '; $seconds = intval($averagetime % 60) . 's'; $averagemin .= str_pad($seconds, 2, "0", STR_PAD_LEFT); } else { // ######### There is no Admin password ############### //define all the variables to get (delte any ones you don't want) $page = ereg_replace(".*<body>", "", $page); //extract data $page = ereg_replace("</body>.*", ",", $page); //extract data $numbers = explode(",", $page); //extract data $currentlisteners = $numbers[0]; $streamstatus = $numbers[1]; $peaklisteners = $numbers[2]; $maxlisteners = $numbers[3]; $currentlisteners = $numbers[4]; $bitrate = $numbers[5]; $song[0] = $numbers[6]; }
// ######### Create links and media player pages ######## // ###################################################### $listenamp = 'http://' . $scip . ':' . $scport . '/listen.pls'; $listenlnk = 'http://' . $scip . ':' . $scport . '/listen.pls';
// Player template requests
// Server is online display stats if ($scfp) { if ($streamstatus == "1") { echo "
<html>
<head> <title>$scdef</title> </head>
<body> <table width=100%> <tr> <td><img src=$pfad/radio.gif align=middle></td> </tr> <tr> <td> <a href=$listenamp><b>$scdef <br> Server is </b></a> <a href=$listenamp></a> </td> </tr> <tr> <td colspan=2 ><marquee width=98% scrolldelay=100 scrollamount=5> <img src=$pfad/radio.gif align=middle> <b>$song[0] @ $scdef</b> <img src=$pfad/im_genre.gif align=middle></marquee><br></td> </tr> <tr> <td><marquee width=98% scrolldelay=100 scrollamount=5><b>DJ: $servertitle </b> </marquee></td> </tr> <tr> <td><marquee width=98% scrolldelay=100 scrollamount=5> <b>Current Listeners $currentlisteners / $maxlisteners </b> <b>Bitrate @ $bitrate kbps </b> </marquee> </td> </tr> </table> <table width=100%> <tr> <td><center><a href=$listenamp><img src=$pfad/im_qt.gif align=middle> </a></center></td> <td><center><a href=$listenamp><img src=$pfad/im_real.gif align=middle> </a></center></td> <td><center><a href=$listenamp><img src=$pfad/im_winamp.gif align=middle> </a> </center> </td> <td><center><a href=$listenamp><img src=$pfad/im_winmp.gif align=middle> </a></center></td> </tr> </table> </body> </html>";
} //if ($scoff == 1) else { echo" <html>
<head> <title>$scdef</title> </head>
<body > <table width=100%> <tr> <td> <img border=0 src=$pfad/shoutcast_off.gif alt=''> <br><b>$scdef ist derzeit leider</b></br> <img src= $pfad/offline.gif /> </td> <tr><td colspan=2>Sorry, but at moment the radio is offline</td></tr> </tr> </table> </body> </html>"; } } //} ?>
feel free in use and modify how u like...
|