<?php
/*判断网站是否安装*/
$site_code = root_path . "/install.lck";
if (!is_file($site_code))
{
	header("location:http://".$_SERVER['HTTP_HOST']."/setup/setup.php");
	exit();
}
$mysql_conn = 'c';
if(is_file(root_path.'/lib/safety/mysqlconn.cfg'))
{
	$mysql_conn = file_get_contents(root_path.'/lib/safety/mysqlconn.cfg');
}
	if($mysql_conn == 'p')
	{
		$link = mysql_pconnect($cfg['SQL_HOST'], $cfg['SQL_USER'], $cfg['SQL_PASS']);
	}
	else
	{
		$link = mysql_connect($cfg['SQL_HOST'], $cfg['SQL_USER'], $cfg['SQL_PASS']);
	}
	if (!$link) 
	{
		die('MYSQL LINK ERROR!连接数据库失败!' . mysql_error());
	}
//选择数据库
$db = mysql_select_db($cfg['SQL_SEL'], $link) or die('数据库链接失败!找不到指定的数据库里!请重新审核配置文件!');
if (isset($cfg['CHAR'])) {
    mysql_query("SET NAMES '{$cfg['CHAR']}'");
} else {
    //mysql_query("SET NAMES 'latin1'");
    mysql_query("SET NAMES 'utf8'");
}