<?php
echo '<pre style="line-height: 25px;">';
// Loads PathManager class
require_once "class.pathparser.php";
$path = 'http://www.php.net:80/./donwloads/../faq/.././manual/en/install.php?version=502#top';
$Path = new PathParser($path);
echo "\nOriginal path: " . $path;
echo "\nResolved path: " . $Path->path;
echo "\n\nPath parts: \n";
print_r($Path->parse());
echo "\n\n\n Dirty paths:\n";
$paths[] = 'C://////////Windows//////System'; // C:/Windows/System/
$paths[] = 'C:\HTML\javascript\..\examples\colors.html'; // C:/HTML/examples/colors.html
$paths[] = '/root/./wwwroot/scripts/../././webpage'; // /root/wwwroot/webpage/
$paths[] = 'wwwroot/webpage/../index.php?querystring'; // wwwroot/index.php?querystring
$paths[] = 'http://www.php.net/manual/en/../../downloads'; // http://www.php.net/downloads/
$paths[] = 'http://www.php.net/downloads/.././docs.php'; // http://www.php.net/docs.php
$paths[] = '../downloads/../docs.php'; // ../docs.php
$paths[] = 'localhost//projetos/../_arquivos/../'; // localhost/
$paths[] = 'C:/downloads/../../../'; // C:/
$paths[] = 'downloads/../../../'; // ../../
foreach ($paths as $path)
{
echo "\n"" . $path . "" = "" . $Path->fix($path) . """;
}
echo "\n\n\n Finding relative paths:\n";
$path_a = 'http://www.php.net/manual/en/install.php';
$path_b = 'http://www.php.net/downloads';
echo "\nPath A: " . $path_a;
echo "\nPath B: " . $path_b;
echo "\nA to B: " . $Path->findRelativePath($path_a, $path_b); // ../../downloads/
echo "\nB to A: " . $Path->findRelativePath($path_b, $path_a); // ../manual/en/install.php
echo '</pre>';
?>
|