Ejemplo n.º 1
0
 /**
  * Verifies if a username is valid or invalid.
  *
  * @param boolean True when valid, false when invalid.
  */
 function verify_username()
 {
     global $mybb;
     $username =& $this->data['username'];
     require_once MYBB_ROOT . 'inc/functions_user.php';
     // Fix bad characters
     $username = trim_blank_chrs($username);
     $username = str_replace(array(unichr(160), unichr(173), unichr(0xca), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);
     // Remove multiple spaces from the username
     $username = preg_replace("#\\s{2,}#", " ", $username);
     // Check if the username is not empty.
     if ($username == '') {
         $this->set_error('missing_username');
         return false;
     }
     // Check if the username belongs to the list of banned usernames.
     if (is_banned_username($username, true)) {
         $this->set_error('banned_username');
         return false;
     }
     // Check for certain characters in username (<, >, &, commas and slashes)
     if (strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || strpos($username, ",") !== false || !validate_utf8_string($username, false, false)) {
         $this->set_error("bad_characters_username");
         return false;
     }
     // Check if the username is of the correct length.
     if ($mybb->settings['maxnamelength'] != 0 && my_strlen($username) > $mybb->settings['maxnamelength'] || $mybb->settings['minnamelength'] != 0 && my_strlen($username) < $mybb->settings['minnamelength']) {
         $this->set_error('invalid_username_length', array($mybb->settings['minnamelength'], $mybb->settings['maxnamelength']));
         return false;
     }
     return true;
 }
Ejemplo n.º 2
0
         echo json_encode($lang->complex_password_fails);
     } else {
         // Return nothing but an OK password if passes regex
         echo json_encode("true");
     }
     exit;
 } else {
     if ($mybb->input['action'] == "username_availability") {
         if (!verify_post_check($mybb->get_input('my_post_key'), true)) {
             xmlhttp_error($lang->invalid_post_code);
         }
         require_once MYBB_ROOT . "inc/functions_user.php";
         $username = $mybb->get_input('username');
         // Fix bad characters
         $username = trim_blank_chrs($username);
         $username = str_replace(array(unichr(160), unichr(173), unichr(0xca), dec_to_utf8(8238), dec_to_utf8(8237), dec_to_utf8(8203)), array(" ", "-", "", "", "", ""), $username);
         // Remove multiple spaces from the username
         $username = preg_replace("#\\s{2,}#", " ", $username);
         header("Content-type: application/json; charset={$charset}");
         if (empty($username)) {
             echo json_encode($lang->banned_characters_username);
             exit;
         }
         // Check if the username belongs to the list of banned usernames.
         $banned_username = is_banned_username($username, true);
         if ($banned_username) {
             echo json_encode($lang->banned_username);
             exit;
         }
         // Check for certain characters in username (<, >, &, and slashes)
         if (strpos($username, "<") !== false || strpos($username, ">") !== false || strpos($username, "&") !== false || my_strpos($username, "\\") !== false || strpos($username, ";") !== false || strpos($username, ",") !== false || !validate_utf8_string($username, false, false)) {
Ejemplo n.º 3
0
/**
 * Checks for the length of a string, mb strings accounted for
 *
 * @param string The string to check the length of.
 * @return int The length of the string.
 */
function my_strlen($string)
{
    global $lang;
    $string = preg_replace("#&\\#([0-9]+);#", "-", $string);
    if (strtolower($lang->settings['charset']) == "utf-8") {
        // Get rid of any excess RTL and LTR override for they are the workings of the devil
        $string = str_replace(dec_to_utf8(8238), "", $string);
        $string = str_replace(dec_to_utf8(8237), "", $string);
        // Remove dodgy whitespaces
        $string = str_replace(chr(0xca), "", $string);
    }
    $string = trim($string);
    if (function_exists("mb_strlen")) {
        $string_length = mb_strlen($string);
    } else {
        $string_length = strlen($string);
    }
    return $string_length;
}