<?php
header("Expires: Sat, 05 Nov 2005 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

require_once "../../maincore.php";
require_once "infusion_db.php";

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

// Load studiobox settings
$sb_setting = @dbarray(dbquery("SELECT `default_sp`,`guests_allowed`,`infotext` FROM `".$sb_db['table_settings']."` WHERE `profile` = 'default' LIMIT 1"));

// convert current timestamp using global offset settings
$timestamp = (time() + (3600*$settings['timeoffset']));
if(IsSet($settings['serveroffset'])) { $timestamp += (3600*$settings['serveroffset']); }

// IMPORTANT: generate dateformat in gmt for db tables (without MESZ changes!)
$requestday = gmmktime(12,0,0,date("m",$timestamp),date("d",$timestamp),date("Y",$timestamp));

// Load scheduler settings
$sp_setting = @dbarray(dbquery("SELECT * FROM `".DB_PREFIX."sendeplan".($sb_setting['default_sp']>0 ? $sb_setting['default_sp'] : '')."_settings` WHERE `profile` = 'default' LIMIT 1"));

// Wer ist aktueller DJ ?
$result = dbquery("SELECT `".date("G",$timestamp)."` FROM `".DB_PREFIX."sendeplan".($sb_setting['default_sp']>0 ? $sb_setting['default_sp'] : '')."` WHERE `day` = ".$requestday);
$rows = dbrows($result);
if ($rows != 0) {
	$entry = dbarray($result);
	if($entry[date("G",$timestamp)]!="") {
		$dj_current_id = explode(".",$entry[date("G",$timestamp)]);
	}
	else { $dj_current_id[0] = 0; }
}
else { $dj_current_id[0] = 0; }

if(!checkgroup($sp_setting['dj_group']) && !checkgroup($sp_setting['dj_admingroup']) && !iSUPERADMIN) die($sb_locale['resctricted_access']);
/*
echo "	<script type='text/javascript'>\n";
echo "	function changeTitle() {
			window.document.title=\"".$sb_locale['studiobox_name']." (".dbcount('(*)',$sb_db['table_posts'])." ".$sb_locale['new'].")\";
		}\n";
//echo "		changeTitle();\n";
//echo "		setTimeout(\"changeTitle()\",15000);\n";
//echo "		window.document.title=\"".$sb_locale['studiobox_name']." (".dbcount('(*)',$sb_db['table_posts'])." ".$sb_locale['new'].")\";";
echo "	</script>\n";*/
echo $sb_locale['studiobox_name']." (".dbcount('(*)',$sb_db['table_posts'])." ".$sb_locale['new'].")";
?>
