当前位置: 首页>>代码示例>>PHP>>正文


PHP UserUtil::isValidUsername方法代码示例

本文整理汇总了PHP中UserUtil::isValidUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP UserUtil::isValidUsername方法的具体用法?PHP UserUtil::isValidUsername怎么用?PHP UserUtil::isValidUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UserUtil的用法示例。


在下文中一共展示了UserUtil::isValidUsername方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValidUsername

 /**
  * Returns true if the given name is a valid username.
  * 
  * @param	string		$name		username
  * @return	boolean
  */
 public static function isValidUsername($name)
 {
     if (!UserUtil::isValidUsername($name)) {
         return false;
     }
     $length = mb_strlen($name);
     if ($length < REGISTER_USERNAME_MIN_LENGTH || $length > REGISTER_USERNAME_MAX_LENGTH) {
         return false;
     }
     if (!self::checkForbiddenUsernames($name)) {
         return false;
     }
     if (REGISTER_USERNAME_FORCE_ASCII) {
         if (!preg_match('/^[\\x20-\\x7E]+$/', $name)) {
             return false;
         }
     }
     return true;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:25,代码来源:UserRegistrationUtil.class.php

示例2: validate

 /**
  * @see	Form::validate()
  */
 public function validate()
 {
     parent::validate();
     // only for guests
     if (WCF::getUser()->userID == 0) {
         // username
         if (empty($this->username)) {
             throw new UserInputException('username');
         }
         if (!UserUtil::isValidUsername($this->username)) {
             throw new UserInputException('username', 'notValid');
         }
         if (!UserUtil::isAvailableUsername($this->username)) {
             throw new UserInputException('username', 'notAvailable');
         }
         WCF::getSession()->setUsername($this->username);
     } else {
         $this->username = WCF::getUser()->username;
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Bash-Database,代码行数:23,代码来源:NewsAddForm.class.php

示例3: validateUsername

 /**
  * Validates the username
  */
 protected function validateUsername()
 {
     if (!WCF::getUser()->userID) {
         if (empty($this->username)) {
             throw new UserInputException('username');
         }
         if (!UserUtil::isValidUsername($this->username)) {
             throw new UserInputException('username', 'notValid');
         }
         if (!UserUtil::isAvailableUsername($this->username)) {
             throw new UserInputException('username', 'notAvailable');
         }
         WCF::getSession()->setUsername($this->username);
     } else {
         $this->username = WCF::getUser()->username;
     }
 }
开发者ID:0xLeon,项目名称:com.leon.pokemon.cheatdatabase.core,代码行数:20,代码来源:CheatDatabaseEntryAddForm.class.php

示例4: createUser

 /**
  * Shows the page for creating the admin account.
  */
 protected function createUser()
 {
     $errorType = $errorField = $username = $email = $confirmEmail = $password = $confirmPassword = '';
     $username = '';
     $email = $confirmEmail = '';
     $password = $confirmPassword = '';
     if (isset($_POST['send']) || self::$developerMode) {
         if (isset($_POST['send'])) {
             if (isset($_POST['username'])) {
                 $username = StringUtil::trim($_POST['username']);
             }
             if (isset($_POST['email'])) {
                 $email = StringUtil::trim($_POST['email']);
             }
             if (isset($_POST['confirmEmail'])) {
                 $confirmEmail = StringUtil::trim($_POST['confirmEmail']);
             }
             if (isset($_POST['password'])) {
                 $password = $_POST['password'];
             }
             if (isset($_POST['confirmPassword'])) {
                 $confirmPassword = $_POST['confirmPassword'];
             }
         } else {
             $username = $password = $confirmPassword = 'root';
             $email = $confirmEmail = 'woltlab@woltlab.com';
         }
         // error handling
         try {
             // username
             if (empty($username)) {
                 throw new UserInputException('username');
             }
             if (!UserUtil::isValidUsername($username)) {
                 throw new UserInputException('username', 'notValid');
             }
             // e-mail address
             if (empty($email)) {
                 throw new UserInputException('email');
             }
             if (!UserUtil::isValidEmail($email)) {
                 throw new UserInputException('email', 'notValid');
             }
             // confirm e-mail address
             if ($email != $confirmEmail) {
                 throw new UserInputException('confirmEmail', 'notEqual');
             }
             // password
             if (empty($password)) {
                 throw new UserInputException('password');
             }
             // confirm e-mail address
             if ($password != $confirmPassword) {
                 throw new UserInputException('confirmPassword', 'notEqual');
             }
             // no errors
             // init database connection
             $this->initDB();
             // get language id
             $languageID = 0;
             $sql = "SELECT\tlanguageID\n\t\t\t\t\tFROM\twcf" . WCF_N . "_language\n\t\t\t\t\tWHERE\tlanguageCode = '" . escapeString(self::$selectedLanguageCode) . "'";
             $row = self::getDB()->getFirstRow($sql);
             if (isset($row['languageID'])) {
                 $languageID = $row['languageID'];
             }
             // create user
             $user = UserEditor::create($username, $email, $password, array(1, 3, 4), array(), array('languageID' => $languageID), array(), false);
             // go to next step
             $this->gotoNextStep('installPackages');
             exit;
         } catch (UserInputException $e) {
             $errorField = $e->getField();
             $errorType = $e->getType();
         }
     }
     WCF::getTPL()->assign(array('errorField' => $errorField, 'errorType' => $errorType, 'username' => $username, 'email' => $email, 'confirmEmail' => $confirmEmail, 'password' => $password, 'confirmPassword' => $confirmPassword, 'nextStep' => 'createUser'));
     WCF::getTPL()->display('stepCreateUser');
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:81,代码来源:WCFSetup.class.php

示例5: validateUsername

 /**
  * Throws a UserInputException if the username is not unique or not valid.
  * 
  * @param	string		$username
  */
 protected function validateUsername($username)
 {
     if (empty($username)) {
         throw new UserInputException('username');
     }
     // check for forbidden chars (e.g. the ",")
     if (!UserUtil::isValidUsername($username)) {
         throw new UserInputException('username', 'notValid');
     }
     // Check if username exists already.
     if (!UserUtil::isAvailableUsername($username)) {
         throw new UserInputException('username', 'notUnique');
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:19,代码来源:UserAddForm.class.php

示例6: isValidUsername

 /**
  * Returns true, if the given name is a valid username.
  * 
  * @param	string		$name		username
  * @return 	boolean
  */
 public static function isValidUsername($name)
 {
     $length = StringUtil::length($name);
     return UserUtil::isValidUsername($name) && $length >= REGISTER_USERNAME_MIN_LENGTH && $length <= REGISTER_USERNAME_MAX_LENGTH && self::checkForbiddenUsernames($name);
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:11,代码来源:UserRegistrationUtil.class.php

示例7: validateUsername

 /**
  * Validates the username.
  */
 protected function validateUsername()
 {
     // only for guests
     if (WCF::getUser()->userID == 0) {
         if (empty($this->username)) {
             throw new UserInputException('username');
         }
         if (!UserUtil::isValidUsername($this->username)) {
             throw new UserInputException('username', 'invalid');
         }
         if (!UserUtil::isAvailableUsername($this->username)) {
             throw new UserInputException('username', 'notUnique');
         }
         WCF::getSession()->register('username', $this->username);
     }
 }
开发者ID:Griborim,项目名称:de.incendium.cms.linklist,代码行数:19,代码来源:EntryAddForm.class.php


注:本文中的UserUtil::isValidUsername方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。