<?php
if (!defined('IN_PHPQUAN'))
{
    die('Access Denied');
}
define('DEBUG',0);
if(DEBUG) {
	error_reporting(E_ERROR | E_WARNING | E_PARSE);
} else {
	error_reporting(0);
}
define('PHPQUAN_ROOT', str_replace("\\", '/', substr(dirname(__FILE__), 0, -7)));
$PHP_SELF = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
if ('/' == substr($php_self, -1))$PHP_SELF .= 'index.php';
$PHP_QUERYSTRING = $_SERVER['QUERY_STRING'];
$PHP_DOMAIN = $_SERVER['SERVER_NAME'];
$PHP_SCHEME = $_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://';
$PHP_PORT = $_SERVER['SERVER_PORT'] == '80' ? '' : ':'.$_SERVER['SERVER_PORT'];
$PHP_URL = $PHP_SCHEME.$PHP_DOMAIN.$PHP_PORT.$PHP_SELF.($PHP_QUERYSTRING ? '?'.$PHP_QUERYSTRING : '');
$PHP_TIME = $PHPQUAN_TIME = time();
if (!file_exists(PHPQUAN_ROOT . 'data/install.lock')) {
	header("Location:./install/index.php");
	exit;
}
require PHPQUAN_ROOT . 'data/config.php';
require PHPQUAN_ROOT . 'include/global.fun.php';
@set_magic_quotes_runtime(0);
@ini_set('session.auto_start', 0);
session_start();
header('Content-type: text/html; charset='.$charset);
if(!get_magic_quotes_gpc()) {
		if (!empty($_GET))$_GET  = addslashes_deep($_GET);
		if (!empty($_POST))$_POST = addslashes_deep($_POST);
		if (!empty($_COOKIE))$_COOKIE   = addslashes_deep($_COOKIE);
		if (!empty($_REQUEST))$_REQUEST  = addslashes_deep($_REQUEST);
}
if (!empty($_REQUEST)){
	$_REQUEST  = sql_replace($_REQUEST);key_replace($_REQUEST);
}
if (!empty($_POST)){
	$_POST  = sql_replace($_POST);key_replace($_POST);
}
if (!empty($_GET)){
	$_GET  = sql_replace($_GET);key_replace($_GET);
}
unset($_REQUEST['table']);
if(function_exists('date_default_timezone_set')){
    date_default_timezone_set('Etc/GMT-8');
}

require PHPQUAN_ROOT . 'include/mysql.class.php';
$db = new mysql($db_host, $db_user, $db_pass, $db_name, '1');
$db_host = $db_user = $db_pass = $db_name = NULL;
$CFG = get_config();
$_userid = 0;
$_username = '';
$user_ck = unserialize(decrypt(get_cookie('userkey')));
$uid = $user_ck['userid'] ? $user_ck['userid'] : '';
$password = $user_ck['password'] ? $user_ck['password'] : '';
if(!empty($uid)) {
	$user_info = $db->getRow("select userid,username,face,registertime,lastposttime,status,gid from {$table}member where userid='$uid' and password='$password' ");
	if($user_info) {
		$_userid = $user_info['userid'];
		$_username = $user_info['username'];
		$_username = htmlspecialchars($_username,ENT_QUOTES);
		$_face = $user_info['face'] ? $user_info['face'] : $CFG['weburl'].'/images/face.png';
		$_lastposttime = $user_info['lastposttime'];
		$_regtime = $user_info['registertime'];
		$_status = $user_info['status'];
		$_gid = $user_info['gid'];
	}
}
define('DEBUG_MODE', 0);
define('PHPQUAN_PATH', $CFG['weburl'].'/');//网址
define('CSS_PATH', $CFG['weburl'].'/templates/'.$CFG['tplname'].'/css/');//css网址
define('IMG_PATH', $CFG['weburl'].'/templates/'.$CFG['tplname'].'/images/');//图片网址
define('JS_PATH', $CFG['weburl'].'/js/');//JS网址
define('IMG_QR', $CFG['weburl'].'/phpqrcode/temp/');//二维码图片网址
require PHPQUAN_ROOT . 'include/header.php';
?>