PHP - Bug Fix Required Path


/ Published in: PHP
Save to your folder(s)

Bug Fix Required Path (Corrige o bug no caminho do arquivo)


Copy this code and paste it in your HTML
  1. if (!function_exists('bugFixRequirePath'))
  2. {
  3. function bugFixRequirePath($newPath)
  4. {
  5. $stringPath = dirname(__FILE__);
  6. if (strstr($stringPath,":")) $stringExplode = "\\"; else $stringExplode = "/";
  7. $paths = explode($stringExplode,$stringPath);
  8. $newPaths = explode("/",$newPath);
  9. if (count($newPaths) > 0)
  10. {
  11. for($i=0;$i<count($newPaths);$i++) { if ($newPaths[$i] == "..") array_pop($paths); }
  12. for($i=0;$i<count($newPaths);$i++) { if ($newPaths[$i] == "..") unset($newPaths[$i]); }
  13. reset($newPaths);
  14. $stringNewPath = implode($stringExplode,$paths).$stringExplode.implode($stringExplode,$newPaths);
  15. return $stringNewPath;
  16. }
  17. }
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.