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


PHP Token::checkToken方法代码示例

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


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

示例1: savePwd

 public function savePwd($userId)
 {
     if (!Auth::compareIds($userId, App::$instance)) {
         $this->error('403');
     }
     Token::checkToken();
     $request = Request::createFromGlobals();
     $request = $request->request;
     //check pass
     $this->validator->validate(['Старый пароль' => [$request->get('old_pwd'), 'required'], 'Новый_пароль' => [$request->get('new_pwd'), 'required|min(5)|max(25)|pwd'], 'Новый пароль подтверждение' => [$request->get('new_pwd_confirm'), 'required|matches(Новый_пароль)']]);
     //if no passes
     if (!$this->validator->passes()) {
         App::$instance->MQ->setMessage($this->validator->errors()->all());
         ST::redirect("back");
     }
     $oldPwd = md5($request->get('old_pwd'));
     if (User::where("id", $userId)->where('password', $oldPwd)->count()) {
         $user = User::find($userId);
         $user->password = md5($request->get('new_pwd'));
         try {
             $user->save();
         } catch (Exception $e) {
             App::$instance->MQ->setMessage('Ошибка при сохранении');
         }
         App::$instance->MQ->setMessage('Пароль обновлен');
         ST::redirect("back");
     } else {
         App::$instance->MQ->setMessage('Старый пароль введен не верно');
         ST::redirect("back");
     }
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:31,代码来源:AuthNew_controller.php

示例2: store

 public function store()
 {
     Token::checkToken();
     $xml = new SimpleXMLElement('<root/>');
     //        dump($this->request->request->get('modules'));
     //        die;
     if ($this->request->request->has('modules')) {
         foreach ($this->request->request->get('modules') as $module) {
             $this->validator->validate(['name' => [$module['name'], 'required|max(255)'], 'description' => [$module['description'], 'required|max(560)'], 'help' => [$module['help'], 'required|max(1000)'], 'value' => [$module['value'], 'between(0,1)']]);
             //if no passes
             if (!$this->validator->passes()) {
                 $this->putUserDataAtBackPack($this->request);
                 App::$instance->MQ->setMessage($this->validator->errors()->all());
                 ST::redirect("back");
             }
             $srvXml = $xml->addChild('module');
             $srvXml->addAttribute('name', $module['name']);
             $srvXml->addAttribute('description', $module['name']);
             $srvXml->addAttribute('help', $module['help']);
             $srvXml->addAttribute('value', intval($module['value']));
         }
     }
     $xml->asXML("config/modules-cfg.xml");
     App::$instance->MQ->setMessage('Список обновлен');
     App::$instance->log->logWrite(LOG_CONFIG_CHANGE, 'Изменен список модулей системы');
     ST::redirect("back");
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:27,代码来源:Modules_controller.php

示例3: login

 public function login()
 {
     $categories = $this->category->getAllCategories();
     $Products = $this->product->getAllProducts();
     if (isset($_POST['submit'])) {
         //$user =$this->loadModel('UserModel');
         $validator = $this->loadModel('Validator');
         $this->security->post_secx();
         // get data
         $validator->setData('input_user', htmlentities($_POST['userName'], ENT_QUOTES));
         $validator->setData('input_pass', htmlentities($_POST['password'], ENT_QUOTES));
         // validate data
         if ($_POST['userName'] == '' || $_POST['password'] == '') {
             // show error
             if ($_POST['userName'] == '') {
                 $validator->setData('error_user', 'required field!');
             }
             if ($_POST['password'] == '') {
                 $validator->setData('error_pass', 'required field!');
             }
             require APP . 'view/user/login.php';
         }
         if (Token::checkToken($_POST['token']) == true) {
             $result = $this->user->validateUser($validator->getData('input_user'), $validator->getData('input_pass'));
             switch ($result) {
                 case 'valid':
                     header('location:' . URL);
                     break;
                 case 'invalid':
                     $validator->setData('login_fail', 'invalid user or password');
                     require APP . 'view/user/login.php';
                     break;
                 case 'blocked':
                     $validator->setData('login_fail', 'you are blocked for 30 minutes');
                     require APP . 'view/user/login.php';
                     break;
                 default:
                     # code...
                     break;
             }
         }
     } else {
         require APP . 'view/user/login.php';
     }
 }
开发者ID:Jakub41,项目名称:Web-Development,代码行数:45,代码来源:user.php

示例4: update

 public function update($id)
 {
     Auth::isAdminOrDie(App::$instance);
     Token::checkToken();
     $request = $this->request->request;
     $this->validator->validate(['Префикс' => [$request->get('prefix'), 'required|int'], 'Название' => [$request->get('name'), 'required|max(255)']]);
     //if no passes
     if (!$this->validator->passes()) {
         App::$instance->MQ->setMessage($this->validator->errors()->all());
         ST::redirect("back");
     }
     $dep = Department::findOrFail($id);
     $dep->fill($request->all());
     $dep->save();
     App::$instance->MQ->setMessage("Успешно отредактировано");
     App::$instance->log->logWrite(LOG_CONFIG_CHANGE, 'Подразделение отредактировано' . $dep->name);
     ST::redirectToRoute('Departments/index');
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:18,代码来源:Departments_controller.php

示例5: update

 public function update($id)
 {
     $this->isDefaultUserIteractBlock($id);
     Auth::isAdminOrDie(App::$instance);
     Token::checkToken();
     $request = $this->request->request;
     $this->validator->validate(['Название' => [$request->get('name'), 'required|max(255)']]);
     //if no passes
     if (!$this->validator->passes()) {
         App::$instance->MQ->setMessage($this->validator->errors()->all());
         ST::redirect("back");
     }
     $nitiator = Initiator::findOrFail($id);
     $nitiator->fill($request->all());
     $nitiator->save();
     App::$instance->MQ->setMessage("Успешно отредактировано");
     App::$instance->log->logWrite(LOG_CONFIG_CHANGE, 'Инициатор отредактирован' . $nitiator->name);
     ST::redirectToRoute('Initiators/index');
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:19,代码来源:Initiators_controller.php

示例6: addCommment

 public function addCommment()
 {
     if (isset($_POST['submit'])) {
         $productId = $_POST['productId'];
         $validator = $this->loadModel('Validator');
         $Products = $this->product->getProductById($productId);
         $Comments = $this->comment->getAllCommentsByProductId($productId);
         $this->security->post_secx();
         $validator->setData('input_productId', htmlentities($_POST['productId'], ENT_QUOTES));
         $validator->setData('input_name', htmlentities($_POST['name'], ENT_QUOTES));
         $validator->setData('input_email', htmlentities($_POST['email'], ENT_QUOTES));
         $validator->setData('input_comments', htmlentities($_POST['comments'], ENT_QUOTES));
         if ($_POST['name'] == '' || $_POST['email'] == '' || $_POST['comments'] == '') {
             // show error
             if ($_POST['name'] == '') {
                 $validator->setData('error_name', 'required field!');
             }
             if ($_POST['email'] == '') {
                 $validator->setData('error_email', 'required field!');
             }
             if ($_POST['comments'] == '') {
                 $validator->setData('error_comments', 'required field!');
             }
             require APP . 'view/product/productDetails.php';
             //header('location:'.URL.'Product/ProductDetails?id='.$productId);
         } else {
             if (!preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\\._-]+)+\$/", $_POST['email'])) {
                 $validator->setData('error_email', 'invalid email');
                 require APP . 'view/product/productDetails.php';
             } else {
                 if (Token::checkToken($_POST['token']) == true) {
                     $this->comment->addNewComment($validator->getData('input_productId'), $validator->getData('input_comments'), $validator->getData('input_name'), $validator->getData('input_email'));
                     header('location:' . URL . 'product/productDetails?id=' . $productId);
                 }
             }
         }
     }
 }
开发者ID:Jakub41,项目名称:Web-Development,代码行数:38,代码来源:comment.php

示例7: storeHelp

 public function storeHelp()
 {
     Token::checkToken();
     $xml = new SimpleXMLElement('<root/>');
     if ($this->request->request->has('help')) {
         foreach ($this->request->request->get('help') as $help) {
             $this->validator->validate([$help['humanized'] => [$help['content'], 'required|max(320)']]);
             //if no passes
             if (!$this->validator->passes()) {
                 $this->putUserDataAtBackPack($this->request);
                 App::$instance->MQ->setMessage($this->validator->errors()->all());
                 ST::redirect("back");
             }
             $srvXml = $xml->addChild('element');
             $srvXml->addChild('humanized', $help['humanized']);
             $srvXml->addChild('name', $help['name']);
             $srvXml->addChild('content', $help['content']);
         }
         $xml->asXML("config/help_standart.xml");
         App::$instance->MQ->setMessage('Список обновлен');
         App::$instance->log->logWrite(LOG_CONFIG_CHANGE, 'изменены сообщения помощи');
     } else {
         App::$instance->MQ->setMessage('Нет обязательного параметра');
     }
     return ST::redirectToRoute('index/index');
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:26,代码来源:Settings_controller.php

示例8: storeColors

 public function storeColors()
 {
     Token::checkToken();
     if ($this->request->request->has('color')) {
         //            dump($this->request->request->get('color'));
         foreach ($this->request->request->get('color') as $color) {
             //                dump($color);
             //                die;
             $this->validator->validate(['Имя плашки для ' . $color['name'] => [$color['name'], 'required'], 'Описание для ' . $color['name'] => [$color['description'], 'required'], 'Фоновый цвет в ' . $color['name'] => [$color['backgroundColor'], 'required'], 'Цвет границы ' . $color['name'] => [$color['borderColor'], 'required'], 'Цвет текста ' . $color['name'] => [$color['textColor'], 'required']]);
             //if no passes
             if (!$this->validator->passes()) {
                 $this->putUserDataAtBackPack($this->request);
                 App::$instance->MQ->setMessage($this->validator->errors()->all());
                 ST::redirect("back");
             }
         }
         //prepare for json save
         $result = array();
         foreach ($this->request->request->get('color') as $color) {
             $result[$color['name']] = array('description' => $color['description'], 'backgroundColor' => "#" . $color['backgroundColor'], 'borderColor' => "#" . $color['borderColor'], 'textColor' => "#" . $color['textColor']);
         }
         $result = array_merge($this->getDefaultColors(), $result);
         //            dump($result);
         //            die;
         $user = User::find(App::$instance->user->id);
         $user->colors = json_encode($result);
         $user->save();
         App::$instance->user->colors = json_encode($result);
         App::$instance->MQ->setMessage('Цветовая схема обновлена');
     } else {
         App::$instance->MQ->setMessage('Не задан обязательный элемент, цветвоая схема не сохранена');
     }
     ST::redirect("back");
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:34,代码来源:User_controller.php

示例9: joinCaCreate

 public function joinCaCreate($referral = false)
 {
     Token::checkToken();
     $request = $this->request->request;
     if ($referral) {
         $request->set('referrer', $referral);
     }
     $this->validator->validate(['Приглашение от ЦА' => [$request->get('referrer'), 'required']]);
     //if no passes
     if (!$this->validator->passes()) {
         App::$instance->MQ->setMessage($this->validator->errors()->all());
         ST::redirect("back");
     }
     //check codes
     $caWS = CAVks::where('referral', $request->get('referrer'))->with('owner', 'connection_codes', 'insideParp', 'phoneParp', 'outsideParp')->first();
     $caNS = CAVksNoSupport::where('referral', $request->get('referrer'))->first();
     if (!$caWS && !$caNS) {
         App::$instance->MQ->setMessage("Приглашение {$request->get('referrer')}  не действительно");
         ST::redirectToRoute("Vks/select");
     }
     $caVks = $caWS ? $caWS : $caNS;
     $this->convertToLocalTime($caVks);
     $valid = true;
     if (isset($caVks->status)) {
         if (!in_array($caVks->status, [VKS_STATUS_APPROVED, VKS_STATUS_TRANSPORT_FOR_TB])) {
             $valid = false;
         }
     } else {
         if (!in_array($caVks->status, [VKS_STATUS_APPROVED, VKS_STATUS_TRANSPORT_FOR_TB])) {
             $valid = false;
         }
     }
     if (!$valid) {
         App::$instance->MQ->setMessage("Приглашение {$request->get('referrer')}  не действительно, в ЦА поменяли статус этой ВКС и теперь она недоступна");
         ST::redirectToRoute("Vks/select");
     }
     //my tb is can be accepted?
     $participants = isset($caVks->insideParp) ? $caVks->insideParp : $caVks->participants;
     $flag = false;
     foreach ($participants as $parp) {
         if ($parp->attendance_id == App::$instance->tbId) {
             $flag = true;
         }
     }
     $referral = $request->get('referrer');
     if ($this->isAlreadyEnd(date_create($caVks->end_date_time))) {
         App::$instance->MQ->setMessage("Приглашение {$request->get('referrer')}  не действительно, ВКС уже закончилась", 'danger');
         ST::redirectToRoute("Vks/select");
     }
     if (!$flag && $caVks->local->start_date_time->getTimestamp() - date_create()->getTimestamp() < 1800) {
         App::$instance->MQ->setMessage("Ваш ТБ не заявлен на эту ВКС и до начала ВКС осталось менее 30 минут, заявиться на такую ВКС уже не получится, обратитесь к администратору системы", 'danger');
         ST::redirectToRoute("Vks/select");
     }
     $departments = Department::orderBy('prefix')->get();
     $vks = ST::lookAtBackPack();
     $vks = $vks->request;
     if (!$vks->has('inner_participants') && !count($vks->get('inner_participants'))) {
         LocalStorage_controller::staticRemove('vks_participants_create');
     }
     $available_points = Attendance::techSupportable()->get()->toArray();
     array_walk($available_points, function (&$e) {
         $e['selectable'] = true;
     });
     $this->render('vks/joinCa', compact('vks', 'caVks', 'departments', 'referral', 'flag', 'available_points'));
 }
开发者ID:inilotic,项目名称:vks_nodes_core,代码行数:65,代码来源:Vks_controller.php


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