• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP explode_url函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中explode_url函数的典型用法代码示例。如果您正苦于以下问题:PHP explode_url函数的具体用法?PHP explode_url怎么用?PHP explode_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: resolve_url

 static function resolve_url($url, $proto, $host, $base_path)
 {
     $parsed_url = explode_url($url);
     $message = null;
     $remote = $proto && $proto !== "file://" || $parsed_url['protocol'] != "";
     $datauri = strpos($parsed_url['protocol'], "data:") === 0;
     try {
         if (!DOMPDF_ENABLE_REMOTE && $remote && !$datauri) {
             throw new DOMPDF_Image_Exception("DOMPDF_ENABLE_REMOTE is set to FALSE");
         } else {
             if (DOMPDF_ENABLE_REMOTE && $remote || $datauri) {
                 $full_url = dompdf_build_url($proto, $host, $base_path, $url);
                 if (isset(self::$_cache[$full_url])) {
                     $resolved_url = self::$_cache[$full_url];
                 } else {
                     $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_");
                     if ($datauri) {
                         if ($parsed_data_uri = parse_data_uri($url)) {
                             $image = $parsed_data_uri['data'];
                         }
                     } else {
                         $old_err = set_error_handler("record_warnings");
                         $image = wp_remote_get($full_url);
                         $image = isset($image['body']) ? $image['body'] : '';
                         restore_error_handler();
                     }
                     if (strlen($image) == 0) {
                         $msg = $datauri ? "Data-URI could not be parsed" : "Image not found";
                         throw new DOMPDF_Image_Exception($msg);
                     } else {
                         file_put_contents($resolved_url, $image);
                     }
                 }
             } else {
                 $resolved_url = dompdf_build_url($proto, $host, $base_path, $url);
             }
         }
         if (!is_readable($resolved_url) || !filesize($resolved_url)) {
             throw new DOMPDF_Image_Exception("Image not readable or empty");
         } else {
             list($width, $height, $type) = dompdf_getimagesize($resolved_url);
             if ($width && $height && in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_BMP))) {
                 if (DOMPDF_ENABLE_REMOTE && $remote) {
                     self::$_cache[$full_url] = $resolved_url;
                 }
             } else {
                 throw new DOMPDF_Image_Exception("Image type unknown");
                 unlink($resolved_url);
             }
         }
     } catch (DOMPDF_Image_Exception $e) {
         $resolved_url = self::$broken_image;
         $type = IMAGETYPE_PNG;
         $message = $e->getMessage() . " \n {$url}";
     }
     return array($resolved_url, $type, $message);
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:57,代码来源:image_cache.cls.php


示例2: resolve_url

 /**
  * Resolve and fetch an image for use.
  *
  * @param string $url        The url of the image
  * @param string $proto      Default protocol if none specified in $url
  * @param string $host       Default host if none specified in $url
  * @param string $base_path  Default path if none specified in $url
  * @return array             An array with two elements: The local path to the image and the image extension
  */
 static function resolve_url($url, $proto, $host, $base_path)
 {
     global $_dompdf_warnings;
     $resolved_url = null;
     // Remove dynamic part of url to determine the file extension
     $tmp = preg_replace('/\\?.*/', '', $url);
     // We need to preserve the file extenstion
     $i = mb_strrpos($tmp, ".");
     if ($i === false) {
         throw new DOMPDF_Exception("Unknown image type: {$url}.");
     }
     $ext = mb_strtolower(mb_substr($tmp, $i + 1));
     $parsed_url = explode_url($url);
     $remote = $proto != "" && $proto != "file://";
     $remote = $remote || $parsed_url['protocol'] != "";
     if (!DOMPDF_ENABLE_REMOTE && $remote) {
         $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
         $ext = "png";
     } else {
         if (DOMPDF_ENABLE_REMOTE && $remote) {
             // Download remote files to a temporary directory
             $url = build_url($proto, $host, $base_path, $url);
             if (isset(self::$_cache[$url])) {
                 list($resolved_url, $ext) = self::$_cache[$url];
                 //echo "Using cached image $url (" . $resolved_url . ")\n";
             } else {
                 //echo "Downloading file $url to temporary location: ";
                 $resolved_url = tempnam(DOMPDF_TEMP_DIR, "dompdf_img_");
                 //echo $resolved_url . "\n";
                 $old_err = set_error_handler("record_warnings");
                 $image = file_get_contents($url);
                 restore_error_handler();
                 if (strlen($image) == 0) {
                     $image = file_get_contents(DOMPDF_LIB_DIR . "/res/broken_image.png");
                     $ext = "png";
                 }
                 file_put_contents($resolved_url, $image);
                 self::$_cache[$url] = array($resolved_url, $ext);
             }
         } else {
             $resolved_url = build_url($proto, $host, $base_path, $url);
             //echo $resolved_url . "\n";
         }
     }
     if (!is_readable($resolved_url) || !filesize($resolved_url)) {
         $_dompdf_warnings[] = "File " . $resolved_url . " is not readable or is an empty file.\n";
         $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
         $ext = "png";
     }
     // Assume for now that all dynamic images are pngs
     if ($ext == "php") {
         $ext = "png";
     }
     return array($resolved_url, $ext);
 }
