Пример #1
0
 /**
  * Load the config
  */
 function load_config()
 {
     $query = "SELECT `config_name`, `config_value` FROM `" . $this->db->table('config') . "` ORDER BY `id` ASC;";
     $results = $this->db->query($query);
     if (!$results || $this->db->num_rows($results) == 0) {
         die("Cannot get roster configuration from database<br />\nMySQL Said: " . $this->db->error() . "<br /><br />\nYou might not have roster installed<br />\n<a href=\"install.php\">INSTALL</a>");
     }
     while ($row = $this->db->fetch($results)) {
         $this->config[$row['config_name']] = $row['config_value'];
     }
     $this->db->free_result($results);
     /**
      * Inject some different settings if the debug url switch is set
      */
     if (isset($_GET['rdebug']) && is_numeric($_GET['rdebug'])) {
         switch ($_GET['rdebug']) {
             case 2:
                 $this->config['debug_mode'] = 2;
                 $this->config['sql_window'] = 2;
                 break;
             case 1:
             default:
                 $this->config['debug_mode'] = 1;
                 $this->config['sql_window'] = 1;
                 break;
         }
     }
     /*/ BETA ONLY, COMMENT THIS IN RC OR LATER!
     // if these equal 0, force these on
     		if( $this->config['debug_mode'] == 0 )
     		{
     			$this->config['debug_mode'] = 1;
     		}
     		if( $this->config['sql_window'] == 0 )
     		{
     			$this->config['sql_window'] = 1;
     		}
     // END BETA ONLY
     */
     $this->db->log_level($this->config['sql_window']);
 }
Пример #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();
}