Пример #1
0
function buildPath($root, $path)
{
    // build an absolute path from root+path and checks security
    $dst = '/' . get_absolute_path($root . DIRECTORY_SEPARATOR . $path);
    checkJail($dst, $root);
    return $dst;
}
Пример #2
0
/**
 * Executes locally a file
 * 
 * @param type $workdir the working directory
 * @param type $script_path the script file, with path relative to the study_dir
 */
function execute_script_local($workdir, $cmd, $study, $jobid)
{
    include 'config.inc.php';
    if (chdir($workdir)) {
        $outfile = get_absolute_path(get_job_output_file($study, $jobid));
        # things that are needed to proc_open, see http://it2.php.net/manual/en/function.proc-open.php
        $pipes = 0;
        $descriptors = array(0 => array('pipe', 'r'), 1 => array('file', $outfile, 'a'), 2 => array('file', $outfile, 'a'));
        $env = array();
        $env["HOME"] = get_local_exec_dir(OC_User::getUser());
        $env["PATH"] = $_SERVER["PATH"];
        # use a UNIX command to get the current user name
        $env["USER"] = exec("whoami");
        chmod($cmd, 0755);
        $cmd = str_replace(" ", "\\ ", $cmd);
        $ph = proc_open($cmd . " &", $descriptors, $pipes, $workdir, $env);
        if ($ph) {
            /**
             * @var $status array
             */
            $status = proc_get_status($ph);
            $pid = $status["pid"];
            proc_close($ph);
            //
            // UGLY HACK , I increase the PID returned by proc_get_status by 1
            // why ? because proc_open() spawns a process /bin/sh, that in turn launches our script.
            // the full command is /bin/sh -c $command $args
            // Our process is the direct child of such shell process.
            // The $pid returned above is the PID of the shell process, not the script launched by that shell.
            //
            // Since in Unix the child process is always parent_pid + 1, it's mostly safe to increment that value by 1
            // to obtain the real PID
            //
            if ($pid) {
                $pid = (int) $pid + 1;
                $jobinfo = array("jobid" => $jobid, "pid" => $pid, "start_date" => date("Y-m-d H:i:s"), "script" => $cmd, "exec_dir" => $workdir, "exec_type" => "local");
                save_job_info($study, $jobid, $jobinfo);
                // TODO: here we should check if the job is effectively running with that PID
            }
            return $pid;
        }
        return false;
    } else {
        return false;
    }
}
Пример #3
0
        if ('..' == $part) {
            array_pop($absolutes);
        } else {
            $absolutes[] = $part;
        }
    }
    $prefix = '';
    if (DIRECTORY_SEPARATOR == '/') {
        $prefix = '/';
    }
    return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes);
}
//we know the path from root so we remove it to get the root
// '/../../..' for plugins; '/../..' for modules
define('_JEXEC', 1);
define('JPATH_BASE', get_absolute_path(dirname($_SERVER['SCRIPT_FILENAME']) . '/../../..'));
define('JPATH_MYWEBAPP', dirname($_SERVER['SCRIPT_FILENAME']));
require_once JPATH_BASE . '/includes/defines.php';
require_once JPATH_BASE . '/includes/framework.php';
require_once JPATH_LIBRARIES . '/joomla/factory.php';
require_once JPATH_LIBRARIES . '/import.php';
require_once JPATH_LIBRARIES . '/cms.php';
// Pre-Load configuration.
ob_start();
require_once JPATH_CONFIGURATION . '/configuration.php';
ob_end_clean();
// Now that you have it, use jimport to get the specific packages your application needs.
jimport('joomla.environment.uri');
jimport('joomla.utilities.date');
jimport('joomla.utilities.utility');
jimport('joomla.event.dispatcher');
Пример #4
0
            $absolutes[] = $part;
        }
    }
    $prefix = '';
    if (DIRECTORY_SEPARATOR == '/') {
        $prefix = '/';
    }
    return $prefix . implode(DIRECTORY_SEPARATOR, $absolutes);
}
if (file_exists(dirname(__FILE__) . '/defines.php')) {
    include_once dirname(__FILE__) . '/defines.php';
}
// Define some things. Doing it here instead of a file because this
// is a super simple application.
define('JPATH_BASE', dirname($_SERVER['SCRIPT_FILENAME']));
define('JPATH_ROOT', get_absolute_path(JPATH_BASE . '/../../..'));
define('JPATH_PLATFORM', JPATH_ROOT . '/libraries');
define('JPATH_SITE', JPATH_ROOT);
define('JPATH_CONFIGURATION', JPATH_ROOT);
define('JPATH_ADMINISTRATOR', JPATH_ROOT . '/administrator');
define('JPATH_LIBRARIES', JPATH_ROOT . '/libraries');
define('JPATH_PLUGINS', JPATH_ROOT . '/plugins');
define('JPATH_INSTALLATION', JPATH_ROOT . '/installation');
define('JPATH_THEMES', JPATH_ADMINISTRATOR . '/templates');
define('JPATH_CACHE', JPATH_ROOT . '/cache');
define('JPATH_MANIFESTS', JPATH_ADMINISTRATOR . '/manifests');
define('JPATH_MYWEBAPP', JPATH_BASE);
// Usually this will be in the framework.php file in the
// includes folder.
require_once JPATH_PLATFORM . '/import.php';
// Force library to be in JError legacy mode
Пример #5
0
<?php

