note 46503 added to function.realpath

From: Date: Wed, 13 Oct 2004 15:14:21 +0000
Subject: note 46503 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-78496@lists.php.net to get a copy of this message
A recursive function to simplify path : remove '..' from an URL. <?php function getRealpathUrl($path) { $p = strpos($path, '..'); if ($p !== false) { // searh for the first / on the left of .. $pos_slash = -1; $i = $p - 2; while ($i > 0) { if ($path[$i] == '/') { $pos_slash = $i; break; } $i --; } $path = substr($path, 0, $pos_slash).substr($path, $p + 2, strlen($path)); return getRealpathUrl($path); } return $path; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46503 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46503&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46503&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46503&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46503&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46503&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46503&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+46503&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78496) next »