Merge branch 'quota'

This commit is contained in:
Florian Aders (EleRas)
2011-06-23 11:18:18 +02:00
13 changed files with 396 additions and 165 deletions

View File

@@ -18,18 +18,18 @@
/*
* Function getNextCronjobs
*
* checks which cronjobs have to be executed
* checks which cronjobs have to be executed
*
* @return array array of cron-files which are to be executed
*/
function getNextCronjobs()
{
global $db;
$query = "SELECT `id`, `cronfile` FROM `".TABLE_PANEL_CRONRUNS."` WHERE `interval` <> '0' AND `isactive` = '1' AND (";
$intervals = getIntervalOptions();
$x = 0;
foreach($intervals as $name => $ival)
{
@@ -37,23 +37,23 @@ function getNextCronjobs()
if($x == 0) {
$query.= '(UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL '.$ival.')) <= UNIX_TIMESTAMP() AND `interval`=\''.$ival.'\')';
} else {
} else {
$query.= ' OR (UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL '.$ival.')) <= UNIX_TIMESTAMP() AND `interval`=\''.$ival.'\')';
}
$x++;
}
$query.= ');';
$result = $db->query($query);
$cron_files = array();
while($row = $db->fetch_array($result))
{
$cron_files[] = $row['cronfile'];
$db->query("UPDATE `".TABLE_PANEL_CRONRUNS."` SET `lastrun` = UNIX_TIMESTAMP() WHERE `id` ='".(int)$row['id']."';");
}
return $cron_files;
}
@@ -63,10 +63,10 @@ function includeCronjobs($debugHandler, $pathtophpfiles)
global $settings;
$cronjobs = getNextCronjobs();
$jobs_to_run = array();
$cron_path = makeCorrectDir($pathtophpfiles.'/scripts/jobs/');
if($cronjobs !== false
&& is_array($cronjobs)
&& isset($cronjobs[0]))
@@ -77,7 +77,7 @@ function includeCronjobs($debugHandler, $pathtophpfiles)
$jobs_to_run[] = $cron_file;
}
}
return $jobs_to_run;
}
@@ -103,7 +103,7 @@ function getIntervalOptions()
$cronlog->logAction(CRON_ACTION, LOG_ERROR, "Invalid SQL-Interval ".$row['interval']." detected. Please fix this in the database.");
}
}
return $cron_intervals;
}
@@ -111,14 +111,14 @@ function getIntervalOptions()
function getCronjobsLastRun()
{
global $db, $lng;
$query = "SELECT `lastrun`, `desc_lng_key` FROM `".TABLE_PANEL_CRONRUNS."` WHERE `isactive` = '1' ORDER BY `cronfile` ASC";
$result = $db->query($query);
$cronjobs_last_run = '';
while($row = $db->fetch_array($result))
{
{
$lastrun = $lng['cronjobs']['notyetrun'];
if($row['lastrun'] > 0) {
$lastrun = date('d.m.Y H:i:s', $row['lastrun']);
@@ -129,18 +129,18 @@ function getCronjobsLastRun()
eval("\$cronjobs_last_run .= \"" . getTemplate("index/overview_item") . "\";");
}
return $cronjobs_last_run;
}
function toggleCronStatus($module = null, $isactive = 0)
{
global $db;
if($isactive != 1) {
$isactive = 0;
}
$query = "UPDATE `".TABLE_PANEL_CRONRUNS."` SET `isactive` = '".(int)$isactive."' WHERE `module` = '".$module."'";
$db->query($query);
@@ -149,10 +149,10 @@ function toggleCronStatus($module = null, $isactive = 0)
function getOutstandingTasks()
{
global $db, $lng;
$query = "SELECT * FROM `".TABLE_PANEL_TASKS."` ORDER BY `type` ASC";
$result = $db->query($query);
$value = '<ul class="cronjobtask">';
$tasks = '';
while($row = $db->fetch_array($result))
@@ -161,7 +161,7 @@ function getOutstandingTasks()
{
$row['data'] = unserialize($row['data']);
}
/*
* rebuilding webserver-configuration
*/
@@ -208,16 +208,23 @@ function getOutstandingTasks()
}
$task_desc = $lng['tasks']['deleting_customerfiles'];
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
}
}
/*
* Set FS - quota
*/
elseif($row['type'] == '10')
{
$task_desc = $lng['tasks']['diskspace_set_quota'];
}
if($task_desc != '') {
$tasks .= '<li>'.$task_desc.'</li>';
}
}
$query2 = "SELECT DISTINCT `Task` FROM `".TABLE_APS_TASKS."` ORDER BY `Task` ASC";
$result2 = $db->query($query2);
while($row2 = $db->fetch_array($result2))
{
/*
@@ -262,7 +269,7 @@ function getOutstandingTasks()
{
$task_desc = $lng['tasks']['aps_task_sysdownload'];
}
if($task_desc != '') {
$tasks .= '<li>'.$task_desc.'</li>';
}

View File

@@ -0,0 +1,53 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2011 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2011-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
function getFilesystemQuota()
{
global $settings;
if ($settings['system']['diskquota_enabled'])
{
# Fetch all quota in the desired partition
exec($settings['system']['diskquota_repquota_path'] . " -np " . escapeshellarg($settings['system']['diskquota_customer_partition']), $repquota);
$usedquota = array();
foreach ($repquota as $tmpquota)
{
# Let's see if the line matches a quota - line
if (preg_match('/^#([0-9]+)\s*[+-]{2}\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)\s*(\d+)/i', $tmpquota, $matches))
{
# It matches - put it into an array with userid as key (for easy lookup later)
$usedquota[$matches[1]] = array(
'block' => array(
'used' => $matches[2],
'soft' => $matches[3],
'hard' => $matches[4],
'grace' => $matches[5]
),
'file' => array(
'used' => $matches[6],
'soft' => $matches[7],
'hard' => $matches[8],
'grace' => $matches[9]
),
);
}
}
return $usedquota;
}
return false;
}

View File

@@ -35,7 +35,8 @@ function inserttask($type, $param1 = '', $param2 = '', $param3 = '', $param4 = '
|| $type == '3'
|| $type == '4'
|| $type == '5'
|| $type == '9')
|| $type == '9'
|| $type == '10')
{
$db->query('DELETE FROM `' . TABLE_PANEL_TASKS . '` WHERE `type`="' . $type . '"');
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`) VALUES ("' . $type . '")');