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


PHP HTTP::ExtractFilename方法代码示例

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


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

示例1: curl_exec


//.........这里部分代码省略.........
                     $name = urldecode($postvar);
                     $val = "";
                 } else {
                     $name = urldecode(substr($postvar, 0, $pos));
                     $val = urldecode(substr($postvar, $pos + 1));
                 }
                 if (!isset($postvars2[$name])) {
                     $postvars2[$name] = array();
                 }
                 $postvars2[$name][] = $val;
             }
             $postvars = $postvars2;
             unset($postvars2);
         }
         foreach ($postvars as $name => $vals) {
             if (is_string($vals) || is_numeric($vals)) {
                 $vals = array($vals);
             }
             foreach ($vals as $num => $val) {
                 // Move files to their own array.
                 if (substr($val, 0, 1) == "@") {
                     $pos = strrpos($val, ";type=");
                     if ($pos === false) {
                         $mimetype = "";
                     } else {
                         $mimetype = substr($val, $pos + 6);
                         $val = substr($val, 0, $pos);
                     }
                     $val = substr($val, 1);
                     if (file_exists($val)) {
                         if (!isset($options["files"])) {
                             $options["files"] = array();
                         }
                         $options["files"][] = array("name" => $name, "filename" => HTTP::FilenameSafe(HTTP::ExtractFilename($val)), "type" => $mimetype, "datafile" => $val);
                         unset($vals[$num]);
                     }
                 }
             }
             if (!count($vals)) {
                 unset($postvars[$name]);
             } else {
                 $postvars[$name] = $vals;
             }
         }
         $options["postvars"] = $postvars;
         $options["method"] = "POST";
     }
     // Process the URL.
     if (!isset($curl_init__map[$key]["options"][CURLOPT_URL]) || !is_string($curl_init__map[$key]["options"][CURLOPT_URL]) || $curl_init__map[$key]["options"][CURLOPT_URL] == "") {
         $curl_init__map[$key]["errorno"] = CURLE_URL_MALFORMAT;
         $curl_init__map[$key]["errorinfo"] = HTTP::HTTPTranslate("No CURLOPT_URL option specified.");
         return false;
     }
     $url = HTTP::ExtractURL($curl_init__map[$key]["options"][CURLOPT_URL]);
     if ($url["scheme"] == "") {
         $curl_init__map[$key]["errorno"] = CURLE_URL_MALFORMAT;
         $curl_init__map[$key]["errorinfo"] = HTTP::HTTPTranslate("CURLOPT_URL does not have a scheme.");
         return false;
     }
     if ($url["host"] == "") {
         $curl_init__map[$key]["errorno"] = CURLE_URL_MALFORMAT;
         $curl_init__map[$key]["errorinfo"] = HTTP::HTTPTranslate("CURLOPT_URL does not specify a valid host.");
         return false;
     }
     if (isset($curl_init__map[$key]["options"][CURLOPT_PORT]) && (int) $curl_init__map[$key]["options"][CURLOPT_PORT] > 0 && (int) $curl_init__map[$key]["options"][CURLOPT_PORT] < 65536) {
         $url["port"] = (int) $curl_init__map[$key]["options"][CURLOPT_PORT];
开发者ID:Scraps-Git,项目名称:PingPong,代码行数:67,代码来源:emulate_curl.php

示例2: Process

 public function Process($url, $profile = "auto", $tempoptions = array())
 {
     $startts = microtime(true);
     $redirectts = $startts;
     if (isset($tempoptions["timeout"])) {
         $timeout = $tempoptions["timeout"];
     } else {
         if (isset($this->data["httpopts"]["timeout"])) {
             $timeout = $this->data["httpopts"]["timeout"];
         } else {
             $timeout = false;
         }
     }
     if (!isset($this->data["httpopts"]["headers"])) {
         $this->data["httpopts"]["headers"] = array();
     }
     $this->data["httpopts"]["headers"] = HTTP::NormalizeHeaders($this->data["httpopts"]["headers"]);
     unset($this->data["httpopts"]["method"]);
     unset($this->data["httpopts"]["write_body_callback"]);
     unset($this->data["httpopts"]["body"]);
     unset($this->data["httpopts"]["postvars"]);
     unset($this->data["httpopts"]["files"]);
     $httpopts = $this->data["httpopts"];
     $numfollow = $this->data["maxfollow"];
     $numredirects = 0;
     $totalrawsendsize = 0;
     if (!isset($tempoptions["headers"])) {
         $tempoptions["headers"] = array();
     }
     $tempoptions["headers"] = HTTP::NormalizeHeaders($tempoptions["headers"]);
     if (isset($tempoptions["headers"]["Referer"])) {
         $this->data["referer"] = $tempoptions["headers"]["Referer"];
     }
     // If a referrer is specified, use it to generate an absolute URL.
     if ($this->data["referer"] != "") {
         $url = HTTP::ConvertRelativeToAbsoluteURL($this->data["referer"], $url);
     }
     $urlinfo = HTTP::ExtractURL($url);
     do {
         if (!isset($this->data["allowedprotocols"][$urlinfo["scheme"]]) || !$this->data["allowedprotocols"][$urlinfo["scheme"]]) {
             return array("success" => false, "error" => HTTP::HTTPTranslate("Protocol '%s' is not allowed in '%s'.", $urlinfo["scheme"], $url), "errorcode" => "allowed_protocols");
         }
         $filename = HTTP::ExtractFilename($urlinfo["path"]);
         $pos = strrpos($filename, ".");
         $fileext = $pos !== false ? strtolower(substr($filename, $pos + 1)) : "";
         // Set up some standard headers.
         $headers = array();
         $profile = strtolower($profile);
         $tempprofile = explode("-", $profile);
         if (count($tempprofile) == 2) {
             $profile = $tempprofile[0];
             $fileext = $tempprofile[1];
         }
         if (substr($profile, 0, 2) == "ie" || $profile == "auto" && substr($this->data["useragent"], 0, 2) == "ie") {
             if ($fileext == "css") {
                 $headers["Accept"] = "text/css";
             } else {
                 if ($fileext == "png" || $fileext == "jpg" || $fileext == "jpeg" || $fileext == "gif" || $fileext == "svg") {
                     $headers["Accept"] = "image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5";
                 } else {
                     if ($fileext == "js") {
                         $headers["Accept"] = "application/javascript, */*;q=0.8";
                     } else {
                         if ($this->data["referer"] != "" || $fileext == "" || $fileext == "html" || $fileext == "xhtml" || $fileext == "xml") {
                             $headers["Accept"] = "text/html, application/xhtml+xml, */*";
                         } else {
                             $headers["Accept"] = "*/*";
                         }
                     }
                 }
             }
             $headers["Accept-Language"] = "en-US";
             $headers["User-Agent"] = HTTP::GetUserAgent(substr($profile, 0, 2) == "ie" ? $profile : $this->data["useragent"]);
         } else {
             if ($profile == "firefox" || $profile == "auto" && $this->data["useragent"] == "firefox") {
                 if ($fileext == "css") {
                     $headers["Accept"] = "text/css,*/*;q=0.1";
                 } else {
                     if ($fileext == "png" || $fileext == "jpg" || $fileext == "jpeg" || $fileext == "gif" || $fileext == "svg") {
                         $headers["Accept"] = "image/png,image/*;q=0.8,*/*;q=0.5";
                     } else {
                         if ($fileext == "js") {
                             $headers["Accept"] = "*/*";
                         } else {
                             $headers["Accept"] = "text/html, application/xhtml+xml, */*";
                         }
                     }
                 }
                 $headers["Accept-Language"] = "en-us,en;q=0.5";
                 $headers["Cache-Control"] = "max-age=0";
                 $headers["User-Agent"] = HTTP::GetUserAgent("firefox");
             } else {
                 if ($profile == "opera" || $profile == "auto" && $this->data["useragent"] == "opera") {
                     // Opera has the right idea:  Just send the same thing regardless of the request type.
                     $headers["Accept"] = "text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1";
                     $headers["Accept-Language"] = "en-US,en;q=0.9";
                     $headers["Cache-Control"] = "no-cache";
                     $headers["User-Agent"] = HTTP::GetUserAgent("opera");
                 } else {
                     if ($profile == "safari" || $profile == "chrome" || $profile == "auto" && ($this->data["useragent"] == "safari" || $this->data["useragent"] == "chrome")) {
//.........这里部分代码省略.........
开发者ID:harrylongworth,项目名称:tv-bb,代码行数:101,代码来源:web_browser.php


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