Example #1
0
 function convert_data($data)
 {
     $insert_data = array();
     // phpBB 2 values
     $insert_data['usergroup'] = $this->board->get_group_id($data, array("not_multiple" => true));
     $insert_data['additionalgroups'] = str_replace($insert_data['usergroup'], '', $this->board->get_group_id($data));
     $insert_data['displaygroup'] = $this->board->get_group_id($data, array("not_multiple" => true));
     $insert_data['import_usergroup'] = $this->board->get_group_id($data, array("not_multiple" => true, "original" => true));
     $insert_data['import_additionalgroups'] = $this->board->get_group_id($data, array("original" => true));
     $insert_data['import_displaygroup'] = $data['group_id'];
     $insert_data['import_uid'] = $data['user_id'];
     $insert_data['username'] = encode_to_utf8($data['username'], "users", "users");
     $insert_data['email'] = $data['user_email'];
     $insert_data['regdate'] = $data['user_regdate'];
     $insert_data['lastactive'] = $data['user_lastvisit'];
     $insert_data['lastvisit'] = $data['user_lastvisit'];
     $insert_data['website'] = $data['user_website'];
     $insert_data['avatar'] = $data['user_avatar'];
     list($width, $height) = @getimagesize($data['user_avatar']);
     $insert_data['avatardimensions'] = $width . '|' . $height;
     if ($insert_data['avatar'] == '') {
         $insert_data['avatartype'] = "";
     } else {
         $insert_data['avatartype'] = 'remote';
     }
     $last_post = $this->get_last_post($data['user_id']);
     $insert_data['lastpost'] = intval($last_post['post_time']);
     $insert_data['icq'] = $data['user_icq'];
     $insert_data['aim'] = $data['user_aim'];
     $insert_data['yahoo'] = $data['user_yim'];
     $insert_data['msn'] = $data['user_msnm'];
     $insert_data['hideemail'] = $data['hideEmail'];
     $insert_data['invisible'] = int_to_01($data['user_allow_viewonline']);
     $insert_datar['allownotices'] = $data['user_notify'];
     if ($data['user_notify'] == 1) {
         $subscription_method == 2;
     } else {
         $subscription_method = 0;
     }
     $insert_data['subscriptionmethod'] = $subscription_method;
     $insert_data['receivepms'] = $data['user_allow_pm'];
     $insert_data['pmnotice'] = $data['user_popup_pm'];
     $insert_data['pmnotify'] = $data['pm_email_notify'];
     $insert_data['showsigs'] = $data['user_attachsig'];
     $insert_data['showavatars'] = $data['user_allowavatar'];
     $insert_data['timeformat'] = $data['user_dateformat'];
     $insert_data['timezone'] = $data['user_timezone'];
     $insert_data['regip'] = $last_post['poster_ip'];
     $insert_data['totalpms'] = $this->get_private_messages($data['user_id']);
     $insert_data['unreadpms'] = $data['user_unread_privmsg'];
     $insert_data['salt'] = generate_salt();
     $insert_data['signature'] = encode_to_utf8(str_replace(':' . $data['user_sig_bbcode_uid'], '', utf8_unhtmlentities($data['user_sig'])), "users", "users");
     $insert_data['password'] = salt_password($data['user_password'], $insert_data['salt']);
     $insert_data['loginkey'] = generate_loginkey();
     return $insert_data;
 }
Example #2
0
 function convert_data($data)
 {
     $insert_data = array();
     // Mingle values
     $insert_data['usergroup'] = $this->board->get_group_id($data['ID'], array("not_multiple" => true));
     $insert_data['displaygroup'] = $insert_data['usergroup'];
     $insert_data['import_displaygroup'] = $insert_data['import_usergroup'];
     $insert_data['import_uid'] = $data['ID'];
     $insert_data['username'] = encode_to_utf8($data['user_login'], "users", "users");
     $insert_data['email'] = $data['user_email'];
     $insert_data['regdate'] = strtotime($data['user_registered']);
     $insert_data['website'] = $data['user_url'];
     $insert_data['lastpost'] = $this->get_user_lastpost($data['ID']);
     $insert_data['passwordconvert'] = $data['user_pass'];
     $insert_data['passwordconverttype'] = 'mingle';
     $insert_data['loginkey'] = generate_loginkey();
     return $insert_data;
 }
