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


PHP Request::isPost方法代码示例

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


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

示例1: helpAction

 /**
  * @param Request $request
  * @return array|\Zend\Http\Response
  * @throws \Exception
  */
 public function helpAction($request)
 {
     $this->layout('layout/single-column');
     $this->getNavService()->setActive('setting');
     $helpForm = $this->autoFilledForm(HelpForm::class);
     $helpForm->populateValues($this->user()->getArrayCopy());
     if ($request->isPost()) {
         if ($formValid = $helpForm->isValid()) {
             $config = $this->service('Config');
             if (is_array($config) && isset($config['slack']['webhook']['help-support'])) {
                 $formData = $helpForm->getData();
                 $data = ['fields' => [['name' => 'Name', 'value' => $formData['name'], 'short' => true], ['name' => 'Email', 'value' => $formData['email'], 'short' => true], ['name' => 'Contact No.', 'value' => $formData['contact_no'], 'short' => true], ['name' => 'Type', 'value' => $formData['type'], 'short' => true], ['name' => 'Severity', 'value' => $formData['severity'], 'short' => true], ['name' => 'Need Reply?', 'value' => $formData['need_reply'], 'short' => true], ['name' => 'Message', 'value' => $formData['message'], 'short' => false]]];
                 $json = sprintf('payload=%s', json_encode($data));
                 $ch = curl_init($config['slack']['webhook']['help-support']['url']);
                 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 curl_exec($ch);
                 curl_close($ch);
                 $this->flashMessenger()->addSuccessMessage('Terimakasih, pesan Anda telah terkirim.');
                 return $this->redirect()->toRoute(...$this->routeSpec('web.index.help'));
             }
             $this->flashMessenger()->addErrorMessage('Maaf, tidak dapat mengirim pesan Anda saat ini, mohon hubungi admin.');
             return $this->redirect()->toRoute(...$this->routeSpec('web.index.help'));
         }
     }
     return compact('helpForm', 'formValid');
 }
开发者ID:hanif,项目名称:stokq,代码行数:33,代码来源:IndexController.php

示例2: request

 /**
  * @param string $name
  * @param mixed $default
  * @return mixed
  */
 public function request($name, $default = null)
 {
     //The RequestInterface expects this method to return values from a form submission or from
     //the decoded JSON body
     if ($this->data === null) {
         /* @var $contentType ContentType */
         $mediaType = $this->httpRequest->getHeaders('Content-type') ? $this->httpRequest->getHeaders('Content-type')->getFieldValue() : null;
         if ($mediaType == 'application/x-www-form-urlencoded' && ($this->httpRequest->isPut() || $this->httpRequest->isDelete())) {
             parse_str($this->httpRequest->getContent(), $this->data);
         } else {
             if ($mediaType == 'application/json' && ($this->httpRequest->isPost() || $this->httpRequest->isPut() || $this->httpRequest->isDelete())) {
                 $this->data = json_decode($this->httpRequest->getContent(), true);
             } else {
                 $this->data = $this->httpRequest->getPost()->toArray();
             }
         }
     }
     return isset($this->data[$name]) ? $this->data[$name] : $default;
 }
开发者ID:VictorAlencar,项目名称:zf2-oauth2-provider,代码行数:24,代码来源:RequestAdapter.php

示例3: TreatRequest

 public function TreatRequest()
 {
     $request = new Request();
     if ($request->isGet()) {
         $this->DoGet();
     } else {
         if ($request->isPost()) {
             $this->DoPost();
         } else {
             return new \Exception();
         }
     }
 }
开发者ID:CrunchyArtie,项目名称:Audio,代码行数:13,代码来源:AudioWebServices.php

示例4: saveAction

 public function saveAction(Request $request, Create $createService, Form $form, View $view, Redirect $redirect)
 {
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $createService->create($form->getData());
             return $redirect->toRoute('admin-translate-words');
         }
     }
     $view->setForm($form);
     $view->setTemplate('translate/admin/word/edit');
     return $view;
 }
开发者ID:sebaks,项目名称:Translate,代码行数:13,代码来源:WordController.php

示例5: TreatRequest

 public function TreatRequest()
 {
     $req = new Request();
     if ($req->isGet()) {
         return $this->DoGet();
     }
     if ($req->isDelete() && $this->IsAuthorized()) {
         return $this->DoDelete();
     } else {
         if ($req->isPost()) {
             return $this->DoPost();
         } else {
             return new \Exception();
         }
     }
 }
