Tools directory for ticket #1

This commit is contained in:
DavidWyand-GG 2012-09-19 11:22:58 -04:00
parent ecfd936095
commit 8337cad7ee
207 changed files with 25761 additions and 0 deletions

View file

@ -0,0 +1,24 @@
<?php
// Turn foo/../bar/../baz/ into baz/
function smarty_modifier_collapse_path($p)
{
$p=explode('/', $p);
$o=array();
for ($i=0; $i<sizeof($p); $i++)
{
// Skip meaningless . or empty terms.
if (''==$p[$i] || '.'==$p[$i])
continue;
// Consider if we can pop something off the list.
if ('..'==$p[$i] && $i>0 && '..'!=$o[sizeof($o)-1])
{
array_pop($o);
continue;
}
array_push($o, $p[$i]);
}
return implode('/', $o);
}
?>