Example #3
0
function loginconvert_convert(&$login)
{
    global $mybb, $valid_login_types, $db, $settings;
    $options = array("fields" => array('username', "password", "salt", 'loginkey', 'coppauser', 'usergroup', "passwordconvert", "passwordconverttype", "passwordconvertsalt"), "username_method" => (int) $settings['username_method']);
    if ($login->username_method !== null) {
        $options['username_method'] = (int) $login->username_method;
    }
    $user = get_user_by_username($login->data['username'], $options);
    // There's nothing to check for, let MyBB do everything
    // This fails also when no user was found above, so no need for an extra check
    if (!isset($user['passwordconvert']) || $user['passwordconvert'] == '') {
        return;
    }
    if (!array_key_exists($user['passwordconverttype'], $valid_login_types)) {
        // TODO: Is there an easy way to make the error translatable without adding a new language file?
        redirect($mybb->settings['bburl'] . "/member.php?action=lostpw", "We're sorry but we couldn't convert your old password. Please select a new one", "", true);
    } else {
        $function = "check_" . $valid_login_types[$user['passwordconverttype']];
        $check = $function($login->data['password'], $user);
        if (!$check) {
            // Yeah, that function is called later too, but we need to know whether the captcha is right
            // If we wouldn't call that function the error would always be shown
            $login->verify_attempts($mybb->settings['captchaimage']);
            $login->invalid_combination(true);
        } else {
            // The password was correct, so use MyBB's method the next time (even if the captcha was wrong we can update the password)
            $salt = generate_salt();
            $update = array("salt" => $salt, "password" => salt_password(md5($login->data['password']), $salt), "loginkey" => generate_loginkey(), "passwordconverttype" => "", "passwordconvert" => "", "passwordconvertsalt" => "");
            $db->update_query("users", $update, "uid='{$user['uid']}'");
            // Make sure the password isn't tested again
            unset($login->data['password']);
            // Also make sure all data is available when creating the session (otherwise SQL errors -.-)
            $login->login_data = array_merge($user, $update);
        }
    }
}
Example #4
0
/**
 * Installation is finished
 */