开发者ID:SkMamtajuddin,项目名称:bamboo-invoice,代码行数:64,代码来源:image_cache.cls.php


示例3: set_background_image

 /**
  * Set the background image url
  *
  * @link http://www.w3.org/TR/CSS21/colors.html#background-properties
  * @param string $url
  */
 function set_background_image($val)
 {
     if (mb_strpos($val, "url") !== false) {
         $val = preg_replace("/url\\(['\"]?([^'\")]+)['\"]?\\)/", "\\1", trim($val));
     } else {
         $val = "none";
     }
     // Resolve the url now in the context of the current stylesheet
     $parsed_url = explode_url($val);
     if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") {
         $url = realpath($this->_stylesheet->get_base_path() . $parsed_url["file"]);
     } else {
         $url = build_url($this->_stylesheet->get_protocol(), $this->_stylesheet->get_host(), $this->_stylesheet->get_base_path(), $val);
     }
     $this->_props["background_image"] = $url;
 }
开发者ID:artre,项目名称:study,代码行数:22,代码来源:style.cls.php


示例4: _process_html

 /**
  * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to
  * the {@link Frame_Tree}
  */
 protected function _process_html()
 {
     $this->_tree->build_tree();
     $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET, Stylesheet::ORIG_UA);
     $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES;
     $acceptedmedia[] = $this->get_option("default_media_type");
     // <base href="" />
     $base_nodes = $this->_xml->getElementsByTagName("base");
     if ($base_nodes->length && ($href = $base_nodes->item(0)->getAttribute("href"))) {
         list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($href);
     }
     // Set the base path of the Stylesheet to that of the file being processed
     $this->_css->set_protocol($this->_protocol);
     $this->_css->set_host($this->_base_host);
     $this->_css->set_base_path($this->_base_path);
     // Get all the stylesheets so that they are processed in document order
     $xpath = new DOMXPath($this->_xml);
     $stylesheets = $xpath->query("//*[name() = 'link' or name() = 'style']");
     foreach ($stylesheets as $tag) {
         switch (strtolower($tag->nodeName)) {
             // load <link rel="STYLESHEET" ... /> tags
             case "link":
                 if (mb_strtolower(stripos($tag->getAttribute("rel"), "stylesheet") !== false) || mb_strtolower($tag->getAttribute("type")) === "text/css") {
                     //Check if the css file is for an accepted media type
                     //media not given then always valid
                     $formedialist = preg_split("/[\\s\n,]/", $tag->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY);
                     if (count($formedialist) > 0) {
                         $accept = false;
                         foreach ($formedialist as $type) {
                             if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) {
                                 $accept = true;
                                 break;
                             }
                         }
                         if (!$accept) {
                             //found at least one mediatype, but none of the accepted ones
                             //Skip this css file.
                             continue;
                         }
                     }
                     $url = $tag->getAttribute("href");
                     $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url);
                     $this->_css->load_css_file($url, Stylesheet::ORIG_AUTHOR);
                 }
                 break;
                 // load <style> tags
             // load <style> tags
             case "style":
                 // Accept all <style> tags by default (note this is contrary to W3C
                 // HTML 4.0 spec:
                 // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media
                 // which states that the default media type is 'screen'
                 if ($tag->hasAttributes() && ($media = $tag->getAttribute("media")) && !in_array($media, $acceptedmedia)) {
                     continue;
                 }
                 $css = "";
                 if ($tag->hasChildNodes()) {
                     $child = $tag->firstChild;
                     while ($child) {
                         $css .= $child->nodeValue;
                         // Handle <style><!-- blah --></style>
                         $child = $child->nextSibling;
                     }
                 } else {
                     $css = $tag->nodeValue;
                 }
                 $this->_css->load_css($css);
                 break;
         }
     }
 }
