public function register($userName, $email, $password, $pwdChk, &$err = null) { $init_err = $err; Utils::checkEmail($email, $err); Utils::checkPassword($password, $err); if (strcmp($password, $pwdChk) !== 0) { $err[] = I18n::get("error_pwd_mismatch"); } $email = mb_strtolower($email, 'UTF-8'); $lowUsername = mb_strtolower($userName, 'UTF-8'); $others = $this->db->getUsersByUserNameOrEmail($lowUsername, $email); if ($others) { foreach ($others as $o) { if (strcmp(mb_strtolower($o["username"], 'UTF-8'), $lowUsername) == 0) { $err[] = I18n::get("error_username_already_taken"); } if (strcmp($o["email"], $email) == 0) { $err[] = I18n::get("error_email_already_taken"); } } } if ($init_err != $err) { return false; } $password = password_hash($password, PASSWORD_DEFAULT); $this->db->createUser($userName, $email, $password); return true; }