Skip to content
Snippets Groups Projects
Commit ef38bfe8 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

fullpath fix for Windows

darcs-hash:20070930214958-7ad00-bc8ca26f86ea4c9e68ea2b8f3cacc2a598543122.gz
parent d0a27cb0
No related branches found
Tags develsnap_2007-10-01
No related merge requests found
...@@ -410,10 +410,13 @@ EOT; ...@@ -410,10 +410,13 @@ EOT;
* @link http://de3.php.net/manual/en/function.realpath.php#75992 * @link http://de3.php.net/manual/en/function.realpath.php#75992
*/ */
function fullpath($path){ function fullpath($path){
$iswin = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
if($iswin) $path = str_replace('\\','/',$path); // windows compatibility
// check if path begins with "/" ie. is absolute // check if path begins with "/" or "c:" ie. is absolute
// if it isnt concat with script path // if it isnt concat with script path
if (strpos($path,"/") !== 0) { if ((!$iswin && $path{0} !== '/') ||
($iswin && $path{1} !== ':')) {
$base=dirname($_SERVER['SCRIPT_FILENAME']); $base=dirname($_SERVER['SCRIPT_FILENAME']);
$path=$base."/".$path; $path=$base."/".$path;
} }
...@@ -421,15 +424,16 @@ function fullpath($path){ ...@@ -421,15 +424,16 @@ function fullpath($path){
// canonicalize // canonicalize
$path=explode('/', $path); $path=explode('/', $path);
$newpath=array(); $newpath=array();
for ($i=0; $i<sizeof($path); $i++) { foreach($path as $p) {
if ($path[$i]==='' || $path[$i]==='.') continue; if ($p === '' || $p === '.') continue;
if ($path[$i]==='..') { if ($p==='..') {
array_pop($newpath); array_pop($newpath);
continue; continue;
} }
array_push($newpath, $path[$i]); array_push($newpath, $p);
} }
$finalpath="/".implode('/', $newpath); $finalpath = implode('/', $newpath);
if(!$iswin) $finalpath = '/'.$finalpath;
// check then return valid path or filename // check then return valid path or filename
if (file_exists($finalpath)) { if (file_exists($finalpath)) {
......
...@@ -359,6 +359,7 @@ function insertAtCarret(edid,value){ ...@@ -359,6 +359,7 @@ function insertAtCarret(edid,value){
field.focus(); field.focus();
sel = document.selection.createRange(); sel = document.selection.createRange();
sel.text = value; sel.text = value;
//MOZILLA/NETSCAPE support //MOZILLA/NETSCAPE support
}else if (field.selectionStart || field.selectionStart == '0') { }else if (field.selectionStart || field.selectionStart == '0') {
var startPos = field.selectionStart; var startPos = field.selectionStart;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment