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


PHP sfWebRequest::getHttpHeader方法代码示例

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


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

示例1: executeShow

 /**
  * Executes index action
  *
  * @param sfWebRequest $request A request object
  */
 public function executeShow(sfWebRequest $request)
 {
     // for apiKey check
     $memberId = $this->getUser()->getMember();
     $reqFileName = $request->getParameter('filename');
     $separates = explode('.', $reqFileName);
     $cnt = count($separates);
     $fileId = '';
     $ext = '';
     if (1 == $cnt) {
         $fileId = $reqFileName;
     } else {
         $fileId = join('', array_slice($separates, 0, $cnt - 1));
         $ext = '.' . $separates[$cnt - 1];
     }
     $file = Doctrine::getTable('File')->find($fileId);
     $this->forward404Unless($file);
     $filebin = $file->getFileBin();
     $data = $filebin->getBin();
     $filename = $file->getName();
     if (!$data) {
         return $this->renderJSON(array('status' => 'error', 'message' => 'file download error'));
     }
     $filename = substr($filename, strpos($filename, "/", 1));
     $finfo = new finfo(FILEINFO_MIME_TYPE);
     $type = $finfo->buffer($data);
     $this->getResponse()->setHttpHeader('Content-Type', $type);
     $this->getResponse()->setHttpHeader('Content-Length', strlen($data));
     // for ie
     if (1 === preg_match('/MSIE/', $request->getHttpHeader('User-Agent'))) {
         $filename = mb_convert_encoding($filename, 'sjis-win', 'utf8');
     }
     $this->getResponse()->setHttpHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
     return $this->renderText($data);
 }
开发者ID:nishizoe,项目名称:opUploadFilePlugin,代码行数:40,代码来源:actions.class.php

示例2: executeIndex

 public function executeIndex(sfWebRequest $request)
 {
     if ($request->getHttpHeader('X-PJAX')) {
         $this->setLayout(false);
     }
     $this->date = $this->checkDateForRequest($request);
     $this->list = Doctrine::getTable('Kakiage')->findByTargetDate($this->date);
 }
开发者ID:balibali,项目名称:opKakiagePlugin,代码行数:8,代码来源:actions.class.php

示例3: extractParameters

 /**
  *
  * @param sfWebRequest $request 
  * @return WSRequestParameters
  */
 public function extractParameters(sfWebRequest $request)
 {
     $webRequestParameters = new WSRequestParameters();
     $logger = Logger::getLogger('core.webservices');
     $requestMethod = $request->getMethod();
     $contentType = $request->getContentType();
     $logger->debug("HTTP Method: {$requestMethod}, Content-Type: {$contentType}");
     $requestParameters = $request->getRequestParameters();
     $logger->debug("Request Parameters: " . print_r($requestParameters, true));
     if (!isset($requestParameters['ws_method'])) {
         throw new WebServiceException('Web service method is not specified', 400);
     }
     $webServiceMethod = $requestParameters['ws_method'];
     $methodParameters = array();
     // Checking for deprecated method of sending parameters using an http header
     $header = $request->getHttpHeader('ohrm_ws_method_parameters');
     if (!empty($header)) {
         $methodParameters = json_decode($header, true);
         if (!is_array($methodParameters)) {
             throw new WebServiceException("header ohrm_ws_method_parameters should be json encoded", 400);
         }
     } else {
         // get request parameters in URL (eg: /empNumber/11) after removing the default parameters
         $methodParameters = array_diff_key($requestParameters, array_flip(array('action', 'module', 'ws_method', '_sf_route')));
         // Merge with GET parameters
         $methodParameters = array_merge($methodParameters, $request->getGetParameters());
         // Check for JSON encoded body
         if ($contentType === 'application/json') {
             $postParams = json_decode(file_get_contents('php://input'), true);
             $methodParameters = array_merge($methodParameters, $postParams);
         } else {
             if ($requestMethod === 'POST') {
                 $methodParameters = array_merge($methodParameters, $request->getPostParameters());
             }
         }
     }
     //        $arrayName = $this->getArrayNameForFunction($function);
     //        if(!array_key_exists($arrayName, $methodParameters)) {
     //            throw new WebServiceException('Required array name not provided', 404);
     //        }
     $webRequestParameters->setRequestMethod($requestMethod);
     $webRequestParameters->setMethod($webServiceMethod);
     $webRequestParameters->setParameters($methodParameters);
     //        $webRequestParameters->setAppId($authenticationParamerters['app_id']);
     //        $webRequestParameters->setAppToken($authenticationParamerters['app_token']);
     //        $webRequestParameters->setSessionToken($authenticationParamerters['session_token']);
     return $webRequestParameters;
 }
