View file index.php

File size: 2.2Kb
<?
define('SECURED', true);
include'ini.php';
include'includes/func_validate.php';

ini_set('url_rewriter.tags','');
session_name("SessionID");
session_start();

if((isset($_GET['wml']) || $_COOKIE['version']=='wml' || $_SESSION['s_version']=='wml') && !isset($_GET['xhtml']))
{
	$ver='wml';
	$_SESSION['s_version']='wml';
	SetCookie("version", 'wml', time()+3600*24*14);
	include'themes/wml.php';
} else
{
	$ver='html';
	$_SESSION['s_version']='xhtml';
	SetCookie("version", 'xhtml', time()+3600*24*14);
	include'themes/html.php';
}

if(!empty($_SESSION['s_sid'])) $sid=$_SESSION['s_sid'];
if(!empty($_COOKIE['c_sid'])) $sid=$_COOKIE['c_sid'];
if(!empty($_GET['sid'])) $sid=$_GET['sid'];

$_SESSION['s_sid']=$sid;
SetCookie("c_sid", $sid, time()+3600*24*14);//'sid='.$_GET['sid'].'&amp;'.
$url=htmlspecialchars($_GET['url']);
if(empty($_COOKIE['c_sid'])) define('SID', session_name().'='.session_id()."&amp;url=$url");
else define('SID', "url=$url");
//echo "$_GET[sid]|$_SESSION[s_sid]|$_COOKIE[c_sid]|$sid";
if ($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']) 
{
	$agent = val($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']); 
} else 
{
	$agent=val($_SERVER['HTTP_USER_AGENT']);
}

$agent=strtok($agent,'(');
$agent=strtok($agent,' ');
$agent=substr($agent,0,22);
if(empty($agent)) $agent='[not detected]';
$ip=getenv('REMOTE_ADDR');
				
$goback='&#187; <a href="'.$_SERVER['PHP_SELF'].'?'.SID.'">Файлообменник</a><br/>';

if(isset($_GET['exit']))
{
	mysql_query("update users set session='' where session='".val($sid)."';");
	SetCookie("c_sid", null);
	unset($_SESSION['s_sid']);
	$msg='Вы успешно вышли из системы!<br/>';
}

$user=mysql_fetch_array(mysql_query("select * from users where session='".val($sid)."' and session!='';"));
if(mysql_affected_rows()!=0)
{
	mysql_query("update `users` set `last`=".time().",`ip`='$ip',`soft`='$agent' where id='".$user['id']."';");
	$login=$user['login'];
	$level=$user['level'];
	$auth=true;
} else
{
	$login='Гость';
	$level=0;
	$auth=false;
}

$mode=$_GET['mode'];
if(!in_array($mode,$modes)) 
{
	$mode='index';
}

if($mode!='get') head();

include 'pages/'.$mode.'.php';

footer();
mysql_close();
?>