function relative2absolute($absolute, $relative) { $p = @parse_url($relative); if(!$p) { return false; } if(isset($p["scheme"])) return $relative; $parts=(parse_url($absolute)); if(substr($relative,0,1)=='/') { $cparts = (explode("/", $relative)); array_shift($cparts); } else { if(isset($parts['path'])){ $aparts=explode('/',$parts['path']); array_pop($aparts); $aparts=array_filter($aparts); } else { $aparts=array(); } $rparts = (explode("/", $relative)); $cparts = array_merge($aparts, $rparts); foreach($cparts as $i => $part) { if($part == '.') { unset($cparts[$i]); } else if($part == '..') { unset($cparts[$i]); unset($cparts[$i-1]); } } } $path = implode("/", $cparts); $url = ''; if($parts['scheme']) { $url = "$parts[scheme]://"; } if(isset($parts['user'])) { $url .= $parts['user']; if(isset($parts['pass'])) { $url .= ":".$parts['pass']; } $url .= "@"; } if(isset($parts['host'])) { $url .= $parts['host']."/"; } $url .= $path; return $url; }link : http://w-shadow.com
Thursday, October 09, 2008
translate relative url to absolute url
Saturday, October 04, 2008
php sub folder scan
you can use php to scan all file in sub folder from this code
<?php // *** requires PHP5 *** // search for gif files (can be empty for all file) $filter = ".gif"; // path to the directory you want to scan(can be .. to search all drive) $directory = './'; $it = new RecursiveDirectoryIterator("$directory"); foreach(new RecursiveIteratorIterator($it) as $file) { if (!((strpos(strtolower($file), $filter)) === false) || empty($filter)) { $items[] = preg_replace("#\\\#", "/", $file); } } sort($items); print_r($items); ?>
but if your server not PHP5 don't worry please see this link http://www.php.net and find class RecDir
Subscribe to:
Posts (Atom)