开发者ID:CrunchyArtie,项目名称:Audio,代码行数:16,代码来源:LoginWebServices.php

示例6: Edit

 public function Edit()
 {
     if (CommonController::IsAuthentified()) {
         $request = new Request();
         if ($request->isGet()) {
             $data = json_decode($this->GetCurrentCollection(), true);
             if (!is_null($data)) {
                 CommonController::SetView("collection", "edit", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id'])))));
                 return;
             }
         } else {
             if ($request->isPost()) {
                 $label = $request->getPost('label');
                 $description = $request->getPost('description');
                 $id = $request->getPost('id');
                 if (!is_null($label) && !is_null($description)) {
                     if (!is_null($id)) {
                         $WSCtrl = new WebServicesController();
                         $return = $WSCtrl->Call("Collection", "POST", array("id" => $id, "label" => $label, "description" => $description));
                         var_dump($return);
                         if ($return == "true") {
                             CommonController::Redirect("Collection", "Index", $id);
                         } else {
                             $data = json_decode($this->GetCurrentCollection(), true);
                             if (!is_null($data)) {
                                 CommonController::SetView("collection", "index", array_merge($data, array('url' => array('edit' => CommonController::GetLink("Collection", "edit", $data['collection']['id']), 'delete' => CommonController::GetLink("Collection", "delete", $data['collection']['id'])), 'error' => 'Impossible de sauver la collection')));
                                 return;
                             }
                         }
                     } else {
                         //Create
                     }
                 }
             }
         }
     }
     CommonController::Redirect("home");
 }
开发者ID:CrunchyArtie,项目名称:Audio,代码行数:38,代码来源:CollectionController.php

示例7: TreatRequest

 public function TreatRequest()
 {
     if ($this->IsAuthorized()) {
         $request = new Request();
         if ($request->isGet()) {
             return $this->DoGet();
         } else {
             if ($request->isPost()) {
                 return $this->DoPost();
             } else {
                 if ($request->isPut()) {
                     return $this->DoPut();
                 } else {
                     if ($request->isDelete()) {
                         return $this->DoDelete();
                     }
                 }
             }
         }
     } else {
         throw new \Exception();
     }
 }
开发者ID:CrunchyArtie,项目名称:Audio,代码行数:23,代码来源:UserWebServices.php

示例8: changePasswordAction

 /**
  * @param Request $request
  * @return array|\Zend\Stdlib\ResponseInterface
  */
 public function changePasswordAction($request)
 {
     $this->layout('layout/single-column');
     $this->getNavService()->setActive('setting');
     $changePasswordForm = $this->autoFilledForm(ChangePasswordForm::class);
     if ($request->isPost()) {
         if ($formValid = $changePasswordForm->isValid()) {
             /** @var PasswordInterface $passwordService */
             $passwordService = $this->service(PasswordInterface::class);
             $data = $changePasswordForm->getData();
             if ($passwordService->verify($data['old_password'], $this->user()->getPassword())) {
                 $user = $this->user();
                 $user->setPassword($passwordService->create($data['new_password']));
                 $this->persist($user)->commit();
                 $this->flashMessenger()->addSuccessMessage('Password yang baru telah di simpan.');
                 return $this->redirect()->toRoute(...$this->routeSpec('web.setting.change-password'));
             }
             $this->flashMessenger()->addErrorMessage('Password yang lama tidak cocok.');
             return $this->redirect()->toRoute(...$this->routeSpec('web.setting.change-password'));
         }
     }
     return compact('changePasswordForm', 'formValid');
 }
开发者ID:hanif,项目名称:stokq,代码行数:27,代码来源:SettingController.php

示例9: Request

 /**
  * Validates a token.
  *
  * Automatically validates a token when a request has an header with authorization.
  *
  * @since 4.3.0
  *
  * @return int|false user-id when token is valid, false when it is invalid.
  */
 function validate_token()
 {
     $request = new Request();
     if ($request->isGet() || $request->isPost()) {
         $authHeader = $request->getHeader('authorization');
         if ($authHeader) {
             list($jwt) = sscanf($authHeader->toString(), 'Authorization: Bearer %s');
             if ($jwt) {
                 try {
                     $secretKey = base64_decode(get_option('jwt_secret'));
                     $token = JWT::decode($jwt, $secretKey, array('HS256'));
                     return $token->data->userId;
                 } catch (Exception $e) {
                     // FALSE if token is invalid
                     return false;
                 }
             } else {
                 //  FALSE if no token was passed
                 return false;
             }
         }
     }
     return false;
 }
开发者ID:YanikPei,项目名称:wp-jwt-authentication,代码行数:33,代码来源:class-wak-functions.php

示例10: array

        }
    }
    $data = json_decode($app->request()->getBody());
    if (null !== $token) {
        $response = array("success" => true, "data" => $app->dataAccessService->getUser($data));
        $app->apiService->json(200, $response);
    } else {
        $response = array("success" => false, "data" => "Invalid token!");
        $app->apiService->json(401, $response);
    }
});
$app->post('/admin/users/verify', function () use($app) {
    // user role id for user (verified)
    $verified = 3;
    $request = new Request();
    if ($request->isPost()) {
        $header = $request->getHeader('authorization');
        if ($header) {
            $token = $app->apiService->extractToken($header);
        }
    }
    $data = json_decode($app->request()->getBody());
    if (null !== $token) {
        $app->dataAccessService->updateUserRole($data->user_name, $verified);
        $response = array("success" => true, "data" => "User verified successfully.");
        $app->apiService->json(200, $response);
    } else {
        $response = array("success" => false, "data" => "Invalid token!");
        $app->apiService->json(401, $response);
    }
});
开发者ID:jkatajamki,项目名称:lummox,代码行数:31,代码来源:admin.php

