<?
ob_start(); 
session_start();
include 'db.php';
include 'ip.php';
include 'class.php';

list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;

#error_reporting(0);

// Права доступа
if (empty($_SESSION['id'])) {
if (isset($_COOKIE['cusr_ps']) && isset($_COOKIE['cusr_id'])) {
$usr_id = $_COOKIE['cusr_id'];
$usr_ps = $_COOKIE['cusr_ps'];
$_SESSION['id'] = num($usr_id);
$_SESSION['pass'] = html($usr_ps);
}
}

$usr_id = isset($_SESSION['usr_id']) ? intval($_SESSION['usr_id']) : '';
$usr_ps = isset($_SESSION['usr_ps']) ? $_SESSION['usr_ps'] : '';

$id = abs(intval($_SESSION['id']));

$date = time();//Получаем дату
$t = time();//Получаем время
$dt = time();

if ( $id )
mysql_query("UPDATE `profile` SET `time` = ".(time() + 300)." WHERE `id` = '".$id."' LIMIT 1");//online

$user = mysql_fetch_assoc(mysql_query("SELECT * FROM `profile` WHERE `id` = '".$id."'"));
$config = mysql_fetch_assoc(mysql_query("SELECT * FROM `config`"));
if($user['theme'] == 0){ $icon = 'img';}

///////////Session User

function html($str)
{
return strtr(htmlspecialchars(stripcslashes($str),ENT_QUOTES,'UTF-8'), array('$'=>'$','%'=>'%','_'=>'_'));
}


function num($str)
{
return abs(intval($str));
}


$id_session = html($user['id']);
$login_session = html($user['login']);
$pass_session = html($user['pass']);
$name_session = html($user['name']);
$mail_session = html($user['mail']);
$sex_session = num($user['sex']);
$day_session = num($user['d']);
$month_session = num($user['m']);
$year_session = num($user['g']);
$opsos_session = html($user['psos']);
$info_session = html($user['info']);
$pass_session = html($user['pass']);
$mobile_session = html($user['mobile']);
$uin_session = num($user['uin']);
$chat_post_session = $user['postov'];
$level_session = num($user['level']);
$ip_session = html($user['ip']);
$brauser_session = html($user['brauser']);
$max_msg_chat_session = num($user['max']);
$theme_session = num($user['theme']);
$online_session = num($user['online']);
$time_obnov_session = num($user['obnov']);
$history_msg_chat_session = num($user['history']);
$extraball_session = num($user['extra_ball']);
$xstatus_session = num($user['xstatus']);
$xstatus_info_session = html($user['xstatus_info']);
$status_session = num($user['status']);
$color_login_session = num($user['color_login']);
$many_session = num($user['many']);
$postov_forum_session = num($user['postov_forum']);
$theme_forum_session = num($user['theme_forum']);
$vk_session = num($user['vk']);
$sp_session = num($user['sp']);
$sp_s_session = num($user['sp_s']);
$set_extra_session = num($user['set_extra']);
$set_pole_session = num($user['set_pole']);
$set_themes_session = num($user['set_themes']);
$set_posts_session = html($user['set_posts']);
$img_v_session = num($user['set_img_v']);
$img_s_session = num($user['set_img_s']);
$vvod_session = num($user['vvod']);
$ava_session = $user['ava'];
$online_session = $user['online'];
$set_color_post_session = $user['set_color_post'];
$osnov_photo_session = $user['osnov_photo'];
$set_private_session = $user['set_private'];
$brak_session = $user['brak'];
$k_activ_session = $user['k_activ'];
$love_rayting_session = $user['love_rayring'];
$level_forum_session = $user['level_forum'];
$mobilen_session = $user['mobilen'];
$skype_session = $user['skype'];
$twitter_session = $user['twitter'];
$facebook_session = $user['facebook'];
$livejournal_session = $user['livejournal'];
$deyat_session = $user['deyat'];
$interes_session = $user['interes'];
$music_session = $user['music'];
$video_session = $user['video'];
$cit_session = $user['cit'];
$info2_session = $user['info2'];
$games_session = $user['games'];
$emo_session = $user['setting_emo'];
$colorp_session = $user['setting_colorp'];
$msgp_session = $user['msgp'];
$kumar_session = $user['kumar'];
$kumart_session = $user['kumar_time'];
$kumarz_session = $user['kumar_zakaz'];
$akt_session = $user['akt_rating'];
$forum_abc_session = $user['forum_abc'];
$kik_session = $user['kik'];
$whokik_session = $user['whokik'];
$whykik_session = $user['whykik'];
$vip_session = $user['vip'];
$invis_session = $user['invis'];
$polit_session = $user['polit'];
$relig_session = $user['relig'];
$glavludi_session = $user['glavludi'];
$glavlive_session = $user['glavlive'];
$vdox_session = $user['vdox'];
$city1_session = $user['city'];
$flirt_session = $user['flirt_sett'];
#################################НОВЫЕ НАСТРОЙКИ
$private_msg_session = $user['private_msg'];
$private_friends_session = $user['private_friends'];
$private_stena_session = $user['private_stena'];
$private_friend_session = $user['private_friend'];
$private_str_session = $user['private_str'];
$private_presents_session = $user['private_presents'];

