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


PHP Environment::getHttpRequest方法代码示例

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


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

示例1: handleUpload

 public function handleUpload()
 {
     $files = \Nette\Environment::getHttpRequest()->getFile("user_file");
     foreach ($files as $file) {
         call_user_func($this->handler, $file);
     }
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:7,代码来源:UploadControl.php

示例2: sendStandardFileHeaders

 /**
  * Sends a standard headers for file download
  * @param BaseFileDownload $file            File
  * @param BaseDownloader $downloader    Downloader of the file
  */
 protected function sendStandardFileHeaders(BaseFileDownload $file, BaseDownloader $downloader = null)
 {
     $res = \Nette\Environment::getHttpResponse();
     $req = \Nette\Environment::getHttpRequest();
     //FDTools::clearHeaders($res); // Voláno už v FileDownload.php
     $res->setContentType($file->mimeType, "UTF-8");
     $res->setHeader("X-File-Downloader", "File Downloader (http://filedownloader.projekty.mujserver.net)");
     if ($downloader !== null) {
         $res->setHeader("X-FileDownloader-Actual-Script", $downloader->getReflection()->name);
     }
     $res->setHeader('Pragma', 'public');
     // Fix for IE - Content-Disposition
     $res->setHeader('Content-Disposition', $file->getContentDisposition() . '; filename="' . FDTools::getContentDispositionHeaderData($file->transferFileName) . '"');
     $res->setHeader('Content-Description', 'File Transfer');
     $res->setHeader('Content-Transfer-Encoding', 'binary');
     $res->setHeader('Connection', 'close');
     $res->setHeader('ETag', FDTools::getETag($file->sourceFile));
     $res->setHeader('Content-Length', FDTools::filesize($file->sourceFile));
     // Cache control
     if ($file->enableBrowserCache) {
         $this->setupCacheHeaders($file);
     } else {
         $this->setupNonCacheHeaders($file);
     }
 }
开发者ID:VNovotna,项目名称:MP2014,代码行数:30,代码来源:BaseDownloader.php

示例3: handleUploads

 /**
  * Handles uploaded files
  * forwards it to model
  */
 public function handleUploads()
 {
     // Iterujeme nad přijatými soubory
     foreach (\Nette\Environment::getHttpRequest()->getFiles() as $name => $controlValue) {
         // MFU vždy posílá soubory v této struktuře:
         //
         // array(
         //	"token" => "blablabla",
         //	"files" => array(
         //		0 => HttpUploadedFile(...),
         //		...
         //	)
         // )
         $isFormMFU = (is_array($controlValue) and isset($controlValue["files"]) and isset($_POST[$name]["token"]));
         if ($isFormMFU) {
             $token = $_POST[$name]["token"];
             foreach ($controlValue["files"] as $file) {
                 self::processFile($token, $file);
             }
         }
         // soubory, které se netýkají MFU nezpracujeme -> zpracuje si je standardním způsobem formulář
     }
     return true;
     // Skip all next
 }
开发者ID:patrickkusebauch,项目名称:27skauti,代码行数:29,代码来源:MFUUIHTML4SingleUpload.php

示例4: createTemplate

 /**
  * @return Template
  */
 protected function createTemplate($file = null)
 {
     $template = new Template($file);
     $template->baseUrl = \Nette\Environment::getHttpRequest()->url->baseUrl;
     $template->basePath = rtrim($template->baseUrl, '/');
     $template->interface = $this;
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     return $template;
 }
开发者ID:jurasm2,项目名称:multiplefileupload,代码行数:12,代码来源:AbstractInterface.php

示例5: handleUploads

 /**
  * Handles uploaded files
  * forwards it to model
  */
 public function handleUploads()
 {
     if (!isset($_POST["token"])) {
         return;
     }
     /* @var $token string */
     $token = $_POST["token"];
     /* @var $file \Nette\Http\FileUpload */
     foreach (Environment::getHttpRequest()->getFiles() as $file) {
         self::processFile($token, $file);
     }
     // Response to client
     echo "1";
     // End the script
     exit;
 }
开发者ID:jurasm2,项目名称:multiplefileupload,代码行数:20,代码来源:Controller.php

示例6: absolutizeUrl

 /**
  * Make relative url absolute
  * @param string image url
  * @param string single or double quote
  * @param string absolute css file path
  * @param string source path
  * @return string
  */
 public static function absolutizeUrl($url, $quote, $cssFile, $sourcePath)
 {
     // is already absolute
     if (preg_match("/^([a-z]+:\\/)?\\//", $url)) {
         return $url;
     }
     $docroot = realpath(WWW_DIR);
     $basePath = rtrim(Environment::getHttpRequest()->getUrl()->getScriptPath(), '/');
     // inside document root
     if (Strings::startsWith($cssFile, $docroot)) {
         $path = $basePath . substr(dirname($cssFile), strlen($docroot)) . DIRECTORY_SEPARATOR . $url;
         // outside document root
     } else {
         $path = $basePath . substr($sourcePath, strlen($docroot)) . DIRECTORY_SEPARATOR . $url;
     }
     //$path = self::cannonicalizePath($path);
     return $quote === '"' ? addslashes($path) : $path;
 }
开发者ID:Edke,项目名称:WebLoader,代码行数:26,代码来源:CssUrlsFilter.php

示例7: setUrl

 public function setUrl($url)
 {
     $uriScript = new UriScript($url);
     $uriScript->setScriptPath(Environment::getHttpRequest()->getUri()->getScriptPath());
     $httpRequest = new HttpRequest($uriScript);
     $presenterRequest = Environment::getApplication()->getRouter()->match($httpRequest);
     if ($presenterRequest === null || !String::startsWith($url, Environment::getVariable("baseUri"))) {
         $this->url = $url ?: null;
         $this->destination = null;
         $this->params = array();
     } else {
         $presenter = $presenterRequest->getPresenterName();
         $params = $presenterRequest->getParams();
         $action = isset($params["action"]) ? $params["action"] : "default";
         $module = isset($params["module"]) ? $params["module"] . ":" : "";
         unset($params["action"]);
         $this->destination = "{$module}{$presenter}:{$action}";
         $this->params = $params;
         $this->url = null;
     }
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:21,代码来源:MenuItem.php

示例8: createTemplate

 /**
  * @return ITemplate
  */
 protected function createTemplate($file = null)
 {
     $template = new Nette\Templating\FileTemplate($file);
     //$presenter = Environment::getApplication()->getPresenter();
     $template->onPrepareFilters[] = array($this, 'templatePrepareFilters');
     // default parameters
     //$template->control = $this;
     //$template->presenter = $presenter;
     $template->baseUrl = \Nette\Environment::getHttpRequest()->url->baseUrl;
     $template->basePath = rtrim($template->baseUrl, '/');
     $template->baseModulePath = $template->basePath . '/modules/multipleFileUpload';
     // flash message
     /*if ($presenter !== NULL && $presenter->hasFlashSession()) {
         $id = $this->getParamId('flash');
         $template->flashes = $presenter->getFlashSession()->$id;
       }
       if (!isset($template->flashes) || !is_array($template->flashes)) {
         $template->flashes = array();
       }*/
     $template->registerHelperLoader('Nette\\Templating\\Helpers::loader');
     return $template;
 }
开发者ID:patrickkusebauch,项目名称:27skauti,代码行数:25,代码来源:MFUUIBase.php

示例9: getRequest

	/**
	 * @return Nette\Web\IHttpRequest
	 */
	public function getRequest()
	{
		return Nette\Environment::getHttpRequest();
	}
开发者ID:redhead,项目名称:nette,代码行数:7,代码来源:HttpContext.php

示例10: handleEdit

 /**
  * Handle edit
  */
 public function handleEdit()
 {
     if ($this->presenter->isAjax()) {
         $post = \Nette\Environment::getHttpRequest()->getPost();
         foreach ($post as $column => $value) {
             if ($column == 'id' || $this['columns']->getComponent($column)->isEditable()) {
                 continue;
             }
             throw new \Nette\Application\ForbiddenRequestException("Column {$column} is not editable");
         }
         call_user_func($this->editHandler, $post);
     }
 }
开发者ID:hleumas,项目名称:gridito,代码行数:16,代码来源:Grid.php

示例11: download

 /**
  * Download file!
  * @param BaseFileDownload $file
  */
 function download(BaseFileDownload $transfer)
 {
     $this->currentTransfer = $transfer;
     $this->sendStandardFileHeaders($transfer, $this);
     @ignore_user_abort(true);
     // For onAbort event
     $req = Environment::getHttpRequest();
     $res = Environment::getHttpResponse();
     $filesize = $this->size = $transfer->sourceFileSize;
     $this->length = $this->size;
     // Content-length
     $this->start = 0;
     $this->end = $this->size - 1;
     /* ### Headers ### */
     // Now that we've gotten so far without errors we send the accept range header
     /* At the moment we only support single ranges.
      * Multiple ranges requires some more work to ensure it works correctly
      * and comply with the spesifications: http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
      *
      * Multirange support annouces itself with:
      * header('Accept-Ranges: bytes');
      *
      * Multirange content must be sent with multipart/byteranges mediatype,
      * (mediatype = mimetype)
      * as well as a boundry header to indicate the various chunks of data.
      */
     //$res->setHeader("Accept-Ranges", "0-".$this->end); // single-part - now not accepted by mozilla
     $res->setHeader("Accept-Ranges", "bytes");
     // multi-part (through Mozilla)
     // http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.2
     if ($req->getHeader("Range", false)) {
         try {
             $range_start = $this->start;
             $range_end = $this->end;
             // Extract the range string
             $rangeArray = explode('=', $req->getHeader("Range"), 2);
             $range = $rangeArray[1];
             // Make sure the client hasn't sent us a multibyte range
             if (strpos($range, ',') !== false) {
                 // (?) Shoud this be issued here, or should the first
                 // range be used? Or should the header be ignored and
                 // we output the whole content?
                 throw new FileDownloaderException("HTTP 416", 416);
             }
             // If the range starts with an '-' we start from the beginning
             // If not, we forward the file pointer
             // And make sure to get the end byte if spesified
             if ($range[0] == '-') {
                 // The n-number of the last bytes is requested
                 $range_start = $this->size - (double) substr($range, 1);
             } else {
                 $range = explode('-', $range);
                 $range_start = $range[0];
                 $range_end = isset($range[1]) && is_numeric($range[1]) ? $range[1] : $this->size;
             }
             /**
              * Check the range and make sure it's treated according to the specs.
              * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
              */
             // End bytes can not be larger than $end.
             $range_end = $range_end > $this->end ? $this->end : $range_end;
             // Validate the requested range and return an error if it's not correct.
             if ($range_start > $range_end || $range_start > $this->size - 1 || $range_end >= $this->size) {
                 throw new FileDownloaderException("HTTP 416", 416);
             }
             // All is ok - so assign variables back
             $this->start = $range_start;
             $this->end = $range_end;
             $this->length = $this->end - $this->start + 1;
             // Calculate new content length
         } catch (FileDownloaderException $e) {
             if ($e->getCode() === 416) {
                 $res->setHeader("Content-Range", "bytes {$this->start}-{$this->end}/{$this->size}");
                 FDTools::_HTTPError(416);
             } else {
                 throw $e;
             }
         }
         $res->setCode(206);
         // Partial content
     }
     // End of if partial download
     // Notify the client the byte range we'll be outputting
     $res->setHeader("Content-Range", "bytes {$this->start}-{$this->end}/{$this->size}");
     $res->setHeader("Content-Length", $this->length);
     /* ### Call callbacks ### */
     $transfer->onBeforeOutputStarts($transfer, $this);
     if ($this->start > 0) {
         $transfer->onTransferContinue($transfer, $this);
     } else {
         $transfer->onNewTransferStart($transfer, $this);
     }
     /* ### Send file to browser - document body ### */
     $buffer = FDTools::$readFileBuffer;
     $sleep = false;
     if (is_int($transfer->speedLimit) and $transfer->speedLimit > 0) {
//.........这里部分代码省略.........
开发者ID:OCC2,项目名称:occ2pacs,代码行数:101,代码来源:AdvancedDownloader.php

示例12: createApplication

 /**
  * @return Nette\Application\Application
  */
 public static function createApplication()
 {
     if (Environment::getVariable('baseUri', NULL) === NULL) {
         Environment::setVariable('baseUri', Environment::getHttpRequest()->getUri()->getBasePath());
     }
     $context = clone Environment::getContext();
     $context->addService('Nette\\Application\\IRouter', 'Nette\\Application\\MultiRouter');
     if (!$context->hasService('Nette\\Application\\IPresenterLoader')) {
         $context->addService('Nette\\Application\\IPresenterLoader', function () {
             return new Nette\Application\PresenterLoader(Environment::getVariable('appDir'));
         });
     }
     $application = new Nette\Application\Application();
     $application->setContext($context);
     $application->catchExceptions = Environment::isProduction();
     return $application;
 }
开发者ID:JPalounek,项目名称:IconStore,代码行数:20,代码来源:Configurator.php

示例13: getUserBrowser

 /**
  * Get the user's browser information
  *
  * @return array
  */
 public static function getUserBrowser()
 {
     $browser = ['userBrowser' => '', 'userVersion' => 0];
     $userAgent = \Nette\Environment::getHttpRequest()->getHeader('user-agent');
     // MSIE
     if (preg_match('/mozilla.*?MSIE ([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'IE';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/mozilla.*rv:([0-9a-z\\+\\-\\.]+).*gecko.*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'Gecko';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/mozilla.*applewebkit\\/([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'Webkit';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/mozilla.*opera ([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match) || preg_match('/^opera\\/([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'Opera';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/mozilla.*applewebkit\\/([0-9a-z\\+\\-\\.]+).*mobile.*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'SafMob';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/mozilla.*MSIE ([0-9a-z\\+\\-\\.]+).*Mac.*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'IEMac';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/PPC.*IEMobile ([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'IEMob';
         $browser['userVersion'] = '1.0';
     } elseif (preg_match('/mozilla.*konqueror\\/([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'Konq';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/mozilla.*PSP.*; ([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'PSP';
         $browser['userVersion'] = $match[1];
     } elseif (preg_match('/mozilla.*NetFront\\/([0-9a-z\\+\\-\\.]+).*/si', $userAgent, $match)) {
         $browser['userBrowser'] = 'NetF';
         $browser['userVersion'] = $match[1];
     }
     // Round the version number to one decimal place
     if (($iDot = strpos($browser['userVersion'], '.')) > 0) {
         $browser['userVersion'] = substr($browser['userVersion'], 0, $iDot + 2);
     }
     return $browser;
 }
开发者ID:lohini,项目名称:webloader,代码行数:47,代码来源:CCssFilter.php

示例14: handleUploads

 /**
  * Handles uploading files
  */
 public static function handleUploads()
 {
     // Pokud už bylo voláno handleUploads -> skonči
     if (self::$handleUploadsCalled === true) {
         return;
     } else {
         self::$handleUploadsCalled = true;
     }
     $req = Environment::getHttpRequest();
     // Workaround for: http://forum.nettephp.com/cs/3680-httprequest-getheaders-a-content-type
     $contentType = $req->getHeader("content-type");
     if (!$contentType and isset($_SERVER["CONTENT_TYPE"])) {
         $contentType = $_SERVER["CONTENT_TYPE"];
     }
     if ($req->getMethod() !== "POST") {
         return;
     }
     self::getQueuesModel()->initialize();
     foreach (self::getUIRegistrator()->getInterfaces() as $interface) {
         //			\Nette\Diagnostics\Debugger::log($interface->getReflection()->getName().": is this your upload? ".$interface->isThisYourUpload());
         if ($interface->isThisYourUpload()) {
             $ret = $interface->handleUploads();
             if ($ret === true) {
                 break;
             }
         }
     }
 }
开发者ID:jurasm2,项目名称:multiplefileupload,代码行数:31,代码来源:MultipleFileUpload.php

示例15: actionUpload

 /**
  * Upload souboru
  */
 public function actionUpload()
 {
     // check rights
     if (!$this->getUser()->isInRole("admin")) {
         $this->sendError("Access denied.");
     }
     // path
     $folder = Environment::getHttpRequest()->getPost("folder");
     try {
         $folderPath = $this->getFolderPath($folder);
     } catch (InvalidArgumentException $e) {
         $this->sendError("Folder does not exist or is not writeable.");
     }
     // file
     $file = Environment::getHttpRequest()->getFile("file");
     // check
     if ($file === null || !$file->isOk()) {
         $this->sendError("Upload error.");
     }
     // move
     $fileName = String::webalize($file->getName(), ".");
     $path = $folderPath . "/" . $fileName;
     if (@$file->move($path)) {
         @chmod($path, 0666);
         if ($file->isImage()) {
             $this->payload->filename = ($folder ? "{$folder}/" : "") . $fileName;
             $this->payload->type = "image";
         } else {
             $this->payload->filename = $this->baseFolderUri . ($folder ? "{$folder}/" : "") . $fileName;
             $this->payload->type = "file";
         }
         $this->sendResponse(new JsonResponse($this->payload, "text/plain"));
     } else {
         $this->sendError("Move failed.");
     }
 }
开发者ID:janmarek,项目名称:Neuron,代码行数:39,代码来源:TexylaPresenter.php


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