function fixPath($path){ // Syntax $correctPath = fixPath('.som/phpEncrypted/Path/class/class.QMI.php'); $temp = trim($path); $temp = eregi_replace("(\./|\.\./)","/",$temp); $temp = eregi_replace("([^/]+(\.htm|\.php))","",$temp); if(!eregi($_SERVER['DOCUMENT_ROOT'],$temp,$regs)){ $partsA = explode("/",substr($temp,0,-1)); $partsB = explode("/",$_SERVER['DOCUMENT_ROOT']); //if the path does not match the dir structure diff the array and reconstruct on the TRUE doc root $tHolder = array_diff($partsA,$partsB); foreach($tHolder as $k=>$v){ array_push($partsB,$v); } $temp = implode("/",$partsB)."/"; } return $temp; } ?>