Exemple #1
0
require 'guiconfig.inc';
require_once 'util.inc';
require_once 'blockdevices.lib.php';
require_once 'libs-php/htmltable.class.php';
// define some constants referenced in fbegin.inc
define('INCLUDE_TBLSTYLE', true);
// actual configuration reference
$cfgPtr =& $config['system']['storage'];
// retrieve informations about system block devices
$forceDevRefresh = false;
if (isset($_SESSION['refresh']['blockdevice'])) {
    $forceDevRefresh = true;
    unset($_SESSION['refresh']['blockdevice']);
}
$disksInfo = getBlockDevices($forceDevRefresh);
getDiskUsage($disksInfo);
$_SESSION['diskedit']['info'] = $disksInfo;
//
// init a table object
$tblStorage = new htmlTable('id=table01|class=report');
// fill the table caption
$tblStorage->caption(_('Configured storage'));
// table section heading
$tblStorage->thead();
$tblStorage->tr();
$tblStorage->th(_('Device name'), 'class=colheader');
$tblStorage->th(_('Label'), 'class=colheader');
$tblStorage->th(_('Mount Point'), 'class=colheader');
$tblStorage->th(_('Free'), 'class=colheader');
$tblStorage->th(_('Used'), 'class=colheader');
$tblStorage->th(_('Total'), 'class=colheader');
Exemple #2
0
				table_schema
	';
    while ($row = $sqlData->fetch()) {
        $sql_param = array(':table_schema' => $row['sqld_name']);
        DB::prepare($sql_query);
        $sqlSize = DB::execute($sql_param, true);
        $dbSize += $sqlSize[0];
    }
    return $dbSize;
}
$mailUsage = 0;
$webUsage = 0;
$dbUsage = 0;
$sql_query = "\n\t\tSELECT \n\t\t\tdomain_id, domain_name, domain_disk_countbackup \n\t\tFROM \n\t\t\tdomain \n\t\tWHERE \n\t\t\tstatus = 'ok'";
$domainData = DB::query($sql_query);
while ($row = $domainData->fetch()) {
    $wwwPath = DaemonConfig::$distro->{'APACHE_WWW_DIR'} . '/' . $row['domain_name'];
    $mailPath = DaemonConfig::$distro->{'MTA_VIRTUAL_MAIL_DIR'} . '/' . $row['domain_name'];
    if ($row['domain_disk_countbackup'] !== 'yes') {
        $webUsage = getDiskUsage($wwwPath, true);
    } else {
        $webUsage = getDiskUsage($wwwPath, false);
    }
    $mailUsage = getDiskUsage($mailPath);
    $dbUsage = getDBUsage($row['domain_id']);
    $total = $mailUsage + $webUsage + $dbUsage;
    $sql_param = array(':domain_id' => $row['domain_id'], ':domain_disk_usage' => $total);
    $sql_query = "\n\t\tUPDATE\n\t\t\tdomain\n\t\tSET\n\t\t\tdomain_disk_usage = :domain_disk_usage\n\t\tWHERE\n\t\t\tdomain_id = :domain_id\n\t";
    DB::prepare($sql_query);
    DB::execute($sql_param)->closeCursor();
}
Exemple #3
0
if (!$chunks || $chunk == $chunks - 1) {
    // get mime type
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime = explode('/', finfo_file($finfo, $tmpFilename));
    if ($mime[0] != 'image') {
        unlink($tmpFilename);
        die('{"jsonrpc" : "2.0", "error" : {"code": 902, "message": "Not an image: ' . $originalFilename . '"}, "id" : "id"}');
    }
    $destFilename = "{$destBasename}.{$mime['1']}";
    // Create target dir
    if (!file_exists($targetDir)) {
        if (!mkdir($targetDir, $targetDirMod, true)) {
            die('{"jsonrpc" : "2.0", "error" : {"code": 903, "message": "Could not create target directory ' . $targetDir . '."}, "id" : "id"}');
        }
    }
    if (getDiskUsage($targetDir) > $maxDiskUsage) {
        die('{"jsonrpc" : "2.0", "error" : {"code": 908, "message": "Target disk is full !"}, "id" : "id"}');
    }
    // check for duplicate timestamp
    $num = 1;
    while (file_exists($destFilename)) {
        // throw an error if filesize match too
        if (filesize($destFilename) == filesize($tmpFilename)) {
            die('{"jsonrpc" : "2.0", "error" : {"code": 904, "message": "Duplicate file: ' . "{$originalFilename} ({$timestamp}.{$mime['1']})" . '."}, "id" : "id"}');
        }
        // else rename destination file
        $destFilename = "{$destBasename}.{$num}.{$mime['1']}";
        ++$num;
    }
    // Move and strip the temp .part suffix off
    if (!rename($tmpFilename, $destFilename)) {
        case "load-path":
            $path = findPath($connection->escape_string($_POST["folder"]));
            displayFiles($path);
            break;
        case "update-breadcrumb":
            $path = findPath($connection->escape_string($_POST["folder"]));
            displayBreadcrumbs($path);
            break;
        case "delete-file":
            deleteFile($connection->escape_string($_POST["path"]), $connection->escape_string($_POST["container"]));
            break;
        case "delete-folder":
            deleteFolder($connection->escape_string($_POST["id"]));
            break;
        case "new-folder":
            newFolder($connection->escape_string($_POST["name"]), $connection->escape_string($_POST["path"]));
            break;
        case "edit-folder":
            editFolder($connection->escape_string($_POST["name"]), $connection->escape_string($_POST["id"]));
            break;
        case "get-usage":
            getDiskUsage();
            break;
        case "get-edit-user":
            populateEditModal();
            break;
        case "update-user":
            updateUser($connection->escape_string($_POST["user"]));
            break;
    }
}