function upgrade15_usernameupdate() { global $db, $output, $mybb, $plugins; $output->print_header("Performing Queries"); echo "<p>Performing username updates..</p>"; flush(); require_once MYBB_ROOT . "inc/datahandler.php"; require_once MYBB_ROOT . "inc/datahandlers/user.php"; // Load plugin system for datahandler require_once MYBB_ROOT . "inc/class_plugins.php"; $plugins = new pluginSystem(); $not_renameable = array(); // Because commas can cause some problems with private message sending in usernames we have to remove them $query = $db->simple_select("users", "uid, username", "username LIKE '%,%'"); while ($user = $db->fetch_array($query)) { $prefix = ''; $userhandler = new UserDataHandler('update'); do { $username = str_replace(',', '', $user['username']) . '_' . $prefix; $updated_user = array("uid" => $user['uid'], "username" => $username); $userhandler->set_data($updated_user); ++$prefix; } while (!$userhandler->verify_username() || $userhandler->verify_username_exists()); if (!$userhandler->validate_user()) { $not_renameable[] = htmlspecialchars_uni($user['username']); } else { $db->update_query("users", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); $db->update_query("posts", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); $db->update_query("threads", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); $db->update_query("threads", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'"); $db->update_query("forums", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'"); update_stats(array("numusers" => "+0")); } } if (!empty($not_renameable)) { echo "<span style=\"color: red;\">NOTICE:</span> The following users could not be renamed automatically. Please rename these users in the Admin CP manually after the upgrade process has finished completing:<br />\n\t\t<ul>\n\t\t<li>"; echo implode('</li>\\n<li>', $not_renameable); echo "</li>\n\t\t</ul>"; } $contents .= "Click next to continue with the upgrade process.</p>"; $output->print_contents($contents); $output->print_footer("15_done"); }
function upgrade15_usernameupdate() { global $db, $output, $mybb, $plugins; $output->print_header("Wykonywanie zapytań"); echo "<p>Trwa wykonywanie wymaganych zapytań do bazy danych...</p>"; flush(); require_once MYBB_ROOT . "inc/datahandler.php"; require_once MYBB_ROOT . "inc/datahandlers/user.php"; // Load plugin system for datahandler require_once MYBB_ROOT . "inc/class_plugins.php"; $plugins = new pluginSystem(); $not_renameable = array(); // Because commas can cause some problems with private message sending in usernames we have to remove them $query = $db->simple_select("users", "uid, username", "username LIKE '%,%'"); while ($user = $db->fetch_array($query)) { $prefix = ''; $userhandler = new UserDataHandler('update'); do { $username = str_replace(',', '', $user['username']) . '_' . $prefix; $updated_user = array("uid" => $user['uid'], "username" => $username); $userhandler->set_data($updated_user); ++$prefix; } while (!$userhandler->verify_username() || $userhandler->verify_username_exists()); if (!$userhandler->validate_user()) { $not_renameable[] = htmlspecialchars_uni($user['username']); } else { $db->update_query("users", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); $db->update_query("posts", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); $db->update_query("threads", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'"); $db->update_query("threads", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'"); $db->update_query("forums", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'"); update_stats(array("numusers" => "+0")); } } if (!empty($not_renameable)) { echo "<span style=\"color: red;\">OSTRZEŻENIE:</span> Poniższe loginy nie mogły zostać zmienione automatycznie. Zmień je ręcznie po zakończeniu procesu aktualizacji.<br />\n\t\t<ul>\n\t\t<li>"; echo implode('</li>\\n<li>', $not_renameable); echo "</li>\n\t\t</ul>"; } $contents .= "Naciśnij przycisk Dalej, aby kontynuować proces aktualizacji.</p>"; $output->print_contents($contents); $output->print_footer("15_done"); }
/** * Verifies the author of a post and fetches the username if necessary. * * @return boolean True if the author information is valid, false if invalid. */ function verify_author() { global $mybb; $post =& $this->data; // Don't have a user ID at all - not good (note, a user id of 0 will still work). if (!isset($post['uid'])) { $this->set_error("invalid_user_id"); return false; } else { if ($post['uid'] > 0 && empty($post['username'])) { $user = get_user($post['uid']); $post['username'] = $user['username']; } else { if ($post['uid'] == 0 && $post['username'] != $lang->guest) { // Set up user handler require_once MYBB_ROOT . "inc/datahandlers/user.php"; $userhandler = new UserDataHandler(); $data_array = array('username' => $post['username']); $userhandler->set_data($data_array); if (!$userhandler->verify_username()) { // invalid username $this->errors = array_merge($this->errors, $userhandler->get_errors()); return false; } if ($userhandler->verify_username_exists()) { // username is in use $this->errors = array_merge($this->errors, $userhandler->get_errors()); return false; } } } } // After all of this, if we still don't have a username, force the username as "Guest" (Note, this is not translatable as it is always a fallback) if (!$post['username']) { $post['username'] = "******"; } return true; }
function sign_in_func() { global $db, $lang, $theme, $plugins, $mybb, $session, $settings, $cache, $time, $mybbgroups, $mobiquo_config, $user, $register; // Load global language phrases $lang->load("member"); $parser = new postParser(); $token = trim($_POST['token']); $code = trim($_POST['code']); $username = $mybb->input['username']; $password = $mybb->input['password']; $post_email = $mybb->input['email']; $status = ''; if (!empty($token) && !empty($code)) { $result = tt_register_verify($token, $code); if ($result->result && !empty($result->email)) { $email = $result->email; if (!empty($post_email) && $post_email != $email) { $status = 3; } else { if ($user = tt_get_user_by_email($email)) { if (!empty($username) && strtolower($username) != strtolower($user['username'])) { $status = 3; } else { $register = 0; return tt_login_success(); } } else { if (!empty($username) && !empty($email)) { $profile = $result->profile; if ($mybb->settings['disableregs'] == 1) { error($lang->registrations_disabled); } // Set up user handler. require_once MYBB_ROOT . "inc/datahandlers/user.php"; $userhandler = new UserDataHandler("insert"); $birthday_arr = explode('-', $profile->birthday); $bday = array("day" => $birthday_arr[2], "month" => $birthday_arr[1], "year" => $birthday_arr[0]); $user_field = array('fid3' => ucfirst($profile->gender), 'fid1' => $profile->location, 'fid2' => $profile->description); if ($mybb->settings['regtype'] == "admin") { $usergroup = 5; } else { $usergroup = isset($mybb->settings['tapatalk_register_group']) ? $mybb->settings['tapatalk_register_group'] : 2; } // Set the data for the new user. $user = array("username" => $mybb->input['username'], "password" => $mybb->input['password'], "password2" => $mybb->input['password'], "email" => $email, "email2" => $email, "usergroup" => $usergroup, "referrer" => '', "timezone" => $mybb->settings['timezoneoffset'], "language" => '', "regip" => $session->ipaddress, "longregip" => my_ip2long($session->ipaddress), "coppa_user" => 0, "birthday" => $bday, "website" => $profile->link, "user_fields" => $user_field, "signature" => $profile->signature, "option" => array(), "regdate" => TIME_NOW, "lastvisit" => TIME_NOW); if (!empty($profile->avatar_url)) { $updated_avatar = tt_update_avatar_url($profile->avatar_url); } $userhandler->set_data($user); $userhandler->verify_birthday(); $userhandler->verify_options(); if ($userhandler->verify_username_exists()) { $status = 1; } else { if (!$userhandler->verify_password() || !$userhandler->verify_username()) { $errors = $userhandler->get_friendly_errors(); error($errors[0]); } else { $userhandler->set_validated(true); $user = $userhandler->insert_user(); if (!empty($updated_avatar)) { $db->update_query("users", $updated_avatar, "uid='" . $user['uid'] . "'"); } $register = 1; return tt_login_success(); } } } else { $status = 2; } } } } else { if (!$result->result) { if (!empty($result->result_text)) { error($result->result_text); } else { error("Tapatalk ID verify faile!"); } } } if (!empty($status)) { $response = new xmlrpcval(array('result' => new xmlrpcval(0, 'boolean'), 'result_text' => new xmlrpcval('', 'base64'), 'status' => new xmlrpcval($status, 'string')), 'struct'); return new xmlrpcresp($response); } } else { error("Invlaid params!"); } }