function copyDirR($src,$dst,$mode='0777') { //recursive copy of directory if (substr($src,0,-1)!='/') $src.='/'; if (substr($dst,0,-1)!='/') $dst.='/'; $d = dir($src); while($entry=readdir($d->handle)) { if(is_dir($d->path.$entry)) { if(strlen($entry)>2) { createDir($dst.$entry.'/',$mode); copyDirR($d->path.$entry,$dst.$entry); } else { if($entry[0]!='.') { createDir($dst.$entry,$mode); copyDirR($d->path.$entry,$dst.$entry); } else { if(strlen($entry)>1&&$entry[1]!='.') { createDir($dst.'/'.$entry,$mode); copyDirR($d->path.$entry,$dst.$entry); }; }; }; } else { copy($d->path.$entry,$dst.$entry); }; }; $d->close(); };
function copyFileDir() { if ($_SESSION['adminType'] == 'sadmin') { $fileManPath = RAZOR_SADMIN_PATH; } else { $fileManPath = RAZOR_FILEMAN_PATH; } $dirSelected = ''; if (isset($_POST['copyfile'])) { $copyFrom = $_POST['copyfile']; } if (isset($_POST['copydir'])) { $copyDir = $_POST['copydir']; } if (isset($_POST['dirselected'])) { $dirSelected = $_POST['dirselected']; } // copy file to directory // if (isset($copyFrom) && isset($dirSelected)) { $copyTo = $dirSelected . '/' . basename($copyFrom); if (!file_exists(getSystemRoot(RAZOR_ADMIN_FILENAME) . $fileManPath . $copyTo)) { copyFile($fileManPath . $copyFrom, $fileManPath . $copyTo); } else { MsgBox(lt('Error copying, filename already exists in chosen directory'), 'redbox'); } } if (isset($copyDir) && isset($dirSelected)) { $copyTo = $dirSelected . '/' . basename($copyDir); if (!is_dir(getSystemRoot(RAZOR_ADMIN_FILENAME) . $fileManPath . $copyTo)) { if (copyDirR($fileManPath . $copyDir, $fileManPath . $copyTo)) { MsgBox(lt('Directory and contents copy complete'), 'greenbox'); } } else { MsgBox(lt('Error copying, directory name already exists in chosen directory'), 'redbox'); } } }