Beispiel #1
0
function dida_setup()
{
    global $base_path, $error, $setting_file, $conf_dir;
    if ($_POST) {
        if (empty($_POST['admin'])) {
            $error[] = '管理员帐号不能为空。';
        } else {
            if (empty($_POST['mail'])) {
                $error[] = '邮箱不能为空。';
            } else {
                if (empty($_POST['adminpass'])) {
                    $error[] = '管理员帐号密码不能为空。';
                } else {
                    if ($_POST['adminpass'] != $_POST['adminpass2']) {
                        $error[] = '两次输入的密码不一致。';
                    } else {
                        if (empty($_POST['site_name'])) {
                            $error[] = '网站名称不能为空。';
                        } else {
                            if (empty($_POST['site_mail'])) {
                                $error[] = '站长邮箱不能为空。';
                            } else {
                                if (empty($_POST['status'])) {
                                    $error[] = '请设置网站访问状态。';
                                } else {
                                    if (db_connect('default')) {
                                        require_once DIDA_ROOT . '/modules/system/system.install';
                                        require_once DIDA_ROOT . '/includes/module.inc';
                                        require_once DIDA_ROOT . '/includes/menu.inc';
                                        if (_system_install()) {
                                            if (module_set_list('theme') && module_set_list('module')) {
                                                db_exec('UPDATE {system} SET status = -1 WHERE filename = :name', array(':name' => 'default'));
                                                if ($messages = module_set_enabled('disabled', 'module', array('system', 'block', 'user', 'field'))) {
                                                    _install_setting_chmod();
                                                    // 锁定安装文件,修改配置文件权限
                                                    _install_bootstrap();
                                                    // 载入模块
                                                    module_enabled_variable();
                                                    //写入模块、主题列表
                                                    menu_set_item();
                                                    // 写入menu
                                                    $admin = check_plain($_POST['admin']);
                                                    $pass = user_get_salt_pass($_POST['adminpass']);
                                                    //写入第一个用户
                                                    db_query('INSERT INTO {users} (name, pass, salt, mail, created, status) VALUES(?, ?, ?, ?, ?, 1)', array($admin, $pass['pass'], $pass['salt'], $_POST['mail'], $_SERVER['REQUEST_TIME']));
                                                    //写入匿名用户
                                                    db_query('INSERT INTO {users} (name, created, status) VALUES(?, ?, 1)', array('匿名', $_SERVER['REQUEST_TIME']));
                                                    //调整 uid
                                                    db_query('UPDATE {users} SET uid = 0 WHERE name = ?', array('匿名'));
                                                    //测试简洁链接
                                                    $clean_url = 0;
                                                    $goto = '?q=user/login';
                                                    block_cache_lists('default');
                                                    // 导入区块
                                                    $modules = array('system' => 'modules/system', 'user' => 'modules/user', 'block' => 'modules/block', 'category' => 'modules/category');
                                                    dd_set_lang($modules, array('zh-hans', 'zh-hant'));
                                                    // 导入语言包
                                                    $var_timestamp = serialize($_SERVER['REQUEST_TIME']);
                                                    $var_args = array('status', serialize($_POST['status']), 'site_global', serialize(array('logo' => $base_path . 'misc/images/logo.png', 'favicon' => $base_path . 'misc/images/favicon.ico', 'name' => trim($_POST['site_name']), 'mail' => $_POST['site_mail'])), 'clean_url', serialize($clean_url), 'cache_css_and_js_timestamp', $var_timestamp, 'site_created', $var_timestamp);
                                                    db_query('INSERT INTO {variable} (name, value) VALUES (?, ?), (?, ?), (?, ?), (?, ?), (?, ?)', $var_args);
                                                    require_once './includes/filter.inc';
                                                    /**
                                                     * 输入格式缓存
                                                     */
                                                    filter_get_filters();
                                                    filter_set_cache();
                                                    var_init();
                                                    unset($_SESSION['messages']);
                                                    foreach ($messages as $mmessage) {
                                                        dd_set_message($message);
                                                    }
                                                    // 创建头像字段
                                                    $field = array('name' => t('field', '头像'), 'module' => 'user', 'type' => 'field', 'field_type' => 'file', 'field_key' => 'avatar', 'weight' => -20, 'data' => array('multi' => 1, 'filesize' => 4096, 'filename' => '[uid]', 'extension' => 'jpg', 'savepath' => 'avatar', 'thumbs' => array('thumb' => '85x85', 'medium' => '200x200')));
                                                    $data = (object) $field;
                                                    field_save($data);
                                                    /**
                                                     * 基本安装完成后,可继续执行自定义安装
                                                     * 自定义安装文件名称为:install.custom.php
                                                     * 入口函数:install_custom
                                                     * 文件目录结构如下(按优先级):
                                                     * $conf_dir/install/install.custom.php
                                                     * install/install.custom.php
                                                     */
                                                    if (is_file(DIDA_ROOI . '/' . $conf_dir . '/install/install.custom.php') && function_exists('install_custom')) {
                                                        install_custom();
                                                    } else {
                                                        if (is_file(DIDA_ROOT . '/install/install.custom.php') && function_exists('install_custom')) {
                                                            install_custom();
                                                        }
                                                    }
                                                    // 登录超级用户
                                                    user_login(user_load(1));
                                                    dd_goto('user/login');
                                                }
                                            }
                                            $error[] = dd_get_message();
                                        } else {
                                            $error[] = '无法创建配置表';
                                        }
                                    } else {
                                        $error[] = '连接数据库失败,请检查配置,或<a href="install.php?setup=1&clear=1">重新开始安装</a>';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Beispiel #2
0
  <?php 
echo dd_get_css();
?>
  <?php 
echo dd_get_js('header');
?>
</head>
<body id="print">
  <?php 
echo dd_get_breadcrumb();
?>
  <?php 
echo dd_get_tabs();
?>
  <?php 
echo dd_get_sub_tabs();
?>
  <?php 
echo dd_get_message();
?>
  <?php 
echo dd_get_help();
?>
  <?php 
echo $content;
?>
	<?php 
echo dd_get_js('footer');
?>
</body>
</html>