<?php 
	echo'<!DOCTYPE html>
	<html><head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>'.$this->title.'</title>
	<meta name="description" content="'.$this->description.'" />
	<meta name="author" href="Dario430@yandex.ru" />
	<meta name="keywords" content="'.$this->keywords.'" />
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport" />
	<link rel="shortcut icon" href="http://'.$_SERVER['HTTP_HOST'].'/Content/Images/Favicon.ico" type="image/x-icon" />
	<script type="text/javascript" src="http://'.$_SERVER['HTTP_HOST'].'/Content/JavaScript/Jquery.js"></script>
	<script type="text/javascript" src="http://'.$_SERVER['HTTP_HOST'].'/Content/JavaScript/Default.js"></script>
	<link type="text/css" rel="StyleSheet" href="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/System.css" />
	<link type="text/css" rel="StyleSheet" href="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/Style.css" />';

	echo'<div class="logo"> 
		<table style="width:101%;margin:0px;text-align: center"><tr><td class="tl">
			<a href=javascript:document.location.reload()><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/1.png" height="35" width="35"></a> 
			<td><a href="http://'.$_SERVER['HTTP_HOST'].'"> <img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/logo.png" height="85" width="150"></a>'; 
		if (isset($user)) {	
                   echo'
                        <td><a href="http://'.$_SERVER['HTTP_HOST'].'/Users/'.$user['nick'].'"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/2.png" height="35" width="35"></a><br><td>'; } else {
		echo'
                        <td><a id="up"href="#"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/2.png" height="35" width="35"></a><br><td>';    }

echo'
                 </td></tr></table></div>
		<div id="hide2"><div class="pn">
			<table style="width:100%" cellspacing="0" cellpadding="0"><tr>
			<td><a href="/Login/Authorization.php"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/6.png" alt="*"></a></td>
			<td><a href="/Login/Registration.php"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/7.png" alt="*"></a></td>	
			<td><a href="/Login/Recovery.php"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/8.png" alt="*"></a></td>
				</tr></table></div></div>
		<div class="csgo"><input class="radiusleft" name="q" type="text" value="" maxlength="50"/> 
			<input type="submit" value="Найти" class="radiusright" /><br /><br />Поиск по сайту<br /></div> 
			<div class="rere"></div><div class="rek">
		<img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/r.png" alt="*"><a href="https://billing.lite-host.in/aff.php?aff=513">Надежный и дешевый хостинг сайтов!</a><br/>';
if ($_SERVER['PHP_SELF'] == '/index.php') {
$random = DB ::$dbs->query("SELECT * FROM billing_rekl WHERE gde = ? AND type = ? ORDER BY RAND() DESC",['index',1]); #Рандомный вывод
if($random->rowCount() >0){
while($r = $random->fetch()){
	echo '<img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/r.png" alt="*"><a href="http://'.$r['url'].'">'.$r['name'].'</a><br/>';
}
}
} elseif ($_SERVER['PHP_SELF'] != '/') {
$random = DB ::$dbs->query("SELECT * FROM billing_rekl WHERE gde = ? AND type = ? ORDER BY RAND() DESC",['all',1]);
if($random->rowCount() >0){
while($r = $random->fetch()){
	echo '<img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/r.png" alt="*"><a href="http://'.$r['url'].'">'.$r['name'].'</a><br/>';
}

}
}
		echo'<img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/r.png" alt="*"><a href="/">Купить рекламу</a><br/></div>';
       if (isset($user)) {
if ($user['level'] >= 1) {
$count_compl = DB::$dbs->querySingle("SELECT COUNT(id) FROM `complaint` WHERE `read` = ?", [1]);
if (!empty($count_compl)) {
$vs = $vs + $count_compl;
}
}
if ($user['level'] > 2) {
$count_pay = DB::$dbs->querySingle("SELECT COUNT(id) FROM `pay` WHERE `type` = ?", [3]);
if (!empty($count_pay)) {
$vs = $vs + $count_pay;
}
$count_out = DB::$dbs->querySingle("SELECT COUNT(id) FROM `billing_out` WHERE `type` = ?", [0]);
if (!empty($count_out)) {
$vs = $vs + $count_out;
}
}
if ($user['level']>1) {
$ticket = DB::$dbs->querySingle("SELECT COUNT(id) FROM support WHERE type = ?", [1]);
if (!empty($ticket)) {
$vs = $vs + $ticket;
}
}
if ($user['level']>1) {
$otzyv = DB::$dbs->querySingle("SELECT COUNT(id) FROM otzyvy WHERE activ = ?", [0]);
if (!empty($otzyv)) {
$vs = $vs + $otzyv;
}
$ked = DB::$dbs->querySingle("SELECT COUNT(id) FROM ked WHERE type = ?", [0]);
if (!empty($ked)) {
$vs = $vs + $ked;
}
}
if ($user['level'] > 2) {
$rekl = DB ::$dbs->querySingle("SELECT COUNT(id) FROM billing_rekl WHERE type = ?",[0]);
if (!empty($rekl)) {
$vs = $vs + $rekl;
}
$u = DB::$dbs->querySingle("SELECT COUNT(id) FROM users WHERE type_reg = ?", [1]);
if (!empty($u)) {
$vs = $vs + $u;
}
$count_files = DB::$dbs->querySingle("SELECT COUNT(id) FROM `downs` WHERE `mod` = ?", [1]);
if (!empty($count_files)) {
$vs = $vs + $count_files;
}
$codes = DB::$dbs -> query('SELECT `id` FROM `codes_code` WHERE `check` = "0"')  -> rowCount();
if (!empty($codes)) {
$vs = $vs + $codes;
}
}
$notice = DB::$dbs->querySingle("SELECT COUNT(id) FROM jurnal WHERE user_id = ? AND type = ?", [$user['id'],1]);
$count_letter = DB::$dbs->querySingle("SELECT COUNT(id) FROM `letters` WHERE `idwho` = ? AND `read` = ?", [$user['id'],0]);


			echo'<div class="pn"><table style="width:100%" cellspacing="0" cellpadding="0"><tr>
      <td><a href="/Pages/Umenu/"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/1.png" alt="*"></a></td>

      <td><a href="/Pages/Mail/"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/2.png" alt="*"></a></td><td>'; 
     if (!empty($count_letter)) { echo'<span class="countx">'.$count_letter.'</span>';}

      echo'<td><a href="/Pages/Notice/"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/3.png" alt="*"></a></td><td>';
     if (!empty($notice)) { echo'<span class="countx">'.$notice.'</span>';}
     echo'</td>
      <td><a href="/Pages/Bill/"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/bill.png" alt="*"></a></td><td></td>
      <td><a href="/Pages/Feed/"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/4.png" alt="*"></a></td><td></td>';
      if ($user['level'] > 0) { 
      echo '<td><a href="/Application"><img src="http://'.$_SERVER['HTTP_HOST'].'/Content/Themes/'.$style.'/images/icn/5.png" alt="*"></a></td><td>'.(!empty($vs) ? '<span class="countx">'.$vs.'</span>':NULL).'</td>';     } 			
					echo '</tr></table></div>';

}
      
if (!isset($user)) {echo'<div class="pn">Добро пожаловать, <b>Гость</b>!</br>
Пожалуйста, <a href="/Login/Registration.php">Зарегистрируйтесь</a> либо <a href="/Login/Authorization.php">Войдите</a>!
</div>';}

?>