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