note 26192 deleted from function.copy by aidan
| From: | aidan@php.net | Date: | Mon, 30 Aug 2004 07:27:59 +0000 |
| Subject: | note 26192 deleted from function.copy by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75648@lists.php.net to get a copy of this message | ||
Note Submitter: dallask at sbcglobal dot net
----
yet another mod to the rec_copy function... I found that the other mods left the directory being
copied TO open to the public for writeing (0777) instead of 0775 for only PHP writeing... they also
altered the current working dir, and never changed back :)
<?php
function dir_copy ($from_path, $to_path)
{
$this_path = getcwd();
if(!is_dir($to_path))
{ mkdir($to_path, 0775);
}
if (is_dir($from_path))
{
chdir($from_path);
$handle=opendir('.');
while (($file = readdir($handle))!==false)
{
if (($file != ".") && ($file != ".."))
{
if (is_dir($file))
{
chdir($this_path);
rec_copy ($from_path.$file."/", $to_path.$file."/");
chdir($this_path);
chdir($from_path);
}
if (is_file($file))
{
chdir($this_path);
copy($from_path.$file, $to_path.$file);
chdir($from_path);
}
}
}
closedir($handle);
}
chdir($this_path);
}
?>