header('Content-Type: text/html; charset=utf-8');
date_default_timezone_set('UTC');
require_once 'lib/MarkdownExtra.inc.php';
require_once 'lib/div.php';
require_once 'lib/mosquito-functions.php';
$_CONFIG = array('title' => 'mosquito', 'description' => 'Mini flyweight Static Site Generator written in PHP that can also be used as simple CMS, compiles Markdown files into HTML using the given folder structure as URL router model.', 'keywords' => 'mosquito, CMS, SSG, PHP, Markdown, static, site, generator, content, system', 'language' => 'en', 'author' => 'Jorge Moreno aka Moro ( moro.es, @alterebro )', 'theme' => 'mosquito', 'content_folder' => 'content/', 'file_extension' => '.md', 'minify_output' => true, 'dist_url' => 'http://localhost:8000/', 'dist_folder' => 'dist/', 'dist_extension' => '.html', 'use_menu_global' => true, 'use_breadcrumbs' => false);
$_PATH = array('path' => PHP_SAPI == "cli" ? $_CONFIG['dist_url'] : dirname($_SERVER['PHP_SELF']) . (dirname($_SERVER['PHP_SELF']) == '/' ? '' : '/'), 'url' => PHP_SAPI == "cli" ? $_CONFIG['dist_url'] : 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . (dirname($_SERVER['PHP_SELF']) == '/' ? '' : '/'), 'root' => DIRECTORY_SEPARATOR . get_absolute_path(dirname(__FILE__)) . DIRECTORY_SEPARATOR, 'content' => DIRECTORY_SEPARATOR . get_absolute_path(dirname(__FILE__)) . DIRECTORY_SEPARATOR . $_CONFIG['content_folder']);
$_DATA = array('site' => $_CONFIG, 'path' => $_PATH, 'file' => $_PATH['content'] . 'index' . $_CONFIG['file_extension'], 'content' => '', 'is_404' => false, 'metadata' => ['title' => false, 'description' => false, 'image' => false, 'tags' => false, 'layout' => 'index', 'timestamp' => false, 'url' => false]);
$_default_metadata = $_DATA['metadata'];
// Get the Query URL Parameter.
$_QUERY = !empty($_GET['q']) ? $_GET['q'] : '';
$_QUERY = trim($_QUERY, '/');
// _file
// -------------------
$_DATA['file'] = is_dir($_PATH['content'] . $_QUERY) ? '/' . trim($_PATH['content'] . $_QUERY, '/') . '/index' . $_CONFIG['file_extension'] : '/' . trim($_PATH['content'], '/') . '/' . $_QUERY . $_CONFIG['file_extension'];
// _is_404
// -------------------
$_DATA['is_404'] = file_exists($_DATA['file']) ? false : true;
// _extract_content
// -------------------
$file_to_extract = file_exists($_DATA['file']) ? $_DATA['file'] : $_PATH['content'] . '404' . $_CONFIG['file_extension'];
$c = extract_content($file_to_extract);
$_DATA['metadata'] = array_merge($_default_metadata, $c['metadata']);
$_DATA['metadata']['url'] = $_PATH['url'] . $_QUERY;
$_DATA['content'] = $c['content'];
// _render
// -------------------
function render_template($template, $data, $minify = false, $render = true)
{
Пример #6
0
 /**
  * Return file info or false on error
  *
  * @param  string   $hash      file hash
  * @param  bool     $realpath  add realpath field to file info
  * @return array|false
  * @author Dmitry (dio) Levashov
  **/
 public function file($hash)
 {
     $path = $this->decode($hash);
     //Security
     if (!isFilelinkInFolder($path, get_absolute_path($this->root)) && $path !== $this->root) {
         return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
     }
     return ($file = $this->stat($path)) ? $file : $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
     if (($file = $this->stat($path)) != false) {
         if ($realpath) {
             $file['realpath'] = $path;
         }
         return $file;
     }
     return $this->setError(elFinder::ERROR_FILE_NOT_FOUND);
 }
Пример #7
0
 function get_packages_dir()
 {
     $packages_relative_dir = '../../contenttest-packages/';
     $ret = get_absolute_path(dirname(__FILE__) . DIRECTORY_SEPARATOR . $packages_relative_dir);
     // Don't start with a slash on Windows
     return (DIRECTORY_SEPARATOR == "/" ? DIRECTORY_SEPARATOR : "") . $ret;
 }
Пример #8
0
    $baseUrl = $_POST['baseUrl'];
    $basePath = $_POST['basePath'];
    $virtPath = $_POST['virtPath'];
} else {
    $baseUrl = CONF_MODULE_ARG;
    // '/modules.php?name=leonardo';
    $basePath = '/modules/leonardo';
    $virtPath = $CONF['links']['baseURL'];
}
$virtPath2 = '';
$str = "\n#\nRewriteEngine On\nRewriteBase " . $virtPath . "\n\n# exclude the real path\nrewriteRule ^{$basePath}/ - [L]\n\n# various operations on a flight\nRewriteRule ^" . $virtPath2 . "flight/(\\d*)/kml/(.*)\$ {$basePath}/download.php?type=kml_trk&flightID=\$1&\$2 [L,NC]\nRewriteRule ^" . $virtPath2 . "flight/(\\d*)/igc/(.*)\$ {$basePath}/download.php?type=igc&flightID=\$1&\$2 [L,NC]\nRewriteRule ^" . $virtPath2 . "flight/(\\d*)(.*)\$ {$baseUrl}&op=show_flight&flightID=\$1\$2 [L,NC]\n\n#compare\nRewriteRule ^" . $virtPath2 . "compare/(\\d*)(.*)\$ {$baseUrl}&op=compare&flightID=\$1\$2 [L,NC]\nRewriteRule ^" . $virtPath2 . "compare3d/(\\d*)(.*)\$ {$baseUrl}&op=compare3d&flightID=\$1\$2 [L,NC]\n\n# various operations on a takeoff\nRewriteRule ^" . $virtPath2 . "takeoff/(\\d*)/kml/?\$ {$basePath}/download.php?type=kml_wpt&wptID=\$1 [L,NC]\nRewriteRule ^" . $virtPath2 . "takeoff/(\\d*)/?(.*)\$ {$baseUrl}&op=show_waypoint&waypointIDview=\$1\$2 [L,NC]\n\n# various operations on a pilot\n#RewriteRule ^" . $virtPath2 . "pilot/([\\d_]*)/stats/?(.*)\$   {$baseUrl}&op=pilot_profile_stats&pilotIDview=\$1\$2 [L,NC]\nRewriteRule ^" . $virtPath2 . "pilot/([\\d_]*)/flights/?(.*)\$ {$baseUrl}&op=list_flights&pilotIDview=\$1\$2   [L,NC]\nRewriteRule ^" . $virtPath2 . "pilot/([\\d_]*)/?(.*)\$ {$baseUrl}&op=pilot_profile&pilotIDview=\$1\$2  [L,NC]\n\n# all 'list' ops that are /opname/countryCode/date/....\nRewriteRule ^" . $virtPath2 . "tracks/(.*)/(.*)/(.*)\$ {$baseUrl}&op=list_flights&country=\$1&l_date=\$2&leoSeo=\$3 [L,NC]\nRewriteRule ^" . $virtPath2 . "stats/(.*)/(.*)/(.*)\$ {$baseUrl}&op=pilot_profile_stats&country=\$1&l_date=\$2&leoSeo=\$3 [L,NC]\nRewriteRule ^" . $virtPath2 . "ge/(.*)\$     {$basePath}/download.php?type=explore_ge&leoSeo=\$1 [L,NC]\nRewriteRule ^" . $virtPath2 . "pilots/(.*)/(.*)/(.*)\$  {$baseUrl}&op=list_pilots&country=\$1&l_date=\$2&leoSeo=\$3 [L,NC]\nRewriteRule ^" . $virtPath2 . "league/(.*)/(.*)/(.*)\$  {$baseUrl}&op=competition&country=\$1&l_date=\$2&leoSeo=\$3 [L,NC]\nRewriteRule ^" . $virtPath2 . "takeoffs/(.*)/(.*)/(.*)\$  {$baseUrl}&op=list_takeoffs&country=\$1&l_date=\$2&leoSeo=\$3 [L,NC]\n\nRewriteRule ^" . $virtPath2 . "ranks/(\\d*)\\.(\\d*)/(.*)/(.*)\$  {$baseUrl}&op=comp&rank=\$1&subrank=\$2&l_date=\$3&leoSeo=\$4 [L,NC]\n\n\nRewriteRule ^" . $virtPath2 . "page/(.*)\$ {$baseUrl}&op=\$1 [L,NC]\n\nRewriteRule ^" . $virtPath2 . "&(.*)\$ {$baseUrl}&\$1 [L,NC]\n\n# RewriteRule ^" . $virtPath2 . "?[^.]*\$ {$virtPath}/tracks/world/%{TIME_YEAR}/ [R,NC]\nRewriteRule ^" . $virtPath2 . "/?\$ tracks/world/%{TIME_YEAR}/ [N,NC]\n\nRewriteRule ^" . $virtPath2 . "(.*)\$ {$basePath}/\$1 [L,NC]\n";
if ($_POST['htaccessFile']) {
    $htaccessFile = stripslashes($_POST['htaccessFile']);
} else {
    $htaccessFileName = $CONF['os'] == 'linux' ? '.htaccess' : 'htaccess.txt';
    $htaccessFile = get_absolute_path(dirname(__FILE__) . '/../..' . $virtPath) . '/' . $htaccessFileName;
}
$htaccessFileParts = split('/', $htaccessFile);
array_pop($htaccessFileParts);
$htaccessFiledir = implode('/', $htaccessFileParts);
if ($htaccessFile[0] == '/') {
    $htaccessFiledir = '/' . $htaccessFiledir;
}
$mod_conf_File = dirname(__FILE__) . '/site/config_mod_rewrite.php';
if ($_POST['writeFile'] == 1) {
    $conf_str = '<?
	$CONF[\'links\'][\'type\']=3;
	$CONF[\'links\'][\'baseURL\']=\'' . $virtPath . '\';
?>';
    if (writeFile($mod_conf_File, $conf_str)) {
        echo "<span class='ok'>config_mod_rewrite.php updated</span>";
Пример #9
0
<?php

require "./common.php";
$folder = get_absolute_path(i($QUERY, 'folder'));
$current_folder = realpath(joinPath($base_folder, $folder));
if (!$current_folder) {
    $QUERY['error'] = "Can't find the specified folder - <strong>" . joinPath($base_folder, $folder) . "</strong>";
    render('error.php');
    exit;
}
if (strstr($current_folder, $base_folder) === false) {
    die("Its not that easy. Put in more effort! :-P");
}
// Slight hack attempt
$all_folders = ls('*', $current_folder, false, array('return_folders'));
$all_images = ls('*.*', $current_folder, false, array('return_files'));
render();
function get_absolute_path($path)
{
    $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
    $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
    $absolutes = array();
    foreach ($parts as $part) {
        if ('.' == $part) {
            continue;
        }
        if ('..' == $part) {
            array_pop($absolutes);
        } else {
            $absolutes[] = $part;
        }
Пример #10
0
        $dimensions = $media_detail['width'] . ' x ' . $media_detail['height'] . ' - ';
    } else {
        if ($extension == 'jpg' || $extension == 'gif' || $extension == 'png') {
            $length_size = byte_convert($media_detail['file_size']);
            $link = '../' . $settings['cms']['media_path'] . $media_detail["source"];
            $dimensions = $media_detail['width'] . ' x ' . $media_detail['height'] . ' - ';
        } else {
            $length_size = byte_convert($media_detail['file_size']);
            $link = '../' . $settings['cms']['media_path'] . $media_detail["source"];
            $dimensions = '';
        }
        // Get all non-video link texts
        $page_url_array = explode('/inc/', CMS_PAGE_URL);
        // Requires directus directory name
        $site_path = $page_url_array[0];
        $temp_path = get_absolute_path($site_path . '/../' . $settings['cms']['media_path'] . $media_detail["source"]);
        $link_text = highlight_custom($media_detail['source'], $temp_path, '<b>', '</b>');
    }
    $extension = ucwords($extension);
    //////////////////////////////////////////////////////////////////////////////
    ?>
						<table class="media_modal_details" cellpadding="0" cellspacing="0" border="0" style="width:100%">
							<tr>
								<?php 
    if ($extension == 'MP3' || $extension == 'OGG' || $extension == 'WAV') {
        ?>
								<td class="media_modal_thumb audio">
								<?php 
        echo generate_media_image($extension, $media_detail["source"], $media_detail["height"], $media_detail["width"], $media_detail["file_size"], 100);
        ?>
								</td>
if (!function_exists('get_absolute_path')) {
    function get_absolute_path()
    {
        $domain = '';
        if (isset($_SERVER['HTTP_HOST'])) {
            $domain = $_SERVER['HTTP_HOST'];
        } else {
            if (isset($_SERVER['SERVER_NAME'])) {
                $domain = $_SERVER['SERVER_NAME'];
            }
        }
        $port = strpos($domain, ':');
        if ($port !== false) {
            $domain = substr($domain, 0, $port);
        }
        // Get the path to the file
        $path = substr(dirname(__FILE__), strlen($_SERVER["DOCUMENT_ROOT"]));
        $apath = "//" . $domain . $path;
        $apath = str_replace('\\', '/', $apath);
        return $apath . '/..';
    }
}
// set the defaults url
if (!isset($site_url)) {
    $site_url = get_absolute_path();
}
//  setup new instance of plugin if not standalone
if (class_exists("advancediFrame")) {
    $cons_advancediFrame = new advancediFrame();
    echo $cons_advancediFrame->do_iframe_script(null, null);
}
 /**
  * Write a string to a file
  *
  * @param  string  $path     file path
  * @param  string  $content  new file content
  * @return bool
  * @author Dmitry (dio) Levashov
  **/
 protected function _filePutContents($path, $content)
 {
     //Security
     if (!isFilelinkInFolder($path, get_absolute_path($this->root))) {
         return false;
     }
     $a = register('pfh')->putContent($path, $content);
     return $a;
 }
Пример #13
0
/**
 * Converts a path such as 'login.php' to a full URL, or returns the current absolute url if path is not specified
 * @param string $path The path to convert, blank if the current url should be used
 * @return string The absolute URL
 */
function absolute_url($path = '')
{
    $isHTTPS = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on";
    $port = isset($_SERVER["SERVER_PORT"]) && (!$isHTTPS && $_SERVER["SERVER_PORT"] != "80" || $isHTTPS && $_SERVER["SERVER_PORT"] != "443");
    $port = $port ? ':' . $_SERVER["SERVER_PORT"] : '';
    $base = ($isHTTPS ? 'https://' : 'http://') . $_SERVER["SERVER_NAME"] . $port;
    if ($path != '') {
        $abs_path = str_replace("\\", "/", get_absolute_path(rtrim(dirname($_SERVER['PHP_SELF']), '/\\') . '/' . $path));
        return $base . '/' . $abs_path;
    } else {
        $query = isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != '' ? '?' . $_SERVER['QUERY_STRING'] : "";
        return $base . $_SERVER['PHP_SELF'] . $query;
    }
}
Пример #14
0
	<body onLoad="<?php 
echo $on_load;
?>
">
		<span>Errors: <?php 
print_r($error);
?>
</span>
		<div id="modal_html"><?php 
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
if ($_POST['type'] == 'inline') {
    $page_url_array = explode('/inc/', CMS_PAGE_URL);
    // Requires directus directory name
    $site_path = $page_url_array[0];
    $temp_path = get_absolute_path($site_path . '/../' . $settings['cms']['media_path']);
    foreach ($files_added as $media) {
        ?>
<img src="<?php 
        echo $temp_path . '/' . $media['source'];
        ?>
" alt="<?php 
        echo str_replace('"', "'", $media['title']);
        ?>
" width="<?php 
        echo $media['width'];
        ?>
" height="<?php 
        echo $media['height'];
        ?>
" /><?php 
Пример #15
0
function execfs_ls($nick, $path)
{
    global $fs;
    global $false;
    $path = get_absolute_path($nick, $path);
    $directory =& get_directory($path);
    if ($directory == $false) {
        execfs_privmsg("error: invalid path");
        return;
    }
    $children = array_keys($directory["children"]);
    $vars = array_keys($directory["vars"]);
    $path = get_path($directory);
    execfs_privmsg("current path for {$nick}: {$path}");
    if (count($children) > 0) {
        execfs_privmsg("children: " . implode(" ", $children));
    }
    if (count($vars) > 0) {
        execfs_privmsg("vars: " . implode(" ", $vars));
    }
    unset($directory);
}
Пример #16
0
function isFilelinkInFolder($strFilelink, $strFolder, $blnStrict = false)
{
    $strPath = pathinfo($strFilelink, PATHINFO_DIRNAME);
    if (substr($strFilelink, -1) == "/") {
        $strPath = $strPath . "/" . pathinfo($strFilelink, PATHINFO_BASENAME);
    }
    $strAbsolutePath = get_absolute_path($strPath);
    if (substr($strFolder, -1) == "/") {
        $strFolder = substr($strFolder, 0, -1);
    }
    if ($blnStrict) {
        if ($strAbsolutePath === $strFolder) {
            return true;
        }
    } else {
        if (strpos($strAbsolutePath, $strFolder) === 0) {
            return true;
        }
    }
    return false;
}
Пример #17
0
function resolve_url($url_str, $source_url_str)
{
    if (strpos($url_str, 'http://') === 0) {
        // nothing to do
        return $url_str;
    }
    if (strpos($url_str, 'https://') === 0) {
        // nothing to do
        return $url_str;
    }
    $source_url = parse_url($source_url_str);
    $url = parse_url($url_str);
    $final_url = "{$source_url['scheme']}://";
    if (isset($source_url['user']) || isset($source_url['pass'])) {
        $final_url .= "{$source_url['user']}:{$source_url['pass']}@";
    }
    $final_url .= $source_url['host'];
    if (isset($source_url['port'])) {
        $final_url .= ":{$source_url['port']}";
    }
    if (strpos($url_str, '/') === 0) {
        // absolute url, just add host/user/port
        return $final_url . $url_str;
    }
    if (strrpos($source_url['path'], '/') === strlen($source_url['path']) - 1) {
        $final_url .= '/' . get_absolute_path($source_url['path'] . $url['path']);
    } else {
        $final_url .= '/' . get_absolute_path(dirname($source_url['path']) . '/' . $url['path']);
    }
    if (isset($url['query'])) {
        $final_url .= "?{$url['query']}";
    }
    if (isset($url['fragment'])) {
        $final_url .= "#{$url['fragment']}";
    }
    return $final_url;
}
Пример #18
0
function getImagePath($fileUrl, $smarty)
{
    // Store the image url
    $paths['fileUrl'] = $fileUrl;
    // The name of the file: image.jpg
    $paths['fileName'] = basename($fileUrl);
    // The paths to the document we are working with
    $scriptName = $smarty->_supers['server']['SCRIPT_NAME'];
    $paths['docPath'] = removeFileFromPath(removeDoubleSlashes(str_replace($smarty->_supers['server']['SCRIPT_NAME'], '', $smarty->_supers['server']['SCRIPT_FILENAME']) . '/' . $smarty->_supers['server']['REQUEST_URI']));
    // The relative path to the document
    $docUri = $smarty->_supers['server']['REDIRECT_URL'] ? $smarty->_supers['server']['REDIRECT_URL'] : dirname($smarty->_supers['server']['SCRIPT_NAME']);
    $docUri = removeDoubleSlashes('/' . $docUri . '/');
    // If we've got an absolute image url...make it relative!
    $fileUri = str_replace('http://' . $smarty->_supers['server']['HTTP_HOST'], '', $fileUrl);
    $fileUri = str_replace('https://' . $smarty->_supers['server']['HTTP_HOST'], '', $fileUri);
    if (substr($fileUri, 0, 1) == DIRECTORY_SEPARATOR) {
        $docSegments = explode(DIRECTORY_SEPARATOR, $docUri);
        $fileSegments = explode(DIRECTORY_SEPARATOR, $fileUri);
        // Cycle through the url segments, working back from the current url to the image url
        while (count($docSegments) || count($fileSegments)) {
            $docSegment = array_shift($docSegments);
            $fileSegment = array_shift($fileSegments);
            if ($docSegment != $fileSegment || $up) {
                $up = $docSegment ? '../' : '';
                $relativeUri = $up . $relativeUri . $fileSegment . '/';
            }
        }
        $fileUrl = rtrim($relativeUri, '/');
    }
    // Get the actual path to the file on the server
    $filePath = '/' . get_absolute_path(removeDoubleSlashes($paths['docPath'] . '/' . $fileUrl));
    // Make sure there is actually an image at that path
    if (!is_readable($filePath)) {
        echo "<!-- Imagesizer Error: Could not find the file {$filePath} -->";
        return false;
    }
    // Calculate all the other paths we will need
    $pathInfo = pathinfo($filePath);
    $paths['filePath'] = $pathInfo['dirname'];
    $paths['fileExt'] = $pathInfo['extension'];
    $paths['fileBasename'] = $pathInfo['filename'] ? $pathInfo['filename'] : substr($paths['fileName'], 0, strrpos($paths['fileName'], '.'));
    $paths['fileSrc'] = removeDoubleSlashes($paths['filePath'] . '/' . $paths['fileName']);
    $paths['cachePath'] = removeDoubleSlashes($paths['filePath'] . '/cache/');
    // Make sure the cache folder exists
    if (!is_dir($paths['cachePath'])) {
        // Try to create it
        if (!@mkdir($paths['cachePath'], 0777)) {
            echo "<!-- Imagesizer Error: Could not create cache directory. Please create {$paths['cachePath']} manually and try again. -->";
            return false;
        }
        // Make sure it's really writable
        if (!is_writable($paths['cachePath'])) {
            echo '<!-- Imagesizer Error: The cache directory is not writeable -->';
            return false;
        }
    }
    // The url to the cached image
    $paths['cacheUrl'] = removeDoubleSlashes('/' . get_absolute_path($docUri . '/' . dirname($fileUrl)) . '/cache/');
    return $paths;
}