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


PHP Timestamp::getRFC1123GMT方法代码示例

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


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

示例1: send

 function send($content = null)
 {
     if (empty($this->url)) {
         return false;
     }
     if (!is_null($content)) {
         $this->content = $content;
     }
     $request = @parse_url($this->url);
     for ($trial = 0; $trial < 5; $trial++) {
         unset($this->_response);
         if (empty($request['scheme']) || $request['scheme'] != 'http' || empty($request['host'])) {
             return false;
         }
         if (empty($request['port'])) {
             $request['port'] = 80;
         }
         if (empty($request['path'])) {
             $request['path'] = '/';
         }
         if (!($socket = @fsockopen($request['host'], $request['port'], $errno, $errstr, $this->timeout))) {
             return false;
         }
         $path = empty($request['query']) ? $request['path'] : $request['path'] . '?' . $request['query'];
         fwrite($socket, $this->method . ' ' . $path . " HTTP/1.1\r\n");
         fwrite($socket, 'Host: ' . $request['host'] . "\r\n");
         fwrite($socket, "User-Agent: Mozilla/4.0 (compatible; Textcube " . TEXTCUBE_VERSION . ")\r\n");
         fwrite($socket, "Accept-Encoding: identity\r\n");
         if (!is_null($this->referer)) {
             fwrite($socket, "Referer: {$this->referer}\r\n");
         }
         if (!is_null($this->eTag)) {
             fwrite($socket, "If-None-Match: {$this->eTag}\r\n");
         }
         if (!is_null($this->lastModified)) {
             if (is_numeric($this->lastModified)) {
                 $this->lastModified = Timestamp::getRFC1123GMT($this->lastModified);
             }
             fwrite($socket, "If-Modified-Since: {$this->lastModified}\r\n");
         }
         if (!empty($this->content)) {
             fwrite($socket, "Content-Type: {$this->contentType}\r\n");
             fwrite($socket, "Content-Length: " . strlen($this->content) . "\r\n");
         }
         fwrite($socket, "Connection: close\r\n");
         fwrite($socket, "\r\n");
         if ($this->content !== false) {
             fwrite($socket, $this->content);
         }
         if ($this->async) {
             return true;
         }
         for (; $trial < 5; $trial++) {
             if (!($line = fgets($socket))) {
                 fclose($socket);
                 return false;
             }
             if (!preg_match('@^HTTP/([0-9\\.]+)[ \\t]+([0-9]+)[ \\t]+@', $line, $match)) {
                 fclose($socket);
                 return false;
             }
             $this->_response['version'] = $match[1];
             $this->_response['status'] = $match[2];
             while ($line = fgets($socket)) {
                 $line = rtrim($line);
                 if (empty($line)) {
                     break;
                 }
                 $header = explode(': ', $line, 2);
                 if (count($header) != 2) {
                     continue;
                 }
                 $header[0] = strtolower($header[0]);
                 switch ($header[0]) {
                     case 'connection':
                     case 'content-length':
                     case 'content-type':
                     case 'date':
                     case 'etag':
                     case 'last-modified':
                     case 'location':
                     case 'transfer-encoding':
                     case 'X-Pingback':
                     case 'X-CommunicationFeed':
                         $this->_response[$header[0]] = trim($header[1]);
                         break;
                 }
             }
             if ($this->_response['status'] != 100) {
                 break;
             }
             unset($this->_response);
         }
         if (in_array($this->_response['status'], array(300, 301, 302, 307))) {
             fclose($socket);
             if (empty($this->_response['location'])) {
                 return false;
             }
             $this->url = $this->_response['location'];
             $request['path'] = '/';
//.........这里部分代码省略.........
开发者ID:Avantians,项目名称:Textcube,代码行数:101,代码来源:Needlworks.PHP.HTTPRequest.php

示例2: fopen

    Respond::NotFoundPage();
}
if (!($attachment = getAttachmentByOnlyName($blogid, $suri['value']))) {
    Respond::NotFoundPage();
}
$fp = fopen(__TEXTCUBE_ATTACH_DIR__ . "/{$blogid}/{$attachment['name']}", 'rb');
if (!$fp) {
    Respond::NotFoundPage();
}
$fstat = fstat($fp);
if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    $modifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);
    if ($modifiedSince && $modifiedSince >= $fstat['mtime']) {
        fclose($fp);
        header('HTTP/1.1 304 Not Modified');
        header('Connection: close');
        exit;
    }
}
ini_set('zlib.output_compression', 'off');
header('Content-Disposition: attachment; filename="' . rawurlencode(Utils_Unicode::bring($attachment['label'])) . '"');
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . Timestamp::getRFC1123GMT($fstat['mtime']));
header('Content-Length: ' . $fstat['size']);
header('Content-Type: ' . $attachment['mime']);
header('Cache-Control: private');
header('Pragma: no-cache');
header('Connection: close');
fpassthru($fp);
fclose($fp);
downloadAttachment($attachment['name']);
开发者ID:webhacking,项目名称:Textcube,代码行数:31,代码来源:attachment.php


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