开发者ID:keshvenderg,项目名称:cloudshop,代码行数:75,代码来源:dompdf.cls.php


示例5: load_html_file

 /**
  * Loads an HTML file
  *
  * Parse errors are stored in the global array _dompdf_warnings.
  *
  * @param string $file a filename or url to load
  */
 function load_html_file($file)
 {
     $this->save_locale();
     // Store parsing warnings as messages (this is to prevent output to the
     // browser if the html is ugly and the dom extension complains,
     // preventing the pdf from being streamed.)
     if (!$this->_protocol && !$this->_base_host && !$this->_base_path) {
         list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
     }
     if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol !== "file://")) {
         throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
     }
     if ($this->_protocol == "" || $this->_protocol === "file://") {
         $realfile = realpath($file);
         if (!$file) {
             throw new DOMPDF_Exception("File '{$file}' not found.");
         }
         if (strpos($realfile, DOMPDF_CHROOT) !== 0) {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         // Exclude dot files (e.g. .htaccess)
         if (substr(basename($realfile), 0, 1) === ".") {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         $file = $realfile;
     }
     $contents = file_get_contents($file, null, $this->_http_context);
     $encoding = null;
     // See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
     if (isset($http_response_header)) {
         foreach ($http_response_header as $_header) {
             if (preg_match("@Content-Type:\\s*[\\w/]+;\\s*?charset=([^\\s]+)@i", $_header, $matches)) {
                 $encoding = strtoupper($matches[1]);
                 break;
             }
         }
     }
     $this->restore_locale();
     $this->load_html($contents, $encoding);
 }
开发者ID:practo,项目名称:dompdf,代码行数:47,代码来源:dompdf.cls.php


示例6: _image

 protected function _image($val)
 {
     $DEBUGCSS = DEBUGCSS;
     $parsed_url = "none";
     if (mb_strpos($val, "url") === false) {
         $path = "none";
         //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
     } else {
         $val = preg_replace("/url\\(['\"]?([^'\")]+)['\"]?\\)/", "\\1", trim($val));
         // Resolve the url now in the context of the current stylesheet
         $parsed_url = explode_url($val);
         if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") {
             if ($parsed_url["path"][0] === '/' || $parsed_url["path"][0] === '\\') {
                 $path = $_SERVER["DOCUMENT_ROOT"] . '/';
             } else {
                 $path = $this->_stylesheet->get_base_path();
             }
             $path .= $parsed_url["path"] . $parsed_url["file"];
             $path = realpath($path);
             // If realpath returns FALSE then specifically state that there is no background image
             if (!$path) {
                 $path = 'none';
             }
         } else {
             $path = build_url($this->_stylesheet->get_protocol(), $this->_stylesheet->get_host(), $this->_stylesheet->get_base_path(), $val);
         }
     }
     if ($DEBUGCSS) {
         print "<pre>[_image\n";
         print_r($parsed_url);
         print $this->_stylesheet->get_protocol() . "\n" . $this->_stylesheet->get_base_path() . "\n" . $path . "\n";
         print "_image]</pre>";
     }
     return $path;
 }
开发者ID:skyosev,项目名称:OpenCart-Overclocked,代码行数:35,代码来源:style.cls.php


示例7: add_link

 /**
  * Add a link to the pdf
  *
  * @param string $url The url to link to
  * @param float  $x   The x position of the link
  * @param float  $y   The y position of the link
  * @param float  $width   The width of the link
  * @param float  $height   The height of the link
  */
 function add_link($url, $x, $y, $width, $height)
 {
     $y = $this->y($y) - $height;
     if (strpos($url, '#') === 0) {
         // Local link
         $name = substr($url, 1);
         if ($name) {
             $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=" . substr($url, 1) . " linewidth=0");
         }
     } else {
         list($proto, $host, $path, $file) = explode_url($url);
         if ($proto == "" || $proto == "file://") {
             return;
         }
         // Local links are not allowed
         $url = build_url($proto, $host, $path, $file);
         $url = str_replace("=", "%3D", rawurldecode($url));
         $action = $this->_pdf->create_action("URI", "url=" . $url);
         $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate={$action}} linewidth=0");
     }
 }