$settforum_forma_session = $user['settforum_forma'];
$settforum_upload_session = $user['settforum_upload'];
$settforum_priv_session = $user['settforum_priv'];
$settforum_photo_session = $user['settforum_photo'];
$settforum_simvol_session = $user['settforum_simvol'];
$settforum_postov_session = $user['settforum_postov'];

$settchat_vvod_session = $user['settchat_vvod'];
$settchat_emo_session = $user['settchat_emo'];
$settchat_color_session = $user['settchat_color'];
$settchat_adres_session = $user['settchat_adres'];
$settchat_postov_session = $user['settchat_postov'];
$settchat_restart_session = $user['settchat_restart'];

$sett_invis_session = $user['sett_invis'];

$bezopas_email_session = $user['bezopas_email'];
$bezopas_icq_session = $user['bezopas_icq'];
$bezopas_vopros_session = $user['bezopas_vopros'];
$bezopas_otvet_session = $user['bezopas_otvet'];

$sett_garem_session = $user['sett_garem'];
$sett_flirt_session = $user['sett_flirt'];
$sett_sivor_session = $user['sett_sivor'];
$sett_duel_session = $user['sett_duel'];

$settopovew_icq_session = $user['settopovew_icq'];
$settopovew_email_session = $user['settopovew_email'];
#################################
$ppresent_session = $user['private_present'];
$plichka_session = $user['private_lichka'];
$pfriend_session = $user['private_friend'];
$pstena_session = $user['private_stena'];
#################################
//////////Город///Страна///Регион




$city = $city_info['city_name'];
$region = $region_info['region_name'];
$country = $country_info['country_name'];

if(empty($city)) $city = 'Не выбрано';
if(empty($region)) $region = 'Не выбрано';
if(empty($country)) $country = 'Не выбрано';
///////////////////////////////////////////////
define('news','<div class="news">');
define('head','<div class="head">');
define('logo','<div class="logo">');
define('main','<div class="main">');
define('main2','<div class="main2">');
define('input','<div class="input">');
define('aut','<div class="aut">');
define('citata','<div class="citata">');
define('news','<div class="news">');
define('link1','<div class="link1">');
define('link2','<div class="link2">');
define('au','<div class="login">');
define('div','</div>');
define('login_f','<div class="login_f">');
define('clouds','<div class="clouds">');
define('padding','<div class="padding">');
define('kub','<div class="kub">');
define('clouds_2','<div class="clouds_2">');
define('katalog','<div class="katalog">');
define('anketa','<div class="anketa">');
define('menu','<div class="menu">');
/////////////////ID Ботов
$bot['system']=0;
$bot['umnik']=0;
$bot['debil']=0;
$bot['barmen']=0;
$bot['shutnik']=0;
$bot['striptiz']=0;
$bot['horo']=0;
$bot['fas']=0;
$bot['razgovor']=0;
/////////////////Комнаты Ботов
$room_bot['umnik']=4;
$bot['debil']=4;
$room_bot['barmen']=1;
$room_bot['shutnik']=5;
$bot['striptiz']=7;
$room_bot['fas']=6;
$room_bot['razgovor']=6;
/////////////////Курс
$kurs_ru=5; //////1 рубль = 5 постов
$kurs_ball=5; //////1 рубль = 5 постов
/////////////////Кланы
$forum_clan=$config['forumclan']; //////Форум в котором создаем подраздел клана
$forum_zags=$config['forumzags']; //////Форум брак
$forum_zags_razdel=$config['forumzagsr']; //////Форум брак (раздел)
//////////////Ограничения
$ava = $config['post_ava'];//////Нужное кол-во постов для установки авы
$gradient_cena = $config['cena_gradiient'];//////цена градиента
$login_cena = $config['cena_login'];//////цена градиента
$happy_cena = $config['cena_dr'];//////цена поздравления
$vot = $config['post_vote'];//////Нужное кол-во постов для голосования
$pr_chat = $config['post_private'];//////Постов для привата