示例11: firstRunAction

 /**
  * @param Request $request
  * @return mixed
  */
 public function firstRunAction($request)
 {
     $accountMapper = $this->mapper(Account::class);
     if ($accountMapper->count()) {
         return $this->notFoundAction();
     }
     /** @var FirstRunForm $firstRunForm */
     $firstRunForm = $this->autoFilledForm(FirstRunForm::class);
     if ($request->isPost()) {
         if ($formValid = $firstRunForm->isValid()) {
             $this->getAccountMService()->setupFirstRun($accountMapper, $this->mapper(User::class), $firstRunForm);
             $this->getStockService()->createDefaultUnit($this->mapper(StockUnit::class), $this->getStockService()->createDefaultUnitType($this->mapper(UnitType::class)));
             $this->getStockService()->createDefaultCategory($this->mapper(Category::class));
             $this->getStockService()->createDefaultStorageType($this->mapper(StorageType::class));
             $this->getMenuService()->createDefaultIngredientType($this->mapper(IngredientType::class));
             $this->getMenuService()->createDefaultMenuType($this->mapper(Type::class));
             $this->commit();
             $this->flashMessenger()->addSuccessMessage('Akun anda telah dibuat, silahkan login dengan user & password yang dipilih.');
             return $this->redirect()->toRoute(...$this->routeSpec('web.access.login'));
         }
     }
     $model = new ViewModel();
     $model->setTemplate('stokq/web/access/first-run');
     $model->setVariables(compact('firstRunForm', 'formValid'));
     $model->setTerminal(true);
     return $model;
 }
开发者ID:hanif,项目名称:stokq,代码行数:31,代码来源:AccessController.php

示例12: Request

// Wczytujemy wcześniej zdefiniowany plik ustawień
require 'phpsettings.php';
require 'vendor/autoload.php';
// Na wszelki wypadek przechwytujemy wszystkie potencjalne wyjątki
try {
    /* @var $container Zend\ServiceManager\ServiceManager */
    $container = (require 'config/container.php');
    $request = new Request();
    $paramPage = $request->getQuery('page');
    switch ($paramPage) {
        case 'login':
            /* @var $form \Aura\Input\Form */
            $form = $container->get(App\Form\LoginForm::class);
            if ($request->isGet()) {
                require 'views/login.php';
            } elseif ($request->isPost()) {
                $data = $request->getPost()->toArray();
                $form->fill($data);
                if ($form->filter()) {
                    $userGateway = $container->get(App\Db\UserTableGateway::class);
                    $result = $userGateway->fetchByEmail($request->getPost('email'));
                    if (password_verify($request->getPost('password'), $result['password'])) {
                        echo 'Użytkownik zalogowany prawidłowo.';
                    } else {
                        echo 'Nie udało się zalogować użytkownika.';
                    }
                } else {
                    require 'views/login.php';
                }
            }
            break;
开发者ID:wwwgo-pl,项目名称:PHP-Login-Register-Form,代码行数:31,代码来源:index.php


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