开发者ID:artre,项目名称:study,代码行数:30,代码来源:pdflib_adapter.cls.php


示例8: load_html_file

 /**
  * Loads an HTML file
  *
  * Parse errors are stored in the global array _dompdf_warnings.
  *
  * @param string $file a filename or url to load
  */
 function load_html_file($file)
 {
     // Store parsing warnings as messages (this is to prevent output to the
     // browser if the html is ugly and the dom extension complains,
     // preventing the pdf from being streamed.)
     if (!$this->_protocol && !$this->_base_host && !$this->_base_path) {
         list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
     }
     if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol !== "file://")) {
         throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
     }
     if ($this->_protocol == "" || $this->_protocol === "file://") {
         $realfile = realpath($file);
         if (!$file) {
             throw new DOMPDF_Exception("File '{$file}' not found.");
         }
         if (strpos($realfile, DOMPDF_CHROOT) !== 0) {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         // Exclude dot files (e.g. .htaccess)
         if (substr(basename($realfile), 0, 1) === ".") {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         $file = $realfile;
     }
     $this->load_html(file_get_contents($file));
 }
开发者ID:aodkrisda,项目名称:PHP-Digital-Format-Convert-Epub-Mobi-PDF,代码行数:34,代码来源:dompdf.cls.php


示例9: load_css_file

 /**
  * load and parse a CSS file
  *
  * @param string $file
  */
 function load_css_file($file)
 {
     global $_dompdf_warnings;
     // Prevent circular references
     if (array_key_exists($file, $this->_loaded_files)) {
         return;
     }
     $this->_loaded_files[$file] = true;
     list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = explode_url($file);
     if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol != "file://")) {
         record_warnings(E_USER_ERROR, "Remote CSS file '{$file}' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__);
         return;
     }
     if ($this->_protocol == "") {
         $file = $this->_base_path . $filename;
     }
     set_error_handler("record_warnings");
     $css = file_get_contents($file);
     restore_error_handler();
     if ($css == "") {
         record_warnings(E_USER_ERROR, "Unable to load css file {$file}", __FILE__, __LINE__);
         return;
     }
     $this->_parse_css($css);
 }
开发者ID:andrewroth,项目名称:c4c_intranet,代码行数:30,代码来源:stylesheet.cls.php


示例10: load_css_file

 /**
  * load and parse a CSS file
  *
  * @param string $file
  * @param int    $origin
  */
 function load_css_file($file, $origin = self::ORIG_AUTHOR)
 {
     if ($origin) {
         $this->_current_origin = $origin;
     }
     // Prevent circular references
     if (isset($this->_loaded_files[$file])) {
         return;
     }
     $this->_loaded_files[$file] = true;
     if (strpos($file, "data:") === 0) {
         $parsed = parse_data_uri($file);
         $css = $parsed["data"];
     } else {
         $parsed_url = explode_url($file);
         list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = $parsed_url;
         // Fix submitted by Nick Oostveen for aliased directory support:
         if ($this->_protocol == "") {
             $file = $this->_base_path . $filename;
         } else {
             $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename);
         }
         set_error_handler("record_warnings");
         $css = file_get_contents($file, null, $this->_dompdf->get_http_context());
         restore_error_handler();
         $good_mime_type = true;
         // See http://the-stickman.com/web-development/php/getting-http-response-headers-when-using-file_get_contents/
         if (isset($http_response_header) && !$this->_dompdf->get_quirksmode()) {
             foreach ($http_response_header as $_header) {
                 if (preg_match("@Content-Type:\\s*([\\w/]+)@i", $_header, $matches) && $matches[1] !== "text/css") {
                     $good_mime_type = false;
                 }
             }
         }
         if (!$good_mime_type || $css == "") {
             record_warnings(E_USER_WARNING, "Unable to load css file {$file}", __FILE__, __LINE__);
             return;
         }
     }
     $this->_parse_css($css);
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:47,代码来源:stylesheet.cls.php


