Пример #1
0
 /**
  * @param  HttpRequest $request
  * @return string
  */
 protected function detectMethod(HttpRequest $request)
 {
     $requestMethod = $request->getMethod();
     if ($requestMethod !== 'POST') {
         return $request->getMethod();
     }
     $method = $request->getHeader(self::HTTP_HEADER_OVERRIDE);
     if (isset($method)) {
         return strtoupper($method);
     }
     $method = $request->getQuery(self::QUERY_PARAM_OVERRIDE);
     if (isset($method)) {
         return strtoupper($method);
     }
     return $requestMethod;
 }
Пример #2
0
 private function _detectAction(HttpRequest $request)
 {
     $method = $request->getMethod();
     if (isset($this->actions[$method])) {
         return $this->actions[$method];
     }
     throw new InvalidStateException('Method ' . $method . ' is not allowed.');
 }
Пример #3
0
 /**
  */
 public function renderShow($seo_url)
 {
     dump(func_get_args());
     $httpRequest = new Nette\Http\Request(new Nette\Http\UrlScript($_SERVER['REQUEST_URI']));
     dump($httpRequest->getUrl());
     dump($httpRequest->getMethod());
     dump($httpRequest->getHeaders());
     // get article
     $this->template->article = $this->_articleModel->fetchSingle($seo_url);
 }
Пример #4
0
 /**
  */
 public function renderDefault($city)
 {
     dump(func_get_args());
     $httpRequest = new Nette\Http\Request(new Nette\Http\UrlScript($_SERVER['REQUEST_URI']));
     dump($httpRequest->getUrl());
     dump($httpRequest->getMethod());
     dump($httpRequest->getHeaders());
     // get city
     $this->template->city = $city;
 }
Пример #5
0
 public function renderAuthFtp()
 {
     if ($this->httpRequest->getMethod() != "POST") {
         $this->error('Neplatná metoda.', 403);
     }
     $this->httpResponse->setContentType('text/plain', 'UTF-8');
     $username = $this->httpRequest->getPost('username', '');
     $password = $this->httpRequest->getPost('password', '');
     $s = $this->share->findOneBy(array('var' => $username, 'var2' => $password));
     $out = array();
     if (!$s) {
         $out[] = 'auth_ok:0';
     } else {
         $out[] = 'auth_ok:1';
         $out[] = 'uid:' . Model\Share::shareuid;
         $out[] = 'gid:' . Model\Share::sharegid;
         $out[] = 'dir:' . Model\Share::dataBaseUrl . $s->folder->name . '/';
     }
     $out[] = 'end';
     $this->send($out);
 }
Пример #6
0
 /**
  * @return string|null
  */
 public function getMethods()
 {
     if (isset($this->config['methods'])) {
         if ($this->config['methods'] === '*' && $this->httpRequest->getMethod() === 'OPTIONS') {
             $this->config['methods'] = array('GET', 'DELETE', 'PUT', 'POST', 'OPTIONS', 'HEAD', 'TRACE', 'CONNECT', 'PATCH', 'COPY', 'SEARCH');
         }
         if (is_array($this->config['methods'])) {
             $this->config['methods'] = implode(',', $this->config['methods']);
         }
         return (string) $this->config['methods'];
     }
 }
 /**
  * @param \Nette\Http\Request
  */
 public function log(\Nette\Http\Request $req)
 {
     $this->server->send('access', array('ua' => $req->getHeader('User-Agent'), 'ip' => $req->getRemoteAddress(), 'host' => $req->getRemoteHost(), 'method' => $req->getMethod(), 'url' => (string) $req->getUrl(), 'memory' => function_exists('memory_get_peak_usage') ? number_format(memory_get_peak_usage() / 1000000, 2, '.', ' ') : 'n/a', 'time' => number_format((microtime(TRUE) - \Nette\Diagnostics\Debugger::$time) * 1000, 1, '.', ' '), 'referer' => (string) $req->getHeader('Referer')));
 }
Пример #8
0
 public function getMethod()
 {
     return $this->request->getMethod();
 }
Пример #9
0
 /**
  * Creates Nette Application request
  * @return \Nette\Application\Request
  */
 public function createApplicationRequest()
 {
     list($presenter, $action) = $this->getDestination();
     $data = $this->getData($presenter . ':' . $action);
     return new \Nette\Application\Request($this->module . ":" . $presenter, $this->httpRequest->getMethod(), array_merge(['action' => $action], $data), $this->httpRequest->getPost(), $this->httpRequest->getFiles(), array(\Nette\Application\Request::SECURED => $this->httpRequest->isSecured()));
 }