///////////Подарки
$present_many = $config['cena_present'];

///////////Обменник
$top_obmen = 10;//кол-во файлов в ТОП

///////////WOW
$wow_rur = $config['cena_wow'];//Цена
$wow_time = $config['cena_wowtime'];//Время

///////////Цены
$email_rur = $config['cena_mail'];
$sms_rur = $config['cena_sms'];
$icq_rur = $config['cena_icq'];
$UIN = $config['uin']; 
$PASSWORD = $config['uin_pass'];
$e_mail = $config['mail'];
$anti_spam = $config['antispam'];//////в чате, в сек

$ava_w = 120;





$ip = false;
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '127.0.0.1' && ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$", $_SERVER['HTTP_X_FORWARDED_FOR']))
{
$ip2['xff'] = $_SERVER['HTTP_X_FORWARDED_FOR'];
$ipa[] = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if (isset($_SERVER['HTTP_CLIENT_IP']) && $_SERVER['HTTP_CLIENT_IP'] != '127.0.0.1' && ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$", $_SERVER['HTTP_CLIENT_IP']))
{
$ip2['cl'] = $_SERVER['HTTP_CLIENT_IP'];
$ipa[] = $_SERVER['HTTP_CLIENT_IP'];
}
if (isset($_SERVER['REMOTE_ADDR']) && ereg("^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$", $_SERVER['REMOTE_ADDR']))
{
$ip2['add'] = $_SERVER['REMOTE_ADDR'];
$ipa[] = $_SERVER['REMOTE_ADDR'];
}

$ip = $ipa[0];

$iplong = ip2long($ip);

if (isset($_SERVER['HTTP_USER_AGENT']))
{
$ua = $_SERVER['HTTP_USER_AGENT'];
$ua = strtok($ua, '/');
$ua = strtok($ua, '(');
$ua = eregi_replace('[^a-z_\./ 0-9\-]', null, $ua);

if (isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) && ereg('Opera', $ua))
{
$ua_om = $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'];
$ua_om = strtok($ua_om, '/');
$ua_om = strtok($ua_om, '(');
$ua_om = eregi_replace('[^a-z_\. 0-9\-]', null, $ua_om);
$ua = 'Opera Mini ('.$ua_om.')';
}
}
else $ua = 'Нет данных';
$brauser = html($_SERVER['HTTP_USER_AGENT']);

function getRealIpAddr()
{
  if (!empty($_SERVER['HTTP_CLIENT_IP'])) // Определение IP-адреса
  {
    $ip=$_SERVER['HTTP_CLIENT_IP'];
  }
  elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) // Проверка того, что IP идёт через прокси
  {
    $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  }
  else
  {
    $ip=$_SERVER['REMOTE_ADDR'];
  }
  return $ip;
}
mysql_query("UPDATE `profile` SET `brauser` = '".$brauser."', `brauser_1` = '".$ua."', `brauser_2` = '', `ip` = '".getRealIpAddr()."', `date_aut` = '".time()."', `perexodu` = '".($user['perexodu']+1)."' WHERE `id` = '".$id."'");