示例11: load_html_file

 /**
  * Loads an HTML file
  *
  * Parse errors are stored in the global array _dompdf_warnings.
  *
  * @param string $file a filename or url to load
  */
 function load_html_file($file)
 {
     // Store parsing warnings as messages (this is to prevent output to the
     // browser if the html is ugly and the dom extension complains,
     // preventing the pdf from being streamed.)
     list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
     if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol != "file://")) {
         throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
     }
     if (!DOMPDF_ENABLE_PHP) {
         set_error_handler("record_warnings");
         $this->_xml->loadHTMLFile($file);
         restore_error_handler();
     } else {
         $this->load_html(file_get_contents($file));
     }
 }
开发者ID:emeraldstudio,项目名称:somosmaestros,代码行数:24,代码来源:dompdf.cls.php


示例12: resolve_url

 /**
  * Resolve and fetch an image for use.
  *
  * @param string $url        The url of the image
  * @param string $proto      Default protocol if none specified in $url
  * @param string $host       Default host if none specified in $url
  * @param string $base_path  Default path if none specified in $url
  * @return array             An array with two elements: The local path to the image and the image extension
  */
 static function resolve_url($url, $proto, $host, $base_path)
 {
     global $_dompdf_warnings;
     $parsed_url = explode_url($url);
     $DEBUGPNG = DEBUGPNG;
     //=DEBUGPNG; Allow override of global setting for ad hoc debug
     $full_url_dbg = '';
     //debugpng
     if ($DEBUGPNG) {
         print 'resolve_url(' . $url . ',' . $proto . ',' . $host . ',' . $base_path . ')(' . $parsed_url['protocol'] . ')';
     }
     $remote = $proto != "" && $proto !== "file://";
     $remote = $remote || $parsed_url['protocol'] != "";
     if (!DOMPDF_ENABLE_REMOTE && $remote) {
         $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
         $ext = "png";
         //debugpng
         if ($DEBUGPNG) {
             $full_url_dbg = '(blockedremote)';
         }
     } else {
         if (DOMPDF_ENABLE_REMOTE && $remote) {
             // Download remote files to a temporary directory
             $full_url = build_url($proto, $host, $base_path, $url);
             if (isset(self::$_cache[$full_url])) {
                 list($resolved_url, $ext) = self::$_cache[$full_url];
                 //debugpng
                 if ($DEBUGPNG) {
                     $full_url_dbg = $full_url . '(cache)';
                 }
             } else {
                 $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_");
                 //debugpng
                 if ($DEBUGPNG) {
                     echo $resolved_url . "\n";
                 }
                 $old_err = set_error_handler("record_warnings");
                 $image = file_get_contents($full_url);
                 restore_error_handler();
                 if (strlen($image) == 0) {
                     //target image not found
                     $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
                     $ext = "png";
                     //debugpng
                     if ($DEBUGPNG) {
                         $full_url_dbg = $full_url . '(missing)';
                     }
                 } else {
                     file_put_contents($resolved_url, $image);
                     //e.g. fetch.php?media=url.jpg&cache=1
                     //- Image file name might be one of the dynamic parts of the url, don't strip off!
                     //  if ( preg_match("/.*\.(\w+)/",$url,$match) ) $ext = $match[1];
                     //- a remote url does not need to have a file extension at all
                     //- local cached file does not have a matching file extension
                     //Therefore get image type from the content
                     $imagedim = getimagesize($resolved_url);
                     if ($imagedim[2] >= 1 && $imagedim[2] <= 3 && $imagedim[0] && $imagedim[1]) {
                         //target image is valid
                         $imagetypes = array('', 'gif', 'jpeg', 'png', 'swf');
                         $ext = $imagetypes[$imagedim[2]];
                         if (rename($resolved_url, $resolved_url . '.' . $ext)) {
                             $resolved_url .= '.' . $ext;
                         }
                         //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup.
                         //Only execute on successfull caching of remote image.
                         self::$_cache[$full_url] = array($resolved_url, $ext);
                     } else {
                         //target image is not valid.
                         unlink($resolved_url);
                         $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png";
                         $ext = "png";
                     }
                 }
             }
         } else {
             $resolved_url = build_url($proto, $host, $base_path, $url);
             if ($DEBUGPNG) {
                 print 'build_url(' . $proto . ',' . $host . ',' . $base_path . ',' . $url . ')(' . $resolved_url . ')';
             }
             if (!preg_match("/.*\\.(\\w+)/", $url, $match)) {
                 //debugpng
                 if ($DEBUGPNG) {
                     print '[resolve_url exception ' . $url . ']';
                 }
                 throw new DOMPDF_Exception("Unknown image type: {$url}.");
             }
             $ext = $match[1];
             //debugpng
             if ($DEBUGPNG) {
                 $full_url_dbg = '(local)';
             }
//.........这里部分代码省略.........
开发者ID:kuwox,项目名称:buenavista,代码行数:101,代码来源:image_cache.cls.php


示例13: load_html_file

 function load_html_file($file)
 {
     $this->save_locale();
     if (!$this->_protocol && !$this->_base_host && !$this->_base_path) {
         list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file);
     }
     if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol !== "file://")) {
         throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false.");
     }
     if ($this->_protocol == "" || $this->_protocol === "file://") {
         $realfile = realpath($file);
         if (!$file) {
             throw new DOMPDF_Exception("File '{$file}' not found.");
         }
         if (strpos($realfile, DOMPDF_CHROOT) !== 0) {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         if (substr(basename($realfile), 0, 1) === ".") {
             throw new DOMPDF_Exception("Permission denied on {$file}.");
         }
         $file = $realfile;
     }
     $contents = file_get_contents($file, null, $this->_http_context);
     $encoding = null;
     if (isset($http_response_header)) {
         foreach ($http_response_header as $_header) {
             if (preg_match("@Content-Type:\\s*[\\w/]+;\\s*?charset=([^\\s]+)@i", $_header, $matches)) {
                 $encoding = strtoupper($matches[1]);
                 break;
             }
         }
     }
     $this->restore_locale();
     $this->load_html($contents, $encoding);
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:35,代码来源:dompdf.cls.php


示例14: _image

 protected function _image($val)
 {
     $DEBUGCSS = DEBUGCSS;
     if (mb_strpos($val, "url") === false) {
         $path = "none";
     } else {
         $val = preg_replace("/url\\(['\"]?([^'\")]+)['\"]?\\)/", "\\1", trim($val));
         $parsed_url = explode_url($val);
         if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") {
             if ($parsed_url["path"][0] === '/' || $parsed_url["path"][0] === '\\') {
                 $path = $_SERVER["DOCUMENT_ROOT"] . '/';
             } else {
                 $path = $this->_stylesheet->get_base_path();
             }
             $path .= $parsed_url["path"] . $parsed_url["file"];
             $path = realpath($path);
             if (!$path) {
                 $path = 'none';
             }
         } else {
             $path = dompdf_build_url($this->_stylesheet->get_protocol(), $this->_stylesheet->get_host(), $this->_stylesheet->get_base_path(), $val);
         }
     }
     if ($DEBUGCSS) {
         print "<pre>[_image\n";
         print_r($parsed_url);
         print $this->_stylesheet->get_protocol() . "\n" . $this->_stylesheet->get_base_path() . "\n" . $path . "\n";
         print "_image]</pre>";
     }
     return $path;
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:31,代码来源:style.cls.php


示例15: resolve_url

 /**
  * Resolve and fetch an image for use.
  *
  * @param string $url        The url of the image
  * @param string $proto      Default protocol if none specified in $url
  * @param string $host       Default host if none specified in $url
  * @param string $base_path  Default path if none specified in $url
  * @return array             An array with two elements: The local path to the image and the image extension
  */
 static function resolve_url($url, $proto, $host, $base_path)
 {
     $parsed_url = explode_url($url);
     $message = null;
     $remote = $proto && $proto !== "file://" || $parsed_url['protocol'] != "";
     $datauri = strpos($parsed_url['protocol'], "data:") === 0;
     try {
         // Remote not allowed and is not DataURI
         if (!DOMPDF_ENABLE_REMOTE && $remote && !$datauri) {
             throw new DOMPDF_Image_Exception("DOMPDF_ENABLE_REMOTE is set to FALSE");
         } else {
             if (DOMPDF_ENABLE_REMOTE && $remote || $datauri) {
                 // Download remote files to a temporary directory
                 $full_url = build_url($proto, $host, $base_path, $url);
                 // From cache
                 if (isset(self::$_cache[$full_url])) {
                     $resolved_url = self::$_cache[$full_url];
                 } else {
                     $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_");
                     if ($datauri) {
                         if ($parsed_data_uri = parse_data_uri($url)) {
                             $image = $parsed_data_uri['data'];
                         }
                     } else {
                         $old_err = set_error_handler("record_warnings");
                         $image = file_get_contents($full_url);
                         restore_error_handler();
                     }
                     // Image not found or invalid
                     if (strlen($image) == 0) {
                         $msg = $datauri ? "Data-URI could not be parsed" : "Image not found";
                         throw new DOMPDF_Image_Exception($msg);
                     } else {
                         //e.g. fetch.php?media=url.jpg&cache=1
                         //- Image file name might be one of the dynamic parts of the url, don't strip off!
                         //- a remote url does not need to have a file extension at all
                         //- local cached file does not have a matching file extension
                         //Therefore get image type from the content
                         file_put_contents($resolved_url, $image);
                     }
                 }
             } else {
                 $resolved_url = build_url($proto, $host, $base_path, $url);
             }
         }
         // Check if the local file is readable
         if (!is_readable($resolved_url) || !filesize($resolved_url)) {
             throw new DOMPDF_Image_Exception("Image not readable or empty");
         } else {
             list($width, $height, $type) = dompdf_getimagesize($resolved_url);
             // Known image type
             if ($width && $height && in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_PNG, IMAGETYPE_JPEG, IMAGETYPE_BMP))) {
                 //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup.
                 //Only execute on successfull caching of remote image.
                 if (DOMPDF_ENABLE_REMOTE && $remote) {
                     self::$_cache[$full_url] = $resolved_url;
                 }
             } else {
                 throw new DOMPDF_Image_Exception("Image type unknown");
                 unlink($resolved_url);
             }
         }
     } catch (DOMPDF_Image_Exception $e) {
         $resolved_url = self::$broken_image;
         $type = IMAGETYPE_PNG;
         $message = $e->getMessage() . " \n {$url}";
     }
     return array($resolved_url, $type, $message);
 }
