note 92552 added to function.realpath

From: Date: Wed, 29 Jul 2009 07:36:58 +0000
Subject: note 92552 added to function.realpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-158862@lists.php.net to get a copy of this message
<?php // fixes windows paths... // (windows accepts forward slashes and backwards slashes, so why does PHP use backwards? function fix_path($path) { return str_replace('\\','/',$path); } // takes two absolute paths and determines if one is a subdirectory of the other // it doesn't care if it is an immediate child or 10 subdirectories deep... // use absolute paths for both for best results function is_child($parent, $child) { if(false !== ($parent = realpath($parent))) { $parent = fix_path($parent); if(false !== ($child = realpath($child))) { $child = fix_path($child); if(substr($child, 0, strlen($parent)) == $parent) return true; } } return false; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 71.238.254.92 ---- Manual Page -- http://www.php.net/manual/en/function.realpath.php Edit -- https://master.php.net/note/edit/92552 Del: integrated -- https://master.php.net/note/delete/92552/integrated Del: useless -- https://master.php.net/note/delete/92552/useless Del: bad code -- https://master.php.net/note/delete/92552/bad+code Del: spam -- https://master.php.net/note/delete/92552/spam Del: non-english -- https://master.php.net/note/delete/92552/non-english Del: in docs -- https://master.php.net/note/delete/92552/in+docs Del: other reasons-- https://master.php.net/note/delete/92552 Reject -- https://master.php.net/note/reject/92552 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#158862) next »