<?


//Проверка на бан
if(isset($u['id']) && empty($page_page)){
   if(ban($u['id'])) header ("Location: page.php?id=".$u['id']."");
}

if($u['setting_theme']){
   $theme = 'themes/'.$u['setting_theme'].'/';
   //Если является директорией 
   if(!is_dir($theme)){
   $theme = 'themes/default/';
   }
} else {
$theme = 'themes/default/';
}

echo '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru">
<head>
<meta http-equiv="Content-Type" content="application/vnd.wap.xhtml+xml; charset=utf-8"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<title>'.$title.'</title>
<link rel="stylesheet" href="'.$theme.'/bootstrap.css" type="text/css"/>
<link rel="stylesheet" href="'.$theme.'/style.css" type="text/css"/>
<title>'.$title.'</title>
</head>
<body>';

//######################### Верхушка #########################


//------------------------ Авторизованным ------------------------
echo "<style type='text/css'>
#navi{color:#$u[panel_color_line];font-size:small;padding:4px 0px 5px 0px;background-color:#$u[panel_color_fon];}
#navi a:link,#navi a:visited{color:#$u[panel_color_link];text-decoration:none;font-size:small}
#navi a:focus,#navi a:hover,#navi a:active{color:#$u[panel_color_focus_link];background-color:#$u[panel_color_focus_fon];}
#logo_panel {
    padding: 7px 10px;
    border-top: 1px solid rgb(153, 153, 153);
    background: none repeat scroll 0% 0% rgb(245, 245, 245);
}
#time {
    background-color: rgb(204, 204, 204);
    color: rgb(0, 0, 0);
    font: 14px Tahoma, Arial, Verdana;
    text-align: right;
    border-left: 1px solid rgb(153, 153, 153);
        border-left-width-value: 1px;
        border-left-style-value: solid;
        border-left-color-value: rgb(153, 153, 153);
        border-left-width-ltr-source: physical;
        border-left-width-rtl-source: physical;
        border-left-style-ltr-source: physical;
        border-left-style-rtl-source: physical;
        border-left-color-ltr-source: physical;
        border-left-color-rtl-source: physical;
    border-right: 1px solid rgb(153, 153, 153);
        border-right-width-value: 1px;
        border-right-style-value: solid;
        border-right-color-value: rgb(153, 153, 153);
        border-right-width-ltr-source: physical;
        border-right-width-rtl-source: physical;
        border-right-style-ltr-source: physical;
        border-right-style-rtl-source: physical;
        border-right-color-ltr-source: physical;
        border-right-color-rtl-source: physical;
    padding: 0px 10px 0px 0px;
        padding-top: 0px;
        padding-right-value: 10px;
        padding-bottom: 0px;
        padding-left-value: 0px;
        padding-left-ltr-source: physical;
        padding-left-rtl-source: physical;
        padding-right-ltr-source: physical;
        padding-right-rtl-source: physical;
}

