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


PHP HTTP::GetDateTimestamp方法代码示例

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


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

示例1: curl_getinfo

 function curl_getinfo($ch, $opt = 0)
 {
     global $curl_init__map;
     $key = get_check_curl_init_key($ch);
     if (!isset($curl_init__map[$key]["lastresult"])) {
         return false;
     }
     $result = array("url" => $curl_init__map[$key]["lastresult"]["url"], "content_type" => isset($curl_init__map[$key]["lastresult"]["headers"]) && isset($curl_init__map[$key]["lastresult"]["headers"]["Content-Type"]) ? $curl_init__map[$key]["lastresult"]["headers"]["Content-Type"][0] : null, "http_code" => isset($curl_init__map[$key]["lastresult"]["response"]) && isset($curl_init__map[$key]["lastresult"]["response"]["code"]) ? (int) $curl_init__map[$key]["lastresult"]["response"]["code"] : null, "header_size" => isset($curl_init__map[$key]["lastresult"]["rawrecvheadersize"]) ? $curl_init__map[$key]["lastresult"]["rawrecvheadersize"] : 0, "request_size" => isset($curl_init__map[$key]["lastresult"]["totalrawsendsize"]) ? $curl_init__map[$key]["lastresult"]["totalrawsendsize"] : 0, "filetime" => isset($curl_init__map[$key]["options"][CURLOPT_FILETIME]) && $curl_init__map[$key]["options"][CURLOPT_FILETIME] && isset($curl_init__map[$key]["lastresult"]["headers"]) && isset($curl_init__map[$key]["lastresult"]["headers"]["Last-Modified"]) ? HTTP::GetDateTimestamp($curl_init__map[$key]["lastresult"]["headers"]["Last-Modified"][0]) : -1, "ssl_verify_result" => 0, "redirect_count" => isset($curl_init__map[$key]["lastresult"]["numredirects"]) ? $curl_init__map[$key]["lastresult"]["numredirects"] : 0, "total_time" => isset($curl_init__map[$key]["lastresult"]["startts"]) && isset($curl_init__map[$key]["lastresult"]["endts"]) ? $curl_init__map[$key]["lastresult"]["endts"] - $curl_init__map[$key]["lastresult"]["startts"] : 0, "namelookup_time" => isset($curl_init__map[$key]["lastresult"]["startts"]) && isset($curl_init__map[$key]["lastresult"]["connected"]) ? ($curl_init__map[$key]["lastresult"]["connected"] - $curl_init__map[$key]["lastresult"]["startts"]) / 2 : 0, "connect_time" => isset($curl_init__map[$key]["lastresult"]["startts"]) && isset($curl_init__map[$key]["lastresult"]["connected"]) ? ($curl_init__map[$key]["lastresult"]["connected"] - $curl_init__map[$key]["lastresult"]["startts"]) / 2 : 0, "pretransfer_time" => isset($curl_init__map[$key]["lastresult"]["connected"]) && isset($curl_init__map[$key]["lastresult"]["sendstart"]) ? $curl_init__map[$key]["lastresult"]["sendstart"] - $curl_init__map[$key]["lastresult"]["connected"] : 0, "size_upload" => isset($curl_init__map[$key]["lastresult"]["rawsendsize"]) && isset($curl_init__map[$key]["lastresult"]["rawsendheadersize"]) ? $curl_init__map[$key]["lastresult"]["rawsendsize"] - $curl_init__map[$key]["lastresult"]["rawsendheadersize"] : 0, "size_download" => isset($curl_init__map[$key]["lastresult"]["rawrecvsize"]) && isset($curl_init__map[$key]["lastresult"]["rawrecvheadersize"]) ? $curl_init__map[$key]["lastresult"]["rawrecvsize"] - $curl_init__map[$key]["lastresult"]["rawrecvheadersize"] : 0);
     $result["speed_download"] = isset($curl_init__map[$key]["lastresult"]["recvstart"]) && isset($curl_init__map[$key]["lastresult"]["endts"]) && $curl_init__map[$key]["lastresult"]["endts"] - $curl_init__map[$key]["lastresult"]["recvstart"] > 0 ? $result["size_download"] / ($curl_init__map[$key]["lastresult"]["endts"] - $curl_init__map[$key]["lastresult"]["recvstart"]) : 0;
     $result["speed_upload"] = isset($curl_init__map[$key]["lastresult"]["sendstart"]) && isset($curl_init__map[$key]["lastresult"]["recvstart"]) && $curl_init__map[$key]["lastresult"]["recvstart"] - $curl_init__map[$key]["lastresult"]["sendstart"] > 0 ? $result["size_upload"] / ($curl_init__map[$key]["lastresult"]["recvstart"] - $curl_init__map[$key]["lastresult"]["sendstart"]) : 0;
     $result["download_content_length"] = isset($curl_init__map[$key]["lastresult"]["headers"]) && isset($curl_init__map[$key]["lastresult"]["headers"]["Content-Length"]) ? $curl_init__map[$key]["lastresult"]["headers"]["Content-Length"][0] : -1;
     $result["upload_content_length"] = $result["size_upload"];
     $result["starttransfer_time"] = isset($curl_init__map[$key]["lastresult"]["startts"]) && isset($curl_init__map[$key]["lastresult"]["sendstart"]) ? $curl_init__map[$key]["lastresult"]["sendstart"] - $curl_init__map[$key]["lastresult"]["startts"] : 0;
     $result["redirect_time"] = isset($curl_init__map[$key]["lastresult"]["firstreqts"]) && isset($curl_init__map[$key]["lastresult"]["redirectts"]) ? $curl_init__map[$key]["lastresult"]["redirectts"] - $curl_init__map[$key]["lastresult"]["firstreqts"] : 0;
     if (isset($curl_init__map[$key]["rawheaders"])) {
         $result["request_header"] = $curl_init__map[$key]["rawheaders"];
     }
     if ($opt == 0) {
         return $result;
     }
     $tempmap = array(CURLINFO_EFFECTIVE_URL => "url", CURLINFO_HTTP_CODE => "http_code", CURLINFO_FILETIME => "filetime", CURLINFO_TOTAL_TIME => "total_time", CURLINFO_NAMELOOKUP_TIME => "namelookup_time", CURLINFO_CONNECT_TIME => "connect_time", CURLINFO_PRETRANSFER_TIME => "pretransfer_time", CURLINFO_STARTTRANSFER_TIME => "starttransfer_time", CURLINFO_REDIRECT_TIME => "redirect_time", CURLINFO_SIZE_UPLOAD => "size_upload", CURLINFO_SIZE_DOWNLOAD => "size_download", CURLINFO_SPEED_DOWNLOAD => "speed_download", CURLINFO_SPEED_UPLOAD => "speed_upload", CURLINFO_HEADER_SIZE => "header_size", CURLINFO_HEADER_OUT => "request_header", CURLINFO_REQUEST_SIZE => "request_size", CURLINFO_SSL_VERIFYRESULT => "ssl_verify_result", CURLINFO_CONTENT_LENGTH_DOWNLOAD => "download_content_length", CURLINFO_CONTENT_LENGTH_UPLOAD => "upload_content_length", CURLINFO_CONTENT_TYPE => "content_type");
     if (!isset($tempmap[$opt]) || !isset($result[$tempmap[$opt]])) {
         return false;
     }
     return $result[$tempmap[$opt]];
 }
