Ejemplo n.º 1
0
function guide_step2()
{
    global $roster;
    $roster->tpl->assign_var('S_STEP_2', true);
    $name = trim(post_or_db('name'));
    $server = trim(post_or_db('server'));
    $region = strtoupper(substr(trim(post_or_db('region')), 0, 2));
    if (!empty($name) || !empty($server) || !empty($region)) {
        $query = "UPDATE `" . $roster->db->table('upload') . "` SET `default` = '0';";
        if (!$roster->db->query($query)) {
            die_quietly($roster->db->error(), 'Database Error', __FILE__, __LINE__, $query);
        }
        $query = "INSERT INTO `" . $roster->db->table('upload') . "`" . " (`name`,`server`,`region`,`type`,`default`)" . " VALUES ('" . $name . "','" . $server . "','" . $region . "','0','1');";
        if (!$roster->db->query($query)) {
            die_quietly($roster->db->error(), 'Database Error', __FILE__, __LINE__, $query);
        }
        $roster->tpl->assign_var('MESSAGE', messagebox(sprintf($roster->locale->act['guide_complete'], makelink('rostercp-install'))));
    } else {
        $roster->tpl->assign_var('MESSAGE', messagebox($roster->locale->act['upload_rules_error'], '', 'sred'));
    }
}
Ejemplo n.º 2
0
function process_step4()
{
    global $DEFAULTS;
    $tpl = new Template_Wrap();
    $tpl->set_handle('body', 'install_step4.html');
    /**
     * Get our posted data
     */
    $user_password1 = post_or_db('user_password1');
    $user_password2 = post_or_db('user_password2');
    /**
     * Update admin account
     */
    include ROSTER_BASE . 'conf.php';
    define('ROSTER_DB_DIR', ROSTER_LIB . 'dbal' . DIR_SEP);
    switch ($db_config['dbtype']) {
        case 'mysql':
            include_once ROSTER_DB_DIR . 'mysql.php';
            break;
        case 'PDO':
            include_once ROSTER_DB_DIR . 'pdo.php';
            break;
        default:
            include_once ROSTER_DB_DIR . 'mysql.php';
            break;
    }
    $db = new roster_db($db_config['host'], $db_config['database'], $db_config['username'], $db_config['password'], $db_config['table_prefix']);
    $db->log_level();
    $db->error_die();
    if (!is_resource($db->link_id)) {
        $tpl->message_die('Failed to connect to database <strong>' . $db_config['database'] . '</strong> as <strong>' . $db_config['username'] . '@' . $db_config['host'] . '</strong><br /><br /><a href="index.php">Restart Installation</a>');
    }
    /**
     * Insert account data. This isn't in the data sql file because we don't
     * want to include it in a settings reset
     */
    if ($user_password1 == '' || $user_password2 == '') {
        $pass_word = md5('admin');
    } elseif ($user_password1 == $user_password2) {
        $pass_word = md5($user_password1);
    } else {
        $pass_word = md5('admin');
    }
    $db->query("INSERT INTO `" . $db->table('user_members') . "` (`usr`) VALUES\t('Admin');");
    $db->query("UPDATE `" . $db->table('user_members') . "` SET `pass` = '" . $pass_word . "',`access` = '11:0',`active`='1',`user_permissions` = '{\"id\":\"1\",\"roster_cp\":\"1\",\"gp_update\":\"1\",\"cp_update\":\"1\",\"lua_update\":\"1\"}' WHERE `usr` = 'Admin';");
    $tpl->message_append('The WoWRoster Admin account has created<br />Please do not forget your password');
    /**
     * Rewrite the config file to its final form
     */
    $config_file = file(ROSTER_BASE . 'conf.php');
    $config_file[] = "\ndefine('ROSTER_INSTALLED', true);";
    $config_file = implode('', $config_file);
    // Set our permissions to execute-only
    @umask(0111);
    if (!($fp = @fopen('conf.php', 'w'))) {
        $error_message = 'The <strong>conf.php</strong> file couldn\'t be opened for writing.<br />Paste the following in to conf.php and save the file to continue:<br /><pre>' . htmlspecialchars($config_file) . '</pre>';
        $tpl->error_append($error_message);
    } else {
        @fwrite($fp, $config_file, strlen($config_file));
        @fclose($fp);
    }
    /**
     * Print out the login form
     */
    if ($user_password1 != $user_password2 || $user_password1 == '' || $user_password2 == '') {
        $tpl->message_append('<span style="font-weight:bold;font-size:14px;" class="negative">NOTICE</span><br /><br />Your passwords did not match, so it has been reset to <strong>admin</strong><br />You can change it by logging in and going to your account settings.');
    }
    $tpl->message_append('Your administrator account has been created, log in to be taken to the WoWRoster configuration page.');
    $tpl->sql_output($db);
    $tpl->page_header();
    $tpl->page_tail();
}