开发者ID:teju,项目名称:Android,代码行数:78,代码来源:image_cache.cls.php


示例16: foreach

}
$dompdf->set_paper($paper, $orientation);
$dompdf->render();
if ($_dompdf_show_warnings) {
    foreach ($_dompdf_warnings as $msg) {
        echo $msg . "\n";
    }
    flush();
}
if ($save_file) {
    //   if ( !is_writable($outfile) )
    //     throw new DOMPDF_Exception("'$outfile' is not writable.");
    if (strtolower(DOMPDF_PDF_BACKEND) == "gd") {
        $outfile = str_replace(".pdf", ".png", $outfile);
    }
    list($proto, $host, $path, $file) = explode_url($outfile);
    if ($proto != "") {
        // i.e. not file://
        $outfile = $file;
    }
    // just save it locally, FIXME? could save it like wget: ./host/basepath/file
    $outfile = realpath(dirname($outfile)) . DIRECTORY_SEPARATOR . basename($outfile);
    if (strpos($outfile, DOMPDF_CHROOT) !== 0) {
        throw new DOMPDF_Exception("Permission denied.");
    }
    file_put_contents($outfile, $dompdf->output(array("compress" => 0)));
    exit(0);
}
if (!headers_sent()) {
    $dompdf->stream($outfile);
}
开发者ID:emeraldstudio,项目名称:somosmaestros,代码行数:31,代码来源:dompdf.php


