当前位置: 首页>>代码示例>>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;未经允许,请勿转载。