<?php
/**************************************************************************/
/* PHP-NUKE: Web Portal System                                            */
/* ===========================                                            */
/*                                                                        */
/* Copyright (c) 2001 by Francisco Burzi (fbc@mandrakesoft.com)           */
/* http://phpnuke.org                                                     */
/*                                                                        */
/* 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.         */
/*                                                                        */
/* Internet Radio Block/Module V3.0 by Rene Hart (webmaster@just4me.nl)   */
/* http://www.just4me.nl                                                  */
/* For PHP-Nuke                                                           */
/*                                                                        */
/*                                                                        */
/**************************************************************************/

// setplayer display width change this if it doesn't fit in your template
$radio_width = 150;

setcookie ("FloatCookie","RadioFloating",time() +3600*24);  

echo "<script language=\"JavaScript\">var exit=true;function xit(){if (exit)document.cookie=\"FloatCookie=RadioFloating;expires=Fri, 30-Nov-1999 00:00:00 GMT\";}</script><body leftmargin=\"0\" topmargin=\"0\" onunload=\"xit()\" onload=\"sizeonload();\">";

echo "
<script>

function sizeonload()
{
window.resizeTo(10,10);
w = (document.all)?document.body.scrollWidth:document.documentElement.offsetWidth;
h = (document.all)?document.body.scrollHeight:document.documentElement.offsetHeight;
window.resizeTo(w + 32, h + 32);
}
</script>
";


if (!eregi("modules.php", $PHP_SELF)) {
    die ("You can't access this file directly...");
}

require_once("mainfile.php");

global $prefix, $dbi, $user, $bgcolor, $radio, $Default_Theme, $theme, $cookie, $bgcolor1, $num;

$module_name = basename(dirname(__FILE__));

if (isset($currentlang)) {
        include("modules/$module_name/language/lang-$currentlang.php");
        $language = $currentlang;
} else {
    include("modules/$module_name/language/lang-$language.php");}

if(is_user($user)) {
	$user2 = base64_decode($user);
	$cookie = explode(":", $user2);
	if($cookie[9]=="") $cookie[9]=$Default_Theme;
	if(isset($theme)) $cookie[9]=$theme;
	if(!$file=@opendir("themes/$cookie[9]")) {
	    $ThemeSel = $Default_Theme;
	} else {
	    $ThemeSel = $cookie[9];
	}
    } else {
	$ThemeSel = $Default_Theme;
}

include("themes/$ThemeSel/theme.php");

echo "<LINK REL=\"StyleSheet\" HREF=\"themes/$ThemeSel/style/style.css\" TYPE=\"text/css\">\n\n\n";

// radio station selected from floating block
if(!$radio){
$radio = $_POST['select'];}

//radio station selection
if ($radio != 0){
$result = sql_query("SELECT radio_name, radio_stream, radio_url, radio_picture FROM ".$prefix."_internet_radio WHERE radio_id='$radio'", $dbi);
list($radio_name, $radio_stream, $radio_url, $radio_picture) = sql_fetch_row($result, $dbi);
$stream = $radio_stream;
if ($radio_url !="" AND $radio_url != "http://"){
$url = $radio_url;}
$stationname = $radio_name;
$radiostart = "true";}
else
{$stationname = ""._INRADNOC."";}

$result = sql_query("SELECT picture, picture_dir, defpicture, nopicture_name FROM ".$prefix."_internet_radio_settings", $dbi);
  list($picture, $picture_dir, $defpicture, $nopicture_name) = sql_fetch_row($result, $dbi);


// picture settings
$picture_name = $radio_picture;
if ($picture == 1 and ($picture_name =="" and $defpicture == 1))
 {$picture_name = $nopicture_name;}

