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

@@ -0,0 +1,60 @@
<?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 Settings
*
*/
return array(
'groups' => array(
'diskquota' => array(
'title' => $lng['diskquota'],
'fields' => array(
'diskquota_enabled' => array(
'label' => $lng['serversettings']['diskquota_enabled'],
'settinggroup' => 'system',
'varname' => 'diskquota_enabled',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
'overview_option' => true
),
'diskquota_repquota_path' => array(
'label' => $lng['serversettings']['diskquota_repquota_path']['description'],
'settinggroup' => 'system',
'varname' => 'diskquota_repquota_path',
'type' => 'string',
'default' => '/usr/sbin/repquota',
'save_method' => 'storeSettingField',
),
'diskquota_quotatool_path' => array(
'label' => $lng['serversettings']['diskquota_quotatool_path']['description'],
'settinggroup' => 'system',
'varname' => 'diskquota_quotatool_path',
'type' => 'string',
'default' => '/usr/bin/quotatool',
'save_method' => 'storeSettingField',
),
'diskquota_customer_partition' => array(
'label' => $lng['serversettings']['diskquota_customer_partition']['description'],
'settinggroup' => 'system',
'varname' => 'diskquota_customer_partition',
'type' => 'string',
'default' => '/dev/root',
'save_method' => 'storeSettingField',
),
),
),
),
);
?>

View File

