当前位置: 首页>>代码示例>>PHP>>正文


PHP ilUtil::dirsize方法代码示例

本文整理汇总了PHP中ilUtil::dirsize方法的典型用法代码示例。如果您正苦于以下问题:PHP ilUtil::dirsize方法的具体用法?PHP ilUtil::dirsize怎么用?PHP ilUtil::dirsize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilUtil的用法示例。


在下文中一共展示了ilUtil::dirsize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleQuotaUpdate

 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);
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:5,代码来源:class.ilObjPortfolio.php

示例2: _lookupDiskUsage

 /**
  * 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);
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:12,代码来源:class.ilObjFileAccess.php

示例3: downloadAllDeliveredFiles

 /**
  * 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);
 }
开发者ID:jmcgettrick,项目名称:ilias-ephorus,代码行数:93,代码来源:class.ilEphAssignment.php

示例4: _lookupDiskUsage

 /**
  * 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;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:11,代码来源:class.ilObjSAHSLearningModuleAccess.php

示例5: dirsize

 /**
  * 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;
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:42,代码来源:class.ilUtil.php

示例6: _lookupDiskUsageOfUser

 /**
  * 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);
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:29,代码来源:class.ilFileDataMail.php

示例7: quotaHandleVerification

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") . ")");
        }
    }
}
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:27,代码来源:dbupdate_03.php

示例8: _lookupDiskUsage

 /**
  * 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;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:22,代码来源:class.ilObjMediaCastAccess.php


注:本文中的ilUtil::dirsize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。