Пример #1
0
function quota($path, $recurse = false)
{
    if ($path == '' || $path[0] == '/') {
        return 0;
    }
    // we use glob, which grants access to the system. We should try to avoid that mistake
    $size = 0;
    if (!is_dir($path)) {
        return false;
    }
    if ($path[strlen($path) - 1] != "/") {
        $path .= "/";
    }
    if ($recurse) {
        // we divide in two for performance reasons (less testing)
        foreach (glob($path . '*') as $file) {
            if (is_dir($file)) {
                $size += quota($file, true);
            } else {
                $size += floor(filesize($file) / 1024);
            }
        }
    } else {
        foreach (glob($path . '*') as $file) {
            if (is_file($file)) {
                $size += floor(filesize($file) / 1024);
            }
        }
    }
    return $size;
}
Пример #2
0
     $httpderrlog = str_replace("{m}", date("m"), $httpderrlog);
     $httpderrlog = str_replace("{d}", date("d"), $httpderrlog);
     if (is_file(CONS_HTTPD_ERRDIR . $httpderrlog) && filesize(CONS_HTTPD_ERRDIR . $httpderrlog) > 1048576) {
         # php log has more than 1Mb, come on!
         $this->raise(604, "size=" . filesize(CONS_HTTPD_ERRDIR . $httpderrlog), "PHP error log too big");
     }
 } else {
     $httpderrlog = "";
 }
 if ($this->dimconfig['_errcontrol'] > 100) {
     # system reports more than 100 errors!
     $this->errorControl->raise(605, "errors=" . ($httpderrlog != "" && is_file(CONS_HTTPD_ERRDIR . $httpderrlog) ? filesize(CONS_HTTPD_ERRDIR . $httpderrlog) : $this->dimconfig['_errcontrol']), "Too many system errors");
 }
 // quota ok?
 $quota = isset($this->dimconfig['quota']) ? $this->dimconfig['quota'] : CONS_MAX_QUOTA;
 $this->dimconfig['_usedquota'] = quota(CONS_FMANAGER, true) * 1024;
 if ($this->dimconfig['_usedquota'] > $quota) {
     $this->errorControl->raise(110);
     if (isset($this->dimconfig['adminmail']) && isMail($this->dimconfig['adminmail'])) {
         @mail($this->dimconfig['adminmail'], "QUOTA EXCEEDED @ " . $_SESSION['CODE'], "Quota exceeded: " . $this->dimconfig['_usedquota'] . " from {$quota}");
     }
 }
 // auto clean
 foreach ($this->modules as $name => &$module) {
     if (isset($module->options[CONS_MODULE_AUTOCLEAN]) && $module->options[CONS_MODULE_AUTOCLEAN] != "" && (strpos($module->options[CONS_MODULE_AUTOCLEAN], "DAY") !== false || strpos($module->options[CONS_MODULE_AUTOCLEAN], "WEEK") !== false || strpos($module->options[CONS_MODULE_AUTOCLEAN], "MONTH") !== false || strpos($module->options[CONS_MODULE_AUTOCLEAN], "YEAR") !== false)) {
         # daily only runs autocleans with DAY, WEEK, MONTH or YEAR
         if ($module->options[CONS_MODULE_VOLATILE]) {
             $sql = "DELETE FROM " . $module->dbname . " WHERE " . $module->options[CONS_MODULE_AUTOCLEAN];
             $this->dbo->simpleQuery($sql);
         } else {
             $sql = "SELECT * FROM " . $module->dbname . " WHERE " . $module->options[CONS_MODULE_AUTOCLEAN];
Пример #3
0
    }
    if ($dir != "" && ($dir[0] = "/")) {
        $dir = substr($dir, 1);
    }
    if (!is_dir(CONS_FMANAGER . $dir)) {
        $dir = "/";
    } else {
        $dir = "/" . $dir;
    }
} else {
    $dir = "/";
}
$core->template->assign("dir", $dir);
$core->template->assign("maxupload", ini_get('upload_max_filesize'));
# Quota:
$usedSpace = quota(CONS_FMANAGER, true) * 1024;
$core->loadDimconfig(true);
$quota = isset($core->dimconfig['quota']) ? $core->dimconfig['quota'] : CONS_MAX_QUOTA;
$percent = $usedSpace / $quota;
$core->template->assign('used', humanSize($usedSpace));
$core->template->assign('quota', humanSize($quota));
$core->template->assign("pct", number_format($percent * 100, 2));
$pbar = ceil($percent * 99);
if ($pbar > 99) {
    $pbar = 99;
}
$core->template->assign("pctd", $pbar);
$core->dimconfig['_usedquota'] = $usedSpace;
$core->saveConfig();
// safe fmanager?
$fm = $core->loaded('bi_fm');