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


PHP Invitation::setMysql方法代码示例

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


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

示例1: register

 /**
  * Register a new user in the system
  * @param username string Username
  * @param password1 string Password
  * @param password2 string Password verification
  * @param pin int 4 digit PIN code
  * @param email1 string Email address
  * @param email2 string Email confirmation
  * @return bool
  **/
 public function register($username, $password1, $password2, $pin, $email1 = '', $email2 = '', $tac = '', $strToken = '')
 {
     $this->debug->append("STA " . __METHOD__, 4);
     if ($tac != 1) {
         $this->setErrorMessage('You need to accept our <a href="' . $_SERVER['SCRIPT_NAME'] . '?page=tac" target="_blank">Terms and Conditions</a>');
         return false;
     }
     if (strlen($username) > 40) {
         $this->setErrorMessage('Username exceeding character limit');
         return false;
     }
     if (preg_match('/[^a-z_\\-0-9]/i', $username)) {
         $this->setErrorMessage('Username may only contain alphanumeric characters');
         return false;
     }
     if ($this->getEmail($email1)) {
         $this->setErrorMessage('This e-mail address is already taken');
         return false;
     }
     if (strlen($password1) < 8) {
         $this->setErrorMessage('Password is too short, minimum of 8 characters required');
         return false;
     }
     if ($password1 !== $password2) {
         $this->setErrorMessage('Password do not match');
         return false;
     }
     if (empty($email1) || !filter_var($email1, FILTER_VALIDATE_EMAIL)) {
         $this->setErrorMessage('Invalid e-mail address');
         return false;
     }
     if ($email1 !== $email2) {
         $this->setErrorMessage('E-mail do not match');
         return false;
     }
     if (!is_numeric($pin) || strlen($pin) > 4 || strlen($pin) < 4) {
         $this->setErrorMessage('Invalid PIN');
         return false;
     }
     if (isset($strToken) && !empty($strToken)) {
         if (!($aToken = $this->token->getToken($strToken, 'invitation'))) {
             $this->setErrorMessage('Unable to find token');
             return false;
         }
         // Circle dependency, so we create our own object here
         $invitation = new Invitation();
         $invitation->setMysql($this->mysqli);
         $invitation->setDebug($this->debug);
         $invitation->setLog($this->log);
         $invitation->setUser($this);
         $invitation->setConfig($this->config);
         if (!$invitation->setActivated($aToken['id'])) {
             $this->setErrorMessage('Unable to activate your invitation');
             return false;
         }
         if (!$this->token->deleteToken($strToken)) {
             $this->setErrorMessage('Unable to remove used token');
             $this->log->log("warn", "{$username} tried to register but failed to delete the invitation token");
             return false;
         }
     }
     if ($this->mysqli->query("SELECT id FROM {$this->table} LIMIT 1")->num_rows > 0) {
         !$this->setting->getValue('accounts_confirm_email_disabled') ? $is_locked = 1 : ($is_locked = 0);
         $is_admin = 0;
         $stmt = $this->mysqli->prepare("\n        INSERT INTO {$this->table} (username, pass, email, signup_timestamp, pin, api_key, is_locked)\n        VALUES (?, ?, ?, ?, ?, ?, ?)\n        ");
     } else {
         $is_locked = 0;
         $is_admin = 1;
         $stmt = $this->mysqli->prepare("\n        INSERT INTO {$this->table} (username, pass, email, signup_timestamp, pin, api_key, is_admin, is_locked)\n        VALUES (?, ?, ?, ?, ?, ?, 1, ?)\n        ");
     }
     // Create hashed strings using original string and salt
     $password_hash = $this->getHash($password1);
     $pin_hash = $this->getHash($pin);
     $apikey_hash = $this->getHash($username);
     $username_clean = strip_tags($username);
     $signup_time = time();
     if ($this->checkStmt($stmt) && $stmt->bind_param('sssissi', $username_clean, $password_hash, $email1, $signup_time, $pin_hash, $apikey_hash, $is_locked) && $stmt->execute()) {
         if (!$this->setting->getValue('accounts_confirm_email_disabled') && $is_admin != 1) {
             if ($token = $this->token->createToken('confirm_email', $stmt->insert_id)) {
                 $aData['username'] = $username_clean;
                 $aData['token'] = $token;
                 $aData['email'] = $email1;
                 $aData['subject'] = 'E-Mail verification';
                 if (!$this->mail->sendMail('register/confirm_email', $aData)) {
                     $this->setErrorMessage('Unable to request email confirmation: ' . $this->mail->getError());
                     return false;
                 }
                 return true;
             } else {
                 $this->setErrorMessage('Failed to create confirmation token');
//.........这里部分代码省略.........
开发者ID:xisi,项目名称:mpos-fusion,代码行数:101,代码来源:user.class.php


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