Beispiel #1
0
 function copyto($newfilepath, $aclonly = 0)
 {
     global $bhconfig;
     # Clean up filepath
     $newfilepath = bh_fpclean($newfilepath);
     if ($aclonly == 0) {
         if ($this->is_dir()) {
         } else {
             copy($this->absfilepath, $bhconfig['fileroot'] . $newfilepath);
             chmod($bhconfig['fileroot'] . $newfilepath, 0777);
         }
     }
     # If directory, do the ACL stuff for all files.
     if ($this->is_dir()) {
         $this->loadfile();
         if ($aclonly == 0) {
             @mkdir($bhconfig['fileroot'] . $newfilepath, 0777);
         }
         foreach ($this->filecontents as $file2copy) {
             #echo "(".$file2copy['filepath']." --to-- ".bh_fpclean($newfilepath."/".bh_get_filename($file2copy['filename'])).") ";
             $file2copyobj = new bhfile($file2copy['filepath']);
             $file2copyobj->copyto(bh_fpclean($newfilepath . "/" . bh_get_filename($file2copy['filename'])));
             unset($filetocopyobj);
         }
     }
     # Insert ACL/metadata/filecode entries of old self
     $acl_u_rows = select_bhdb("aclusers", array("filepath" => $this->filepath), "");
     foreach ($acl_u_rows as $acl_u_row) {
         $acl_u_row['filepath'] = $newfilepath;
         insert_bhdb("aclusers", $acl_u_row);
     }
     $acl_g_rows = select_bhdb("aclgroups", array("filepath" => $this->filepath), "");
     foreach ($acl_g_rows as $acl_g_row) {
         $acl_g_row['filepath'] = $newfilepath;
         insert_bhdb("aclgroups", $acl_g_row);
     }
     $acl_p_rows = select_bhdb("aclpublic", array("filepath" => $this->filepath), "");
     foreach ($acl_p_rows as $acl_p_row) {
         $acl_p_row['filepath'] = $newfilepath;
         insert_bhdb("aclpublic", $acl_p_row);
     }
     $md_rows = select_bhdb("metadata", array("filepath" => $this->filepath), "");
     foreach ($md_rows as $md_row) {
         $md_row['filepath'] = $newfilepath;
         insert_bhdb("metadata", $md_row);
     }
     # Done.
 }
Beispiel #2
0
 function COPY(&$options)
 {
     global $bhsession;
     $destfilepath = bh_fpclean($options['dest']);
     $filepath = bh_fpclean($options['path']);
     $infolder = bh_get_parent($destfilepath);
     $fileexist = bh_user_file_exists($filepath);
     if (!$fileexist) {
         return "404 Not Found";
     }
     if (bh_checkrights(bh_fpclean($infolder), $bhsession['username']) <= 1) {
         return "403 Forbidden";
     }
     $fileobj = new bhfile($filepath);
     $fileobj->copyto($destfilepath);
     return "204 No Content";
 }
Beispiel #3
0
}
if (empty($infolder)) {
    $infolder = $_POST['infolder'];
}
if (empty($infolder)) {
    $infolder = $bhsession['lastdir'];
}
if (empty($infolder)) {
    $infolder = $bhcurrent['userobj']->homedir;
}
if (bh_file_exists($filepath) == true) {
    if ($_POST['newname']) {
        $destfilepath = bh_fpclean($infolder . "/" . $_POST['newname']);
        if (bh_checkrights($infolder, $bhsession['username']) >= 2) {
            $fileobj = new bhfile($filepath);
            $fileobj->copyto($destfilepath);
            bh_log($bhlang['notice:file_copied'], "BH_NOTICE");
            bh_log(str_replace("#DEST#", $newfilepath, str_replace("#FILE#", $filepath, str_replace("#USER#", $bhsession['username'], $bhlang['log:#USER#_copied_#FILE#_to_#DEST#']))), "BH_FILE_COPIED");
            $_GET['filepath'] = $infolder;
            require "modules/viewdir.inc.php";
        } else {
            die("You are not allowed to upload files there.");
        }
    } else {
        $layoutobj = new bhlayout("copyform");
        $layoutobj->infolder = $infolder;
        $layoutobj->subtitle1 = str_replace("#FILE#", $filename, $bhlang['title:copying_#FILE#']);
        $layoutobj->title = str_replace("#FILE#", $filename, $bhlang['title:copying_#FILE#']);
        $layoutobj->content1 = $filename;
        $layoutobj->filepath = $filepath;
        $layoutobj->display();