// function to check for real player files
function check_real($t_url){

$temp_url = basename($t_url);
$temp_url = trim($temp_url);
$temp_url = strtolower($temp_url);
$check_ram = substr($temp_url, -3);
$check_rm = substr($temp_url, -2);

if ($check_rm == "rm"){
	return true;
	} elseif ($check_ram == "ram") {
			return true;
		} elseif ($check_rm == "ra") {
				return true;
			} elseif ($check_ram == "pls") {
				return true;
			  } elseif ($check_ram == "rpm") {
			 	return true;
					} else {
					return false;
					}
}

// content to display
if ($url !=""){
$content = "<center>"._INRADSEL.":<br> <a HREF=$url target=\"_blank\">$stationname</a><br><br>";
if ($picture == 1 and $picture_name != ""){
$content .= "<a href= $url target=\"_blank\"><img border=\"0\" src='$picture_dir/$picture_name'></a><br><br>";}
}
else {
$content = "<center>"._INRADSEL.":<br> $stationname</a><br><br>";
if ($picture == 1 and $picture_name != ""){
$content .= "<img border=\"0\" src='$picture_dir/$picture_name'></a><br><br>";}
}

if (check_real($stream) == true)

{$content .= "
<OBJECT	ID=player	CLASSID='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'
	HEIGHT=60 WIDTH='$radio_width'>
	<PARAM NAME='controls' VALUE='ControlPanel,StatusField'>
	<PARAM NAME='console' VALUE='Clip1'>
	<PARAM NAME='autostart' VALUE=$radiostart>
	<PARAM NAME='src' VALUE='$stream'>
	<EMBED SRC='$stream' type='audio/x-pn-realaudio-plugin' CONSOLE='Clip1' CONTROLS='ControlPanel,StatusField' 
HEIGHT=60 WIDTH=$radio_width AUTOSTART=$radiostart pluginspage='http://www.real.com/'></EMBED>
	</OBJECT>";
}

else

{$content .= "
<OBJECT ID='Player' HEIGHT='50' WIDTH='$radio_width' classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112' standby='Loading Microsoft® Windows® Media Player components...'      type='application/x-oleobject'>
	 <PARAM NAME='Filename' value='$stream'>
	 <PARAM NAME='ShowControls' VALUE='true'>
   <PARAM NAME='ShowStatusBar' VALUE='true'>
   <PARAM NAME='ShowPositionControls' value='False'>
   <PARAM NAME='ShowTracker' value='False'>
	<EMBED type='application/x-mplayer2'
	pluginspage = 'http://www.microsoft.com/Windows/MediaPlayer/'
	SRC='$stream'
	name='Player'
	width='$radio_width'
	height='60'
	AutoStart=$radiostart
	showcontrols='$ShowControls' showstatusbar='$ShowStatusBar' showdisplay='$ShowDisplay'>
	</EMBED>
	</OBJECT>";
}
if ($num != 1){
$content .= "<br><br><form name=\"form\" method=\"post\" action=\"modules.php?name=$module_name&file=popup\">";
$content .= "<select name=\"select\" onchange=\"form.submit()\">";
$content .= "<option>- "._INRADCHO." -</option>";
$result = sql_query("SELECT radio_id, radio_name FROM ".$prefix."_internet_radio WHERE radio_language='$language' OR radio_language='' ORDER BY radio_name ASC", $dbi);
while(list($radio_id, $radio_name) = sql_fetch_row($result, $dbi)) {
$content .= "<OPTION VALUE=\"$radio_id\">$radio_name</option>";}
$content .= "</select></form>";
}
else
{
$content .= "<br><br>";
}

$content .= "Copyright <a HREF=\"http://www.just4me.nl\" target=\"_blank\">Just4me.NL</a>
<br>";
$content .= "</center>";


$title = ereg_replace("_", " ", $module_name);
$headtitle = "<center>$title</a></center>";
echo "<title>$sitename</title>\n";
echo "<body bgcolor=$bgcolor1><center>";
echo "<br>";
themesidebox($headtitle,$content);
echo "</center>";

?>