本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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") . ")");
}
}
}
示例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;
}