示例17: load_css_file

 /**
  * load and parse a CSS file
  *
  * @param string $file
  */
 function load_css_file($file)
 {
     global $_dompdf_warnings;
     // Prevent circular references
     if (isset($this->_loaded_files[$file])) {
         return;
     }
     $this->_loaded_files[$file] = true;
     $parsed_url = explode_url($file);
     list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = $parsed_url;
     if (!DOMPDF_ENABLE_REMOTE && ($this->_protocol != "" && $this->_protocol != "file://")) {
         record_warnings(E_USER_WARNING, "Remote CSS file '{$file}' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__);
         return;
     }
     // Fix submitted by Nick Oostveen for aliased directory support:
     if ($this->_protocol == "") {
         $file = $this->_base_path . $filename;
     } else {
         $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename);
     }
     set_error_handler("record_warnings");
     $css = file_get_contents($file);
     restore_error_handler();
     if ($css == "") {
         record_warnings(E_USER_WARNING, "Unable to load css file {$file}", __FILE__, __LINE__);
         return;
     }
     $this->_parse_css($css);
 }
开发者ID:automatweb,项目名称:automatweb_dev,代码行数:34,代码来源:stylesheet.cls.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP explore函数代码示例发布时间:2022-05-15
下一篇:
PHP explode_keyword6函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap