當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StringHelper::generateToken方法代碼示例

本文整理匯總了PHP中StringHelper::generateToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP StringHelper::generateToken方法的具體用法?PHP StringHelper::generateToken怎麽用?PHP StringHelper::generateToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在StringHelper的用法示例。


在下文中一共展示了StringHelper::generateToken方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addPlayer

 public function addPlayer($args)
 {
     $model = new Player();
     $model->setAttributes($args);
     $model->token = StringHelper::generateToken(20, 30);
     $model->created_at = new CDbExpression('NOW()');
     if ($model->save(FALSE)) {
         return $model->id;
     }
     return FALSE;
 }
開發者ID:huynt57,項目名稱:quizder,代碼行數:11,代碼來源:Player.php

示例2: actionLogin

 public function actionLogin()
 {
     $this->retVal = new stdClass();
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $user_email = Yii::app()->request->getPost('user_email');
             $user_password = Yii::app()->request->getPost('user_password');
             $user = User::model()->findByAttributes(array('user_email' => $user_email));
             if ($user) {
                 if ($user->user_active == 0) {
                     $this->retVal->message = Yii::app()->params['USER_NOT_ACTIVATE'];
                     $this->retVal->success = FALSE;
                 } else {
                     //user existed, check password
                     if ($user->user_password == md5($user_password)) {
                         //token
                         $token = StringHelper::generateToken(16, 36);
                         $user->user_token = $token;
                         $user->token_created_date = date('Y-m-d H:i:s');
                         $date_token_expiry = strtotime("+30 minutes");
                         $user->token_expiry_date = date('Y-m-d H:i:s', $date_token_expiry);
                         $user->save(FALSE);
                         if ($user->save(FALSE)) {
                             $this->retVal->message = Yii::app()->params['LOGIN_MESSAGE_SUCCESS'];
                             $this->retVal->data = $user;
                             $this->retVal->token = $token;
                             $this->retVal->success = TRUE;
                         } else {
                             $this->retVal->message = Yii::app()->params['LOGIN_MESSAGE_FAIL'];
                             $this->retVal->success = FALSE;
                         }
                     } else {
                         //wrong device token
                         $this->retVal->message = Yii::app()->params['WRONG_PASSWORD'];
                         $this->retVal->success = FALSE;
                     }
                 }
             } else {
                 //user not existed
                 $this->retVal->message = Yii::app()->params['USER_NOT_EXIST'];
                 $this->retVal->success = FALSE;
             }
         } catch (exception $e) {
             $this->retVal->message = $e->getMessage();
         }
         echo CJSON::encode($this->retVal);
         Yii::app()->end();
     }
     $this->render('login');
 }
開發者ID:huynt57,項目名稱:uet_messenger,代碼行數:51,代碼來源:UserController.php

示例3: actionFb_login_result

 public function actionFb_login_result()
 {
     $facebook = $this->getFb();
     $access_token = $facebook->getAccessToken();
     $user = $facebook->api("me", "get", array("access_token" => $access_token));
     //check login tai day
     //print_r($user["id"]);
     //die();
     $user_facebook_exist = User::model()->findByAttributes(array('user_id_fb' => $user["id"]));
     if ($user_facebook_exist) {
         $token = StringHelper::generateToken(16, 36);
         $user_facebook_exist->user_token = $token;
         if (isset($user["name"])) {
             $user_facebook_exist->user_real_name = $user['name'];
         }
         if (isset($user["email"])) {
             $user_facebook_exist->username = $user['email'];
         }
         if (isset($user["quotes"])) {
             $user_facebook_exist->user_qoutes = $user["quotes"];
         }
         $user_facebook_exist->user_dob = $user["birthday"];
         $user_facebook_exist->user_avatar = "http://graph.facebook.com/" . $user["id"] . "/picture?type=large";
         $user_facebook_exist->user_hometown = @$user["hometown"]["name"];
         $user_facebook_exist->user_active = 1;
         $user_facebook_exist->save(FALSE);
         Yii::app()->session['user_avatar'] = $user_facebook_exist->user_avatar;
         Yii::app()->session['user_name'] = $user['name'];
         Yii::app()->session['token'] = $token;
         Yii::app()->session['user_id'] = $user_facebook_exist->user_id;
         $this->redirect(Yii::app()->createUrl('user?token=' . $token));
     } else {
         //   echo 'ok';
         //   die();
         $token = StringHelper::generateToken(16, 36);
         $user_facebook = new User();
         $user["password"] = "bluebee_facebook";
         if (isset($user["name"])) {
             $user_facebook->user_real_name = $user['name'];
         }
         if (isset($user["email"])) {
             $user_facebook->username = $user['email'];
         }
         $user_facebook->user_token = $token;
         $user_facebook->user_dob = $user["birthday"];
         $user_facebook->user_hometown = @$user["hometown"]["name"];
         $user_facebook->user_avatar = "http://graph.facebook.com/" . $user["id"] . "/picture?type=large";
         Yii::app()->session['user_avatar'] = "http://graph.facebook.com/" . $user["id"] . "/picture?type=large";
         Yii::app()->session['token'] = $token;
         Yii::app()->session['user_name'] = $user['name'];
         $user_facebook->user_id_fb = $user["id"];
         $user_facebook->user_active = 1;
         if (isset($user["quotes"])) {
             $user_facebook->user_qoutes = $user["quotes"];
         }
         $user_facebook->user_date_attend = date('d/m/Y');
         $user_facebook->save(FALSE);
         Yii::app()->session['user_id'] = $user_facebook->user_id;
         //return $user;
         $this->redirect(Yii::app()->createUrl('user?token=' . $token));
     }
 }
開發者ID:huynt57,項目名稱:bluebee-uet.com,代碼行數:62,代碼來源:WelcomePageController.php

示例4: actionRegisterProvider

 public function actionRegisterProvider()
 {
     header('Access-Control-Allow-Origin: *');
     header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
     $request = Yii::app()->request;
     try {
         $name = $request->getPost('name');
         $email = $request->getPost('email');
         $phone = $request->getPost('phone');
         $address = $request->getPost('address');
         $provider = new Provider();
         $provider->email = $email;
         $provider->phone = $phone;
         $provider->provider_name = $name;
         $provider->provider_address = $address;
         $token = StringHelper::generateToken(5, 25);
         $provider->token = $token;
         if ($provider->save(FALSE)) {
             $subject = 'Kích hoạt tài khoản provider Meboo của bạn';
             $to_email = $email;
             $from_email = 'hotro@meboo.vn';
             $from_name = 'Hỗ trợ Meboo';
             $message = 'Bấm vào đây để kích hoạt tài khoản Provider Meboo của bạn: http://doitac.meboo.vn/user/activate?token=' . $token;
             MailQueue::model()->addMailQueue($message, $from_email, $from_name, $to_email, $subject);
             ResponseHelper::JsonReturnSuccess('', 'Success');
         } else {
             ResponseHelper::JsonReturnError('', 'Error');
         }
     } catch (Exception $ex) {
         ResponseHelper::JsonReturnError($ex->getMessage(), 'Error');
     }
 }
開發者ID:huynt57,項目名稱:medlatec,代碼行數:32,代碼來源:UserController.php


注:本文中的StringHelper::generateToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。