function install_done()
{
    global $output, $db, $mybb, $errors, $cache, $lang;
    if (empty($mybb->input['adminuser'])) {
        $errors[] = $lang->admin_step_error_nouser;
    }
    if (empty($mybb->input['adminpass'])) {
        $errors[] = $lang->admin_step_error_nopassword;
    }
    if ($mybb->get_input('adminpass') != $mybb->get_input('adminpass2')) {
        $errors[] = $lang->admin_step_error_nomatch;
    }
    if (empty($mybb->input['adminemail'])) {
        $errors[] = $lang->admin_step_error_noemail;
    }
    if (is_array($errors)) {
        create_admin_user();
    }
    require MYBB_ROOT . 'inc/config.php';
    $db = db_connection($config);
    require MYBB_ROOT . 'inc/settings.php';
    $mybb->settings =& $settings;
    ob_start();
    $output->print_header($lang->finish_setup, 'finish');
    echo $lang->done_step_usergroupsinserted;
    // Insert all of our user groups from the XML file
    $usergroup_settings = file_get_contents(INSTALL_ROOT . 'resources/usergroups.xml');
    $parser = new XMLParser($usergroup_settings);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $admin_gid = '';
    $group_count = 0;
    foreach ($tree['usergroups'][0]['usergroup'] as $usergroup) {
        // usergroup[cancp][0][value]
        $new_group = array();
        foreach ($usergroup as $key => $value) {
            if (!is_array($value)) {
                continue;
            }
            $new_group[$key] = $db->escape_string($value[0]['value']);
        }
        $db->insert_query("usergroups", $new_group, false);
        // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs)
        if ($new_group['cancp'] == 1 && !$admin_gid) {
            $admin_gid = $usergroup['gid'][0]['value'];
        }
        $group_count++;
    }
    // Restart usergroup sequence with correct # of groups
    if ($config['database']['type'] == "pgsql") {
        $db->query("SELECT setval('{$config['database']['table_prefix']}usergroups_gid_seq', (SELECT max(gid) FROM {$config['database']['table_prefix']}usergroups));");
    }
    echo $lang->done . '</p>';
    echo $lang->done_step_admincreated;
    $now = TIME_NOW;
    $salt = random_str();
    $loginkey = generate_loginkey();
    $saltedpw = md5(md5($salt) . md5($mybb->get_input('adminpass')));
    $newuser = array('username' => $db->escape_string($mybb->get_input('adminuser')), 'password' => $saltedpw, 'salt' => $salt, 'loginkey' => $loginkey, 'email' => $db->escape_string($mybb->get_input('adminemail')), 'usergroup' => $admin_gid, 'regdate' => $now, 'lastactive' => $now, 'lastvisit' => $now, 'website' => '', 'icq' => '', 'aim' => '', 'yahoo' => '', 'skype' => '', 'google' => '', 'birthday' => '', 'signature' => '', 'allownotices' => 1, 'hideemail' => 0, 'subscriptionmethod' => '0', 'receivepms' => 1, 'pmnotice' => 1, 'pmnotify' => 1, 'buddyrequestspm' => 1, 'buddyrequestsauto' => 0, 'showimages' => 1, 'showvideos' => 1, 'showsigs' => 1, 'showavatars' => 1, 'showquickreply' => 1, 'invisible' => 0, 'style' => '0', 'timezone' => 0, 'dst' => 0, 'threadmode' => '', 'daysprune' => 0, 'regip' => $db->escape_binary(my_inet_pton(get_ip())), 'language' => '', 'showcodebuttons' => 1, 'tpp' => 0, 'ppp' => 0, 'referrer' => 0, 'buddylist' => '', 'ignorelist' => '', 'pmfolders' => '', 'notepad' => '', 'showredirect' => 1, 'usernotes' => '');
    $db->insert_query('users', $newuser);
    echo $lang->done . '</p>';
    echo $lang->done_step_adminoptions;
    $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml');
    $parser = new XMLParser($adminoptions);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $insertmodule = array();
    $db->delete_query("adminoptions");
    // Insert all the admin permissions
    foreach ($tree['adminoptions'][0]['user'] as $users) {
        $uid = $users['attributes']['uid'];
        foreach ($users['permissions'][0]['module'] as $module) {
            foreach ($module['permission'] as $permission) {
                $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value'];
            }
        }
        $defaultviews = array();
        foreach ($users['defaultviews'][0]['view'] as $view) {
            $defaultviews[$view['attributes']['type']] = $view['value'];
        }
        $adminoptiondata = array('uid' => (int) $uid, 'cpstyle' => '', 'notes' => '', 'permissions' => $db->escape_string(my_serialize($insertmodule)), 'defaultviews' => $db->escape_string(my_serialize($defaultviews)));
        $insertmodule = array();
        $db->insert_query('adminoptions', $adminoptiondata);
    }
    echo $lang->done . '</p>';
    // Automatic Login
    my_unsetcookie("sid");
    my_unsetcookie("mybbuser");
    my_setcookie('mybbuser', $uid . '_' . $loginkey, null, true);
    ob_end_flush();
    // Make fulltext columns if supported
    if ($db->supports_fulltext('threads')) {
        $db->create_fulltext_index('threads', 'subject');
    }
    if ($db->supports_fulltext_boolean('posts')) {
        $db->create_fulltext_index('posts', 'message');
    }
    echo $lang->done_step_cachebuilding;
    require_once MYBB_ROOT . 'inc/class_datacache.php';
    $cache = new datacache();
    $cache->update_version();
    $cache->update_attachtypes();
    $cache->update_smilies();
    $cache->update_badwords();
    $cache->update_usergroups();
    $cache->update_forumpermissions();
    $cache->update_stats();
    $cache->update_statistics();
    $cache->update_forums();
    $cache->update_moderators();
    $cache->update_usertitles();
    $cache->update_reportedcontent();
    $cache->update_awaitingactivation();
    $cache->update_mycode();
    $cache->update_profilefields();
    $cache->update_posticons();
    $cache->update_spiders();
    $cache->update_bannedips();
    $cache->update_banned();
    $cache->update_bannedemails();
    $cache->update_birthdays();
    $cache->update_groupleaders();
    $cache->update_threadprefixes();
    $cache->update_forumsdisplay();
    $cache->update("plugins", array());
    $cache->update("internal_settings", array('encryption_key' => random_str(32)));
    $cache->update_default_theme();
    $version_history = array();
    $dh = opendir(INSTALL_ROOT . "resources");
    while (($file = readdir($dh)) !== false) {
        if (preg_match("#upgrade([0-9]+).php\$#i", $file, $match)) {
            $version_history[$match[1]] = $match[1];
        }
    }
    sort($version_history, SORT_NUMERIC);
    $cache->update("version_history", $version_history);
    // Schedule an update check so it occurs an hour ago.  Gotta stay up to date!
    $update['nextrun'] = TIME_NOW - 3600;
    $db->update_query("tasks", $update, "tid='12'");
    $cache->update_update_check();
    $cache->update_tasks();
    echo $lang->done . '</p>';
    echo $lang->done_step_success;
    $written = 0;
    if (is_writable('./')) {
        $lock = @fopen('./lock', 'w');
        $written = @fwrite($lock, '1');
        @fclose($lock);
        if ($written) {
            echo $lang->done_step_locked;
        }
    }
    if (!$written) {
        echo $lang->done_step_dirdelete;
    }
    echo $lang->done_whats_next;
    $output->print_footer('');
}
Example #5
0
 /**
  * Verifies if a new password is valid or not.
  *
  * @return boolean True when valid, false when invalid.
  */
 function verify_password()
 {
     global $mybb;
     $user =& $this->data;
     // Always check for the length of the password.
     if (my_strlen($user['password']) < $mybb->settings['minpasswordlength'] || my_strlen($user['password']) > $mybb->settings['maxpasswordlength']) {
         $this->set_error('invalid_password_length', array($mybb->settings['minpasswordlength'], $mybb->settings['maxpasswordlength']));
         return false;
     }
     // Has the user tried to use their email address or username as a password?
     if ($user['email'] === $user['password'] || $user['username'] === $user['password']) {
         $this->set_error('bad_password_security');
         return false;
     }
     // See if the board has "require complex passwords" enabled.
     if ($mybb->settings['requirecomplexpasswords'] == 1) {
         // Complex passwords required, do some extra checks.
         // First, see if there is one or more complex character(s) in the password.
         if (!preg_match("/^.*(?=.{" . $mybb->settings['minpasswordlength'] . ",})(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).*\$/", $user['password'])) {
             $this->set_error('no_complex_characters', array($mybb->settings['minpasswordlength']));
             return false;
         }
     }
     // If we have a "password2" check if they both match
     if (isset($user['password2']) && $user['password'] !== $user['password2']) {
         $this->set_error("passwords_dont_match");
         return false;
     }
     // MD5 the password
     $user['md5password'] = md5($user['password']);
     // Generate our salt
     $user['salt'] = generate_salt();
     // Combine the password and salt
     $user['saltedpw'] = salt_password($user['md5password'], $user['salt']);
     // Generate the user login key
     $user['loginkey'] = generate_loginkey();
     return true;
 }
