note 94200 deleted from function.chdir by danbrown
| From: | danbrown@php.net | Date: | Thu, 22 Oct 2009 00:18:06 +0000 |
| Subject: | note 94200 deleted from function.chdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161966@lists.php.net to get a copy of this message | ||
Note Submitter: Elias Rodrigues
----
I'm correcting the note I added before.
<?php
// Changing to site's root directory
$dir = preg_replace("/^http:\/\/[a-z0-9_. -]+\//i",
"", $_SERVER["HTTP_REFERER"]);
$dir = explode("/", $dir);
$rootdir = "";
for($i = 0; $i < sizeof($dir) - 1; $i++)
$rootdir .= "../";
if (!empty($rootdir))
chdir($rootdir);
?>