note 26192 added to function.copy
| From: | dallask at sbcglobal dot net | Date: | Tue, 22 Oct 2002 03:14:03 +0000 |
| Subject: | note 26192 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38396@lists.php.net to get a copy of this message | ||
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 :)
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);
}
--
http://www.php.net/manual/en/function.copy.php
http://master.php.net/manage/user-notes.php?action=edit+26192
http://master.php.net/manage/user-notes.php?action=delete+26192
http://master.php.net/manage/user-notes.php?action=reject+26192