コード例 #1
0
 protected function handleQuotaUpdate()
 {
     include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
     ilDiskQuotaHandler::handleUpdatedSourceObject($this->getType(), $this->getId(), ilUtil::dirsize($this->initStorage($this->getId())), array($this->getId()), true);
 }
コード例 #2
0
 /**
  * Returns the number of bytes used on the harddisk by the file object
  * with the specified object id.
  * @param int object id of a file object.
  */
 function _lookupDiskUsage($a_id)
 {
     include_once 'Modules/File/classes/class.ilFSStorageFile.php';
     $fileStorage = new ilFSStorageFile($a_id);
     $dir = $fileStorage->getAbsolutePath();
     return ilUtil::dirsize($dir);
 }
コード例 #3
0
 /**
  * Download all submitted files of an assignment (all user)
  *
  * @param	$members		array of user names, key is user id
  */
 function downloadAllDeliveredFiles($a_eph_id, $a_ass_id, $members)
 {
     global $lng, $ilObjDataCache, $ilias;
     include_once "./Services/Utilities/classes/class.ilUtil.php";
     include_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/Ephorus/classes/class.ilFSStorageEphorus.php";
     $storage = new ilFSStorageEphorus($a_eph_id, $a_ass_id);
     $storage->create();
     ksort($members);
     //$savepath = $this->getEphorusPath() . "/" . $this->obj_id . "/";
     $savepath = $storage->getAbsoluteSubmissionPath();
     $cdir = getcwd();
     // important check: if the directory does not exist
     // ILIAS stays in the current directory (echoing only a warning)
     // and the zip command below archives the whole ILIAS directory
     // (including the data directory) and sends a mega file to the user :-o
     if (!is_dir($savepath)) {
         return;
     }
     // Safe mode fix
     //		chdir($this->getEphorusPath());
     chdir($storage->getTempPath());
     $zip = PATH_TO_ZIP;
     // check first, if we have enough free disk space to copy all files to temporary directory
     $tmpdir = ilUtil::ilTempnam();
     ilUtil::makeDir($tmpdir);
     chdir($tmpdir);
     $dirsize = 0;
     foreach ($members as $id => $object) {
         $directory = $savepath . DIRECTORY_SEPARATOR . $id;
         $dirsize += ilUtil::dirsize($directory);
     }
     if ($dirsize > disk_free_space($tmpdir)) {
         return -1;
     }
     // copy all member directories to the temporary folder
     // switch from id to member name and append the login if the member name is double
     // ensure that no illegal filenames will be created
     // remove timestamp from filename
     $cache = array();
     foreach ($members as $id => $user) {
         $sourcedir = $savepath . DIRECTORY_SEPARATOR . $id;
         if (!is_dir($sourcedir)) {
             continue;
         }
         $userName = ilObjUser::_lookupName($id);
         $directory = ilUtil::getASCIIFilename(trim($userName["lastname"]) . "_" . trim($userName["firstname"]));
         if (array_key_exists($directory, $cache)) {
             // first try is to append the login;
             $directory = ilUtil::getASCIIFilename($directory . "_" . trim(ilObjUser::_lookupLogin($id)));
             if (array_key_exists($directory, $cache)) {
                 // second and secure: append the user id as well.
                 $directory .= "_" . $id;
             }
         }
         $cache[$directory] = $directory;
         ilUtil::makeDir($directory);
         $sourcefiles = scandir($sourcedir);
         foreach ($sourcefiles as $sourcefile) {
             if ($sourcefile == "." || $sourcefile == "..") {
                 continue;
             }
             $targetfile = trim(basename($sourcefile));
             $pos = strpos($targetfile, "_");
             if ($pos === false) {
             } else {
                 $targetfile = substr($targetfile, $pos + 1);
             }
             $targetfile = $directory . DIRECTORY_SEPARATOR . $targetfile;
             $sourcefile = $sourcedir . DIRECTORY_SEPARATOR . $sourcefile;
             if (!copy($sourcefile, $targetfile)) {
                 //echo 'Could not copy '.$sourcefile.' to '.$targetfile;
                 $ilias->raiseError('Could not copy ' . basename($sourcefile) . " to '" . $targetfile . "'.", $ilias->error_obj->MESSAGE);
             } else {
                 // preserve time stamp
                 touch($targetfile, filectime($sourcefile));
             }
         }
     }
     $tmpfile = ilUtil::ilTempnam();
     $tmpzipfile = $tmpfile . ".zip";
     // Safe mode fix
     $zipcmd = $zip . " -r " . ilUtil::escapeShellArg($tmpzipfile) . " .";
     exec($zipcmd);
     ilUtil::delDir($tmpdir);
     $assTitle = ilEphAssignment::lookupTitle($a_ass_id);
     chdir($cdir);
     ilUtil::deliverFile($tmpzipfile, (strlen($assTitle) == 0 ? strtolower($lng->txt("rep_robj_xeph_ephorus_assignment")) : $assTitle) . ".zip", "", false, true);
 }
コード例 #4
0
 /**
  * Returns the number of bytes used on the harddisk by the learning module
  * with the specified object id.
  * @param int object id of a file object.
  */
 function _lookupDiskUsage($a_id)
 {
     $lm_data_dir = ilUtil::getWebspaceDir('filesystem') . "/lm_data";
     $lm_dir = $lm_data_dir . DIRECTORY_SEPARATOR . "lm_" . $a_id;
     return file_exists($lm_dir) ? ilUtil::dirsize($lm_dir) : 0;
 }
コード例 #5
0
 /**
  * get size of a directory or a file.
  *
  * @param string path to a directory or a file
  * @return integer. Returns -1, if the directory does not exist.
  * @static
  * 
  */
 public static function dirsize($directory)
 {
     $size = 0;
     if (!is_dir($directory)) {
         // BEGIN DiskQuota Suppress PHP warning when attempting to determine
         //       dirsize of non-existing directory
         $size = @filesize($directory);
         // END DiskQuota Suppress PHP warning.
         return $size === false ? -1 : $size;
     }
     if ($DIR = opendir($directory)) {
         while (($dirfile = readdir($DIR)) !== false) {
             if (is_link($directory . DIRECTORY_SEPARATOR . $dirfile) || $dirfile == '.' || $dirfile == '..') {
                 continue;
             }
             if (is_file($directory . DIRECTORY_SEPARATOR . $dirfile)) {
                 $size += filesize($directory . DIRECTORY_SEPARATOR . $dirfile);
             } else {
                 if (is_dir($directory . DIRECTORY_SEPARATOR . $dirfile)) {
                     // BEGIN DiskQuota: dirsize is not a global function anymore
                     $dirSize = ilUtil::dirsize($directory . DIRECTORY_SEPARATOR . $dirfile);
                     // END DiskQuota: dirsize is not a global function anymore
                     if ($dirSize >= 0) {
                         $size += $dirSize;
                     } else {
                         return -1;
                     }
                 }
             }
         }
         closedir($DIR);
     }
     return $size;
 }
コード例 #6
0
 /**
  * Returns the number of bytes used on the harddisk for mail attachments,
  * by the user with the specified user id.
  * @param int user id.
  * @return array{'count'=>integer,'size'=>integer}
  *                            // an associative array with the disk
  *                            // usage in bytes and the count of attachments.
  */
 function _lookupDiskUsageOfUser($user_id)
 {
     // XXX - This method is extremely slow. We should
     // use a cache to speed it up, for example, we should
     // store the disk space used in table mail_attachment.
     global $ilDB, $lng;
     $mail_data_dir = ilUtil::getDataDir('filesystem') . DIRECTORY_SEPARATOR . "mail";
     $q = "SELECT path " . "FROM mail_attachment ma " . "JOIN mail m ON ma.mail_id=m.mail_id " . "WHERE m.user_id = " . $ilDB->quote($user_id);
     $result_set = $ilDB->query($q);
     $size = 0;
     $count = 0;
     while ($row = $result_set->fetchRow(DB_FETCHMODE_ASSOC)) {
         $attachment_path = $mail_data_dir . DIRECTORY_SEPARATOR . $row['path'];
         $attachment_size = ilUtil::dirsize($attachment_path);
         if ($attachment_size != -1) {
             $size += $attachment_size;
         }
         $count++;
     }
     return array('count' => $count, 'size' => $size);
 }
コード例 #7
0
ファイル: dbupdate_03.php プロジェクト: Walid-Synakene/ilias
function quotaHandleVerification($a_type, $a_obj_id, $a_owner_id)
{
    global $ilDB;
    // see ilFileSystemStorage::_createPathFromId()
    $tpath = array();
    $tfound = false;
    $tnum = $a_obj_id;
    for ($i = 3; $i > 0; $i--) {
        $factor = pow(100, $i);
        if ($tmp = (int) ($tnum / $factor) or $tfound) {
            $tpath[] = $tmp;
            $tnum = $tnum % $factor;
            $tfound = true;
        }
    }
    $file_path = ilUtil::getDataDir() . "/ilVerification/";
    if (count($tpath)) {
        $file_path .= implode('/', $tpath) . '/';
    }
    $file_path .= "vrfc_" . $a_obj_id;
    if (file_exists($file_path)) {
        $file_size = (int) ilUtil::dirsize($file_path);
        if ($file_size > 0) {
            $ilDB->manipulate("INSERT INTO il_disk_quota" . " (owner_id, src_type, src_obj_id, src_size)" . " VALUES (" . $ilDB->quote($a_owner_id, "integer") . ", " . $ilDB->quote($a_type, "text") . ", " . $ilDB->quote($a_obj_id, "integer") . ", " . $ilDB->quote($file_size, "integer") . ")");
        }
    }
}
コード例 #8
0
 /**
  * Returns the number of bytes used on the harddisk by the file object
  * with the specified object id.
  * @param int object id of a file object.
  */
 function _lookupDiskUsage($a_id)
 {
     require_once 'Modules/MediaCast/classes/class.ilObjMediaCast.php';
     require_once "./Services/News/classes/class.ilNewsItem.php";
     require_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $obj = new ilObjMediaCast($a_id, false);
     $obj->read();
     $items = $obj->getItemsArray();
     $size = 0;
     foreach ($items as $item) {
         $news_item = new ilNewsItem($item["id"]);
         $news_item->read();
         $mobId = $news_item->getMobId();
         $size += ilUtil::dirsize(ilObjMediaObject::_getDirectory($mobId));
     }
     return $size;
 }