Exemplo n.º 1
0
 /**
  *    更新系统信息
  *
  *    @author    Garbin
  *    @return    void
  */
 function _update_system_info()
 {
     save_system_info(array('version' => VERSION, 'release' => RELEASE));
 }
Exemplo n.º 2
0
 /**
  *    完成安装
  *
  *    @author    Garbin
  *    @return    void
  */
 function install_done()
 {
     extract($_POST);
     /* 无实际用途 */
     $_code = rand(10000, 99999);
     setcookie('__INTECODE__', $_code, 0, '/');
     /* 连接数据库 */
     $con = mysql_connect($db_host . ':' . $db_port, $db_user, $db_pass);
     if (!$con) {
         show_process(r(Lang::get('connect_db'), false), 'parent.show_warning("' . Lang::get('connect_db_error') . '")');
         return false;
     }
     show_process(r(Lang::get('connect_db'), true));
     $version = mysql_get_server_info();
     $charset = str_replace('-', '', CHARSET);
     if ($version > '4.1') {
         if ($charset != 'latin1') {
             mysql_query("SET character_set_connection={$charset}, character_set_results={$charset}, character_set_client=binary", $con);
         }
         if ($version > '5.0.1') {
             mysql_query("SET sql_mode=''", $con);
         }
     }
     /* 选择数据库 */
     $selected_db = mysql_select_db($db_name, $con);
     if (!$selected_db) {
         show_process(r(Lang::get('selecte_db'), false), 'parent.show_warning("' . Lang::get('selecte_db_error') . '");');
         return false;
     }
     /* 建立数据库结构 */
     show_process(r(Lang::get('start_setup_db'), true));
     $sqls = get_sql(version_data('structure.sql'));
     foreach ($sqls as $sql) {
         $sql = replace_prefix('ecm_', $db_prefix, $sql);
         if (substr($sql, 0, 12) == 'CREATE TABLE') {
             $name = preg_replace("/CREATE TABLE `{$db_prefix}([a-z0-9_]+)` .*/is", "\\1", $sql);
             mysql_query(create_table($sql));
             show_process(r(sprintf(Lang::get('create_table'), $name), true, 1));
         } else {
             mysql_query($sql, $con);
         }
     }
     /* 安装初始数据 TODO 暂时不完整 */
     $sqls = get_sql(version_data('initdata.sql'));
     $password = md5($admin_pass);
     $sqls[] = "INSERT INTO `ecm_member`(user_name, email, password, reg_time) VALUES('{$admin_name}', '{$admin_email}', '{$password}', " . gmtime() . ")";
     foreach ($sqls as $sql) {
         $rzt = mysql_query(replace_prefix('ecm_', $db_prefix, $sql), $con);
         if (!$rzt) {
             show_process(r(Lang::get('install_initdata'), false), 'parent.show_warning("' . mysql_error() . '");');
             return false;
         }
     }
     if (mysql_errno()) {
         echo mysql_error();
     }
     show_process(r(Lang::get('install_initdata'), true));
     /* 安装初始配置 */
     $db_config = "mysql://{$db_user}:{$db_pass}@{$db_host}:{$db_port}/{$db_name}";
     $ecm_key = get_ecm_key();
     $mall_site_id = product_id();
     save_config_file(array('SITE_URL' => $site_url, 'DB_CONFIG' => $db_config, 'DB_PREFIX' => $db_prefix, 'LANG' => LANG, 'COOKIE_DOMAIN' => '', 'COOKIE_PATH' => '/', 'ECM_KEY' => $ecm_key, 'MALL_SITE_ID' => $mall_site_id, 'ENABLED_GZIP' => 0, 'DEBUG_MODE' => 0, 'CACHE_SERVER' => 'default', 'MEMBER_TYPE' => 'default', 'ENABLED_SUBDOMAIN' => 0, 'SUBDOMAIN_SUFFIX' => ''));
     /* 写入系统信息 */
     save_system_info(array('version' => VERSION, 'release' => RELEASE));
     show_process(r(Lang::get('setup_config'), true));
     /* 锁定安装程序 */
     touch(LOCK_FILE);
     show_process(r(Lang::get('lock_install'), true));
     if (is_file(ROOT_PATH . '/integrate/index.php')) {
         /* 跳至整合程序 */
         show_process(r(Lang::get('install_done'), true), 'parent.goon_install("' . $site_url . '/integrate/index.php", "' . $_code . '");');
     } else {
         /* 安装完成 */
         show_process(r(Lang::get('install_done'), true), 'parent.install_successed();');
         return false;
     }
 }