View file system/inc/core.php

File size: 2.16Kb
<?php
/**********************************
*	@package: PerfCMS			  *
*	@year: 2012					  *
*	@author: Artas				  *
*	@link: http://perfcms.pp.ua	  *
**********************************/
$system = $db->query("SELECT * FROM `system`")->fetch();
date_default_timezone_set($system['timezone']);

if(isset($_SESSION['uid']) && isset($_SESSION['password'])) {
	$user_id = $_SESSION['uid'];
	$user_pass = $_SESSION['password'];
}
elseif(isset($_COOKIE['uid']) && isset($_COOKIE['password'])) {
	$user_id = $_COOKIE['uid'];
	$user_pass = $_COOKIE['password'];
} 
if(isset($user_id) && isset($user_pass)) {
	if($db->query("SELECT * FROM `users` WHERE `id` = '". $user_id ."' AND `password` = '". $user_pass ."'")->rowCount() == 1) {
		$user = $db->query("SELECT * FROM `users` WHERE `id` = '". $user_id ."' AND `password` = '".$user_pass."'")->fetch();
		$settings = $db->query("SELECT * FROM `settings` WHERE `user_id` = '". $user_id ."'")->fetch();
		date_default_timezone_set($settings['timezone']);
		$db->query("UPDATE `users` SET `time` = '". time()."' WHERE `id` = '". $user_id ."'");
	}
}
$ip = trim($_SERVER['REMOTE_ADDR']);
$browser = browser($_SERVER['HTTP_USER_AGENT']);
if(!isset($user)) {
	if($db->query("SELECT * FROM `guests` WHERE `ip` = '$ip' AND `browser` = '$browser' LIMIT 1")->rowCount() == 1) {
	$db->query("UPDATE `guests` SET `time` = '". time() ."' WHERE `ip` = '$ip' AND `browser` = '$browser' LIMIT 1");
	} else {
		$db->query("INSERT INTO `guests` SET `ip` = '$ip', `browser` = '$browser', `time` = '". time() ."'");
	}
}
if(isset($user)) {
	$ames = $settings['ames'];
} else {
	$ames = $system['ames'];
}
$ttype = 'wap';
if(isset($user)) {
	$stylen = $settings['theme'];
} elseif(!isset($user)) {
	$stylen = $system['theme'];
}/* elseif(isset($user) && browser_type() == 'web') {
	$stylen = $settings['web_theme'];
	$ttype = 'web';
} elseif(!isset($user) && browser_type() == 'web') {
	$stylen = $system['web_theme'];
	$ttype = 'web';
}
*/
if(isset($user)) {
	$lng = $settings['lang'];
} else {
	$lng = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);;
}
$theme = parse_ini_file(TPL .'/themes/'. $ttype .'/'. $stylen .'/manifest.ini');