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


PHP Csrf::getCsrfToken方法代碼示例

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


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

示例1: process

 public function process($parameters)
 {
     $activation = new Activation();
     $csfr = new Csrf();
     $userId = $parameters[0];
     if (!$activation->checkIfIsAdminOfUser($_SESSION['id_user'], $userId)) {
         $this->redirect('error');
     }
     if (isset($_POST['sent'])) {
         if (!Csrf::validateCsrfRequest($_POST['csrf'])) {
             $this->messages[] = ['s' => 'error', 'cs' => 'Možný CSRF útok! Zkuste prosím aktivaci znovu', 'en' => 'Possible CSRF attack! Please try activation again'];
             $this->redirect('error');
         }
         $tariffId = $activation->sanitize($_POST['tariff']);
         $startDate = $activation->sanitize($_POST['startDate']);
         $result = $activation->validateForceActivationData($tariffId, $startDate);
         if ($result['s'] == 'success') {
             $result = $activation->forceActivateUser($activation->getUserEmailFromId($userId), $tariffId, $startDate);
         }
         $this->messages[] = $result;
         if ($result['s'] == 'success') {
             $this->redirect('payments/' . $userId);
         }
     }
     $this->data['csrf'] = $csfr->getCsrfToken();
     $this->data['tariffs'] = $activation->returnTariffsData($this->language);
     $this->header['title'] = ['cs' => 'Aktivace uživatele', 'en' => 'User activation'];
     $this->view = 'forceActivation';
 }
開發者ID:ParalelniPolis,項目名稱:TMS2,代碼行數:29,代碼來源:ForceActivationController.php

示例2: process

 function process($parameters)
 {
     $checkUsers = new CheckUsers();
     $userId = $_SESSION['id_user'];
     if (!$checkUsers->checkIfAdmin($userId)) {
         $this->redirect('error');
     }
     $members = $checkUsers->getMembers($userId, $this->language);
     $this->data['csrf'] = Csrf::getCsrfToken();
     $this->data['activeMemberMailList'] = $checkUsers->getActiveMemberMailList($members);
     $this->data['members'] = $members;
     $this->header['title'] = ['cs' => 'Ostatní členové', 'en' => 'Other members'];
     $this->view = 'checkUsers';
 }
開發者ID:vane00ssa,項目名稱:TMS2,代碼行數:14,代碼來源:CheckUsersController.php

示例3: process

 function process($parameters)
 {
     $changePersonals = new ChangePersonals();
     if (!$changePersonals->checkLogin()) {
         $this->redirect('error');
     }
     //if empty parameter, add the current user
     if (isset($parameters[0])) {
         $userId = $parameters[0];
     } else {
         $userId = $_SESSION['id_user'];
     }
     //if not admin of the right place, throw error
     if ($userId != $_SESSION['id_user'] && !$changePersonals->checkIfIsAdminOfUser($_SESSION['id_user'], $userId)) {
         $this->redirect('error');
     }
     //if form is sent
     if (isset($_POST['sent'])) {
         $data = $changePersonals->sanitize(['firstname' => $_POST['firstname'], 'surname' => $_POST['surname'], 'telephone' => $_POST['telephone'], 'address' => $_POST['address'], 'ic' => $_POST['ic'], 'p' => $_POST['p'], 'csrf' => $_POST['csrf']]);
         if (!Csrf::validateCsrfRequest($data['csrf'])) {
             $this->messages[] = ['s' => 'error', 'cs' => 'Možný CSRF útok! Zkuste prosím změnit údaje znovu', 'en' => 'Possible CSRF attack! Please try to change your personals again'];
         } else {
             $result = $changePersonals->validateData($data);
             if ($result['s'] == 'success') {
                 $fakturoid = new FakturoidWrapper();
                 //add fakturoid_id into data
                 $data['fakturoid_id'] = $fakturoid->getFakturoidIdFromUserId($userId);
                 if ($fakturoid->updateCustomer($data) == false) {
                     $result = ['s' => 'error', 'cs' => 'Bohužel se nepovedlo uložit data do Faktuoidu; zkus to prosím za pár minut', 'en' => 'Sorry, we didn\'n safe your data into Fakturoid; try it again after a couple of minutes please'];
                 } else {
                     $result = $changePersonals->changePersonalData($data, $userId);
                 }
             }
             $this->messages[] = $result;
         }
     }
     //data for form
     $userData = $changePersonals->getUserData($userId);
     $this->data = $userData['user'];
     $this->data['csrf'] = Csrf::getCsrfToken();
     $this->header['title'] = ['cs' => 'Změna osobních údajů', 'en' => 'Change personal information'];
     $this->view = 'changePersonals';
 }
開發者ID:ParalelniPolis,項目名稱:TMS2,代碼行數:43,代碼來源:ChangePersonalsController.php

示例4: process

 function process($parameters)
 {
     $changePersonals = new ChangePersonals();
     if (!$changePersonals->checkLogin()) {
         $this->redirect('error');
     }
     //if empty parameter, add there current user
     if (isset($parameters[0])) {
         $userId = $parameters[0];
     } else {
         $userId = $_SESSION['id_user'];
     }
     //if not admin of the right place, throw error
     if ($userId != $_SESSION['id_user'] && !$changePersonals->checkIfIsAdminOfUser($_SESSION['id_user'], $userId)) {
         $this->redirect('error');
     }
     //if form is sent
     if (isset($_POST['sent'])) {
         $data = $changePersonals->sanitize(['firstname' => $_POST['firstname'], 'surname' => $_POST['surname'], 'telephone' => $_POST['telephone'], 'address' => $_POST['address'], 'ic' => $_POST['ic'], 'p' => $_POST['p'], 'csrf' => $_POST['csrf']]);
         if (!Csrf::validateCsrfRequest($data['csrf'])) {
             $this->messages[] = ['s' => 'error', 'cs' => 'Možný CSRF útok! Zkuste prosím změnit údaje znovu', 'en' => 'Possible CSRF attack! Please try change your personals again'];
         } else {
             $result = $changePersonals->validateData($data);
             if ($result['s'] == 'success') {
                 $result = $changePersonals->changePersonalData($data, $userId);
             }
             $this->messages[] = $result;
         }
     }
     //data for form
     $user = $changePersonals->getUserData($userId, $this->language);
     $this->data = $user['user'];
     $this->data['csrf'] = Csrf::getCsrfToken();
     $this->header['title'] = ['cs' => 'Změna osobních údajů', 'en' => 'Change Personal info'];
     $this->view = 'changePersonals';
 }
開發者ID:vane00ssa,項目名稱:TMS2,代碼行數:36,代碼來源:ChangePersonalsController.php


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