Just saw this post over at Digital Media Minute about something called Cake, a PHP web application framework. I have to say after checking it out I’m really excited about it…I hope this sticks around and matures. I wonder how/if this would relate to using AMFPHP?
–update: After reading this post again, i realized how much of a TOTAL FREAKING GEEK i am for getting “really excited” about a php application framework…i love it though!!
Posted by flashape at 01:53 PM | Comments (2)
April 05, 2005
copy directory in php
While trying to figure out how to copy an entire directory to a new location (on the same web server) in php, I came across this function. I took that as a base and modified it to handle premissons better:
function copyr($source, $dest){
// Simple copy for a file
if (is_file($source)) {
$c = copy($source, $dest);
chmod($dest, 0777);
return $c;
}
// Make destination directory
if (!is_dir($dest)) {
$oldumask = umask(0);
mkdir($dest, 0777);
umask($oldumask);
}
// Loop through the folder
$dir = dir($source);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry ‘.’ || $entry ‘..’) {
continue;
}
// Deep copy directories
if ($dest !== “$source/$entry”) {
copyr(”$source/$entry”, “$dest/$entry”);
}
}
// Clean up
$dir->close();
return true;
}
Thanx, good job. One error in this function.
“if ($entry ‘.’ || $entry ‘..’)”
“if ($entry ==‘.’ || $entry ==‘..’)”
Sorry my english.
Bye.