예제 #1
0
파일: install.php 프로젝트: World3D/iCMS
 } else {
     iDB::connect();
 }
 iDB::pre_set();
 iDB::select_db(true) or iPHP::alert("不能链接到数据库" . iPHP_DB_NAME, 'js:top.callback("#DB_NAME");');
 $config = iPATH . 'config.php';
 $content = iFS::read($config, false);
 $content = preg_replace("/define\\(\\'iPHP_DB_HOST\\',\\'.*?\\'\\)/is", "define('iPHP_DB_HOST','" . iPHP_DB_HOST . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_USER\\',\\'.*?\\'\\)/is", "define('iPHP_DB_USER','" . iPHP_DB_USER . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_PASSWORD\\',\\'.*?\\'\\)/is", "define('iPHP_DB_PASSWORD','" . iPHP_DB_PASSWORD . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_NAME\\',\\'.*?\\'\\)/is", "define('iPHP_DB_NAME','" . iPHP_DB_NAME . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_DB_PREFIX\\',\\'.*?\\'\\)/is", "define('iPHP_DB_PREFIX','" . iPHP_DB_PREFIX . "')", $content);
 $content = preg_replace("/define\\(\\'iPHP_KEY\\',\\'.*?\\'\\)/is", "define('iPHP_KEY','" . random(32) . "')", $content);
 $parse_url = parse_url($router_url);
 $host = $parse_url['host'];
 $COOKIE_DOMAIN = '.' . iPHP::domain($host);
 preg_match("/^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/", $host) && ($COOKIE_DOMAIN = '');
 $content = preg_replace("/define\\(\\'iPHP_COOKIE_DOMAIN\\',\\s*\\'.*?\\'\\)/is", "define('iPHP_COOKIE_DOMAIN','{$COOKIE_DOMAIN}')", $content);
 iFS::write($config, $content, false);
 //开始安装 数据库
 $sql_file = dirname(strtr(__FILE__, '\\', '/')) . '/iCMS.V6.sql';
 is_readable($sql_file) or iPHP::alert('数据库文件不存在或者读取失败', 'js:top.callback();');
 //require_once ($config);
 $sql = iFS::read($sql_file);
 // $sql = str_replace('#iCMS@__',$db_prefix,$sql);
 //
 //
 run_query($sql);
 //设置超级管理员
 $admin_password = md5($admin_password);
 iDB::query("\n\t\tUPDATE `#iCMS@__members`\n\t\tSET `username` = '{$admin_name}', `password` = '{$admin_password}'\n\t\tWHERE `uid` = '1';\n\t");