%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/egp/vendor/yiisoft/yii2/filters/ |
Upload File : |
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace yii\filters; use Yii; use yii\base\ActionEvent; use yii\base\Behavior; use yii\web\Controller; use yii\web\MethodNotAllowedHttpException; /** * VerbFilter is an action filter that filters by HTTP request methods. * * It allows to define allowed HTTP request methods for each action and will throw * an HTTP 405 error when the method is not allowed. * * To use VerbFilter, declare it in the `behaviors()` method of your controller class. * For example, the following declarations will define a typical set of allowed * request methods for REST CRUD actions. * * ```php * public function behaviors() * { * return [ * 'verbs' => [ * 'class' => \yii\filters\VerbFilter::className(), * 'actions' => [ * 'index' => ['GET'], * 'view' => ['GET'], * 'create' => ['GET', 'POST'], * 'update' => ['GET', 'PUT', 'POST'], * 'delete' => ['POST', 'DELETE'], * ], * ], * ]; * } * ``` * * @see https://tools.ietf.org/html/rfc2616#section-14.7 * @author Carsten Brandt <mail@cebe.cc> * @since 2.0 */ class VerbFilter extends Behavior { /** * @var array this property defines the allowed request methods for each action. * For each action that should only support limited set of request methods * you add an entry with the action id as array key and an array of * allowed methods (e.g. GET, HEAD, PUT) as the value. * If an action is not listed all request methods are considered allowed. * * You can use `'*'` to stand for all actions. When an action is explicitly * specified, it takes precedence over the specification given by `'*'`. * * For example, * * ```php * [ * 'create' => ['GET', 'POST'], * 'update' => ['GET', 'PUT', 'POST'], * 'delete' => ['POST', 'DELETE'], * '*' => ['GET'], * ] * ``` */ public $actions = []; /** * Declares event handlers for the [[owner]]'s events. * @return array events (array keys) and the corresponding event handler methods (array values). */ public function events() { return [Controller::EVENT_BEFORE_ACTION => 'beforeAction']; } /** * @param ActionEvent $event * @return bool * @throws MethodNotAllowedHttpException when the request method is not allowed. */ public function beforeAction($event) { $action = $event->action->id; if (isset($this->actions[$action])) { $verbs = $this->actions[$action]; } elseif (isset($this->actions['*'])) { $verbs = $this->actions['*']; } else { return $event->isValid; } $verb = Yii::$app->getRequest()->getMethod(); $allowed = array_map('strtoupper', $verbs); if (!in_array($verb, $allowed)) { $event->isValid = false; // https://tools.ietf.org/html/rfc2616#section-14.7 Yii::$app->getResponse()->getHeaders()->set('Allow', implode(', ', $allowed)); throw new MethodNotAllowedHttpException('Method Not Allowed. This URL can only handle the following request methods: ' . implode(', ', $allowed) . '.'); } return $event->isValid; } }