开发者ID:lahirwisada,项目名称:orangehrm,代码行数:53,代码来源:WSHelper.php

示例4: extractParamerts

 /**
  *
  * @param sfWebRequest $request 
  * @return WSRequestParameters
  */
 public function extractParamerts(sfWebRequest $request)
 {
     $webRequestParameters = new WSRequestParameters();
     $requestMethod = $request->getMethod();
     $parameters = array_keys($request->getRequestParameters());
     if (count($parameters) < 4) {
         throw new WebServiceException('Web service method is not specified', 1001);
     }
     //$authenticationParamerters = json_decode($request->getHttpHeader('ohrm_ws_auth_parameters'), true);
     $methodParameters = json_decode($request->getHttpHeader('ohrm_ws_method_parameters'), true);
     //        if (!is_array($authenticationParamerters)) {
     //            throw new WebServiceException('Authentication parameters are sent in a wrong format', 1002);
     //        }
     if (!is_array($methodParameters)) {
         throw new WebServiceException('Method parameters are sent in a wrong format', 1003);
     }
     $webRequestParameters->setRequestMethod($requestMethod);
     $webRequestParameters->setMethod($parameters[2]);
     $webRequestParameters->setParameters($methodParameters);
     //        $webRequestParameters->setAppId($authenticationParamerters['app_id']);
     //        $webRequestParameters->setAppToken($authenticationParamerters['app_token']);
     //        $webRequestParameters->setSessionToken($authenticationParamerters['session_token']);
     return $webRequestParameters;
 }
开发者ID:EFForg,项目名称:lemonhrm,代码行数:29,代码来源:WSHelper.php

示例5: getProxyHeaders

 /**
  * getProxyHeaders
  *
  * @param sfWebRequest $request
  * @param boolean      $isStripUid
  * @return array
  */
 public static function getProxyHeaders($request, $isStripUid = true)
 {
     $results = array();
     if ($request->getHttpHeader('User-Agent')) {
         $userAgent = $request->getHttpHeader('User-Agent');
         if ($isStripUid) {
             if (preg_match('#^(DoCoMo/1\\.0.*)/(ser.*)$#', $userAgent, $match)) {
                 $userAgent = $match[1];
             } elseif (preg_match('#^(DoCoMo/2\\.0) (.*)\\((.*);(ser.*)\\)$#', $userAgent, $match)) {
                 $userAgent = $match[1] . ' ' . $match[2] . '(' . $match[3] . ')';
             } elseif (preg_match('#^((SoftBank|Vodafone|J-PHONE)/.*/.*)(/SN\\S*) (.*)$#', $userAgent, $match)) {
                 $userAgent = $match[1] . ' ' . $match[4];
             }
         }
         $results['User-Agent'] = $userAgent;
     }
     if (!$isStripUid) {
         $headerNames = array('X-DCMGUID', 'X-UP-SUBNO', 'X-JPHONE-UID');
         foreach ($headerNames as $name) {
             if ($request->getHttpHeader($name)) {
                 $results[$name] = $request->getHttpHeader($name);
             }
         }
     }
     $pathArray = $request->getPathInfoArray();
     foreach ($pathArray as $name => $value) {
         if (preg_match('/^HTTP_(X_(UP|JPHONE)_.*)$/', $name, $match)) {
             $name = strtr($match[1], '_', '-');
             if ($name !== 'X-JPHONE-UID' && $name !== 'X-UP-SUBNO') {
                 $results[$name] = $value;
             }
         }
     }
     $name = 'X-S-DISPLAY-INFO';
     if ($request->getHttpHeader($name)) {
         $results[$name] = $request->getHttpHeader($name);
     }
     return $results;
 }
开发者ID:niryuu,项目名称:opOpenSocialPlugin,代码行数:46,代码来源:opOpenSocialToolKit.class.php

