<?php ob_start(ob_gzhandler); require_once(__DIR__ . DIRECTORY_SEPARATOR . "lang/lang.en.php");
if(file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'includes/config.php') && !isset($_GET['stp'])){
	
	require(__DIR__ . DIRECTORY_SEPARATOR . 'includes/config.php');	
	
	
	if($page=="signout"){		
		$z->cookie(user_cookie, "@", -(24*7));
		header("location: ".baseurl); exit;
	}
	
	if($page=="sitemap"){
		header("Content-Type: text/plain; charset=utf-8");
		echo baseurl."\n";
		echo baseurl."genres\n";
		echo baseurl."new-releases\n";
		echo baseurl."discover\n";
		$list = $z->select("SELECT slug FROM genres WHERE status=? ORDER BY title ASC", array("yes"), "s");
		if($list->result=="ok" && $list->count > 0){
			for($n = 0; $n < count($list->fetch); $n++):					
				echo baseurl.'genres/'.$list->fetch[$n]->slug."\n";
			endfor;		
		}
		$list = $z->select("SELECT slug FROM tracks WHERE status=? ORDER BY ID DESC", array("yes"), "s");
		if($list->result=="ok" && $list->count > 0){
			for($n = 0; $n < count($list->fetch); $n++):
				echo baseurl.'track/'.$list->fetch[$n]->slug."\n";
			endfor;		
		}
		exit;
	}
	
	if($z->getSetting("site_status")=="live" || $page=="admin" || $page=="account"){			
		//SITE IS LIVE
		if($z->getSetting("must_signin")=='yes' && $session->result!='ok' && $page!='admin' && $page!='account'){ $page = 'welcome'; }
		if($_SERVER['REQUEST_METHOD'] === 'POST'){
			include(__DIR__ . DIRECTORY_SEPARATOR . "pages/".$page.".php");
		}else{
			include(__DIR__ . DIRECTORY_SEPARATOR . "pages/header.php");
			include(__DIR__ . DIRECTORY_SEPARATOR . "pages/".$page.".php");
			include(__DIR__ . DIRECTORY_SEPARATOR . "pages/footer.php");	
		}		
		if(file_exists(__DIR__ . DIRECTORY_SEPARATOR . '__installer.php')){
			echo '<div class="errorNote fixed size14 fontn">Please remove `<span class="fontb">__installer.php</span>` from ROOT Directory.</div>';
		}		
	}else{
		//SITE IS DOWN
		include(__DIR__ . DIRECTORY_SEPARATOR . "pages/down.php");
	}
	
	/*echo "<!-- Start of LiveChat (www.livechatinc.com) code -->
	<script type=\"text/javascript\">window.__lc = window.__lc || {};window.__lc.license = 9923380;
	(function() {  var lc = document.createElement('script'); lc.type = 'text/javascript'; lc.async = true;
	lc.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'cdn.livechatinc.com/tracking.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(lc, s);})();</script>
	<!-- End of LiveChat code -->";*/
	
}else{
	if(file_exists(__DIR__ . DIRECTORY_SEPARATOR . '__installer.php')){
		include(__DIR__ . DIRECTORY_SEPARATOR . '__installer.php');
	}else{				
		echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
		<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#"  xmlns:fb="http://www.facebook.com/2008/fbml">
		<head>
			<meta name="robots" content="noindex" />
			<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
			<style>
				body{
					background: #f1f1f1;
					font-family: segoe ui, arial, tahoma, sans-serif;
					padding: 0px;
					margin: 0px;
				}
				.error_install_broken{
					background: #fff;
					margin: 0 auto;
					width: 600px;
					padding: 50px;
					box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.07);
					text-align: center;
					margin-top: 80px;
					font-size: 24px;
					border: 1px #ddd solid;
					border-radius: 3px;
					font-weight: lighter;
					border-top: 3px #be0000 solid;
				}
				.error_install_broken .zlogo{
					height: 120px;
					display: block;
					margin: 0 auto;
					margin-bottom: 20px;
				}
			</style>
			<title>'.$lang['ERROR_PAGE_TITLE'].'</title>	
		</head>
		<body>
			<div class="error_install_broken"><img src="https://zuz.host/ui/zuz-logo-public.png" class="zlogo bl">'.$lang['ERROR_INSTALLER_NOTFOND'].'</div>
		</body></html>';	
	}
}
ob_flush(); ?>