开发者ID:Scraps-Git,项目名称:PingPong,代码行数:26,代码来源:emulate_curl.php

示例2: Process


//.........这里部分代码省略.........
             $this->data["referer"] = $url;
         }
         if (isset($result["headers"]["Location"]) && $this->data["followlocation"]) {
             $redirectts = microtime(true);
             unset($tempoptions["method"]);
             unset($tempoptions["write_body_callback"]);
             unset($tempoptions["body"]);
             unset($tempoptions["postvars"]);
             unset($tempoptions["files"]);
             $tempoptions["headers"]["Referer"] = $url;
             $url = $result["headers"]["Location"][0];
             // Generate an absolute URL.
             if ($this->data["referer"] != "") {
                 $url = HTTP::ConvertRelativeToAbsoluteURL($this->data["referer"], $url);
             }
             $urlinfo2 = HTTP::ExtractURL($url);
             if (!isset($this->data["allowedredirprotocols"][$urlinfo2["scheme"]]) || !$this->data["allowedredirprotocols"][$urlinfo2["scheme"]]) {
                 return array("success" => false, "error" => HTTP::HTTPTranslate("Protocol '%s' is not allowed.  Server attempted to redirect to '%s'.", $urlinfo2["scheme"], $url), "info" => $result, "errorcode" => "allowed_redir_protocols");
             }
             if ($urlinfo2["host"] != $urlinfo["host"]) {
                 unset($tempoptions["headers"]["Host"]);
                 unset($httpopts["headers"]["Host"]);
             }
             $urlinfo = $urlinfo2;
             $numredirects++;
         }
         // Handle any 'Set-Cookie' headers.
         if (isset($result["headers"]["Set-Cookie"])) {
             foreach ($result["headers"]["Set-Cookie"] as $cookie) {
                 $items = explode("; ", $cookie);
                 $item = trim(array_shift($items));
                 if ($item != "") {
                     $cookie2 = array();
                     $pos = strpos($item, "=");
                     if ($pos === false) {
                         $cookie2["name"] = urldecode($item);
                         $cookie2["value"] = "";
                     } else {
                         $cookie2["name"] = urldecode(substr($item, 0, $pos));
                         $cookie2["value"] = urldecode(substr($item, $pos + 1));
                     }
                     $cookie = array();
                     foreach ($items as $item) {
                         $item = trim($item);
                         if ($item != "") {
                             $pos = strpos($item, "=");
                             if ($pos === false) {
                                 $cookie[strtolower(trim(urldecode($item)))] = "";
                             } else {
                                 $cookie[strtolower(trim(urldecode(substr($item, 0, $pos))))] = urldecode(substr($item, $pos + 1));
                             }
                         }
                     }
                     $cookie = array_merge($cookie, $cookie2);
                     if (isset($cookie["expires"])) {
                         $ts = HTTP::GetDateTimestamp($cookie["expires"]);
                         $cookie["expires_ts"] = gmdate("Y-m-d H:i:s", $ts === false ? time() - 24 * 60 * 60 : $ts);
                     } else {
                         if (isset($cookie["max-age"])) {
                             $cookie["expires_ts"] = gmdate("Y-m-d H:i:s", time() + (int) $cookie["max-age"]);
                         } else {
                             unset($cookie["expires_ts"]);
                         }
                     }
                     if (!isset($cookie["domain"])) {
                         $cookie["domain"] = $dothost;
                     }
                     if (substr($cookie["domain"], 0, 1) != ".") {
                         $cookie["domain"] = "." . $cookie["domain"];
                     }
                     if (!isset($cookie["path"])) {
                         $cookie["path"] = $cookiepath;
                     }
                     $cookie["path"] = str_replace("\\", "/", $cookie["path"]);
                     if (substr($cookie["path"], -1) != "/") {
                         $cookie["path"] = "/";
                     }
                     if (!isset($this->data["cookies"][$cookie["domain"]])) {
                         $this->data["cookies"][$cookie["domain"]] = array();
                     }
                     if (!isset($this->data["cookies"][$cookie["domain"]][$cookie["path"]])) {
                         $this->data["cookies"][$cookie["domain"]][$cookie["path"]] = array();
                     }
                     $this->data["cookies"][$cookie["domain"]][$cookie["path"]][] = $cookie;
                 }
             }
         }
         if ($numfollow > 0) {
             $numfollow--;
         }
     } while (isset($result["headers"]["Location"]) && $this->data["followlocation"] && $numfollow);
     $result["numredirects"] = $numredirects;
     $result["redirectts"] = $redirectts;
     // Extract the forms from the page in a parsed format.
     // Call WebBrowser::GenerateFormRequest() to prepare an actual request for Process().
     if ($this->data["extractforms"]) {
         $result["forms"] = $this->ExtractForms($result["url"], $result["body"]);
     }
     return $result;
 }
开发者ID:harrylongworth,项目名称:tv-bb,代码行数:101,代码来源:web_browser.php


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