示例6: executeThumbs

 /**
 * Method used to dynamically generate thumbnails for pagination lists.
 * Currently not in use since all thumbnails are stored on disk now.
 * Below is the old markup used in _basicListDisplay template that calls this action:
 * (to reuse this, modify the method to check for the disk on file first, then create 
 * thumbnail if necessary)
 * <div class='l'>
 			<table>
 				<tr><td><?php echo image_tag(url_for("@thumbs?img_file={$part['img_file']}&sf_format={$part['img_mime']}"), array('alt' => "{$part['part_no']}")) ?></td></tr>
 			</table>
 		</div>
 * @param sfWebRequest $request
 */
 public function executeThumbs(sfWebRequest $request)
 {
     // NOTE: All images are now files on disk (6/15/2010)
     $this->setLayout(false);
     $response = $this->getResponse();
     $response->clearHttpHeaders();
     $etag = '"' . md5($request->getParameter('img_file')) . '"';
     $response->setHttpHeader('Etag', $etag);
     if ($request->getHttpHeader('IF_NONE_MATCH') == $etag) {
         $response->setStatusCode(304, 'Not Modified');
     } else {
         // GD library uses jpeg not jpg.
         $mime_type = $request->getParameter('sf_format') == 'jpg' ? 'jpeg' : $request->getParameter('sf_format');
         $response->setContentType("image/{$mime_type}");
         $response->sendHttpHeaders();
         $thumb = new Thumbnail($request->getParameter('img_file'), $mime_type);
         try {
             if ($binary = $thumb->generate()) {
                 $response->setContent($binary);
             } else {
                 $response->setContentType('image/png');
                 $response->setContent(readfile(sfConfig::get('app_thumbs_dir') . 'default-trans.png'));
             }
         } catch (GDErrorException $gde) {
             $response->setContentType('image/png');
             $response->setContent(readfile(sfConfig::get('app_thumbs_dir') . 'default-trans.png'));
         }
         $thumb->freeMemoryResources();
         $response->sendHttpHeaders();
         $response->sendContent();
     }
     return sfView::HEADER_ONLY;
 }
开发者ID:morganney,项目名称:livewire,代码行数:46,代码来源:actions.class.php

示例7: executeScrape

 public function executeScrape(sfWebRequest $r)
 {
     // If it's a browser, redirect to homepage
     if (preg_match('#Mozilla#', $r->getHttpHeader('User-Agent'))) {
         $this->redirect("@homepage");
     }
     // Injection correct MIME header
     $this->getResponse()->setContentType("text/plain");
     // Not very clean, but it works !
     $infohash = array();
     foreach (explode("&", $_SERVER["QUERY_STRING"]) as $item) {
         if (substr($item, 0, 10) == "info_hash=") {
             $hash = substr($item, 10);
             $hash = urldecode($hash);
             if (get_magic_quotes_gpc()) {
                 $info_hash = stripslashes($hash);
             } else {
                 $info_hash = $hash;
             }
             if (strlen($info_hash) == 20) {
                 $info_hash = bin2hex($info_hash);
             } else {
                 if (strlen($info_hash) != 40) {
                     continue;
                 }
             }
             $infohash[] = strtolower($info_hash);
         }
     }
     if (!count($infohash)) {
         $this->btEnvoyerErreur("Invalid hash.");
     }
     $datetime = date("Y-m-d H:i:s", time() - sfConfig::get("app_bt_interval", 900) * 2);
     $q = Doctrine_Query::create()->select("t.hash, t.title")->addSelect('(SELECT COUNT(*) FROM TorrentsPeers tt WHERE remain = 0 AND tt.hash = t.hash AND updated_at > "' . $datetime . '") AS seeders')->addSelect('(SELECT COUNT(*) FROM TorrentsPeers ttt WHERE remain > 0 AND ttt.hash = t.hash AND updated_at > "' . $datetime . '") AS leechers')->addSelect('(SELECT COUNT(*) FROM TorrentsPeers tttt WHERE remain = 0 AND tttt.hash = t.hash) AS completed')->from("Uploads t")->whereIn("t.hash", $infohash)->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     $result = "d5:filesd";
     foreach ($q as $row) {
         $hash = $this->hex2bin($row['hash']);
         $result .= "20:" . $hash . "d";
         $result .= "8:completei" . $row['seeders'] . "e";
         $result .= "10:downloadedi" . $row['completed'] . "e";
         $result .= "10:incompletei" . $row['leechers'] . "e";
         $result .= "4:name" . strlen($row['title']) . ":" . $row['title'] . "e";
         $result .= "e";
     }
     $result .= "ee";
     echo $result;
     exit;
 }
开发者ID:thefkboss,项目名称:ZenTracker,代码行数:48,代码来源:actions.class.php


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