ECSHOP 源码分析(install/index.php2)

作者在 2006-12-06 21:59:00 发布以下内容

/*------------------------------------------------------ */
//-- 设置数据库帐号
/*------------------------------------------------------ */
case 'database' :
    if (file_exists(ROOT_PATH . 'data/config.php'))
    {
        include_once(ROOT_PATH . 'data/config.php');
    }
    else
    {
        $db_host = 'localhost';
        $db_name = 'ecshop';
        $db_user = 'root';
        $db_pass = '';
        $prefix = 'ecs_';
    }

    include_once(ROOT_PATH . 'install/inc_goods_type_'.$selected_lang.'.php');

    $goods_type = '';
    $n = 0;

    foreach ($attributes AS $key=>$val)
    {
        $goods_type .= ' <input type="checkbox" name="goods_type[]" value="' .$key. '" checked="true" /> '. $lang[$key];
        $n ++;

        if ($n >= 4)
        {
            $goods_type .= "<br />";
            $n = 0;
        }
    }
 
 break;

 

/*------------------------------------------------------ */
//-- 安装测试数据,填写管理员帐号
/*------------------------------------------------------ */
case 'administrator' :
 $db_host    = trim($_POST['db_host']);
    $db_name    = trim($_POST['db_name']);
    $db_user    = trim($_POST['db_user']);
    $db_pass    = trim($_POST['db_pass']);
    $prefix     = trim($_POST['db_prefix']);

 include_once(ROOT_PATH . "includes/adodb/adodb.inc.php");
    $connect_success = true;

    /* 测试数据库联接 */
    if (!@mysql_connect($db_host, $db_user, $db_pass))
    {
        $step = 'message';
        $message = $lang['connect_failed'];
        $connect_success = false;
    }
    else
    {
        $mysql_ver = mysql_get_server_info();
   
        if (!@mysql_select_db($db_name))
        {
            $query = ($mysql_ver > '4.1') ? "CREATE DATABASE $db_name DEFAULT CHARACTER SET utf8" : "CREATE DATABASE $db_name";
   
            if (!mysql_query($query))
            {
                $step = 'message';
                $message = $lang['select_db_failed'];
                $connect_success = false;
            }
        }
    }

 @mysql_close();


 /* 初始化数据库类 */
 if

php | 阅读 952 次
文章评论,共0条
游客请输入验证码
浏览96336次