@@ -42,7 +42,7 @@ if($page == 'customers'
{ {
// clear request data // clear request data
unset($_SESSION['requestData']); unset($_SESSION['requestData']);
$log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_customers"); $log->logAction(ADM_ACTION, LOG_NOTICE, "viewed admin_customers");
$fields = array( $fields = array(
'c.loginname' => $lng['login']['username'], 'c.loginname' => $lng['login']['username'],
@@ -83,11 +83,11 @@ if($page == 'customers'
$fields['c.tickets'] = $lng['customer']['tickets']; $fields['c.tickets'] = $lng['customer']['tickets'];
$fields['c.tickets_used'] = $lng['customer']['tickets'] . ' (' . $lng['panel']['used'] . ')'; $fields['c.tickets_used'] = $lng['customer']['tickets'] . ' (' . $lng['panel']['used'] . ')';
} }
if($settings['autoresponder']['autoresponder_active'] == 1) if($settings['autoresponder']['autoresponder_active'] == 1)
{ {
$fields['c.email_autoresponder'] = $lng['customer']['autoresponder']; $fields['c.email_autoresponder'] = $lng['customer']['autoresponder'];
$fields['c.email_autoresponder_used'] = $lng['customer']['autoresponder'] . ' (' . $lng['panel']['used'] . ')'; $fields['c.email_autoresponder_used'] = $lng['customer']['autoresponder'] . ' (' . $lng['panel']['used'] . ')';
} }
*/ */
@@ -175,11 +175,11 @@ if($page == 'customers'
if(isset($_POST['send']) if(isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send')
{ {
$result = $db->query("UPDATE $result = $db->query("UPDATE
`" . TABLE_PANEL_CUSTOMERS . "` `" . TABLE_PANEL_CUSTOMERS . "`
SET SET
`loginfail_count` = '0' `loginfail_count` = '0'
WHERE WHERE
`customerid`= '" . (int)$id . "'" `customerid`= '" . (int)$id . "'"
); );
redirectTo($filename, Array('page' => $page, 's' => $s)); redirectTo($filename, Array('page' => $page, 's' => $s));
@@ -259,7 +259,7 @@ if($page == 'customers'
// remove all package related settings // remove all package related settings
$db->query("DELETE FROM `".TABLE_APS_SETTINGS."` WHERE `InstanceID` = '".(int)$apsrow['ID']."'"); $db->query("DELETE FROM `".TABLE_APS_SETTINGS."` WHERE `InstanceID` = '".(int)$apsrow['ID']."'");
// maybe some leftovers in the tasks // maybe some leftovers in the tasks
$db->query("DELETE FROM `".TABLE_APS_TASKS."` WHERE `InstanceID` = '".(int)$apsrow['ID']."'"); $db->query("DELETE FROM `".TABLE_APS_TASKS."` WHERE `InstanceID` = '".(int)$apsrow['ID']."'");
} }
// now remove all user instances // now remove all user instances
$db->query("DELETE FROM `".TABLE_APS_INSTANCES."` WHERE `CustomerID`='".(int)$id."'"); $db->query("DELETE FROM `".TABLE_APS_INSTANCES."` WHERE `CustomerID`='".(int)$id."'");
@@ -330,13 +330,19 @@ if($page == 'customers'
$log->logAction(ADM_ACTION, LOG_INFO, "deleted user '" . $result['loginname'] . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "deleted user '" . $result['loginname'] . "'");
inserttask('1'); inserttask('1');
inserttask('4'); inserttask('4');
if(isset($_POST['delete_userfiles']) if(isset($_POST['delete_userfiles'])
&& (int)$_POST['delete_userfiles'] == 1) && (int)$_POST['delete_userfiles'] == 1)
{ {
inserttask('6', $result['loginname']); inserttask('6', $result['loginname']);
} }
# Using filesystem - quota, insert a task which cleans the filesystem - quota
if ($settings['system']['diskquota_enabled'])
{
inserttask('10');
}
/* /*
* move old tickets to archive * move old tickets to archive
*/ */
@@ -354,8 +360,8 @@ if($page == 'customers'
$mainticket->Archive(); $mainticket->Archive();
$log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'"); $log->logAction(ADM_ACTION, LOG_NOTICE, "archived ticket '" . $mainticket->Get('subject') . "'");
} }
} }
redirectTo($filename, Array('page' => $page, 's' => $s)); redirectTo($filename, Array('page' => $page, 's' => $s));
} }
else else
@@ -439,7 +445,7 @@ if($page == 'customers'
{ {
$email_quota = - 1; $email_quota = - 1;
} }
if($settings['autoresponder']['autoresponder_active'] == '1') if($settings['autoresponder']['autoresponder_active'] == '1')
{ {
$email_autoresponder = intval_ressource($_POST['email_autoresponder']); $email_autoresponder = intval_ressource($_POST['email_autoresponder']);
@@ -455,13 +461,13 @@ if($page == 'customers'
} }
$email_imap = 0; $email_imap = 0;
if(isset($_POST['email_imap'])) if(isset($_POST['email_imap']))
$email_imap = intval_ressource($_POST['email_imap']); $email_imap = intval_ressource($_POST['email_imap']);
$email_pop3 = 0; $email_pop3 = 0;
if(isset($_POST['email_pop3'])) if(isset($_POST['email_pop3']))
$email_pop3 = intval_ressource($_POST['email_pop3']); $email_pop3 = intval_ressource($_POST['email_pop3']);
$ftps = 0; $ftps = 0;
if(isset($_POST['ftps'])) if(isset($_POST['ftps']))
$ftps = intval_ressource($_POST['ftps']); $ftps = intval_ressource($_POST['ftps']);
@@ -499,7 +505,7 @@ if($page == 'customers'
{ {
$number_of_aps_packages = 0; $number_of_aps_packages = 0;
} }
$createstdsubdomain = 0; $createstdsubdomain = 0;
if(isset($_POST['createstdsubdomain'])) if(isset($_POST['createstdsubdomain']))
$createstdsubdomain = intval($_POST['createstdsubdomain']); $createstdsubdomain = intval($_POST['createstdsubdomain']);
@@ -510,37 +516,37 @@ if($page == 'customers'
{ {
$password = validatePassword($password); $password = validatePassword($password);
} }
$backup_allowed = 0; $backup_allowed = 0;
if(isset($_POST['backup_allowed'])) if(isset($_POST['backup_allowed']))
$backup_allowed = intval($_POST['backup_allowed']); $backup_allowed = intval($_POST['backup_allowed']);
if ($backup_allowed != 0) if ($backup_allowed != 0)
{ {
$backup_allowed = 1; $backup_allowed = 1;
} }
// gender out of range? [0,2] // gender out of range? [0,2]
if ($gender < 0 || $gender > 2) { if ($gender < 0 || $gender > 2) {
$gender = 0; $gender = 0;
} }
$sendpassword = 0; $sendpassword = 0;
if(isset($_POST['sendpassword'])) if(isset($_POST['sendpassword']))
$sendpassword = intval($_POST['sendpassword']); $sendpassword = intval($_POST['sendpassword']);
$phpenabled = 0; $phpenabled = 0;
if(isset($_POST['phpenabled'])) if(isset($_POST['phpenabled']))
$phpenabled = intval($_POST['phpenabled']); $phpenabled = intval($_POST['phpenabled']);
$perlenabled = 0; $perlenabled = 0;
if(isset($_POST['perlenabled'])) if(isset($_POST['perlenabled']))
$perlenabled = intval($_POST['perlenabled']); $perlenabled = intval($_POST['perlenabled']);
$store_defaultindex = 0; $store_defaultindex = 0;
if(isset($_POST['store_defaultindex'])) if(isset($_POST['store_defaultindex']))
$store_defaultindex = intval($_POST['store_defaultindex']); $store_defaultindex = intval($_POST['store_defaultindex']);
$diskspace = $diskspace * 1024; $diskspace = $diskspace * 1024;
$traffic = $traffic * 1024 * 1024; $traffic = $traffic * 1024 * 1024;
@@ -658,40 +664,40 @@ if($page == 'customers'
$_theme = $settings['panel']['default_theme']; $_theme = $settings['panel']['default_theme'];
$result = $db->query( $result = $db->query(
"INSERT INTO `" . TABLE_PANEL_CUSTOMERS . "` SET "INSERT INTO `" . TABLE_PANEL_CUSTOMERS . "` SET
`adminid` = '" . (int)$userinfo['adminid'] . "', `adminid` = '" . (int)$userinfo['adminid'] . "',
`loginname` = '" . $db->escape($loginname) . "', `loginname` = '" . $db->escape($loginname) . "',
`password` = '" . md5($password) . "', `password` = '" . md5($password) . "',
`name` = '" . $db->escape($name) . "', `name` = '" . $db->escape($name) . "',
`firstname` = '" . $db->escape($firstname) . "', `firstname` = '" . $db->escape($firstname) . "',
`gender` = '" . (int)$gender . "', `gender` = '" . (int)$gender . "',
`company` = '" . $db->escape($company) . "', `company` = '" . $db->escape($company) . "',
`street` = '" . $db->escape($street) . "', `street` = '" . $db->escape($street) . "',
`zipcode` = '" . $db->escape($zipcode) . "', `zipcode` = '" . $db->escape($zipcode) . "',
`city` = '" . $db->escape($city) . "', `city` = '" . $db->escape($city) . "',
`phone` = '" . $db->escape($phone) . "', `phone` = '" . $db->escape($phone) . "',
`fax` = '" . $db->escape($fax) . "', `fax` = '" . $db->escape($fax) . "',
`email` = '" . $db->escape($email) . "', `email` = '" . $db->escape($email) . "',
`customernumber` = '" . $db->escape($customernumber) . "', `customernumber` = '" . $db->escape($customernumber) . "',
`def_language` = '" . $db->escape($def_language) . "', `def_language` = '" . $db->escape($def_language) . "',
`documentroot` = '" . $db->escape($documentroot) . "', `documentroot` = '" . $db->escape($documentroot) . "',
`guid` = '" . $db->escape($guid) . "', `guid` = '" . $db->escape($guid) . "',
`diskspace` = '" . $db->escape($diskspace) . "', `diskspace` = '" . $db->escape($diskspace) . "',
`traffic` = '" . $db->escape($traffic) . "', `traffic` = '" . $db->escape($traffic) . "',
`subdomains` = '" . $db->escape($subdomains) . "', `subdomains` = '" . $db->escape($subdomains) . "',
`emails` = '" . $db->escape($emails) . "', `emails` = '" . $db->escape($emails) . "',
`email_accounts` = '" . $db->escape($email_accounts) . "', `email_accounts` = '" . $db->escape($email_accounts) . "',
`email_forwarders` = '" . $db->escape($email_forwarders) . "', `email_forwarders` = '" . $db->escape($email_forwarders) . "',
`email_quota` = '" . $db->escape($email_quota) . "', `email_quota` = '" . $db->escape($email_quota) . "',
`ftps` = '" . $db->escape($ftps) . "', `ftps` = '" . $db->escape($ftps) . "',
`tickets` = '" . $db->escape($tickets) . "', `tickets` = '" . $db->escape($tickets) . "',
`mysqls` = '" . $db->escape($mysqls) . "', `mysqls` = '" . $db->escape($mysqls) . "',
`standardsubdomain` = '0', `standardsubdomain` = '0',
`phpenabled` = '" . $db->escape($phpenabled) . "', `phpenabled` = '" . $db->escape($phpenabled) . "',
`imap` = '" . $db->escape($email_imap) . "', `imap` = '" . $db->escape($email_imap) . "',
`pop3` = '" . $db->escape($email_pop3) . "', `pop3` = '" . $db->escape($email_pop3) . "',
`aps_packages` = '" . (int)$number_of_aps_packages . "', `aps_packages` = '" . (int)$number_of_aps_packages . "',
`perlenabled` = '" . $db->escape($perlenabled) . "', `perlenabled` = '" . $db->escape($perlenabled) . "',
`email_autoresponder` = '" . $db->escape($email_autoresponder) . "', `email_autoresponder` = '" . $db->escape($email_autoresponder) . "',
`backup_allowed` = '" . $db->escape($backup_allowed) . "', `backup_allowed` = '" . $db->escape($backup_allowed) . "',
`theme` = '" . $db->escape($_theme) . "'" `theme` = '" . $db->escape($_theme) . "'"
@@ -768,6 +774,11 @@ if($page == 'customers'
$log->logAction(ADM_ACTION, LOG_INFO, "added user '" . $loginname . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "added user '" . $loginname . "'");
inserttask('2', $loginname, $guid, $guid, $store_defaultindex); inserttask('2', $loginname, $guid, $guid, $store_defaultindex);
# Using filesystem - quota, insert a task which cleans the filesystem - quota
if ($settings['system']['diskquota_enabled'])
{
inserttask('10');
}
// Add htpasswd for the webalizer stats // Add htpasswd for the webalizer stats
if(CRYPT_STD_DES == 1) if(CRYPT_STD_DES == 1)
@@ -809,16 +820,16 @@ if($page == 'customers'
$_stdsubdomain = $loginname . '.' . $settings['system']['hostname']; $_stdsubdomain = $loginname . '.' . $settings['system']['hostname'];
} }
$db->query("INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET " . $db->query("INSERT INTO `" . TABLE_PANEL_DOMAINS . "` SET " .
"`domain` = '". $db->escape($_stdsubdomain) . "', " . "`domain` = '". $db->escape($_stdsubdomain) . "', " .
"`customerid` = '" . (int)$customerid . "', " . "`customerid` = '" . (int)$customerid . "', " .
"`adminid` = '" . (int)$userinfo['adminid'] . "', " . "`adminid` = '" . (int)$userinfo['adminid'] . "', " .
"`parentdomainid` = '-1', " . "`parentdomainid` = '-1', " .
"`ipandport` = '" . $db->escape($settings['system']['defaultip']) . "', " . "`ipandport` = '" . $db->escape($settings['system']['defaultip']) . "', " .
"`documentroot` = '" . $db->escape($documentroot) . "', " . "`documentroot` = '" . $db->escape($documentroot) . "', " .
"`zonefile` = '', " . "`zonefile` = '', " .
"`isemaildomain` = '0', " . "`isemaildomain` = '0', " .
"`caneditdomain` = '0', " . "`caneditdomain` = '0', " .
"`openbasedir` = '1', " . "`openbasedir` = '1', " .
"`safemode` = '1', " . "`safemode` = '1', " .
"`speciallogfile` = '0', " . "`speciallogfile` = '0', " .
@@ -904,11 +915,11 @@ if($page == 'customers'
#$perlenabled = makeyesno('perlenabled', '1', '0', '0'); #$perlenabled = makeyesno('perlenabled', '1', '0', '0');
#$store_defaultindex = makeyesno('store_defaultindex', '1', '0', '1'); #$store_defaultindex = makeyesno('store_defaultindex', '1', '0', '1');
$backup_allowed = makeyesno('backup_allowed', '1', '0', '0'); $backup_allowed = makeyesno('backup_allowed', '1', '0', '0');
$gender_options = makeoption($lng['gender']['undef'], 0, true, true, true); $gender_options = makeoption($lng['gender']['undef'], 0, true, true, true);
$gender_options .= makeoption($lng['gender']['male'], 1, null, true, true); $gender_options .= makeoption($lng['gender']['male'], 1, null, true, true);
$gender_options .= makeoption($lng['gender']['female'], 2, null, true, true); $gender_options .= makeoption($lng['gender']['female'], 2, null, true, true);
$customer_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_add.php'; $customer_add_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_add.php';
$customer_add_form = htmlform::genHTMLForm($customer_add_data); $customer_add_form = htmlform::genHTMLForm($customer_add_data);
@@ -1010,16 +1021,16 @@ if($page == 'customers'
else else
{ {
$email_autoresponder = 0; $email_autoresponder = 0;
} }
$email_imap = 0; $email_imap = 0;
if(isset($_POST['email_imap'])) if(isset($_POST['email_imap']))
$email_imap = intval_ressource($_POST['email_imap']); $email_imap = intval_ressource($_POST['email_imap']);
$email_pop3 = 0; $email_pop3 = 0;
if(isset($_POST['email_pop3'])) if(isset($_POST['email_pop3']))
$email_pop3 = intval_ressource($_POST['email_pop3']); $email_pop3 = intval_ressource($_POST['email_pop3']);
$ftps = 0; $ftps = 0;
if(isset($_POST['ftps'])) if(isset($_POST['ftps']))
$ftps = intval_ressource($_POST['ftps']); $ftps = intval_ressource($_POST['ftps']);
@@ -1036,11 +1047,11 @@ if($page == 'customers'
{ {
$tickets = - 1; $tickets = - 1;
} }
$backup_allowed = 0; $backup_allowed = 0;
if (isset($_POST['backup_allowed'])) if (isset($_POST['backup_allowed']))
$backup_allowed = intval($_POST['backup_allowed']); $backup_allowed = intval($_POST['backup_allowed']);
if($backup_allowed != '0'){ if($backup_allowed != '0'){
$backup_allowed = 1; $backup_allowed = 1;
} }
@@ -1049,7 +1060,7 @@ if($page == 'customers'
if ($gender < 0 || $gender > 2) { if ($gender < 0 || $gender > 2) {
$gender = 0; $gender = 0;
} }
$mysqls = 0; $mysqls = 0;
if(isset($_POST['mysqls'])) if(isset($_POST['mysqls']))
$mysqls = intval_ressource($_POST['mysqls']); $mysqls = intval_ressource($_POST['mysqls']);
@@ -1060,7 +1071,7 @@ if($page == 'customers'
} }
if($settings['aps']['aps_active'] == '1') if($settings['aps']['aps_active'] == '1')
{ {
$number_of_aps_packages = intval_ressource($_POST['number_of_aps_packages']); $number_of_aps_packages = intval_ressource($_POST['number_of_aps_packages']);
if(isset($_POST['number_of_aps_packages_ul'])) if(isset($_POST['number_of_aps_packages_ul']))
@@ -1076,15 +1087,15 @@ if($page == 'customers'
$createstdsubdomain = 0; $createstdsubdomain = 0;
if(isset($_POST['createstdsubdomain'])) if(isset($_POST['createstdsubdomain']))
$createstdsubdomain = intval($_POST['createstdsubdomain']); $createstdsubdomain = intval($_POST['createstdsubdomain']);
$deactivated = 0; $deactivated = 0;
if(isset($_POST['deactivated'])) if(isset($_POST['deactivated']))
$deactivated = intval($_POST['deactivated']); $deactivated = intval($_POST['deactivated']);
$phpenabled = 0; $phpenabled = 0;
if(isset($_POST['phpenabled'])) if(isset($_POST['phpenabled']))
$phpenabled = intval($_POST['phpenabled']); $phpenabled = intval($_POST['phpenabled']);
$perlenabled = 0; $perlenabled = 0;
if(isset($_POST['perlenabled'])) if(isset($_POST['perlenabled']))
$perlenabled = intval($_POST['perlenabled']); $perlenabled = intval($_POST['perlenabled']);
@@ -1210,7 +1221,7 @@ if($page == 'customers'
$db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `postfix`='" . (($deactivated) ? 'N' : 'Y') . "', `pop3`='" . (($deactivated) ? '0' : '1') . "', `imap`='" . (($deactivated) ? '0' : '1') . "' WHERE `customerid`='" . (int)$id . "'"); $db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `postfix`='" . (($deactivated) ? 'N' : 'Y') . "', `pop3`='" . (($deactivated) ? '0' : '1') . "', `imap`='" . (($deactivated) ? '0' : '1') . "' WHERE `customerid`='" . (int)$id . "'");
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `login_enabled`='" . (($deactivated) ? 'N' : 'Y') . "' WHERE `customerid`='" . (int)$id . "'"); $db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `login_enabled`='" . (($deactivated) ? 'N' : 'Y') . "' WHERE `customerid`='" . (int)$id . "'");
$db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `deactivated`='" . (int)$deactivated . "' WHERE `customerid`='" . (int)$id . "'"); $db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `deactivated`='" . (int)$deactivated . "' WHERE `customerid`='" . (int)$id . "'");
/* Retrieve customer's databases */ /* Retrieve customer's databases */
$databases = $db->query("SELECT * FROM " . TABLE_PANEL_DATABASES . " WHERE customerid='" . (int)$id . "' ORDER BY `dbserver`"); $databases = $db->query("SELECT * FROM " . TABLE_PANEL_DATABASES . " WHERE customerid='" . (int)$id . "' ORDER BY `dbserver`");
$db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], ''); $db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], '');
@@ -1232,7 +1243,7 @@ if($page == 'customers'
foreach(array_unique(explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host) foreach(array_unique(explode(',', $settings['system']['mysql_access_host'])) as $mysql_access_host)
{ {
$mysql_access_host = trim($mysql_access_host); $mysql_access_host = trim($mysql_access_host);
/* Prevent access, if deactivated */ /* Prevent access, if deactivated */
if($deactivated) if($deactivated)
{ {
@@ -1240,7 +1251,7 @@ if($page == 'customers'
$db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($row_database['databasename'])) . '` . * FROM `' . $db_root->escape($row_database['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`'); $db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($row_database['databasename'])) . '` . * FROM `' . $db_root->escape($row_database['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`');
} }
else /* Otherwise grant access */ else /* Otherwise grant access */
{ {
$db_root->query('GRANT ALL PRIVILEGES ON `' . $db_root->escape($row_database['databasename']) .'`.* TO `' . $db_root->escape($row_database['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`'); $db_root->query('GRANT ALL PRIVILEGES ON `' . $db_root->escape($row_database['databasename']) .'`.* TO `' . $db_root->escape($row_database['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($row_database['databasename'])) . '` . * TO `' . $db_root->escape($row_database['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`'); $db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($row_database['databasename'])) . '` . * TO `' . $db_root->escape($row_database['databasename']) . '`@`' . $db_root->escape($mysql_access_host) . '`');
} }
@@ -1250,7 +1261,7 @@ if($page == 'customers'
/* At last flush the new privileges */ /* At last flush the new privileges */
$db_root->query('FLUSH PRIVILEGES;'); $db_root->query('FLUSH PRIVILEGES;');
$db_root->close(); $db_root->close();
$log->logAction(ADM_ACTION, LOG_INFO, "deactivated user '" . $result['loginname'] . "'"); $log->logAction(ADM_ACTION, LOG_INFO, "deactivated user '" . $result['loginname'] . "'");
inserttask('1'); inserttask('1');
} }
@@ -1273,6 +1284,12 @@ if($page == 'customers'
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `name`='" . $db->escape($name) . "', `firstname`='" . $db->escape($firstname) . "', `gender`='" . $db->escape($gender) . "', `company`='" . $db->escape($company) . "', `street`='" . $db->escape($street) . "', `zipcode`='" . $db->escape($zipcode) . "', `city`='" . $db->escape($city) . "', `phone`='" . $db->escape($phone) . "', `fax`='" . $db->escape($fax) . "', `email`='" . $db->escape($email) . "', `customernumber`='" . $db->escape($customernumber) . "', `def_language`='" . $db->escape($def_language) . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `deactivated`='" . $db->escape($deactivated) . "', `phpenabled`='" . $db->escape($phpenabled) . "', `email_quota`='" . $db->escape($email_quota) . "', `imap`='" . $db->escape($email_imap) . "', `pop3`='" . $db->escape($email_pop3) . "', `aps_packages`='" . (int)$number_of_aps_packages . "', `perlenabled`='" . $db->escape($perlenabled) . "', `email_autoresponder`='" . $db->escape($email_autoresponder) . "', `backup_allowed`='" . $db->escape($backup_allowed) . "' WHERE `customerid`='" . (int)$id . "'"); $db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `name`='" . $db->escape($name) . "', `firstname`='" . $db->escape($firstname) . "', `gender`='" . $db->escape($gender) . "', `company`='" . $db->escape($company) . "', `street`='" . $db->escape($street) . "', `zipcode`='" . $db->escape($zipcode) . "', `city`='" . $db->escape($city) . "', `phone`='" . $db->escape($phone) . "', `fax`='" . $db->escape($fax) . "', `email`='" . $db->escape($email) . "', `customernumber`='" . $db->escape($customernumber) . "', `def_language`='" . $db->escape($def_language) . "', `password` = '" . $password . "', `diskspace`='" . $db->escape($diskspace) . "', `traffic`='" . $db->escape($traffic) . "', `subdomains`='" . $db->escape($subdomains) . "', `emails`='" . $db->escape($emails) . "', `email_accounts` = '" . $db->escape($email_accounts) . "', `email_forwarders`='" . $db->escape($email_forwarders) . "', `ftps`='" . $db->escape($ftps) . "', `tickets`='" . $db->escape($tickets) . "', `mysqls`='" . $db->escape($mysqls) . "', `deactivated`='" . $db->escape($deactivated) . "', `phpenabled`='" . $db->escape($phpenabled) . "', `email_quota`='" . $db->escape($email_quota) . "', `imap`='" . $db->escape($email_imap) . "', `pop3`='" . $db->escape($email_pop3) . "', `aps_packages`='" . (int)$number_of_aps_packages . "', `perlenabled`='" . $db->escape($perlenabled) . "', `email_autoresponder`='" . $db->escape($email_autoresponder) . "', `backup_allowed`='" . $db->escape($backup_allowed) . "' WHERE `customerid`='" . (int)$id . "'");
$admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` "; $admin_update_query = "UPDATE `" . TABLE_PANEL_ADMINS . "` SET `customers_used` = `customers_used` ";
# Using filesystem - quota, insert a task which cleans the filesystem - quota
if ($settings['system']['diskquota_enabled'])
{
inserttask('10');
}
if($mysqls != '-1' if($mysqls != '-1'
|| $result['mysqls'] != '-1') || $result['mysqls'] != '-1')
{ {
@@ -1568,7 +1585,7 @@ if($page == 'customers'
$gender_options = makeoption($lng['gender']['undef'], 0, ($result['gender'] == '0' ? true : false), true, true); $gender_options = makeoption($lng['gender']['undef'], 0, ($result['gender'] == '0' ? true : false), true, true);
$gender_options .= makeoption($lng['gender']['male'], 1, ($result['gender'] == '1' ? true : false), true, true); $gender_options .= makeoption($lng['gender']['male'], 1, ($result['gender'] == '1' ? true : false), true, true);
$gender_options .= makeoption($lng['gender']['female'], 2, ($result['gender'] == '2' ? true : false), true, true); $gender_options .= makeoption($lng['gender']['female'], 2, ($result['gender'] == '2' ? true : false), true, true);
$customer_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_edit.php'; $customer_edit_data = include_once dirname(__FILE__).'/lib/formfields/admin/customer/formfield.customer_edit.php';
$customer_edit_form = htmlform::genHTMLForm($customer_edit_data); $customer_edit_form = htmlform::genHTMLForm($customer_edit_data);

View File

@@ -32,7 +32,7 @@ if(($page == 'settings' || $page == 'overview')
{ {
$settings_data = loadConfigArrayDir('./actions/admin/settings/'); $settings_data = loadConfigArrayDir('./actions/admin/settings/');
$settings = loadSettings($settings_data, $db); $settings = loadSettings($settings_data, $db);
if(isset($_POST['send']) if(isset($_POST['send'])
&& $_POST['send'] == 'send') && $_POST['send'] == 'send')
{ {
@@ -64,10 +64,10 @@ if(($page == 'settings' || $page == 'overview')
$settings_part = false; $settings_part = false;
$only_enabledisable = true; $only_enabledisable = true;
} }
if(processFormEx( if(processFormEx(
$settings_data, $settings_data,
$_POST, $_POST,
array('filename' => $filename, 'action' => $action, 'page' => $page), array('filename' => $filename, 'action' => $action, 'page' => $page),
$_part, $_part,
$settings_all, $settings_all,
@@ -86,24 +86,24 @@ if(($page == 'settings' || $page == 'overview')
else else
{ {
$_part = isset($_GET['part']) ? $_GET['part'] : ''; $_part = isset($_GET['part']) ? $_GET['part'] : '';
if($_part == '') if($_part == '')
{ {
$_part = isset($_POST['part']) ? $_POST['part'] : ''; $_part = isset($_POST['part']) ? $_POST['part'] : '';
} }
$fields = buildFormEx($settings_data, $_part); $fields = buildFormEx($settings_data, $_part);
$settings_page = ''; $settings_page = '';
if($_part == '') if($_part == '')
{ {
eval("\$settings_page .= \"" . getTemplate("settings/settings_overview") . "\";"); eval("\$settings_page .= \"" . getTemplate("settings/settings_overview") . "\";");
} }
else else
{ {
eval("\$settings_page .= \"" . getTemplate("settings/settings") . "\";"); eval("\$settings_page .= \"" . getTemplate("settings/settings") . "\";");
} }
eval("echo \"" . getTemplate("settings/settings_form_begin") . "\";"); eval("echo \"" . getTemplate("settings/settings_form_begin") . "\";");
eval("echo \$settings_page;"); eval("echo \$settings_page;");
eval("echo \"" . getTemplate("settings/settings_form_end") . "\";"); eval("echo \"" . getTemplate("settings/settings_form_end") . "\";");
@@ -121,6 +121,7 @@ elseif($page == 'rebuildconfigs'
inserttask('4'); inserttask('4');
inserttask('5'); inserttask('5');
inserttask('9'); inserttask('9');
inserttask('10');
standard_success('rebuildingconfigs', '', array('filename' => 'admin_index.php')); standard_success('rebuildingconfigs', '', array('filename' => 'admin_index.php'));
} }
else else

View File

@@ -468,7 +468,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('syste
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'vmail_homedir', '/var/customers/mail/'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'vmail_homedir', '/var/customers/mail/');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bindconf_directory', '/etc/bind/'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bindconf_directory', '/etc/bind/');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bindreload_command', '/etc/init.d/bind9 reload'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bindreload_command', '/etc/init.d/bind9 reload');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('panel', 'version', '0.9.21'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('panel', 'version', '0.9.22-svn1');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'hostname', 'SERVERNAME'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'hostname', 'SERVERNAME');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('login', 'maxloginattempts', '3'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('login', 'maxloginattempts', '3');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('login', 'deactivatetime', '900'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('login', 'deactivatetime', '900');
@@ -632,6 +632,11 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('syste
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_user', ''); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_user', '');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_pass', ''); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_pass', '');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_passive', '1'); INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_passive', '1');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_enabled', '0');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_repquota_path', '/usr/sbin/repquota');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_quotatool_path', '/usr/bin/quotatool');
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_customer_partition', '/dev/root');
# -------------------------------------------------------- # --------------------------------------------------------
# #
@@ -1019,7 +1024,7 @@ CREATE TABLE IF NOT EXISTS `aps_temp_settings` (
DROP TABLE IF EXISTS `cronjobs_run`; DROP TABLE IF EXISTS `cronjobs_run`;
CREATE TABLE IF NOT EXISTS `cronjobs_run` ( CREATE TABLE IF NOT EXISTS `cronjobs_run` (
`id` bigint(20) NOT NULL auto_increment, `id` bigint(20) NOT NULL auto_increment,
`module` varchar(250) NOT NULL, `module` varchar(250) NOT NULL,
`cronfile` varchar(250) NOT NULL, `cronfile` varchar(250) NOT NULL,
`lastrun` int(15) NOT NULL DEFAULT '0', `lastrun` int(15) NOT NULL DEFAULT '0',
`interval` varchar(100) NOT NULL DEFAULT '5 MINUTE', `interval` varchar(100) NOT NULL DEFAULT '5 MINUTE',

View File

@@ -1382,7 +1382,7 @@ if(isFroxlorVersion('0.9.16'))
} }
$check = $db->query_first("SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `varname`='trafficninetypercent_mailbody';"); $check = $db->query_first("SELECT `varname` FROM `" . TABLE_PANEL_TEMPLATES . "` WHERE `varname`='trafficninetypercent_mailbody';");
if(isset($check['varname']) && $check['varname'] == 'trafficninetypercent_mailbody') if(isset($check['varname']) && $check['varname'] == 'trafficninetypercent_mailbody')
{ {
$db->query("UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET `varname` = 'trafficmaxpercent_mailbody' WHERE `varname`='trafficninetypercent_mailbody';"); $db->query("UPDATE `" . TABLE_PANEL_TEMPLATES . "` SET `varname` = 'trafficmaxpercent_mailbody' WHERE `varname`='trafficninetypercent_mailbody';");
} }
lastStepStatus(0); lastStepStatus(0);
@@ -1400,7 +1400,7 @@ if(isFroxlorVersion('0.9.17-svn1'))
`fid` int(11) NOT NULL, `fid` int(11) NOT NULL,
`docrootsettings` text NOT NULL, `docrootsettings` text NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=MyISAM;"); ) ENGINE=MyISAM;");
$db->query("CREATE TABLE IF NOT EXISTS `domain_docrootsettings` ( $db->query("CREATE TABLE IF NOT EXISTS `domain_docrootsettings` (
`id` int(5) NOT NULL auto_increment, `id` int(5) NOT NULL auto_increment,
`fid` int(11) NOT NULL, `fid` int(11) NOT NULL,
@@ -1495,11 +1495,11 @@ if(isFroxlorVersion('0.9.19'))
{ {
showUpdateStep("Updating from 0.9.19 to 0.9.20-svn1"); showUpdateStep("Updating from 0.9.19 to 0.9.20-svn1");
lastStepStatus(0); lastStepStatus(0);
showUpdateStep("Adding new setting for domain validation"); showUpdateStep("Adding new setting for domain validation");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'validate_domain', '1')"); $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'validate_domain', '1')");
lastStepStatus(0); lastStepStatus(0);
updateToVersion('0.9.20-svn1'); updateToVersion('0.9.20-svn1');
} }
@@ -1549,7 +1549,7 @@ if(isFroxlorVersion('0.9.20.1'))
lastStepStatus(0); lastStepStatus(0);
showUpdateStep("Fixing possible broken tables"); showUpdateStep("Fixing possible broken tables");
// The customer-table may miss the columns, if installed a fresh 0.9.20 or 0.9.20.1 - add them // The customer-table may miss the columns, if installed a fresh 0.9.20 or 0.9.20.1 - add them
$result = $db->query("DESCRIBE `" . TABLE_PANEL_CUSTOMERS . "`"); $result = $db->query("DESCRIBE `" . TABLE_PANEL_CUSTOMERS . "`");
$columnfound = 0; $columnfound = 0;
@@ -1593,7 +1593,7 @@ if(isFroxlorVersion('0.9.20.1-svn1') || isFroxlorVersion('0.9.20.2-svn1'))
// add table column for gender // add table column for gender
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `gender` INT( 1 ) NOT NULL DEFAULT '0' AFTER `firstname`"); $db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `gender` INT( 1 ) NOT NULL DEFAULT '0' AFTER `firstname`");
lastStepStatus(0); lastStepStatus(0);
@@ -1604,10 +1604,10 @@ if(isFroxlorVersion('0.9.21-svn1'))
{ {
showUpdateStep("Updating from 0.9.21-svn1 to 0.9.21-svn2"); showUpdateStep("Updating from 0.9.21-svn1 to 0.9.21-svn2");
lastStepStatus(0); lastStepStatus(0);
/* add new setting: backup FTP mode */ /* add new setting: backup FTP mode */
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_passive', '1')"); $db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'backup_ftp_passive', '1')");
lastStepStatus(0); lastStepStatus(0);
updateToVersion('0.9.21-svn2'); updateToVersion('0.9.21-svn2');
@@ -1617,6 +1617,20 @@ if(isFroxlorVersion('0.9.21-svn2'))
{ {
showUpdateStep("Updating from 0.9.21-svn2 to 0.9.21"); showUpdateStep("Updating from 0.9.21-svn2 to 0.9.21");
lastStepStatus(0); lastStepStatus(0);
updateToVersion('0.9.21'); updateToVersion('0.9.21');
} }
if(isFroxlorVersion('0.9.21'))
{
showUpdateStep("Updating from 0.9.21 to 0.9.22-svn1");
lastStepStatus(0);
/* add new settings for diskspacequota - support */
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_enabled', '0');");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_repquota_path', '/usr/sbin/repquota');");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_quotatool_path', '/usr/bin/quotatool');");
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'diskquota_customer_partition', '/dev/root');");
updateToVersion('0.9.22-svn1');
}

View File

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

View File

@@ -73,6 +73,6 @@ define('PACKAGE_ENABLED', 2);
// VERSION INFO // VERSION INFO
$version = '0.9.21'; $version = '0.9.22-svn1';
$dbversion = '2'; $dbversion = '2';
$branding = ''; $branding = '';

View File

@@ -1877,3 +1877,11 @@ $lng['country']['EH'] = "Western Sahara";
$lng['country']['YE'] = "Yemen"; $lng['country']['YE'] = "Yemen";
$lng['country']['ZM'] = "Zambia"; $lng['country']['ZM'] = "Zambia";
$lng['country']['ZW'] = "Zimbabwe"; $lng['country']['ZW'] = "Zimbabwe";
// ADDED IN FROXLOR 0.9.22-svn1
$lng['diskquota'] = 'Quota';
$lng['serversettings']['diskquota_enabled'] = 'Quota activated?';
$lng['serversettings']['diskquota_repquota_path']['description'] = 'Path to repquota';
$lng['serversettings']['diskquota_quotatool_path']['description'] = 'Path to quotatool';
$lng['serversettings']['diskquota_customer_partition']['description'] = 'Partition, on which the customer files are stored';
$lng['tasks']['diskspace_set_quota'] = 'Set quota on filesystem';

View File

@@ -1608,3 +1608,11 @@ $lng['gender']['female'] = 'Frau';
$lng['gender']['undef'] = ''; $lng['gender']['undef'] = '';
$lng['serversettings']['backup_ftp_passive_mode'] = 'Passiven &Uuml;bertragungsmodus verwenden'; $lng['serversettings']['backup_ftp_passive_mode'] = 'Passiven &Uuml;bertragungsmodus verwenden';
$lng['serversettings']['backup_bigfile'] = 'Backup von Kundenverzeichnissen und Datenbanken in eine Datei speichern, statt zu splitten?'; $lng['serversettings']['backup_bigfile'] = 'Backup von Kundenverzeichnissen und Datenbanken in eine Datei speichern, statt zu splitten?';
// ADDED IN FROXLOR 0.9.22-svn1
$lng['diskquota'] = 'Quota';
$lng['serversettings']['diskquota_enabled'] = 'Quota aktiviert?';
$lng['serversettings']['diskquota_repquota_path']['description'] = 'Pfad zu repquota';
$lng['serversettings']['diskquota_quotatool_path']['description'] = 'Pfad zu quotatool';
$lng['serversettings']['diskquota_customer_partition']['description'] = 'Partition, auf welcher die Kundendaten liegen';
$lng['tasks']['diskspace_set_quota'] = 'Quota auf dem Dateisystem setzen';

View File

@@ -64,7 +64,7 @@ while($row = $db->fetch_array($result_tasks))
* (e.g. awstats not installed yet or whatever) * (e.g. awstats not installed yet or whatever)
* fixes #45 * fixes #45
*/ */
if (is_dir($awstatsclean['path'])) if (is_dir($awstatsclean['path']))
{ {
$awstatsclean['dir'] = dir($awstatsclean['path']); $awstatsclean['dir'] = dir($awstatsclean['path']);
while($awstatsclean['entry'] = $awstatsclean['dir']->read()) { while($awstatsclean['entry'] = $awstatsclean['dir']->read()) {
@@ -98,7 +98,7 @@ while($row = $db->fetch_array($result_tasks))
{ {
$configdir = makeCorrectDir($settings['system']['mod_fcgid_configdir']); $configdir = makeCorrectDir($settings['system']['mod_fcgid_configdir']);
if (is_dir($configdir)) if (is_dir($configdir))
{ {
$its = new RecursiveIteratorIterator( $its = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($configdir) new RecursiveDirectoryIterator($configdir)
@@ -108,14 +108,14 @@ while($row = $db->fetch_array($result_tasks))
// look for php-fcgi-starter files // look for php-fcgi-starter files
// and take immutable-flag away from them // and take immutable-flag away from them
// so we can delete them :) // so we can delete them :)
foreach ($its as $fullFileName => $it ) foreach ($its as $fullFileName => $it )
{ {
if ($it->isFile() && $it->getFilename() == 'php-fcgi-starter') if ($it->isFile() && $it->getFilename() == 'php-fcgi-starter')
{ {
removeImmutable($its->getPathname()); removeImmutable($its->getPathname());
} }
} }
// now get rid of old stuff // now get rid of old stuff
//(but append /* so we don't delete the directory) //(but append /* so we don't delete the directory)
$configdir.='/*'; $configdir.='/*';
safe_exec('rm -rf '. makeCorrectFile($configdir)); safe_exec('rm -rf '. makeCorrectFile($configdir));
@@ -127,9 +127,9 @@ while($row = $db->fetch_array($result_tasks))
{ {
$configdir = makeCorrectDir($settings['phpfpm']['configdir']); $configdir = makeCorrectDir($settings['phpfpm']['configdir']);
if (is_dir($configdir)) if (is_dir($configdir))
{ {
// now get rid of old stuff // now get rid of old stuff
//(but append /* so we don't delete the directory) //(but append /* so we don't delete the directory)
$configdir.='/*'; $configdir.='/*';
safe_exec('rm -rf '. makeCorrectFile($configdir)); safe_exec('rm -rf '. makeCorrectFile($configdir));
@@ -211,7 +211,7 @@ while($row = $db->fetch_array($result_tasks))
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($userhomedir . 'webalizer')); $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($userhomedir . 'webalizer'));
safe_exec('mkdir -p ' . escapeshellarg($userhomedir . 'webalizer')); safe_exec('mkdir -p ' . escapeshellarg($userhomedir . 'webalizer'));
} }
// maildir // maildir
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($usermaildir)); $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($usermaildir));
safe_exec('mkdir -p ' . escapeshellarg($usermaildir)); safe_exec('mkdir -p ' . escapeshellarg($usermaildir));
@@ -318,8 +318,8 @@ while($row = $db->fetch_array($result_tasks))
{ {
// e.g. /var/www/php-fcgi-starter/web1/ // e.g. /var/www/php-fcgi-starter/web1/
$configdir = makeCorrectDir($settings['system']['mod_fcgid_configdir'] . '/' . $row['data']['loginname'] . '/'); $configdir = makeCorrectDir($settings['system']['mod_fcgid_configdir'] . '/' . $row['data']['loginname'] . '/');
if (is_dir($configdir)) if (is_dir($configdir))
{ {
$its = new RecursiveIteratorIterator( $its = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($configdir) new RecursiveDirectoryIterator($configdir)
@@ -329,16 +329,16 @@ while($row = $db->fetch_array($result_tasks))
// look for php-fcgi-starter files // look for php-fcgi-starter files
// and take immutable-flag away from them // and take immutable-flag away from them
// so we can delete them :) // so we can delete them :)
foreach ($its as $fullFileName => $it ) foreach ($its as $fullFileName => $it )
{ {
if ($it->isFile() && $it->getFilename() == 'php-fcgi-starter') if ($it->isFile() && $it->getFilename() == 'php-fcgi-starter')
{ {
removeImmutable($its->getPathname()); removeImmutable($its->getPathname());
} }
} }
// now get rid of old stuff // now get rid of old stuff
safe_exec('rm -rf '. escapeshellarg($configdir)); safe_exec('rm -rf '. escapeshellarg($configdir));
} }
} }
} }
} }
@@ -409,7 +409,7 @@ while($row = $db->fetch_array($result_tasks))
*/ */
elseif ($row['type'] == '9') elseif ($row['type'] == '9')
{ {
fwrite($debugHandler, ' cron_tasks: Task9 started - creating backup dir protection' . "\n"); fwrite($debugHandler, ' cron_tasks: Task9 started - creating backup dir protection' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task9 started - creating backup dir protection'); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task9 started - creating backup dir protection');
@@ -457,7 +457,49 @@ while($row = $db->fetch_array($result_tasks))
} }
} }
} }
}
}
/**
* TYPE=10 Set the filesystem - quota
*/
elseif ($row['type'] == '10')
{
if ($settings['system']['diskquota_enabled'])
{
fwrite($debugHandler, ' cron_tasks: Task10 started - setting filesystem quota' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task10 started - setting filesystem quota');
$usedquota = getFilesystemQuota();
# Select all customers Froxlor knows about
$result = $db->query("SELECT `guid`, `loginname`, `diskspace` FROM `" . TABLE_PANEL_CUSTOMERS . "`;");
while($row = $db->fetch_array($result))
{
# We do not want to set a quota for root by accident
if ($row['guid'] != 0)
{
# The user has no quota in Froxlor, but on the filesystem
if (($row['diskspace'] == 0 || $row['diskspace'] == -1024) && $usedquota[$row['guid']]['block']['hard'] != 0)
{
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Disabling quota for " . $row['loginname']);
safe_exec($settings['system']['diskquota_quotatool_path'] . " -u " . $row['guid'] . " -bl 0 -q 0 " . escapeshellarg($settings['system']['diskquota_customer_partition']));
}
# The user quota in Froxlor is different than on the filesystem
elseif($row['diskspace'] != $usedquota[$row['guid']]['block']['hard'] && $row['diskspace'] != -1024)
{
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, "Setting quota for " . $row['loginname'] . " from " . $usedquota[$row['guid']]['block']['hard'] . " to " . $row['diskspace']);
safe_exec($settings['system']['diskquota_quotatool_path'] . " -u " . $row['guid'] . " -bl " . $row['diskspace'] . " -q " . $row['diskspace'] . " " . escapeshellarg($settings['system']['diskquota_customer_partition']));
}
}
}
}
else
{
fwrite($debugHandler, ' cron_tasks: Task10 skipped - filesystem quota not enabled' . "\n");
$cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task10 skipped - filesystem quota not enabled');
} }
} }
} }

View File

@@ -80,7 +80,7 @@ while($row_database = $db->fetch_array($databases))
$databases_list[] = strtolower($databases_list_row['Database']); $databases_list[] = strtolower($databases_list_row['Database']);
} }
} }
if(in_array(strtolower($row_database['databasename']), $databases_list)) if(in_array(strtolower($row_database['databasename']), $databases_list))
{ {
$mysql_usage_result = $db_root->query("SHOW TABLE STATUS FROM `" . $db_root->escape($row_database['databasename']) . "`"); $mysql_usage_result = $db_root->query("SHOW TABLE STATUS FROM `" . $db_root->escape($row_database['databasename']) . "`");
@@ -102,6 +102,11 @@ while($row_database = $db->fetch_array($databases))
$db_root->close(); $db_root->close();
# We are using the file-system quota, this will speed up the diskusage - collection
if ($settings['system']['diskquota_enabled'])
{
$usedquota = getFilesystemQuota();
}
$result = $db->query("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC"); $result = $db->query("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC");
@@ -179,7 +184,7 @@ while($row = $db->fetch_array($result))
safeSQLLogfile($domainlist[$row['customerid']], $row['loginname']); safeSQLLogfile($domainlist[$row['customerid']], $row['loginname']);
} }
// callAwstatsGetTraffic is called ONLY HERE and // callAwstatsGetTraffic is called ONLY HERE and
// *not* also in the special-logfiles-loop, because the function // *not* also in the special-logfiles-loop, because the function
// will iterate through all customer-domains and the awstats-configs // will iterate through all customer-domains and the awstats-configs
// know the logfile-name, #246 // know the logfile-name, #246
@@ -191,7 +196,7 @@ while($row = $db->fetch_array($result))
{ {
$httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']])); $httptraffic+= floatval(callWebalizerGetTraffic($row['loginname'], $row['documentroot'] . '/webalizer/', $caption, $domainlist[$row['customerid']]));
} }
// make the stuff readable for the customer, #258 // make the stuff readable for the customer, #258
makeChownWithNewStats($row); makeChownWithNewStats($row);
@@ -207,7 +212,7 @@ while($row = $db->fetch_array($result))
$db->close(); $db->close();
require_once ($pathtophpfiles . '/lib/userdata.inc.php'); require_once ($pathtophpfiles . '/lib/userdata.inc.php');
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']); $db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']);
if ($db->link_id == 0) { if ($db->link_id == 0) {
fclose($debugHandler); fclose($debugHandler);
unlink($lockfile); unlink($lockfile);
@@ -285,23 +290,33 @@ while($row = $db->fetch_array($result))
fwrite($debugHandler, 'calculating webspace usage for ' . $row['loginname'] . "\n"); fwrite($debugHandler, 'calculating webspace usage for ' . $row['loginname'] . "\n");
$webspaceusage = 0; $webspaceusage = 0;
if(file_exists($row['documentroot']) && is_dir($row['documentroot'])) # Using repquota, it's faster using this tool than using du traversing the complete directory
if ($settings['system']['diskquota_enabled'])
{ {
$back = safe_exec('du -sk ' . escapeshellarg($row['documentroot']) . ''); # We may use the array we created earlier, the used diskspace is stored in [<guid>][block][used]
foreach($back as $backrow) $webspaceusage = floatval($usedquota[$row['guid']]['block']['used']);
{
$webspaceusage = explode(' ', $backrow);
}
$webspaceusage = floatval($webspaceusage['0']);
unset($back);
} }
else else
{ {
fwrite($debugHandler, 'documentroot ' . $row['documentroot'] . ' does not exist' . "\n"); # Use the old fashioned way with "du"
if(file_exists($row['documentroot']) && is_dir($row['documentroot']))
{
$back = safe_exec('du -sk ' . escapeshellarg($row['documentroot']) . '');
foreach($back as $backrow)
{
$webspaceusage = explode(' ', $backrow);
}
$webspaceusage = floatval($webspaceusage['0']);
unset($back);
}
else
{
fwrite($debugHandler, 'documentroot ' . $row['documentroot'] . ' does not exist' . "\n");
}
} }
/** /**
* MailSpace-Usage * MailSpace-Usage
*/ */
@@ -317,7 +332,7 @@ while($row = $db->fetch_array($result))
{ {
$emailusage = explode(' ', $backrow); $emailusage = explode(' ', $backrow);
} }
$emailusage = floatval($emailusage['0']); $emailusage = floatval($emailusage['0']);
unset($back); unset($back);
} }
@@ -380,11 +395,11 @@ while($row = $db->fetch_array($result))
*/ */
$db->query("UPDATE `" . TABLE_FTP_QUOTATALLIES . "` SET `bytes_in_used`='" . (float)$current_diskspace['all'] . "'*1024 WHERE `name` = '" . $row['loginname'] . "' OR `name` LIKE '" . $row['loginname'] . $settings['customer']['ftpprefix'] . "%'"); $db->query("UPDATE `" . TABLE_FTP_QUOTATALLIES . "` SET `bytes_in_used`='" . (float)$current_diskspace['all'] . "'*1024 WHERE `name` = '" . $row['loginname'] . "' OR `name` LIKE '" . $row['loginname'] . $settings['customer']['ftpprefix'] . "%'");
/** /**
* Pureftpd Quota * Pureftpd Quota
*/ */
if($settings['system']['ftpserver'] == "pureftpd") if($settings['system']['ftpserver'] == "pureftpd")
{ {
$result_quota = $db->query("SELECT homedir FROM `" . TABLE_FTP_USERS . "` WHERE customerid = '" . $row['customerid'] . "'"); $result_quota = $db->query("SELECT homedir FROM `" . TABLE_FTP_USERS . "` WHERE customerid = '" . $row['customerid'] . "'");
@@ -400,7 +415,7 @@ while($row = $db->fetch_array($result))
$user = $row['guid']; $user = $row['guid'];
$group = $row['guid']; $group = $row['guid'];
} }
while($row_quota = $db->fetch_array($result_quota)) while($row_quota = $db->fetch_array($result_quota))
{ {
$quotafile = "" . $row_quota['homedir'] . ".ftpquota"; $quotafile = "" . $row_quota['homedir'] . ".ftpquota";