$online = mysql_result(mysql_query("SELECT count(*) FROM `profile` WHERE `time` > '".(time()-300)."' ORDER BY `time`"), 0);
if($online>$config['max_online']){
    mysql_query("UPDATE `config` SET `max_online` = '".$online."', `date_online` = '".mktime()."'");
}



////////////////////////
mysql_query("DELETE FROM `guest_online` WHERE `time` < '".time()."'");
if ( empty($id_session) ) {
    $time = time() + 300;
    $url = $_SERVER['HTTP_REFERER'];
    $perexody = $_SESSION['perexody']++;
    $res = mysql_fetch_assoc(mysql_query("SELECT * FROM `guest_online` WHERE `ip` = '".$ip."'"));
    
    
    if($res['id']==0) {
        mysql_query("INSERT INTO `guest_online` SET `ip` = '".html($ip)."', `ua` = '".html($ua)."', `url` = '".html($url)."', `time` = '".$time."', `perexody` = '0'");
        
    } else {
        mysql_query("UPDATE `guest_online` SET `perexody` = '".$perexody."' WHERE `ip` = '".html($ip)."' LIMIT 1");
        
    }
}
/////////////////////////

mysql_query("DELETE FROM `wow` WHERE `time` < '".time()."'");// Чистка WOW

$timeactiv=time() - $user['date_aut'];
if($timeactiv < 120)
{
$newtimeactiv=$user['timeact']+$timeactiv;
mysql_query("UPDATE `profile` SET `timeact` ='$newtimeactiv' WHERE `id` = '".$id_session."'");
echo mysql_error();}


    
    
if ( $id_session AND empty($login_session)  ) {
    header('Location: index.php');
} 

if ( empty($_SESSION['y']) ) $_SESSION['y'] = 100;

if($user['theme'] == 1){ $theme = 'style/paradise';}
if($user['theme'] == 0){ $theme = 'style/jamob';}
if($user['theme'] == 1){ $icon = 'img1';}
if($user['theme'] == 0){ $icon = 'img';}


$mail = mysql_result(mysql_query("SELECT count(*) FROM `mail` WHERE `to_user` = '".$id."' AND `status` = '0'"), 0);
if($mail>0) $mail1 = "<a href=\"http://".$_SERVER['HTTP_HOST']."/mail.php?act=vhod\"> <img src=\"http://".$_SERVER['HTTP_HOST']."/images/unread_msg.gif\" alt=\"\" />  + ".$mail."</a>";


if ( isset($mail1) OR isset($lmail) )
echo 'Приватное сообщение: ' . $mail1 . ' ' . $lmail; 


    mysql_query ("Select * from banip WHERE ip = '".$ip_session."' LIMIT 1");
    if(mysql_affected_rows()!=0) {
        
        
        echo '<b><big>BAN</big></b>';
        exit();
        
    }
    
if ( isset( $user['id'] ) )
	{

			$extra_n = rand( 1, 100 );
			if ($extra_n == 1 or $extra_n == 20 or $extra_n == 80)
			{
				
				$extra_unic = rand( 1111111111, 9999999999 );
				$_SESSION['unic_code'] = $extra_unic;
                                                $_SESSION['is_str'] = $_SERVER['PHP_SELF'];
				echo'<center><b><a href="http://jamob.ru/extra_ball.php?unic_code=' . $extra_unic . '">Поймать уникальный балл!</a></b></center>';
			} 
		
	}
    
if ($user['vip'] < time())
mysql_query("UPDATE `profile` SET `invis` = '0' WHERE `id` = '".$id_session."'"); 


/*
if ($id_session != 4) {
    
    header("Content-type:text/html; charset=utf-8");
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
echo '<title>Сайт не доступен</title>';
$icon = 'vesna';
echo '<link rel="stylesheet" href="http://'.$_SERVER['HTTP_HOST'].'/style/vesna.css" type="text/css" />';

echo head . 'Сайт не доступен' . div . katalog;

echo 'На сайте ведуться технические работы';
echo div;    
exit();
} */
?>
