function update_sys_config() { $filename = APP_ROOT_PATH . "public/sys_config.php"; if (!file_exists($filename)) { //定义DB require APP_ROOT_PATH . 'system/db/db.php'; $dbcfg = (require APP_ROOT_PATH . "public/db_config.php"); define('DB_PREFIX', $dbcfg['DB_PREFIX']); if (!file_exists(APP_ROOT_PATH . 'public/runtime/app/db_caches/')) { mkdir(APP_ROOT_PATH . 'public/runtime/app/db_caches/', 0777); } $pconnect = false; $db = new mysql_db($dbcfg['DB_HOST'] . ":" . $dbcfg['DB_PORT'], $dbcfg['DB_USER'], $dbcfg['DB_PWD'], $dbcfg['DB_NAME'], 'utf8', $pconnect); //end 定义DB $sys_configs = $db->getAll("select * from " . DB_PREFIX . "conf"); $config_str = "<?php\n"; $config_str .= "return array(\n"; foreach ($sys_configs as $k => $v) { $config_str .= "'" . $v['name'] . "'=>'" . addslashes($v['value']) . "',\n"; } $config_str .= ");\n ?>"; file_put_contents($filename, $config_str); $url = APP_ROOT . "/"; app_redirect($url); } }