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


PHP Token::model方法代码示例

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


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

示例1: actionPostNoticeReturn

 /**
  *  提交消息信息
  */
 public function actionPostNoticeReturn()
 {
     if (!isset($_REQUEST['userId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['noticeId']) || !isset($_REQUEST['status'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('userId'));
     $token = trim(Yii::app()->request->getParam('token'));
     $noticeId = trim(Yii::app()->request->getParam('noticeId'));
     $status = trim(Yii::app()->request->getParam('status'));
     if (!ctype_digit($user_id) || $user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     if (!ctype_digit($noticeId) || $noticeId < 1 || !Notice::model()->isExistNoticeId($noticeId, $user_id)) {
         $this->_return('MSG_ERR_FAIL_NOTICE');
     }
     if (!ctype_digit($status) || !in_array($status, array(1, 2, 3, 4))) {
         $this->_return('MSG_ERR_FAIL_NOTICE_STATUS');
     }
     // 验证token
     if (Token::model()->verifyToken($user_id, $token)) {
         $data = Notice::model()->postNoticeReturn($noticeId, $status);
         $this->_return('MSG_SUCCESS', $data);
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
开发者ID:hucongyang,项目名称:student_cnhutong,代码行数:29,代码来源:NoticeController.php

示例2: actionGetSubjectSchedule

 /**
  * 日历课程接口
  */
 public function actionGetSubjectSchedule()
 {
     if (!isset($_REQUEST['teacherId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['date'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('teacherId', null));
     $token = trim(Yii::app()->request->getParam('token', null));
     $date = trim(Yii::app()->request->getParam('date', null));
     if (!ctype_digit($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     // 用户名不存在,返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     // 验证日期格式合法
     if (!$this->isDate($date)) {
         $this->_return('MSG_ERR_FAIL_DATE_FORMAT');
     }
     $year = mb_substr($date, 0, 4, 'utf8');
     $month = mb_substr($date, 5, 2, 'utf8');
     $day = mb_substr($date, 8, 2, 'utf8');
     if (empty($year) || empty($month) || empty($day)) {
         $this->_return('MSG_ERR_FAIL_DATE_LESS');
     }
     // 验证token
     if (Token::model()->verifyToken($user_id, $token)) {
         // 获取日历课程
         $data = Lesson::model()->getSubjectSchedule($user_id, $year, $month, $day, $date);
         $this->_return('MSG_SUCCESS', $data);
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
开发者ID:hucongyang,项目名称:student_cnhutong,代码行数:37,代码来源:LessonController.php

示例3: actionGetStudentInfo

 /**
  * 获取学员详细信息
  */
 public function actionGetStudentInfo()
 {
     if (!isset($_REQUEST['teacherId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['studentId'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('teacherId', null));
     $token = trim(Yii::app()->request->getParam('token', null));
     $studentId = trim(Yii::app()->request->getParam('studentId', null));
     if (!ctype_digit($user_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //用户名不存在,返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     if (empty($studentId) || $studentId <= 0) {
         $this->_return('MSG_ERR_FAIL_STUDENT');
     }
     // 验证token
     if (Token::model()->verifyToken($user_id, $token)) {
         // 获取学员详细信息
         $data = Student::model()->getStudentInfo($studentId);
         if (!$data) {
             $this->_return('MSG_NO_STUDENT');
         }
         $this->_return('MSG_SUCCESS', $data);
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
开发者ID:hucongyang,项目名称:student_cnhutong,代码行数:33,代码来源:StudentController.php

示例4: beforeAction

 public function beforeAction($action)
 {
     $must_no_token_action = array('checkkey', 'resetpassword', 'lostpassword', 'getcourier', 'setdriverlocation', 'getcountry', 'uploadbarang', 'logindriver', 'login', 'register', 'logout', 'checkawb', 'suggestarea', 'suggestpostal', 'suggestdistrict', 'insertlocation');
     $can_no_token_action = array('getRates', 'requestOrder', 'getGroceryRate', 'requestPickUp');
     if (in_array($action->getId(), $must_no_token_action)) {
     } else {
         if (in_array($action->getId(), $can_no_token_action)) {
             if (isset($_REQUEST['key'])) {
                 $key = $_REQUEST['key'];
                 $token = Token::model()->findByAttributes(array('token' => $key));
                 if (!$token instanceof Token) {
                     echo CJSON::encode($this->statusError('wrong authentication key'));
                     Yii::app()->end();
                 }
                 $this->token = $token;
                 $customer = Customer::model()->findByPk($token->customer_id, 'is_allow_api = 1');
                 if (!$customer instanceof Customer) {
                     echo CJSON::encode($this->statusError('you\'re not permitted to this action'));
                     Yii::app()->end();
                 }
             }
         } else {
             if (!isset($_REQUEST['key'])) {
                 echo CJSON::encode($this->statusError('Key not found'));
                 Yii::app()->end();
             }
             $key = $_REQUEST['key'];
             if (!isset($key)) {
                 echo CJSON::encode($this->statusError('Please insert token'));
                 Yii::app()->end();
             }
             $token = Token::model()->findByAttributes(array('token' => $key));
             if ($token == null) {
                 echo CJSON::encode($this->statusError('Token Error'));
                 Yii::app()->end();
             } else {
                 $this->token = $token;
             }
             $token = Token::model()->findByAttributes(array('token' => $key));
             if (!$token instanceof Token) {
                 echo CJSON::encode($this->statusError('wrong authentication key'));
                 Yii::app()->end();
             }
             $this->token = $token;
             $customer = Customer::model()->findByPk($token->customer_id, 'is_allow_api = 1');
             if (!$customer instanceof Customer) {
                 echo CJSON::encode($this->statusError('you\'re not permitted to this action'));
                 Yii::app()->end();
             }
         }
     }
     return parent::beforeAction($action);
 }
开发者ID:aantonw,项目名称:dcourier.system,代码行数:53,代码来源:ServiceController.php

示例5: actiontokens

 function actiontokens($surveyid, $token, $langcode = '')
 {
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect(array('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Check that there is a SID
     // Get passed language from form, so that we dont loose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sBaseLanguage);
     } else {
         $sLanguageCode = sanitize_languagecode($sLanguageCode);
         Yii::import('application.libraries.Limesurvey_lang', true);
         $clang = new Limesurvey_lang($sLanguageCode);
         $sBaseLanguage = $sLanguageCode;
     }
     Yii::app()->lang = $clang;
     $aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
     if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         $sMessage = $clang->gT('This survey does not seem to exist.');
     } else {
         $oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
         if (!isset($oToken)) {
             $sMessage = $clang->gT('You are not a participant in this survey.');
         } else {
             if ($oToken->emailstatus == 'OptOut') {
                 $oToken->emailstatus = 'OK';
                 $oToken->save();
                 $sMessage = $clang->gT('You have been successfully added back to this survey.');
             } elseif ($oToken->emailstatus == 'OK') {
                 $sMessage = $clang->gT('You are already a part of this survey.');
             } else {
                 $sMessage = $clang->gT('You have been already removed from this survey.');
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$aSurveyInfo['templatedir']) {
         $sTemplate = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $sTemplate = getTemplatePath($aSurveyInfo['templatedir']);
     }
     $this->_renderHtml($sMessage, $sTemplate, $clang, $aSurveyInfo);
 }
开发者ID:josetorerobueno,项目名称:test_repo,代码行数:52,代码来源:OptinController.php

示例6: actiontokens

 function actiontokens($surveyid, $token, $langcode = '')
 {
     Yii::app()->loadHelper('database');
     Yii::app()->loadHelper('sanitize');
     $sLanguageCode = $langcode;
     $iSurveyID = $surveyid;
     $sToken = $token;
     $sToken = sanitize_token($sToken);
     if (!$iSurveyID) {
         $this->redirect(array('/'));
     }
     $iSurveyID = (int) $iSurveyID;
     //Check that there is a SID
     // Get passed language from form, so that we dont loose this!
     if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
         $sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
     } else {
         $sBaseLanguage = sanitize_languagecode($sLanguageCode);
     }
     Yii::app()->setLanguage($sBaseLanguage);
     $aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
     if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
         throw new CHttpException(404, "This survey does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
     } else {
         LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $token, false);
         $oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
         if (!isset($oToken)) {
             $sMessage = gT('You are not a participant in this survey.');
         } else {
             if ($oToken->emailstatus == 'OptOut') {
                 $oToken->emailstatus = 'OK';
                 $oToken->save();
                 $sMessage = gT('You have been successfully added back to this survey.');
             } elseif ($oToken->emailstatus == 'OK') {
                 $sMessage = gT('You are already a part of this survey.');
             } else {
                 $sMessage = gT('You have been already removed from this survey.');
             }
         }
     }
     //PRINT COMPLETED PAGE
     if (!$aSurveyInfo['templatedir']) {
         $sTemplate = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
     } else {
         $sTemplate = getTemplatePath($aSurveyInfo['templatedir']);
     }
     $this->_renderHtml($sMessage, $sTemplate, $aSurveyInfo);
 }
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:48,代码来源:OptinController.php

示例7: getUser

 public static function getUser()
 {
     $headers = apache_request_headers();
     if (!isset($headers['Authorization'])) {
         Helper::renderJSONErorr("Authorization is required");
     }
     $auth = $headers['Authorization'];
     $access_token = explode(' ', $auth);
     $access_token = end($access_token);
     $token = Token::model()->find('token=:token', array(':token' => $access_token));
     if (!$token) {
         Helper::renderJSONErorr("Bad access_token");
     }
     $user = User::model()->find('id=:id', array(':id' => $token->user));
     return $user;
 }
开发者ID:Alexnder,项目名称:angular-yii-rest-test,代码行数:16,代码来源:Helper.php

示例8: actionGetStudentInfo

 /**
  * 获取学员详细信息
  */
 public function actionGetStudentInfo()
 {
     if (!isset($_REQUEST['userId']) || !isset($_REQUEST['token']) || !isset($_REQUEST['memberId'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('userId', null));
     $token = trim(Yii::app()->request->getParam('token', null));
     $memberId = trim(Yii::app()->request->getParam('memberId', null));
     // 用户ID格式错误
     if (!ctype_digit($user_id)) {
         $this->_return('MSG_ERR_FAIL_USER');
     }
     // 用户不存在,返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     if (empty($memberId) || $memberId <= 0) {
         $this->_return('MSG_ERR_FAIL_STUDENT');
     }
     // 验证要添加的memberId是否和userId有绑定关系存在
     $existMemberId = User::model()->existUserIdMemberId($user_id, $memberId);
     if (!$existMemberId) {
         $this->_return('MSG_ERR_FAIL_MEMBER');
     }
     // 验证token
     if (Token::model()->verifyToken($user_id, $token)) {
         // 获取学员详细信息
         $data = Student::model()->getStudentInfo($memberId);
         if (!$data) {
             $this->_return('MSG_NO_MEMBER');
         }
         // 增加用户操作log
         $action_id = 2301;
         $params = '';
         foreach ($_REQUEST as $key => $value) {
             $params .= $key . '=' . $value . '&';
         }
         $params = substr($params, 0, -1);
         Log::model()->action_log($user_id, $action_id, $params);
         $this->_return('MSG_SUCCESS', $data);
     } else {
         $this->_return('MSG_ERR_TOKEN');
     }
 }
开发者ID:hucongyang,项目名称:student_cnhutong,代码行数:47,代码来源:StudentController.php

示例9: actionInviting

 /**
  * 拒绝/接受 好友邀请
  *
  * @param string $user_id
  * @param string $token
  * @param string $friend_id
  * @param string $status   1-已确认, 2-拒绝, 3-取消
  */
 public function actionInviting()
 {
     // 参数检查
     if (!isset($_REQUEST['user_id']) || !isset($_REQUEST['token']) || !isset($_REQUEST['friend_id']) || !isset($_REQUEST['status'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     $user_id = trim(Yii::app()->request->getParam('user_id'));
     $token = trim(Yii::app()->request->getParam('token'));
     $status = trim(Yii::app()->request->getParam('status'));
     $friend_id = trim(Yii::app()->request->getParam('friend_id'));
     if ($status != 1 && $status != 2 && $status != 3) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     if (!is_numeric($user_id) || !is_numeric($friend_id)) {
         $this->_return('MSG_ERR_FAIL_PARAM');
     }
     //用户不存在 返回错误
     if ($user_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //用户不存在 返回错误
     if ($friend_id < 1) {
         $this->_return('MSG_ERR_NO_USER');
     }
     //验证token
     if (!Token::model()->verifyToken($user_id, $token, $GLOBALS['__APPID'])) {
         $this->_return('MSG_ERR_TOKEN');
     }
     $ids = array();
     $ids = UserFriend::model()->newFriendMess($user_id);
     $friend = array();
     foreach ($ids as $id) {
         $friend[] = $id['friend_user_id'];
     }
     if (!in_array($friend_id, $friend)) {
         $this->_return('MSG_ERR_NO_FRIEND_REQ');
     }
     $friend_transaction = Yii::app()->db_friend->beginTransaction();
     try {
         UserFriend::model()->updateFriend($user_id, $friend_id, $status);
         $friend_transaction->commit();
         //log 日志
         $memo = $user_id . '|' . $friend_id . '|' . $status;
         Log::model()->_user_log($user_id, 'REPLY_INVITATION', date("Y-m-d H:i:s"), $memo);
     } catch (Exception $e) {
         error_log($e);
         $friend_transaction->rollback();
         $this->_return('MSG_ERR_UNKOWN');
     }
     $this->_return('MSG_SUCCESS');
 }
开发者ID:hucongyang,项目名称:goddess,代码行数:59,代码来源:FriendController.php

示例10: getAttributeValue

/**
* Retrieves the token attribute value from the related token table
*
* @param mixed $surveyid  The survey ID
* @param mixed $attrName  The token-attribute field name
* @param mixed $token  The token code
* @return string The token attribute value (or null on error)
*/
function getAttributeValue($surveyid, $attrName, $token)
{
    $attrName = strtolower($attrName);
    if (!tableExists('tokens_' . $surveyid)) {
        return null;
    }
    $token = Token::model($surveyid)->findByAttributes(array("token" => $token));
    return isset($token->{$attrName}) ? $token->{$attrName} : null;
}
开发者ID:GuillaumeSmaha,项目名称:LimeSurvey,代码行数:17,代码来源:common_helper.php

示例11: getSurveys_json

 /**
  * Returns surveys in json format
  *
  * @access public
  * @return void
  */
 public function getSurveys_json()
 {
     $this->getController()->loadHelper('surveytranslator');
     $dateformatdetails = getDateFormatData(Yii::app()->session['dateformat']);
     $oSurvey = new Survey();
     $oSurvey->permission(Yii::app()->user->getId());
     $aSurveys = $oSurvey->with(array('languagesettings' => array('condition' => 'surveyls_language=language'), 'owner'))->findAll();
     $aSurveyEntries = new stdClass();
     $aSurveyEntries->page = 1;
     foreach ($aSurveys as $rows) {
         if (!isset($rows->owner->attributes)) {
             $aOwner = array('users_name' => gT('(None)'));
         } else {
             $aOwner = $rows->owner->attributes;
         }
         $rows = array_merge($rows->attributes, $rows->defaultlanguage->attributes, $aOwner);
         $aSurveyEntry = array();
         // Set status
         if ($rows['active'] == "Y" && $rows['expires'] != '' && $rows['expires'] < dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust'))) {
             $aSurveyEntry[] = '<!--a--><img src="' . Yii::app()->getConfig('adminimageurl') . 'expired.png" alt="' . gT("This survey is active but expired.") . '" />';
         } elseif ($rows['active'] == "Y" && $rows['startdate'] != '' && $rows['startdate'] > dateShift(date("Y-m-d H:i:s"), "Y-m-d", Yii::app()->getConfig('timeadjust'))) {
             $aSurveyEntry[] = '<!--b--><img src="' . Yii::app()->getConfig('adminimageurl') . 'notyetstarted.png" alt="' . gT("This survey is active but has a start date.") . '" />';
         } elseif ($rows['active'] == "Y") {
             if (Permission::model()->hasSurveyPermission($rows['sid'], 'surveyactivation', 'update')) {
                 $aSurveyEntry[] = '<!--c--><a href="' . $this->getController()->createUrl('admin/survey/sa/deactivate/surveyid/' . $rows['sid']) . '"><img src="' . Yii::app()->getConfig('adminimageurl') . 'active.png" alt="' . gT("This survey is active - click here to stop this survey.") . '"/></a>';
             } else {
                 $aSurveyEntry[] = '<!--d--><img src="' . Yii::app()->getConfig('adminimageurl') . 'active.png" alt="' . gT("This survey is currently active.") . '" />';
             }
         } else {
             $condition = "sid={$rows['sid']} AND language='" . $rows['language'] . "'";
             $questionsCountResult = Question::model()->count($condition);
             if ($questionsCountResult > 0 && Permission::model()->hasSurveyPermission($rows['sid'], 'surveyactivation', 'update')) {
                 $aSurveyEntry[] = '<!--e--><a href="' . $this->getController()->createUrl('admin/survey/sa/activate/surveyid/' . $rows['sid']) . '"><img src="' . Yii::app()->getConfig('adminimageurl') . 'inactive.png" title="" alt="' . gT("This survey is currently not active - click here to activate this survey.") . '" /></a>';
             } else {
                 $aSurveyEntry[] = '<!--f--><img src="' . Yii::app()->getConfig('adminimageurl') . 'inactive.png" title="' . gT("This survey is currently not active.") . '" alt="' . gT("This survey is currently not active.") . '" />';
             }
         }
         //Set SID
         $aSurveyEntry[] = $rows['sid'];
         '<a href="' . $this->getController()->createUrl("/admin/survey/sa/view/surveyid/" . $rows['sid']) . '">' . $rows['sid'] . '</a>';
         //Set Title
         $aSurveyEntry[] = '<a href="' . $this->getController()->createUrl("/admin/survey/sa/view/surveyid/" . $rows['sid']) . '">' . CHtml::encode($rows['surveyls_title']) . '</a>';
         //Set Date
         Yii::import('application.libraries.Date_Time_Converter', true);
         $datetimeobj = new Date_Time_Converter($rows['datecreated'], "Y-m-d H:i:s");
         $aSurveyEntry[] = '<!--' . $rows['datecreated'] . '-->' . $datetimeobj->convert($dateformatdetails['phpdate']);
         //Set Owner
         if (Permission::model()->hasGlobalPermission('superadmin', 'read') || Yii::app()->session['loginID'] == $rows['owner_id']) {
             $aSurveyEntry[] = $rows['users_name'] . ' (<a class="ownername_edit" translate_to="' . gT('Edit') . '" id="ownername_edit_' . $rows['sid'] . '">' . gT('Edit') . '</a>)';
         } else {
             $aSurveyEntry[] = $rows['users_name'];
         }
         //Set Access
         if (tableExists('tokens_' . $rows['sid'])) {
             $aSurveyEntry[] = gT("Closed");
         } else {
             $aSurveyEntry[] = gT("Open");
         }
         //Set Anonymous
         if ($rows['anonymized'] == "Y") {
             $aSurveyEntry[] = gT("Yes");
         } else {
             $aSurveyEntry[] = gT("No");
         }
         //Set Responses
         if ($rows['active'] == "Y") {
             $cntResult = SurveyDynamic::countAllAndPartial($rows['sid']);
             $all = $cntResult['cntall'];
             $partial = $cntResult['cntpartial'];
             $aSurveyEntry[] = $all - $partial;
             $aSurveyEntry[] = $partial;
             $aSurveyEntry[] = $all;
             $aSurveyEntry['viewurl'] = $this->getController()->createUrl("/admin/survey/sa/view/surveyid/" . $rows['sid']);
             if (tableExists('tokens_' . $rows['sid'])) {
                 $summary = Token::model($rows['sid'])->summary();
                 $tokens = $summary['count'];
                 $tokenscompleted = $summary['completed'];
                 $aSurveyEntry[] = $tokens;
                 $aSurveyEntry[] = $tokens == 0 ? 0 : round($tokenscompleted / $tokens * 100, 1) . ' %';
             } else {
                 $aSurveyEntry[] = $aSurveyEntry[] = '';
             }
         } else {
             $aSurveyEntry[] = $aSurveyEntry[] = $aSurveyEntry[] = $aSurveyEntry[] = $aSurveyEntry[] = '';
         }
         $aSurveyEntries->rows[] = array('id' => $rows['sid'], 'cell' => $aSurveyEntry);
     }
     header('Content-type: application/json');
     echo ls_json_encode($aSurveyEntries);
 }
开发者ID:nicbon,项目名称:LimeSurvey,代码行数:96,代码来源:surveyadmin.php

示例12: tokensExport

function tokensExport($iSurveyID)
{
    $sEmailFiter = trim(App()->request->getPost('filteremail'));
    $iTokenStatus = App()->request->getPost('tokenstatus');
    $iInvitationStatus = App()->request->getPost('invitationstatus');
    $iReminderStatus = App()->request->getPost('reminderstatus');
    $sTokenLanguage = App()->request->getPost('tokenlanguage');
    $oSurvey = Survey::model()->findByPk($iSurveyID);
    $bIsNotAnonymous = $oSurvey->anonymized == 'N' && $oSurvey->active == 'Y';
    // db table exist (survey_$iSurveyID) ?
    $bquery = "SELECT * FROM {{tokens_{$iSurveyID}}} where 1=1";
    $databasetype = Yii::app()->db->getDriverName();
    if (trim($sEmailFiter) != '') {
        if (in_array($databasetype, array('mssql', 'sqlsrv', 'dblib'))) {
            $bquery .= ' and CAST(email as varchar) like ' . dbQuoteAll('%' . $_POST['filteremail'] . '%', true);
        } else {
            $bquery .= ' and email like ' . dbQuoteAll('%' . $_POST['filteremail'] . '%', true);
        }
    }
    if ($_POST['tokenstatus'] == 1) {
        $bquery .= " and completed<>'N'";
    } elseif ($iTokenStatus == 2) {
        $bquery .= " and completed='N'";
    } elseif ($iTokenStatus == 3 && $bIsNotAnonymous) {
        $bquery .= " and completed='N' and token not in (select token from {{survey_{$iSurveyID}}} group by token)";
    } elseif ($iTokenStatus == 4 && $bIsNotAnonymous) {
        $bquery .= " and completed='N' and token in (select token from {{survey_{$iSurveyID}}} group by token)";
    }
    if ($iInvitationStatus == 1) {
        $bquery .= " and sent<>'N'";
    }
    if ($iInvitationStatus == 2) {
        $bquery .= " and sent='N'";
    }
    if ($iReminderStatus == 1) {
        $bquery .= " and remindersent<>'N'";
    }
    if ($iReminderStatus == 2) {
        $bquery .= " and remindersent='N'";
    }
    if ($sTokenLanguage != '') {
        $bquery .= " and language=" . dbQuoteAll($sTokenLanguage);
    }
    $bquery .= " ORDER BY tid";
    Yii::app()->loadHelper('database');
    $bresult = Yii::app()->db->createCommand($bquery)->query();
    //dbExecuteAssoc($bquery) is faster but deprecated!
    //HEADERS should be after the above query else timeout errors in case there are lots of tokens!
    header("Content-Disposition: attachment; filename=tokens_" . $iSurveyID . ".csv");
    header("Content-type: text/comma-separated-values; charset=UTF-8");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Pragma: cache");
    // Export UTF8 WITH BOM
    $tokenoutput = chr(hexdec('EF')) . chr(hexdec('BB')) . chr(hexdec('BF'));
    $tokenoutput .= "tid,firstname,lastname,email,emailstatus,token,language,validfrom,validuntil,invited,reminded,remindercount,completed,usesleft";
    $attrfieldnames = getAttributeFieldNames($iSurveyID);
    $attrfielddescr = getTokenFieldsAndNames($iSurveyID, true);
    foreach ($attrfieldnames as $attr_name) {
        $tokenoutput .= ", {$attr_name}";
        if (isset($attrfielddescr[$attr_name])) {
            $tokenoutput .= " <" . str_replace(",", " ", $attrfielddescr[$attr_name]['description']) . ">";
        }
    }
    $tokenoutput .= "\n";
    echo $tokenoutput;
    $tokenoutput = "";
    // Export token line by line and fill $aExportedTokens with token exported
    Yii::import('application.libraries.Date_Time_Converter', true);
    $aExportedTokens = array();
    while ($brow = $bresult->read()) {
        if (trim($brow['validfrom'] != '')) {
            $datetimeobj = new Date_Time_Converter($brow['validfrom'], "Y-m-d H:i:s");
            $brow['validfrom'] = $datetimeobj->convert('Y-m-d H:i');
        }
        if (trim($brow['validuntil'] != '')) {
            $datetimeobj = new Date_Time_Converter($brow['validuntil'], "Y-m-d H:i:s");
            $brow['validuntil'] = $datetimeobj->convert('Y-m-d H:i');
        }
        $tokenoutput .= '"' . trim($brow['tid']) . '",';
        $tokenoutput .= '"' . trim($brow['firstname']) . '",';
        $tokenoutput .= '"' . trim($brow['lastname']) . '",';
        $tokenoutput .= '"' . trim($brow['email']) . '",';
        $tokenoutput .= '"' . trim($brow['emailstatus']) . '",';
        $tokenoutput .= '"' . trim($brow['token']) . '",';
        $tokenoutput .= '"' . trim($brow['language']) . '",';
        $tokenoutput .= '"' . trim($brow['validfrom']) . '",';
        $tokenoutput .= '"' . trim($brow['validuntil']) . '",';
        $tokenoutput .= '"' . trim($brow['sent']) . '",';
        $tokenoutput .= '"' . trim($brow['remindersent']) . '",';
        $tokenoutput .= '"' . trim($brow['remindercount']) . '",';
        $tokenoutput .= '"' . trim($brow['completed']) . '",';
        $tokenoutput .= '"' . trim($brow['usesleft']) . '",';
        foreach ($attrfieldnames as $attr_name) {
            $tokenoutput .= '"' . trim($brow[$attr_name]) . '",';
        }
        $tokenoutput = substr($tokenoutput, 0, -1);
        // remove last comma
        $tokenoutput .= "\n";
        echo $tokenoutput;
        $tokenoutput = '';
//.........这里部分代码省略.........
开发者ID:wrenchpilot,项目名称:LimeSurvey,代码行数:101,代码来源:export_helper.php

示例13: actionIosVerify

 /**
  * IOS IAP 支付验证
  * $uid
  * $token
  * $item_id
  * $receipt
  */
 public function actionIosVerify()
 {
     // error_log(json_encode($_POST));
     if (!isset($_REQUEST['receipt']) || !isset($_REQUEST['uid']) || !isset($_REQUEST['token']) || !isset($_REQUEST['trade_no'])) {
         $this->_return('MSG_ERR_LESS_PARAM');
     }
     /*沙盒测试开关,正式发布时,需置为false**********************************/
     $isSandbox = true;
     /********************************************************************/
     $receipt = Yii::app()->request->getParam('receipt');
     $uid = trim(Yii::app()->request->getParam('uid'));
     $token = trim(Yii::app()->request->getParam('token'));
     $trade_no = Yii::app()->request->getParam('trade_no');
     $now = date('Y-m-d H:i:s');
     if (!Token::model()->verifyToken($uid, $token, $GLOBALS['__APPID'])) {
         $this->_return('MSG_ERR_TOKEN');
         //#token 错误
     }
     $param = array('uid' => $uid, 'receipt' => $receipt, 'create_ts' => $now, 'trade_no' => $trade_no);
     $trade_info = Pay::model()->getTradeInfo($trade_no);
     if ($trade_info['uid'] != $uid || $trade_info['status'] != 0) {
         Pay::model()->recordIOSIAPInfo($param);
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, "无效或重复的订单");
         $this->_return('MSG_ISO_PAY_WRONG');
     }
     if ($isSandbox) {
         $endpoint = 'https://sandbox.itunes.apple.com/verifyReceipt';
     } else {
         $endpoint = 'https://buy.itunes.apple.com/verifyReceipt';
     }
     $postData = json_encode(array('receipt-data' => $receipt));
     $ch = curl_init($endpoint);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, true);
     //curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
     //curl_setopt($ch, CURLOPT_TIMEOUT, 30);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     //这两行一定要加,不加会报SSL 错误
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     $response = curl_exec($ch);
     $errno = curl_errno($ch);
     $errmsg = curl_error($ch);
     curl_close($ch);
     if ($errno != 0) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, trade_no, $errno . ">" . $errmsg);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_WRONG');
     }
     $param['verify_data'] = $response;
     $data = json_decode($response);
     if (!is_object($data)) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_WRONG', $now, $trade_no, '不能解析返回数据>' . $response);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_WRONG');
         //throw new Exception('Invalid response data');
     }
     if (!isset($data->status) || $data->status != 0) {
         Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_FAIL', $now, $trade_no);
         Pay::model()->recordIOSIAPInfo($param);
         $this->_return('MSG_ISO_PAY_FAIL');
     }
     $add_coin = $trade_info['coin'] + $trade_info['free'];
     Pay::model()->iosPaySuccess($uid, $trade_no, $add_coin);
     Pay::model()->recordIOSIAPInfo($param);
     Log::model()->_pay_log($uid, 'ORDER_IOS_IAP_VERIFY_OK', $now, $trade_no);
     $res = array('gold' => $add_coin);
     $this->_return('MSG_SUCCESS', $res);
 }
开发者ID:hucongyang,项目名称:goddess,代码行数:76,代码来源:PayController.php

示例14: list_participants

 /**
  * RPC Routine to return the ids and info  of token/participants of a survey.
  * if $bUnused is true, user will get the list of not completed tokens (token_return functionality).
  * Parameters iStart and ilimit are used to limit the number of results of this call.
  * Parameter aAttributes is an optional array containing more attribute that may be requested
  *
  * @access public
  * @param string $sSessionKey Auth credentials
  * @param int $iSurveyID Id of the survey to list participants
  * @param int $iStart Start id of the token list
  * @param int  $iLimit Number of participants to return
  * @param bool $bUnused If you want unused tokens, set true
  * @param bool|array $aAttributes The extented attributes that we want
  * @return array The list of tokens
  */
 public function list_participants($sSessionKey, $iSurveyID, $iStart = 0, $iLimit = 10, $bUnused = false, $aAttributes = false)
 {
     if ($this->_checkSessionKey($sSessionKey)) {
         $oSurvey = Survey::model()->findByPk($iSurveyID);
         if (!isset($oSurvey)) {
             return array('status' => 'Error: Invalid survey ID');
         }
         if (Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
             if (!tableExists("{{tokens_{$iSurveyID}}}")) {
                 return array('status' => 'Error: No token table');
             }
             if ($bUnused) {
                 $oTokens = Token::model($iSurveyID)->incomplete()->findAll(array('limit' => $iLimit, 'offset' => $iStart));
             } else {
                 $oTokens = Token::model($iSurveyID)->findAll(array('limit' => $iLimit, 'offset' => $iStart));
             }
             if (count($oTokens) == 0) {
                 return array('status' => 'No Tokens found');
             }
             if ($aAttributes) {
                 $aBasicDestinationFields = Token::model($iSurveyID)->tableSchema->columnNames;
                 $aTokenProperties = array_intersect($aAttributes, $aBasicDestinationFields);
                 $currentAttributes = array('tid', 'token', 'firstname', 'lastname', 'email');
                 $extendedAttributes = array_diff($aTokenProperties, $currentAttributes);
             }
             foreach ($oTokens as $token) {
                 $aTempData = array('tid' => $token->primarykey, 'token' => $token->attributes['token'], 'participant_info' => array('firstname' => $token->attributes['firstname'], 'lastname' => $token->attributes['lastname'], 'email' => $token->attributes['email']));
                 foreach ($extendedAttributes as $sAttribute) {
                     $aTempData[$sAttribute] = $token->attributes[$sAttribute];
                 }
                 $aData[] = $aTempData;
             }
             return $aData;
         } else {
             return array('status' => 'No permission');
         }
     } else {
         return array('status' => 'Invalid Session Key');
     }
 }
开发者ID:jgianpiere,项目名称:lime-survey,代码行数:55,代码来源:remotecontrol_handle.php

示例15: list_participants

 /**
  * RPC Routine to return the ids and info  of token/participants of a survey.
  * if $bUnused is true, user will get the list of not completed tokens (token_return functionality).
  * Parameters iStart and ilimit are used to limit the number of results of this call.
  *
  * @access public
  * @param string $sSessionKey Auth credentials
  * @param int $iSurveyID Id of the survey to list participants
  * @param int $iStart Start id of the token list
  * @param int  $iLimit Number of participants to return
  * @param bool $bUnused If you want unused tokensm, set true
  * @return array The list of tokens
  */
 public function list_participants($sSessionKey, $iSurveyID, $iStart = 0, $iLimit = 10, $bUnused = false)
 {
     if ($this->_checkSessionKey($sSessionKey)) {
         $oSurvey = Survey::model()->findByPk($iSurveyID);
         if (!isset($oSurvey)) {
             return array('status' => 'Error: Invalid survey ID');
         }
         if (Permission::model()->hasSurveyPermission($iSurveyID, 'tokens', 'read')) {
             if (!tableExists("{{tokens_{$iSurveyID}}}")) {
                 return array('status' => 'Error: No token table');
             }
             if ($bUnused) {
                 $oTokens = Token::model($iSurveyID)->incomplete()->findAll(array('limit' => $iLimit, 'offset' => $iStart));
             } else {
                 $oTokens = Token::model($iSurveyID)->findAll(array('limit' => $iLimit, 'offset' => $iStart));
             }
             if (count($oTokens) == 0) {
                 return array('status' => 'No Tokens found');
             }
             // Author: LS Dev Tw@s
             // DON'T USE THIS! IT DOESN'T WORK!!!
             //return array('status' => 'Tokens not found');
             //return array('status' => json_encode($oTokens));
             foreach ($oTokens as $token) {
                 $aData[] = array('tid' => $token->primarykey, 'token' => $token->attributes['token'], 'participant_info' => array('firstname' => $token->attributes['firstname'], 'lastname' => $token->attributes['lastname'], 'email' => $token->attributes['email'], 'usesleft' => $token->attributes['usesleft'], 'sent' => $token->attributes['sent'], 'remindedsent' => $token->attributes['remindersent'], 'remindercount' => $token->attributes['remindercount'], 'completed' => $token->attributes['completed']));
             }
             return $aData;
         } else {
             return array('status' => 'No permission');
         }
     } else {
         return array('status' => 'Invalid Session Key');
     }
 }
开发者ID:sevenearths,项目名称:limesurvey-api-test,代码行数:47,代码来源:remotecontrol_handle.php


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