/**
 * Generates a new login key for a user.
 *
 * @param int $uid The uid of the user to update.
 * @return string The new login key.
 */
function update_loginkey($uid)
{
    global $db;
    $loginkey = generate_loginkey();
    $sql_array = array("loginkey" => $loginkey);
    $db->update_query("users", $sql_array, "uid='{$uid}'");
    return $loginkey;
}
Example #7
0
 function convert_data($data)
 {
     $insert_data = array();
     // phpBB 3 values
     $insert_data['usergroup'] = $this->board->get_group_id($data['user_id'], array("not_multiple" => true));
     $insert_data['additionalgroups'] = str_replace($insert_data['usergroup'], '', $this->board->get_group_id($data['user_id']));
     $insert_data['displaygroup'] = $this->board->get_group_id($data['user_id'], array("not_multiple" => true));
     $insert_data['import_usergroup'] = $this->board->get_group_id($data['user_id'], array("not_multiple" => true, "original" => true));
     $insert_data['import_additionalgroups'] = $this->board->get_group_id($data['user_id'], array("original" => true));
     $insert_data['import_displaygroup'] = $data['group_id'];
     $insert_data['import_uid'] = $data['user_id'];
     $insert_data['username'] = encode_to_utf8($data['username'], "users", "users");
     $insert_data['email'] = $data['user_email'];
     $insert_data['regdate'] = $data['user_regdate'];
     $insert_data['lastactive'] = $data['user_lastvisit'];
     $insert_data['lastvisit'] = $data['user_lastvisit'];
     $insert_data['website'] = $data['user_website'];
     $insert_data['avatardimensions'] = $data['user_avatar_width'] . '|' . $data['user_avatar_height'];
     if ($insert_data['avatardimensions'] == '0x0') {
         $insert_data['avatardimensions'] = '';
     }
     $insert_data['avatar'] = $data['avatar'];
     $insert_data['lastpost'] = $data['user_lastpost_time'];
     $birthday = '';
     $data['user_birthday'] = trim($data['user_birthday']);
     if (!empty($data['user_birthday'])) {
         $birthday_arr = explode('-', $data['user_birthday']);
         foreach ($birthday_arr as $bday_part) {
             if (substr($bday_part, 0, 1) == "0") {
                 $birthday .= substr($bday_part, 1);
             } else {
                 $birthday .= $bday_part;
             }
             $birthday .= "-";
         }
     }
     $insert_data['birthday'] = $birthday;
     $insert_data['icq'] = $data['user_icq'];
     $insert_data['aim'] = $data['user_aim'];
     $insert_data['yahoo'] = $data['user_yim'];
     $insert_data['msn'] = $data['user_msnm'];
     $insert_data['hideemail'] = $data['user_allow_viewemail'];
     $insert_data['invisible'] = $data['user_allow_viewonline'];
     $insert_data['allownotices'] = $data['user_notify'];
     if ($data['user_notify'] == 1) {
         $insert_data['subscriptionmethod'] = 2;
     } else {
         $insert_data['subscriptionmethod'] = 0;
     }
     $insert_data['receivepms'] = $data['user_allow_pm'];
     $insert_data['pmnotice'] = $data['user_notify_pm'];
     $insert_data['pmnotify'] = $data['user_notify_pm'];
     $insert_data['timeformat'] = $data['user_dateformat'];
     $insert_data['timezone'] = $data['user_timezone'];
     $insert_data['timezone'] = str_replace(array('.0', '.00'), array('', ''), $insert_data['timezone']);
     $insert_data['dst'] = $data['user_dst'];
     $insert_data['signature'] = encode_to_utf8($this->bbcode_parser->convert($data['user_sig'], $data['user_sig_bbcode_uid']), "users", "users");
     $insert_data['regip'] = $data['user_ip'];
     $insert_data['totalpms'] = $this->get_private_messages($data['user_id']);
     $insert_data['unreadpms'] = $data['user_unread_privmsg'];
     $insert_data['salt'] = $data['user_form_salt'];
     $insert_data['passwordconvert'] = $data['user_password'];
     $insert_data['passwordconverttype'] = 'phpbb3';
     $insert_data['loginkey'] = generate_loginkey();
     return $insert_data;
 }
