<?php
require_once INFUSIONS."sw_streamstatus1_panel/infusion_db.php";
require_once INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/sw_functions.php";

// Check if locale file is available matching the current site locale setting.
if (file_exists(INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/locale/".$settings['locale'].".php")) {
	// Load the locale file matching the current site locale setting.
	include INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/locale/".$settings['locale'].".php";
} else {
	// Load the infusion's default locale file.
	include INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/locale/English.php";
}

@include INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/listen/streamconfig.php";
@include INFUSIONS.str_replace('/infusions/','',$sp_url)."/infusion_db.php";

// Load default settings
$ssp_setting[$sw_streamstatus_number] = dbarray(dbquery("SELECT * FROM `".$streamstatus_db[$sw_streamstatus_number]['table_settings']."` WHERE `profile` = 'default' LIMIT 1"));

$sp_status_setting = dbarray(dbquery("SELECT * FROM `".DB_PREFIX."sendeplan".($ssp_setting[$sw_streamstatus_number]['sp_number']>0 ? $ssp_setting[$sw_streamstatus_number]['sp_number'] : "")."_settings` WHERE `profile` = 'default' LIMIT 1"));
echo "
	<style type=\"text/css\" media=\"screen\">
	.spshowtitle {
		font-family: ".$sp_status_setting['font_showtitle'].";
		font-size: ".$sp_status_setting['fontsize_showtitle']."px;
		font-weight: ".($sp_status_setting['bold_showtitle']==true ? "bold" : "normal").";
	}
	.spshowdescription {
		font-family: ".$sp_status_setting['font_showdescription'].";
		font-size: ".$sp_status_setting['fontsize_showdescription']."px;
		font-weight: ".($sp_status_setting['bold_showdescription']==true ? "bold" : "normal").";
	}
	</style>
	";

opentable(($sp_channelname != '' ? $sp_channelname." - Status" : "Streamstatus"));
echo "\n<table width='100%' border='0' align='center' cellpadding='5' cellspacing='0'>\n<tr>\n<td align='center' valign='top'><tr><td>\n";

echo '<script type="text/javascript" src="https://www.systemweb.de/supportfiles/sendeplan_v3/sp_tooltip.js"></script>';
					
echo "
	<table width='100%' cellspacing='0' cellpadding='3' border='0'>
		<tr>
			<td style='font-size: 12px; font-weight: normal;' align='center'>
			<div style='height: auto; width: auto; min-height: 140px;'>
			<script type='text/javascript'>
				function loadSP".$sp_id."Data() {
					var xmlHttp = false;
					try {
						xmlHttp  = new ActiveXObject(\"Msxml2.XMLHTTP\");
					} catch(e) {
						try {
							xmlHttp  = new ActiveXObject(\"Microsoft.XMLHTTP\");
						} catch(e) {
							xmlHttp  = false;
						}
					}
					if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
						xmlHttp = new XMLHttpRequest();
					}

					if (xmlHttp) {
						xmlHttp.open('GET', '".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/sp_info.php".(iSUPERADMIN || checkgroup($sp_status_setting['dj_admingroup']) || checkgroup($sp_status_setting['dj_group']) ? "?toolbox=yes" : "")."', true);
						xmlHttp.onreadystatechange = function () {
							if (xmlHttp.readyState == 4) {
								document.getElementById(\"sp".$sp_id."_info\").innerHTML = xmlHttp.responseText;
							}
						};
						xmlHttp.send(null);
					}
				}
			</script>
			<span id='sp".($ssp_setting[$sw_streamstatus_number]['sp_number'])."_info' style='font-size: 12px; font-family: verdana, arial; font-weight: normal;'>
				<em>Sendeplan-Daten werden geladen. Bitte warten...</em>
			</span>
			<script type='text/javascript'>
				loadSP".($ssp_setting[$sw_streamstatus_number]['sp_number'])."Data();
				setInterval('loadSP".($ssp_setting[$sw_streamstatus_number]['sp_number'])."Data()',30000);
			</script>
			</div>
			";
									
echo "</td>									
		</tr>		
		<tr>
			<td valign='top' style='font-size: 14px;' align='center'>
				<div style='height: auto; width: auto; min-height: 60px; overflow: hidden;'>
					<script type='text/javascript'>;					
						function loadSC".$sp_id."Data() {
							var xmlHttp = false;
							try {
								xmlHttp  = new ActiveXObject(\"Msxml2.XMLHTTP\");
							} catch(e) {
								try {
									xmlHttp  = new ActiveXObject(\"Microsoft.XMLHTTP\");
								} catch(e) {
									xmlHttp  = false;
								}
							}
							if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
								xmlHttp = new XMLHttpRequest();
							}

							if (xmlHttp) {
								xmlHttp.open('GET', '".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/streaminfo.php";
								if(iSUPERADMIN || $ssp_setting[$sw_streamstatus_number]['listeners_visible']=='guest' || 
								(iADMIN && $ssp_setting[$sw_streamstatus_number]['listeners_visible']!='superadmin') || 
								(IsNum($ssp_setting[$sw_streamstatus_number]['listeners_visible']) && $ssp_setting[$sw_streamstatus_number]['listeners_visible']>0 && checkgroup($ssp_setting[$sw_streamstatus_number]['listeners_visible'])) ||
								($ssp_setting[$sw_streamstatus_number]['listeners_visible']=='member' && iMEMBER)) {
									echo "?hoerer=1";
								}
								echo "', true);
								xmlHttp.onreadystatechange = function () {
									if (xmlHttp.readyState == 4) {
										document.getElementById(\"sc".$sp_id."_info\").innerHTML = xmlHttp.responseText;
									}
								};
								xmlHttp.send(null);
							}
						}
					</script>
					<small>Aktueller Titel:</small><br />
					<span id='sc".($ssp_setting[$sw_streamstatus_number]['sp_number'])."_info' style='padding: 0px; font-size: 12px; font-family: verdana, arial; font-weight: normal;'>
						<em>Checke Streamstatus...</em>
					</span>
					<script type='text/javascript'>
						loadSC".($ssp_setting[$sw_streamstatus_number]['sp_number'])."Data();
						setInterval('loadSC".($ssp_setting[$sw_streamstatus_number]['sp_number'])."Data()',".$ssp_setting[$sw_streamstatus_number]['refresh_time'].");
					</script>
					
				</div>
				
			</td>
		</tr>
	</table>
";
							
				

//	}				
echo "\n</td>\n";


echo "\n<td align='center' valign='top' width='220' style='padding: 0px;'>\n";

// Playerlinks anzeigen 
	for($i=1;$i<=3;$i++) {
		if(
		IsSet($ssp_setting[$sw_streamstatus_number]['sc_server_'.$i]) && $ssp_setting[$sw_streamstatus_number]['sc_server_'.$i]!='' && 
		IsSet($ssp_setting[$sw_streamstatus_number]['sc_port_'.$i]) && $ssp_setting[$sw_streamstatus_number]['sc_port_'.$i]>0) {
			if(IsSet($ssp_setting[$sw_streamstatus_number]['sc_name_'.$i]) && $ssp_setting[$sw_streamstatus_number]['sc_name_'.$i]!='') {
				echo "<div align='center' style='border: 0px none; text-align: center;padding-bottom: 8px;'><strong>".$ssp_setting[$sw_streamstatus_number]['sc_name_'.$i].":</strong>";
			}
			else {
				echo "<div align='center' style='border: 0px none; text-align: center;' align='center'><strong>Stream #".$i."</strong><br />";
			}
			echo "
				<table align='center' border='0' cellspacing='3' cellpadding='3' style='border: 0px none;'>
					<tr>
						";
						if($ssp_setting[$sw_streamstatus_number]['use_winamp_'.$i]==1) { 
							echo "<td>
								<a href='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/player.php?id=".$i."&amp;player=winamp' target='_blank' title='Winamp-Player starten'>
									<img src='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/images/logo_wa.png' border='0' alt='Winamp' />
								</a>
							</td>
							";
						}
						if($ssp_setting[$sw_streamstatus_number]['use_mediaplayer_'.$i]==1) { 
							echo "<td>
								<a href='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/player.php?id=".$i."&amp;player=mediaplayer' target='_blank' title='Media-Player starten'>
									<img src='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/images/logo_mp.png' border='0' alt='Winamp' />
								</a>
							</td>
							";
						}
						if($ssp_setting[$sw_streamstatus_number]['use_realplayer_'.$i]==1) { 
							echo "<td>
								<a href='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/player.php?id=".$i."&amp;player=realplayer' target='_blank' title='Real-Player starten'>
									<img src='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/images/logo_rp.png' border='0' alt='Winamp' />
								</a>
							</td>
							";
						}
						if($ssp_setting[$sw_streamstatus_number]['use_flashplayer_'.$i]!="") { 
							echo "<td>
								";
									if($ssp_setting[$sw_streamstatus_number]['use_flashplayer_'.$i.'_popup']=='0') {
										echo "<a href='http://".$ssp_setting[$sw_streamstatus_number]['use_flashplayer_'.$i]."' target='_blank' title='Flash-Player starten'>";
									}
									else {
										echo "<a href='javascript:;' onclick='popup=window.open(\"http://".$ssp_setting[$sw_streamstatus_number]['use_flashplayer_'.$i]."\",\"Flashplayer".$i."\",\"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=".$ssp_setting[$sw_streamstatus_number]['use_flashplayer_'.$i.'_popup_width'].",height=".$ssp_setting[$sw_streamstatus_number]['use_flashplayer_'.$i.'_popup_height'].",left=50,top=50\"); return false;' title='Flashplayer' target='_blank'>";
									}
								echo"
									<img src='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/images/logo_flash.png' border='0' alt='Flash-Player' />
								</a>
							</td>
							";
						}
						if($ssp_setting[$sw_streamstatus_number]['use_javaplayer_'.$i]!="") { 
							echo "<td>
								";
									if($ssp_setting[$sw_streamstatus_number]['use_javaplayer_'.$i.'_popup']=='0') {
										echo "<a href='http://".$ssp_setting[$sw_streamstatus_number]['use_javaplayer_'.$i]."' target='_blank' title='Javascript-Player starten'>";
									}
									else {
										echo "<a href='javascript:;' onclick='popup=window.open(\"http://".$ssp_setting[$sw_streamstatus_number]['use_javaplayer_'.$i]."\",\"JavascriptPlayer".$i."\",\"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=".$ssp_setting[$sw_streamstatus_number]['use_javaplayer_'.$i.'_popup_width'].",height=".$ssp_setting[$sw_streamstatus_number]['use_javaplayer_'.$i.'_popup_height'].",left=50,top=50\"); return false;' title='Javascript-Player' target='_blank'>";
									}
								echo"
									<img src='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/images/logo_js.png' border='0' alt='Javascript-Player' />
								</a>
							</td>
							";
						}
						if($ssp_setting[$sw_streamstatus_number]['use_nsvplayer_'.$i]!="") { 
							echo "<td>
								";
									if($ssp_setting[$sw_streamstatus_number]['use_nsvplayer_'.$i.'_popup']=='0') {
										echo "<a href='http://".$ssp_setting[$sw_streamstatus_number]['use_nsvplayer_'.$i]."' target='_blank' title='Video-Player starten'>";
									}
									else {
										echo "<a href='javascript:;' onclick='popup=window.open(\"http://".$ssp_setting[$sw_streamstatus_number]['use_nsvplayer_'.$i]."\",\"VideoPlayer".$i."\",\"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=".$ssp_setting[$sw_streamstatus_number]['use_nsvplayer_'.$i.'_popup_width'].",height=".$ssp_setting[$sw_streamstatus_number]['use_nsvplayer_'.$i.'_popup_height'].",left=50,top=50\"); return false;' title='Video-Player' target='_blank'>";
									}
								echo"
									<img src='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/images/logo_nsv.png' border='0' alt='Video-Player' />
								</a>
							</td>
							";
						}
						if($i==1 && $ssp_setting[$sw_streamstatus_number]['phonostar_id']>0) { 
							echo "<td>
								<a href='http://www.phonostar.de/listen.php?id=".$ssp_setting[$sw_streamstatus_number]['phonostar_id']."' target='_blank' title='Phonostar-Player starten'>
									<img src='".INFUSIONS."sw_streamstatus".$sw_streamstatus_number."_panel/images/phonostar_button30.gif' border='0' alt='Winamp' />
								</a>
							</td>
							";
						}

					echo "
					</tr>
				</table>\n";			
		}

	}
	if($ssp_setting[$sw_streamstatus_number]['phonepublisher_live']!="") {
		echo "</div>\n<div align='center'><span style='border: 0px none; text-align: center;padding-top: 8px;'><strong>*Telefonstream:</strong></span><br />\n";
		echo "".$ssp_setting[$sw_streamstatus_number]['phonepublisher_live']."
		<span style='font-size: 9px;'><br />*&uuml;bliche Anrufkosten ins deutsche Festnetz</span>";
	}
	echo "
	</div>

";
// Ende Playerlinks

echo "\n</td>\n</tr></table>\n<div align='right'><a href='https://www.systemweb.de/' target='_blank' title='Streamstatus v2.2 by Systemweb' style='text-decoration: none; font-size: 11px;'><small>&copy;</small></a></div>";

closetable();
?>
