- }
-
- return $content;
- }
-
- /**
- * Get absolute URL.
- */
- private static function _getAbsoluteLink($relativeLink, $url)
- {
- /* return if already absolute URL */
- if (parse_url($relativeLink, PHP_URL_SCHEME) != '') {
- return $relativeLink;
- }
-
- /* queries and anchors */
- if ($relativeLink[0] == '#' || $relativeLink[0] == '?') {
- return $url.$relativeLink;
- }
-
- /* parse base URL and convert to local variables:
- $scheme, $host, $path */
- extract(parse_url($url));
-
- /* remove non-directory element from path */
- $path = preg_replace('#/[^/]*$#', '', $path);
-
- /* destroy path if relative url points to root */
- if ($relativeLink[0] == '/') {
- $path = '';
- }
-
- /* dirty absolute URL */
- $abs = $host.$path.'/'.$relativeLink;
-
- /* replace '//' or '/./' or '/foo/../' with '/' */
- $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#');
- for ($n = 1; $n > 0; $abs = preg_replace($re, '/', $abs, -1, $n)) {
- }
-
- /* absolute URL is ready! */
- return $scheme.'://'.$abs;
- }
-
- /**
- * Downloading pictures.
- *
- * @return bool true if the download and processing is OK, false else
- */
- private static function _downloadPictures($absolute_path, $fullpath)
- {
- $rawdata = Tools::getFile($absolute_path);
- $fullpath = urldecode($fullpath);