Example #8
0
 /**
  * Verifies if a new password is valid or not.
  *
  * @return boolean True when valid, false when invalid.
  */
 function verify_password()
 {
     global $mybb;
     $user =& $this->data;
     // Always check for the length of the password.
     if (my_strlen($user['password']) < $mybb->settings['minpasswordlength'] || my_strlen($user['password']) > $mybb->settings['maxpasswordlength']) {
         $this->set_error('invalid_password_length', array($mybb->settings['minpasswordlength'], $mybb->settings['maxpasswordlength']));
         return false;
     }
     // See if the board has "require complex passwords" enabled.
     if ($mybb->settings['requirecomplexpasswords'] == 1) {
         // Complex passwords required, do some extra checks.
         // First, see if there is one or more complex character(s) in the password.
         if (!preg_match('#[\\W]+#', $user['password'])) {
             $this->set_error('no_complex_characters');
             return false;
         }
     }
     // If we have a "password2" check if they both match
     if (isset($user['password2']) && $user['password'] != $user['password2']) {
         $this->set_error("passwords_dont_match");
         return false;
     }
     // MD5 the password
     $user['md5password'] = md5($user['password']);
     // Generate our salt
     $user['salt'] = generate_salt();
     // Combine the password and salt
     $user['saltedpw'] = salt_password($user['md5password'], $user['salt']);
     // Generate the user login key
     $user['loginkey'] = generate_loginkey();
     return true;
 }
Example #9
0
isset($_GET["confirm"]) ? $confirm = $_GET["confirm"] : ($confirm = "");
if ($act == "") {
    die;
}
if ($act == "member_import" && $confirm == "yes") {
    $query = "SELECT u.id, u.username, u.id_level, u.password, u.email, UNIX_TIMESTAMP(u.joined) joined, u.cip, ul.id as real_level FROM {$TABLE_PREFIX}users u LEFT JOIN {$TABLE_PREFIX}users_level ul on u.id_level=ul.id WHERE u.id >1 GROUP BY u.id ORDER BY u.id ASC";
    $list = mysql_query($query);
    $count = mysql_num_rows($list);
    if ($count > 0) {
        @mysql_query("TRUNCATE TABLE {$mybb_prefix}users");
        while ($account = mysql_fetch_assoc($list)) {
            $username = $account["username"];
            $email = $account["email"];
            $salt = random_str(8);
            $pass = salt_password($account["password"], $salt);
            $key = generate_loginkey();
            $joined = time();
            $id_level = mybb_level_check($account["real_level"]);
            mysql_query("INSERT INTO {$mybb_prefix}users (`username`, `password`, `salt`,`loginkey`,`usergroup`,`email`, `regdate`,`regip`,`lastip`,`hideemail`,`receivepms`) VALUES ('{$username}', '{$pass}', '{$salt}','{$key}',{$id_level}, '{$email}',{$joined},'{$ip_address}','{$ip_address}',1,1)") or die(mysql_error());
            $fid = mysql_insert_id();
            mysql_query("UPDATE {$TABLE_PREFIX}users SET mybb_fid={$fid} where id=" . $account["id"]);
            mysql_query("UPDATE `{$mybb_prefix}settings` SET `value`=1 where `sid`=61");
            mysql_query("UPDATE `{$mybb_prefix}usergroups` SET `namestyle`='<span style=\"color: orangered;\"><strong>{username}</strong></span>' where `gid`=4");
            mysql_query("UPDATE `{$mybb_prefix}usergroups` SET `namestyle`='<span style=\"color: green;\"><strong>{username}</strong></span>' where `gid`=6");
            rebuild_stats();
            //rebuild users stats in forum
            $counter = $count;
            header("location:" . $_SERVER["PHP_SELF"] . "?act=completed&counter={$counter}");
        }
    }
} elseif ($act == "completed") {
Example #10
0
 /**
  * @param bool $strict
  *
  * @return bool
  */
 function verify_password($strict = true)
 {
     global $db, $mybb, $plugins;
     $this->get_login_data();
     if (empty($this->login_data['username'])) {
         // Username must be validated to apply a password to
         $this->invalid_combination();
         return false;
     }
     $args = array('this' => &$this, 'strict' => &$strict);
     $plugins->run_hooks('datahandler_login_verify_password_start', $args);
     $user =& $this->data;
     $password = md5($user['password']);
     if (!$this->login_data['uid'] || $this->login_data['uid'] && !$this->login_data['salt'] && $strict == false) {
         $this->invalid_combination();
     }
     if ($strict == true) {
         if (!$this->login_data['salt']) {
             // Generate a salt for this user and assume the password stored in db is a plain md5 password
             $this->login_data['salt'] = generate_salt();
             $this->login_data['password'] = salt_password($this->login_data['password'], $this->login_data['salt']);
             $sql_array = array("salt" => $this->login_data['salt'], "password" => $this->login_data['password']);
             $db->update_query("users", $sql_array, "uid = '{$this->login_data['uid']}'");
         }
         if (!$this->login_data['loginkey']) {
             $this->login_data['loginkey'] = generate_loginkey();
             $sql_array = array("loginkey" => $this->login_data['loginkey']);
             $db->update_query("users", $sql_array, "uid = '{$this->login_data['uid']}'");
         }
     }
     $salted_password = md5(md5($this->login_data['salt']) . $password);
     $plugins->run_hooks('datahandler_login_verify_password_end', $args);
     if ($salted_password !== $this->login_data['password']) {
         $this->invalid_combination(true);
         return false;
     }
     return true;
 }
Example #11
0
 function login($type, $uid, $password)
 {
     global $db;
     $password = trim($password);
     $return = false;
     switch ($type) {
         case 'vb3':
             $return = $this->authenticate_vb3($password);
             break;
         case 'ipb2':
             $return = $this->authenticate_ipb2($password);
             break;
         case 'smf11':
             $return = $this->authenticate_smf11($password);
             break;
         case 'smf2':
             $return = $this->authenticate_smf2($password);
             break;
         case 'smf':
             $return = $this->authenticate_smf($password);
             break;
         case 'punbb':
             $return = $this->authenticate_punbb($password);
             break;
         case 'phpbb3':
             $return = $this->authenticate_phpbb3($password);
             break;
         case 'bbpress':
             $return = $this->authenticate_bbpress($password);
             break;
         case 'mingle':
             $return = $this->authenticate_bbpress($password);
             break;
         default:
             return false;
     }
     if ($return == true) {
         // Generate a salt for this user and assume the password stored in db is empty
         $user['salt'] = generate_salt();
         $this->user['salt'] = $user['salt'];
         $user['password'] = salt_password(md5($password), $user['salt']);
         $this->user['password'] = $user['password'];
         $user['loginkey'] = generate_loginkey();
         $this->user['loginkey'] = $user['loginkey'];
         $user['passwordconverttype'] = '';
         $this->user['passwordconverttype'] = '';
         $user['passwordconvert'] = '';
         $this->user['passwordconvert'] = '';
         $user['passwordconvertsalt'] = '';
         $this->user['passwordconvertsalt'] = '';
         $db->update_query("users", $user, "uid='{$uid}'", 1);
         return $this->user;
     }
     return false;
 }
Example #12
0
function install_done()
{
    global $output, $db, $mybb, $errors, $cache, $lang;
    if (empty($mybb->input['adminuser'])) {
        $errors[] = $lang->admin_step_error_nouser;
    }
    if (empty($mybb->input['adminpass'])) {
        $errors[] = $lang->admin_step_error_nopassword;
    }
    if ($mybb->input['adminpass'] != $mybb->input['adminpass2']) {
        $errors[] = $lang->admin_step_error_nomatch;
    }
    if (empty($mybb->input['adminemail'])) {
        $errors[] = $lang->admin_step_error_noemail;
    }
    if (is_array($errors)) {
        create_admin_user();
    }
    require MYBB_ROOT . 'inc/config.php';
    $db = db_connection($config);
    require MYBB_ROOT . 'inc/settings.php';
    $mybb->settings =& $settings;
    ob_start();
    $output->print_header($lang->finish_setup, 'finish');
    echo $lang->done_step_usergroupsinserted;
    // Insert all of our user groups from the XML file
    $settings = file_get_contents(INSTALL_ROOT . 'resources/usergroups.xml');
    $parser = new XMLParser($settings);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $admin_gid = '';
    $group_count = 0;
    foreach ($tree['usergroups'][0]['usergroup'] as $usergroup) {
        // usergroup[cancp][0][value]
        $new_group = array();
        foreach ($usergroup as $key => $value) {
            if ($key == "gid" || !is_array($value)) {
                continue;
            }
            $new_group[$key] = $db->escape_string($value[0]['value']);
        }
        $return_gid = $db->insert_query("usergroups", $new_group);
        // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs)
        if ($new_group['cancp'] == 1 && !$admin_gid) {
            $admin_gid = $return_gid;
        }
        $group_count++;
    }
    echo $lang->done . '</p>';
    echo $lang->done_step_admincreated;
    $now = TIME_NOW;
    $salt = random_str();
    $loginkey = generate_loginkey();
    $saltedpw = md5(md5($salt) . md5($mybb->input['adminpass']));
    $newuser = array('username' => $db->escape_string($mybb->input['adminuser']), 'password' => $saltedpw, 'salt' => $salt, 'loginkey' => $loginkey, 'email' => $db->escape_string($mybb->input['adminemail']), 'usergroup' => $admin_gid, 'regdate' => $now, 'lastactive' => $now, 'lastvisit' => $now, 'website' => '', 'icq' => '', 'aim' => '', 'yahoo' => '', 'msn' => '', 'birthday' => '', 'signature' => '', 'allownotices' => 1, 'hideemail' => 0, 'subscriptionmethod' => '0', 'receivepms' => 1, 'pmnotice' => 1, 'pmnotify' => 1, 'remember' => 1, 'showsigs' => 1, 'showavatars' => 1, 'showquickreply' => 1, 'invisible' => 0, 'style' => '0', 'timezone' => 0, 'dst' => 0, 'threadmode' => '', 'daysprune' => 0, 'regip' => $db->escape_string(get_ip()), 'longregip' => intval(ip2long(get_ip())), 'language' => '', 'showcodebuttons' => 1, 'tpp' => 0, 'ppp' => 0, 'referrer' => 0, 'buddylist' => '', 'ignorelist' => '', 'pmfolders' => '', 'notepad' => '', 'showredirect' => 1);
    $db->insert_query('users', $newuser);
    echo $lang->done . '</p>';
    echo $lang->done_step_adminoptions;
    $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml');
    $parser = new XMLParser($adminoptions);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    $insertmodule = array();
    $db->delete_query("adminoptions");
    // Insert all the admin permissions
    foreach ($tree['adminoptions'][0]['user'] as $users) {
        $uid = $users['attributes']['uid'];
        foreach ($users['permissions'][0]['module'] as $module) {
            foreach ($module['permission'] as $permission) {
                $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value'];
            }
        }
        $defaultviews = array();
        foreach ($users['defaultviews'][0]['view'] as $view) {
            $defaultviews[$view['attributes']['type']] = $view['value'];
        }
        $adminoptiondata = array('uid' => intval($uid), 'cpstyle' => '', 'notes' => '', 'permissions' => $db->escape_string(serialize($insertmodule)), 'defaultviews' => $db->escape_string(serialize($defaultviews)));
        $insertmodule = array();
        $db->insert_query('adminoptions', $adminoptiondata);
    }
    echo $lang->done . '</p>';
    // Automatic Login
    my_unsetcookie("sid");
    my_unsetcookie("mybbuser");
    my_setcookie('mybbuser', $uid . '_' . $loginkey, null, true);
    ob_end_flush();
    // Make fulltext columns if supported
    if ($db->supports_fulltext('threads')) {
        $db->create_fulltext_index('threads', 'subject');
    }
    if ($db->supports_fulltext_boolean('posts')) {
        $db->create_fulltext_index('posts', 'message');
    }
    // Register a shutdown function which actually tests if this functionality is working
    add_shutdown('test_shutdown_function');
    echo $lang->done_step_cachebuilding;
    require_once MYBB_ROOT . 'inc/class_datacache.php';
    $cache = new datacache();
    $cache->update_version();
    $cache->update_attachtypes();
    $cache->update_smilies();
    $cache->update_badwords();
    $cache->update_usergroups();
    $cache->update_forumpermissions();
    $cache->update_stats();
    $cache->update_forums();
    $cache->update_moderators();
    $cache->update_usertitles();
    $cache->update_reportedposts();
    $cache->update_mycode();
    $cache->update_posticons();
    $cache->update_update_check();
    $cache->update_tasks();
    $cache->update_spiders();
    $cache->update_bannedips();
    $cache->update_banned();
    $cache->update_birthdays();
    $cache->update("plugins", array());
    $cache->update("internal_settings", array('encryption_key' => random_str(32)));
    echo $lang->done . '</p>';
    echo $lang->done_step_success;
    $written = 0;
    if (is_writable('./')) {
        $lock = @fopen('./lock', 'w');
        $written = @fwrite($lock, '1');
        @fclose($lock);
        if ($written) {
            echo $lang->done_step_locked;
        }
    }
    if (!$written) {
        echo $lang->done_step_dirdelete;
    }
    echo $lang->done_subscribe_mailing;
    $output->print_footer('');
}