</style>";
if($u[id]){
$lenta = mysql_result(mysql_query("SELECT COUNT(*) FROM `lenta` WHERE `user` = '".$u['id']."' and `new` = '1'"), 0);
$jn = mysql_result(mysql_query("SELECT COUNT(*) FROM `jurnal` WHERE `user` = '".$u['id']."' and `new` = '1'"), 0);
$mn = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_messages` WHERE `user` = '".$u['id']."' and `inuser` = '".$u['id']."' and `new` = '1'"), 0);
echo '<div id="logo_panel">';
if($u['admin']==0){
if($u['sex']==zh)$pol='http://new-i09.spaces.ru/woman_on.gif';
if($u['sex']==m)$pol='http://new-i09.spaces.ru/man_on.gif';
}
if($u['admin']==1){
if($u['sex']==zh)$pol='http://new-i09.spaces.ru//admin_woman_on.gif';
if($u['sex']==m)$pol='http://new-i09.spaces.ru//admin_man_on.gif';
}
if($u['admin']==2){
if($u['sex']==zh)$pol='http://new-i09.spaces.ru//mod_woman_on.gif';
if($u['sex']==m)$pol='http://new-i09.spaces.ru//mod_man_on.gif';
}

echo "<a href='index.php'><img src='/img/logo.png' alt='ViSiTi.Ru' title='ViSiTi.Ru' /></a>";
echo '<qq class="right top_user_links service_links_block" style="margin-top:4px;"><img src="'.$pol.'" alt="Я" title="Я" /><a href="page.php"><font color="purple"> '.$u[login].' </font></a>'; 

if ($_SERVER['PHP_SELF']=='/index.php'){
echo '<font color =""> | </font> <a href="aut.php?out=1"> Выход </a></span>';
}
echo '</div>';     
echo '</div>';     
echo '</div>';     
echo '<div id="navi">';
echo "<table style='width:100%' cellspacing='0' cellpadding='0'><tbody><tr>";
echo "<td style='vertical-align:top;width:20%;border-right:solid;border-width:1px'><a style='text-align:center;display:block;padding:3px' href='/start.php'>".($u['panel']==0?"<img src='/img/home.png' title='$u[login]' />":null)."".($u['panel']==1?"С":null)."".($u['panel']==2?"Старт":null)."</a></td>";
echo "<td style='vertical-align:top;width:20%;border-right:solid;border-width:1px'>".($mn!=0?"<a style='text-align:center;display:block;padding:3px' href='/mail.php'>".($u['panel']==0?"<img src='/img/mail.png' alt='Почта' title='Почта' />":null)."".($u['panel']==1?"П":null)."".($u['panel']==2?"Почта":null)." <span style='color:#$u[panel_color_new]'><b>$mn</b></span></a>":"<a style='text-align:center;display:block;padding:3px' href='/mail.php'>".($u['panel']==0?"<img src='/img/mail.png' alt='Почта' title='Почта' />":null)."".($u['panel']==1?"П":null)."".($u['panel']==2?"Почта":null)."</a>")."</td>";
echo "<td style='vertical-align:top;width:20%;border-right:solid;border-width:1px'><a style='text-align:center;display:block;padding:3px' href='/jurnal.php'>".($u['panel']==0?"<img src='/img/journal.png' alt='Журнал' title='Журнал' />":null)."".($u['panel']==1?"Ж":null)."".($u['panel']==2?"Журнал":null)."".($jn>0?" <span style='color:#$u[panel_color_new]'><b>$jn</b></span>":null)."</a></td>";
echo "<td style='vertical-align:top;width:20%;border-right:solid;border-width:1px'><a style='text-align:center;display:block;padding:3px' href='/lenta.php'>".($u['panel']==0?"<img src='img/qlt_lenta2_b.png' alt='Лента' title='Лента' />":null)."".($u['panel']==1?"Л":null)."".($u['panel']==2?"Лента":null)."".($lenta>0?" <span style='color:#$u[panel_color_new]'><b>$lenta</b></font>":null)."</a></span></td>";
echo "<td style='vertical-align:top;width:20%;border-right:solid;border-width:0px'><a style='text-align:center;display:block;padding:3px' href='/search.php'>".($u['panel']==0?"<img src='http://new-i09.spaces.ru/qlt_search_b.png' alt='Поиск' title='Поиск' />":null)."".($u['panel']==1?"Ж":null)."".($u['panel']==2?"Поиск":null)."</a></td>";
echo "</tr></tbody></table>";
echo "</div>";
echo "</div></div>";

if ($u['set_times']==1)
{
echo "<div id='time'>\n";
echo "<span style='color:#$u[panel_color_time]'>".vremya(time())." </span>";
echo "</div>";
}
}
else
{







}
















//echo '<div class="rek"> <a href="">У нас нет рекламы!!!</a><br/> </div>';

if($u['id']){

//Дуэли ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
$duels_end = mysql_result(mysql_query("SELECT COUNT(*) FROM `duels_list` WHERE `time_end` < '".time()."'"), 0);
if($duels_end > 0){
$result = mysql_query("SELECT * FROM `duels_list` WHERE `time_end` < '".time()."'");
      while($duel = mysql_fetch_assoc($result)){
	  $count1 = mysql_result(mysql_query("SELECT COUNT(*) FROM `duels_votes` WHERE `vote` = '1' AND `duel` = '".$duel['id']."'"), 0);
	  $count2 = mysql_result(mysql_query("SELECT COUNT(*) FROM `duels_votes` WHERE `vote` = '2' AND `duel` = '".$duel['id']."'"), 0);
	  if($count1 == $count2) $victory = 0;
	  else if($count1>$count2) $victory = $duel['user1']; 
	       else $victory = $duel['user2'];
	  mysql_query("UPDATE `duels_list` SET `victory` = '$victory' WHERE `id` = '".$duel['id']."'");
	  }
}

//Обновления данных, онлайн, локация
mysql_query("UPDATE `users` SET `online` = '".time()."', `location` = '$location', `chat_location` = '$chat_location' WHERE `id` = '".$u['id']."'");

//Счет времени проведенного на сайте
if($u['online']){
$timeplus = time()-$u['online'];
if($timeplus < $system['online_time']){
mysql_query("UPDATE `users` SET `anketa_alltime` = '".($u['anketa_alltime'] + $timeplus)."' WHERE `id` = '".$u['id']."'");
} else {
mysql_query("UPDATE `users` SET `anketa_alltime` = '".($u['anketa_alltime'] + $system['online_time'])."' WHERE `id` = '".$u['id']."'");
}
}
$ratings = rand( -0.10, +0.10 );
//Рейтинг
if($u['rating_time'] != date("d")){
mysql_query("UPDATE `users` SET `act` = `act`+ $ratings WHERE `id` = '".$u['id']."'");
mysql_query("UPDATE `users` SET `rating_time` = '".date("d")."' WHERE `id` = '".$u['id']."'");
}


//Админам
if($u['admin'] ==1){
//Спамы
$count_spam = mysql_result(mysql_query("SELECT COUNT(*) FROM `spam`"), 0);
if($count_spam){
   echo '<div class = "user_menu">';
   if($count_spam) echo '<a href = "admin_panel.php?act=spam">Спам ('.$count_spam.')</a>';
   echo '</div>';
   }
}

} else {
echo '<div id="logo_panel">';

echo "<a href='index.php'><img src='/img/logo.png' alt='ViSiTi.Ru' title='ViSiTi.Ru' /></a>";
echo '<qq class="right top_user_links service_links_block" style="margin-top:10px;"><a href="aut.php">Войти</a> | <a href="reg.php">Регистрация</a></qq></div>';
echo '<div class="index";background-color: rgb(255, 255, 255);><a href="http://visiti.ru/help.php">Первый раз на ViSiTi.Ru?</a></div>';
}
?>