svn:eol-style got murdered on some files for whatever reason so it gets resurrected now, also set some svn:keywords

This commit is contained in:
Robert Foerster (Dessa)
2010-01-27 08:54:31 +00:00
parent 30f2de8f9e
commit 883963d2e2
190 changed files with 34136 additions and 34136 deletions

View File

@@ -1,99 +1,99 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Create or modify the AWStats configuration file for the given domain.
* Modified by Berend Dekens to allow custom configurations.
*
* @param logFile
* @param siteDomain
* @param hostAliases
* @return
* @author Michael Duergner
* @author Berend Dekens
*/
function createAWStatsConf($logFile, $siteDomain, $hostAliases)
{
global $pathtophpfiles;
// Generation header
$header = "## GENERATED BY SYSCP\n";
$header2 = "## Do not remove the line above! This tells Froxlor to update this configuration\n## If you wish to manually change this configuration file, remove the first line to make sure Froxlor won't rebuild this file\n## Generated for domain {SITE_DOMAIN} on " . date('l dS \of F Y h:i:s A') . "\n";
// These are the variables we will replace
$regex = array(
'/\{LOG_FILE\}/',
'/\{SITE_DOMAIN\}/',
'/\{HOST_ALIASES\}/'
);
$replace = array(
$logFile,
$siteDomain,
$hostAliases
);
// File names
$domain_file = '/etc/awstats/awstats.' . $siteDomain . '.conf';
$model_file = '/etc/awstats/awstats.model.conf.froxlor';
// Test if the file exists
if(file_exists($domain_file))
{
// Check for the generated header - if this is a manual modification we won't update
$awstats_domain_conf = fopen($domain_file, 'r');
if(fgets($awstats_domain_conf, strlen($header)) != $header)
{
fclose($awstats_domain_conf);
return;
}
// Close the file
fclose($awstats_domain_conf);
}
$awstats_domain_conf = fopen($domain_file, 'w');
$awstats_model_conf = fopen($model_file, 'r');
// Write the header
fwrite($awstats_domain_conf, $header);
fwrite($awstats_domain_conf, preg_replace($regex, $replace, $header2));
// Write the configuration file
while(($line = fgets($awstats_model_conf, 4096)) !== false)
{
if(!preg_match('/^#/', $line)
&& trim($line) != '')
{
fwrite($awstats_domain_conf, preg_replace($regex, $replace, $line));
}
}
fclose($awstats_domain_conf);
fclose($awstats_model_conf);
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Create or modify the AWStats configuration file for the given domain.
* Modified by Berend Dekens to allow custom configurations.
*
* @param logFile
* @param siteDomain
* @param hostAliases
* @return
* @author Michael Duergner
* @author Berend Dekens
*/
function createAWStatsConf($logFile, $siteDomain, $hostAliases)
{
global $pathtophpfiles;
// Generation header
$header = "## GENERATED BY SYSCP\n";
$header2 = "## Do not remove the line above! This tells Froxlor to update this configuration\n## If you wish to manually change this configuration file, remove the first line to make sure Froxlor won't rebuild this file\n## Generated for domain {SITE_DOMAIN} on " . date('l dS \of F Y h:i:s A') . "\n";
// These are the variables we will replace
$regex = array(
'/\{LOG_FILE\}/',
'/\{SITE_DOMAIN\}/',
'/\{HOST_ALIASES\}/'
);
$replace = array(
$logFile,
$siteDomain,
$hostAliases
);
// File names
$domain_file = '/etc/awstats/awstats.' . $siteDomain . '.conf';
$model_file = '/etc/awstats/awstats.model.conf.froxlor';
// Test if the file exists
if(file_exists($domain_file))
{
// Check for the generated header - if this is a manual modification we won't update
$awstats_domain_conf = fopen($domain_file, 'r');
if(fgets($awstats_domain_conf, strlen($header)) != $header)
{
fclose($awstats_domain_conf);
return;
}
// Close the file
fclose($awstats_domain_conf);
}
$awstats_domain_conf = fopen($domain_file, 'w');
$awstats_model_conf = fopen($model_file, 'r');
// Write the header
fwrite($awstats_domain_conf, $header);
fwrite($awstats_domain_conf, preg_replace($regex, $replace, $header2));
// Write the configuration file
while(($line = fgets($awstats_model_conf, 4096)) !== false)
{
if(!preg_match('/^#/', $line)
&& trim($line) != '')
{
fwrite($awstats_domain_conf, preg_replace($regex, $replace, $line));
}
}
fclose($awstats_domain_conf);
fclose($awstats_model_conf);
}

View File

@@ -1,47 +1,47 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* This function generates the VHost configuration for AWStats
* This will enable the /awstats url and enable security on these folders
* @param siteDomain Name of the domain we want stats for
* @return String with configuration for use in vhost file
* @author Berend Dekens
*/
function createAWStatsVhost($siteDomain, $settings = null)
{
if($settings['system']['mod_fcgid'] != '1')
{
$vhosts_file = ' # AWStats statistics' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\n";
$vhosts_file.= ' RewriteRule ^/awstats(/.*)?$ /awstats/awstats.pl?config=' . $siteDomain . ' [L,PT]' . "\n";
$vhosts_file.= ' RewriteRule ^/awstats.pl(.*)$ /awstats/awstats.pl$1 [QSA,L,PT]' . "\n";
}
else
{
$vhosts_file = ' <IfModule mod_proxy.c>' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\n";
$vhosts_file.= ' RewriteRule awstats.pl(.*)$ http://' . $settings['system']['hostname'] . '/cgi-bin/awstats.pl$1 [R,P]' . "\n";
$vhosts_file.= ' RewriteRule awstats$ http://' . $settings['system']['hostname'] . '/cgi-bin/awstats.pl?config=' . $siteDomain . ' [R,P]' . "\n";
$vhosts_file.= ' </IfModule>' . "\n";
}
return $vhosts_file;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* This function generates the VHost configuration for AWStats
* This will enable the /awstats url and enable security on these folders
* @param siteDomain Name of the domain we want stats for
* @return String with configuration for use in vhost file
* @author Berend Dekens
*/
function createAWStatsVhost($siteDomain, $settings = null)
{
if($settings['system']['mod_fcgid'] != '1')
{
$vhosts_file = ' # AWStats statistics' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\n";
$vhosts_file.= ' RewriteRule ^/awstats(/.*)?$ /awstats/awstats.pl?config=' . $siteDomain . ' [L,PT]' . "\n";
$vhosts_file.= ' RewriteRule ^/awstats.pl(.*)$ /awstats/awstats.pl$1 [QSA,L,PT]' . "\n";
}
else
{
$vhosts_file = ' <IfModule mod_proxy.c>' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\n";
$vhosts_file.= ' RewriteRule awstats.pl(.*)$ http://' . $settings['system']['hostname'] . '/cgi-bin/awstats.pl$1 [R,P]' . "\n";
$vhosts_file.= ' RewriteRule awstats$ http://' . $settings['system']['hostname'] . '/cgi-bin/awstats.pl?config=' . $siteDomain . ' [R,P]' . "\n";
$vhosts_file.= ' </IfModule>' . "\n";
}
return $vhosts_file;
}

View File

@@ -1,49 +1,49 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getAdmins($limit_resource = '')
{
global $db;
$additional_conditions = '';
$additional_conditions_array = array();
if(getSessionUserDetail('customers_see_all') != true)
{
$additional_conditions_array[] = '`adminid` = \'' . (int)getSessionUserDetail('adminid') . '\'';
}
if($limit_resource != '')
{
$additional_conditions_array[] = '(`' . $limit_resource . '_used` < `' . $limit_resource . '` OR `' . $limit_resource . '` = \'-1\')';
}
if(!empty($additional_conditions_array))
{
$additional_conditions = ' WHERE ' . implode(' AND ', $additional_conditions_array) . ' ';
}
$query = 'SELECT `adminid`, `loginname`, `name`, `firstname`, `company` FROM `' . TABLE_PANEL_ADMINS . '` ' . $additional_conditions . ' ORDER BY `name` ASC';
$result = $db->query($query);
$admins_array = array();
while($row = $db->fetch_array($result))
{
$admins_array[$row['adminid']] = getCorrectFullUserDetails($row) . ' (' . $row['loginname'] . ')';
}
return $admins_array;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getAdmins($limit_resource = '')
{
global $db;
$additional_conditions = '';
$additional_conditions_array = array();
if(getSessionUserDetail('customers_see_all') != true)
{
$additional_conditions_array[] = '`adminid` = \'' . (int)getSessionUserDetail('adminid') . '\'';
}
if($limit_resource != '')
{
$additional_conditions_array[] = '(`' . $limit_resource . '_used` < `' . $limit_resource . '` OR `' . $limit_resource . '` = \'-1\')';
}
if(!empty($additional_conditions_array))
{
$additional_conditions = ' WHERE ' . implode(' AND ', $additional_conditions_array) . ' ';
}
$query = 'SELECT `adminid`, `loginname`, `name`, `firstname`, `company` FROM `' . TABLE_PANEL_ADMINS . '` ' . $additional_conditions . ' ORDER BY `name` ASC';
$result = $db->query($query);
$admins_array = array();
while($row = $db->fetch_array($result))
{
$admins_array[$row['adminid']] = getCorrectFullUserDetails($row) . ' (' . $row['loginname'] . ')';
}
return $admins_array;
}

View File

@@ -1,35 +1,35 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getCustomerDetail($customerid, $varname)
{
global $db;
$query = 'SELECT `' . $db->escape($varname) . '` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `customerid` = \'' . (int)$customerid . '\'';
$customer = $db->query_first($query);
if(isset($customer[$varname]))
{
return $customer[$varname];
}
else
{
return false;
}
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getCustomerDetail($customerid, $varname)
{
global $db;
$query = 'SELECT `' . $db->escape($varname) . '` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `customerid` = \'' . (int)$customerid . '\'';
$customer = $db->query_first($query);
if(isset($customer[$varname]))
{
return $customer[$varname];
}
else
{
return false;
}
}

View File

@@ -1,49 +1,49 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getCustomers($limit_resource = '')
{
global $db;
$additional_conditions = '';
$additional_conditions_array = array();
if(getSessionUserDetail('customers_see_all') != true)
{
$additional_conditions_array[] = '`adminid` = \'' . (int)getSessionUserDetail('adminid') . '\'';
}
if($limit_resource != '')
{
$additional_conditions_array[] = '(`' . $limit_resource . '_used` < `' . $limit_resource . '` OR `' . $limit_resource . '` = \'-1\')';
}
if(!empty($additional_conditions_array))
{
$additional_conditions = ' WHERE ' . implode(' AND ', $additional_conditions_array) . ' ';
}
$query = 'SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `' . TABLE_PANEL_CUSTOMERS . '` ' . $additional_conditions . ' ORDER BY `name` ASC';
$result = $db->query($query);
$customers_array = array();
while($row = $db->fetch_array($result))
{
$customers_array[$row['customerid']] = getCorrectFullUserDetails($row) . ' (' . $row['loginname'] . ')';
}
return $customers_array;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getCustomers($limit_resource = '')
{
global $db;
$additional_conditions = '';
$additional_conditions_array = array();
if(getSessionUserDetail('customers_see_all') != true)
{
$additional_conditions_array[] = '`adminid` = \'' . (int)getSessionUserDetail('adminid') . '\'';
}
if($limit_resource != '')
{
$additional_conditions_array[] = '(`' . $limit_resource . '_used` < `' . $limit_resource . '` OR `' . $limit_resource . '` = \'-1\')';
}
if(!empty($additional_conditions_array))
{
$additional_conditions = ' WHERE ' . implode(' AND ', $additional_conditions_array) . ' ';
}
$query = 'SELECT `customerid`, `loginname`, `name`, `firstname`, `company` FROM `' . TABLE_PANEL_CUSTOMERS . '` ' . $additional_conditions . ' ORDER BY `name` ASC';
$result = $db->query($query);
$customers_array = array();
while($row = $db->fetch_array($result))
{
$customers_array[$row['customerid']] = getCorrectFullUserDetails($row) . ' (' . $row['loginname'] . ')';
}
return $customers_array;
}

View File

@@ -12,7 +12,7 @@
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id: $
* @version $Id$
*/
function getIntervalOptions()

View File

@@ -1,43 +1,43 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getIpAddresses()
{
global $db;
$query = 'SELECT `id`, `ip`, `port` FROM `' . TABLE_PANEL_IPSANDPORTS . '` ORDER BY `ip` ASC, `port` ASC';
$result = $db->query($query);
$system_ipaddress_array = array();
while($row = $db->fetch_array($result))
{
if(!isset($system_ipaddress_array[$row['ip']])
&& !in_array($row['ip'], $system_ipaddress_array))
{
if(filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$row['ip'] = '[' . $row['ip'] . ']';
}
$system_ipaddress_array[$row['ip']] = $row['ip'];
}
}
return $system_ipaddress_array;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getIpAddresses()
{
global $db;
$query = 'SELECT `id`, `ip`, `port` FROM `' . TABLE_PANEL_IPSANDPORTS . '` ORDER BY `ip` ASC, `port` ASC';
$result = $db->query($query);
$system_ipaddress_array = array();
while($row = $db->fetch_array($result))
{
if(!isset($system_ipaddress_array[$row['ip']])
&& !in_array($row['ip'], $system_ipaddress_array))
{
if(filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$row['ip'] = '[' . $row['ip'] . ']';
}
$system_ipaddress_array[$row['ip']] = $row['ip'];
}
}
return $system_ipaddress_array;
}

View File

@@ -1,56 +1,56 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getIpPortCombinations($ssl = null)
{
global $db;
$additional_conditions = '';
$additional_conditions_array = array();
if(getSessionUserDetail('ip') != '-1')
{
$admin_ip = $db->query_first('SELECT `id`, `ip`, `port` FROM `' . TABLE_PANEL_IPSANDPORTS . '` WHERE `id` = \'' . (int)getSessionUserDetail('ip') . '\' ORDER BY `ip`, `port` ASC');
$additional_conditions_array[] = '`ip` = \'' . $admin_ip['ip'] . '\'';
unset($admin_ip);
}
if($ssl !== null)
{
$additional_conditions_array[] = '`ssl` = \'' . ( $ssl === true ? '1' : '0' ) . '\'';
}
if(!empty($additional_conditions_array))
{
$additional_conditions = ' WHERE ' . implode(' AND ', $additional_conditions_array) . ' ';
}
$query = 'SELECT `id`, `ip`, `port` FROM `' . TABLE_PANEL_IPSANDPORTS . '` ' . $additional_conditions . ' ORDER BY `ip` ASC, `port` ASC';
$result = $db->query($query);
$system_ipaddress_array = array();
while($row = $db->fetch_array($result))
{
if(filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$row['ip'] = '[' . $row['ip'] . ']';
}
$system_ipaddress_array[$row['id']] = $row['ip'] . ':' . $row['port'];
}
return $system_ipaddress_array;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getIpPortCombinations($ssl = null)
{
global $db;
$additional_conditions = '';
$additional_conditions_array = array();
if(getSessionUserDetail('ip') != '-1')
{
$admin_ip = $db->query_first('SELECT `id`, `ip`, `port` FROM `' . TABLE_PANEL_IPSANDPORTS . '` WHERE `id` = \'' . (int)getSessionUserDetail('ip') . '\' ORDER BY `ip`, `port` ASC');
$additional_conditions_array[] = '`ip` = \'' . $admin_ip['ip'] . '\'';
unset($admin_ip);
}
if($ssl !== null)
{
$additional_conditions_array[] = '`ssl` = \'' . ( $ssl === true ? '1' : '0' ) . '\'';
}
if(!empty($additional_conditions_array))
{
$additional_conditions = ' WHERE ' . implode(' AND ', $additional_conditions_array) . ' ';
}
$query = 'SELECT `id`, `ip`, `port` FROM `' . TABLE_PANEL_IPSANDPORTS . '` ' . $additional_conditions . ' ORDER BY `ip` ASC, `port` ASC';
$result = $db->query($query);
$system_ipaddress_array = array();
while($row = $db->fetch_array($result))
{
if(filter_var($row['ip'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
{
$row['ip'] = '[' . $row['ip'] . ']';
}
$system_ipaddress_array[$row['id']] = $row['ip'] . ':' . $row['port'];
}
return $system_ipaddress_array;
}

View File

@@ -1,38 +1,38 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getLanguages()
{
global $db;
$query = 'SELECT * FROM `' . TABLE_PANEL_LANGUAGE . '` ';
$result = $db->query($query);
$languages_array = array();
while($row = $db->fetch_array($result))
{
if(!isset($languages_array[$row['language']])
&& !in_array($row['language'], $languages_array))
{
$languages_array[$row['language']] = html_entity_decode($row['language']);
}
}
return $languages_array;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getLanguages()
{
global $db;
$query = 'SELECT * FROM `' . TABLE_PANEL_LANGUAGE . '` ';
$result = $db->query($query);
$languages_array = array();
while($row = $db->fetch_array($result))
{
if(!isset($languages_array[$row['language']])
&& !in_array($row['language'], $languages_array))
{
$languages_array[$row['language']] = html_entity_decode($row['language']);
}
}
return $languages_array;
}

View File

@@ -12,7 +12,7 @@
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id: $
* @version $Id$
*/
/*

View File

@@ -1,32 +1,32 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getSessionUserDetail($varname)
{
global $userinfo;
if(isset($userinfo[$varname]))
{
return $userinfo[$varname];
}
else
{
return false;
}
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function getSessionUserDetail($varname)
{
global $userinfo;
if(isset($userinfo[$varname]))
{
return $userinfo[$varname];
}
else
{
return false;
}
}

View File

@@ -12,7 +12,7 @@
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id: $
* @version $Id$
*/
function includeCronjobs($debugHandler, $pathtophpfiles)

View File

@@ -1,104 +1,104 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Inserts a task into the PANEL_TASKS-Table
*
* @param int Type of task
* @param string Parameter 1
* @param string Parameter 2
* @param string Parameter 3
* @author Florian Lippert <flo@syscp.org>
*/
function inserttask($type, $param1 = '', $param2 = '', $param3 = '')
{
global $db, $settings;
if($type == '1'
|| $type == '3'
|| $type == '4'
|| $type == '5')
{
$db->query('DELETE FROM `' . TABLE_PANEL_TASKS . '` WHERE `type`="' . $type . '"');
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`) VALUES ("' . $type . '")');
$doupdate = true;
}
elseif($type == '2'
&& $param1 != ''
&& $param2 != ''
&& $param3 != '')
{
$data = Array();
$data['loginname'] = $param1;
$data['uid'] = $param2;
$data['gid'] = $param3;
$data = serialize($data);
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`, `data`) VALUES ("2", "' . $db->escape($data) . '")');
$doupdate = true;
}
elseif($type == '6'
&& $param1 != '')
{
$data = Array();
$data['loginname'] = $param1;
$data = serialize($data);
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`, `data`) VALUES ("6", "' . $db->escape($data) . '")');
$doupdate = true;
}
if($doupdate === true
&& (int)$settings['system']['realtime_port'] !== 0)
{
$timeout = 15;
$socket = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if($socket !== false)
{
// create the request packet
$packet = chr(0) . chr(1) . 'RUN' . chr(0);
// UDP is connectionless, so we just send on it.
@socket_sendto($socket, $packet, strlen($packet), 0x100, '127.0.0.1', (int)$settings['system']['realtime_port']);
/*
* this is for TCP-Connections
*
$time = time();
while(!@socket_connect($socket, '127.0.0.1', (int)$settings['system']['realtime_port']))
{
$err = socket_last_error($socket);
if($err == 115
|| $err == 114)
{
if((time() - $time) >= $timeout)
{
break;
}
sleep(1);
continue;
}
}
*/
@socket_close($socket);
}
}
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Inserts a task into the PANEL_TASKS-Table
*
* @param int Type of task
* @param string Parameter 1
* @param string Parameter 2
* @param string Parameter 3
* @author Florian Lippert <flo@syscp.org>
*/
function inserttask($type, $param1 = '', $param2 = '', $param3 = '')
{
global $db, $settings;
if($type == '1'
|| $type == '3'
|| $type == '4'
|| $type == '5')
{
$db->query('DELETE FROM `' . TABLE_PANEL_TASKS . '` WHERE `type`="' . $type . '"');
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`) VALUES ("' . $type . '")');
$doupdate = true;
}
elseif($type == '2'
&& $param1 != ''
&& $param2 != ''
&& $param3 != '')
{
$data = Array();
$data['loginname'] = $param1;
$data['uid'] = $param2;
$data['gid'] = $param3;
$data = serialize($data);
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`, `data`) VALUES ("2", "' . $db->escape($data) . '")');
$doupdate = true;
}
elseif($type == '6'
&& $param1 != '')
{
$data = Array();
$data['loginname'] = $param1;
$data = serialize($data);
$db->query('INSERT INTO `' . TABLE_PANEL_TASKS . '` (`type`, `data`) VALUES ("6", "' . $db->escape($data) . '")');
$doupdate = true;
}
if($doupdate === true
&& (int)$settings['system']['realtime_port'] !== 0)
{
$timeout = 15;
$socket = @socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if($socket !== false)
{
// create the request packet
$packet = chr(0) . chr(1) . 'RUN' . chr(0);
// UDP is connectionless, so we just send on it.
@socket_sendto($socket, $packet, strlen($packet), 0x100, '127.0.0.1', (int)$settings['system']['realtime_port']);
/*
* this is for TCP-Connections
*
$time = time();
while(!@socket_connect($socket, '127.0.0.1', (int)$settings['system']['realtime_port']))
{
$err = socket_last_error($socket);
if($err == 115
|| $err == 114)
{
if((time() - $time) >= $timeout)
{
break;
}
sleep(1);
continue;
}
}
*/
@socket_close($socket);
}
}
}

View File

@@ -1,48 +1,48 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function loadConfigArrayDir($data_dirname)
{
// Workaround until we use gettext
global $lng;
$data = array();
if(is_dir($data_dirname))
{
$data_files = array();
$data_dirhandle = opendir($data_dirname);
while(false !== ($data_filename = readdir($data_dirhandle)))
{
if($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, -4 ) == '.php')
{
$data_files[] = $data_dirname . $data_filename;
}
}
sort($data_files);
foreach($data_files as $data_filename)
{
$data = array_merge_recursive($data, include($data_filename));
}
}
return $data;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
function loadConfigArrayDir($data_dirname)
{
// Workaround until we use gettext
global $lng;
$data = array();
if(is_dir($data_dirname))
{
$data_files = array();
$data_dirhandle = opendir($data_dirname);
while(false !== ($data_filename = readdir($data_dirhandle)))
{
if($data_filename != '.' && $data_filename != '..' && $data_filename != '' && substr($data_filename, -4 ) == '.php')
{
$data_files[] = $data_dirname . $data_filename;
}
}
sort($data_files);
foreach($data_files as $data_filename)
{
$data = array_merge_recursive($data, include($data_filename));
}
}
return $data;
}

View File

@@ -12,7 +12,7 @@
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id: $
* @version $Id$
*/
/*

View File

@@ -1,286 +1,286 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Function which updates all counters of used ressources in panel_admins and panel_customers
* @param bool Set to true to get an array with debug information
* @return array Contains debug information if parameter 'returndebuginfo' is set to true
*
* @author Florian Lippert <flo@syscp.org>
*/
function updateCounters($returndebuginfo = false)
{
global $db;
$returnval = array();
if($returndebuginfo === true)
{
$returnval = array(
'admins' => array(),
'customers' => array()
);
}
$admin_resources = array();
// Customers
$customers = $db->query('SELECT * FROM `' . TABLE_PANEL_CUSTOMERS . '` ORDER BY `customerid`');
while($customer = $db->fetch_array($customers))
{
if(!isset($admin_resources[$customer['adminid']]))
{
$admin_resources[$customer['adminid']] = Array();
}
if(!isset($admin_resources[$customer['adminid']]['diskspace_used']))
{
$admin_resources[$customer['adminid']]['diskspace_used'] = 0;
}
if(($customer['diskspace'] / 1024) != '-1')
{
$admin_resources[$customer['adminid']]['diskspace_used']+= intval_ressource($customer['diskspace']);
}
if(!isset($admin_resources[$customer['adminid']]['traffic_used']))
{
$admin_resources[$customer['adminid']]['traffic_used'] = 0;
}
$admin_resources[$customer['adminid']]['traffic_used']+= $customer['traffic_used'];
if(!isset($admin_resources[$customer['adminid']]['mysqls_used']))
{
$admin_resources[$customer['adminid']]['mysqls_used'] = 0;
}
if($customer['mysqls'] != '-1')
{
$admin_resources[$customer['adminid']]['mysqls_used']+= intval_ressource($customer['mysqls']);
}
if(!isset($admin_resources[$customer['adminid']]['ftps_used']))
{
$admin_resources[$customer['adminid']]['ftps_used'] = 0;
}
if($customer['ftps'] != '-1')
{
$admin_resources[$customer['adminid']]['ftps_used']+= intval_ressource($customer['ftps']);
}
if(!isset($admin_resources[$customer['adminid']]['tickets_used']))
{
$admin_resources[$customer['adminid']]['tickets_used'] = 0;
}
if($customer['tickets'] != '-1')
{
$admin_resources[$customer['adminid']]['tickets_used']+= intval_ressource($customer['tickets']);
}
if(!isset($admin_resources[$customer['adminid']]['emails_used']))
{
$admin_resources[$customer['adminid']]['emails_used'] = 0;
}
if($customer['emails'] != '-1')
{
$admin_resources[$customer['adminid']]['emails_used']+= intval_ressource($customer['emails']);
}
if(!isset($admin_resources[$customer['adminid']]['email_accounts_used']))
{
$admin_resources[$customer['adminid']]['email_accounts_used'] = 0;
}
if($customer['email_accounts'] != '-1')
{
$admin_resources[$customer['adminid']]['email_accounts_used']+= intval_ressource($customer['email_accounts']);
}
if(!isset($admin_resources[$customer['adminid']]['email_forwarders_used']))
{
$admin_resources[$customer['adminid']]['email_forwarders_used'] = 0;
}
if($customer['email_forwarders'] != '-1')
{
$admin_resources[$customer['adminid']]['email_forwarders_used']+= intval_ressource($customer['email_forwarders']);
}
if(!isset($admin_resources[$customer['adminid']]['email_quota_used']))
{
$admin_resources[$customer['adminid']]['email_quota_used'] = 0;
}
if($customer['email_quota'] != '-1')
{
$admin_resources[$customer['adminid']]['email_quota_used']+= intval_ressource($customer['email_quota']);
}
if(!isset($admin_resources[$customer['adminid']]['subdomains_used']))
{
$admin_resources[$customer['adminid']]['subdomains_used'] = 0;
}
if($customer['subdomains'] != '-1')
{
$admin_resources[$customer['adminid']]['subdomains_used']+= intval_ressource($customer['subdomains']);
}
$customer_mysqls = $db->query_first('SELECT COUNT(*) AS `number_mysqls` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['mysqls_used_new'] = (int)$customer_mysqls['number_mysqls'];
$customer_emails = $db->query_first('SELECT COUNT(*) AS `number_emails` FROM `' . TABLE_MAIL_VIRTUAL . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['emails_used_new'] = (int)$customer_emails['number_emails'];
$customer_emails_result = $db->query('SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `' . TABLE_MAIL_VIRTUAL . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '" ');
$customer_email_forwarders = 0;
$customer_email_accounts = 0;
while($customer_emails_row = $db->fetch_array($customer_emails_result))
{
if($customer_emails_row['destination'] != '')
{
$customer_emails_row['destination'] = explode(' ', makeCorrectDestination($customer_emails_row['destination']));
$customer_email_forwarders+= count($customer_emails_row['destination']);
if(in_array($customer_emails_row['email_full'], $customer_emails_row['destination']))
{
$customer_email_forwarders-= 1;
$customer_email_accounts++;
}
}
}
$customer['email_accounts_used_new'] = $customer_email_accounts;
$customer['email_forwarders_used_new'] = $customer_email_forwarders;
$customer_ftps = $db->query_first('SELECT COUNT(*) AS `number_ftps` FROM `' . TABLE_FTP_USERS . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['ftps_used_new'] = ((int)$customer_ftps['number_ftps'] - 1);
$customer_tickets = $db->query_first('SELECT COUNT(*) AS `number_tickets` FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = "0" AND `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['tickets_used_new'] = (int)$customer_tickets['number_tickets'];
$customer_subdomains = $db->query_first('SELECT COUNT(*) AS `number_subdomains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '" AND `parentdomainid` <> "0"');
$customer['subdomains_used_new'] = (int)$customer_subdomains['number_subdomains'];
$customer_email_quota = $db->query_first('SELECT SUM(`quota`) AS `email_quota` FROM `' . TABLE_MAIL_USERS . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['email_quota_used_new'] = (int)$customer_email_quota['email_quota'];
$db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used` = "' . (int)$customer['mysqls_used_new'] . '", `emails_used` = "' . (int)$customer['emails_used_new'] . '", `email_accounts_used` = "' . (int)$customer['email_accounts_used_new'] . '", `email_forwarders_used` = "' . (int)$customer['email_forwarders_used_new'] . '", `email_quota_used` = "' . (int)$customer['email_quota_used_new'] . '", `ftps_used` = "' . (int)$customer['ftps_used_new'] . '", `tickets_used` = "' . (int)$customer['tickets_used_new'] . '", `subdomains_used` = "' . (int)$customer['subdomains_used_new'] . '" WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
if($returndebuginfo === true)
{
$returnval['customers'][$customer['customerid']] = $customer;
}
}
// Admins
$admins = $db->query('SELECT * FROM `' . TABLE_PANEL_ADMINS . '` ORDER BY `adminid`');
while($admin = $db->fetch_array($admins))
{
$admin_customers = $db->query_first('SELECT COUNT(*) AS `number_customers` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `adminid` = "' . (int)$admin['adminid'] . '"');
$admin['customers_used_new'] = $admin_customers['number_customers'];
$admin_domains = $db->query_first('SELECT COUNT(*) AS `number_domains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `adminid` = "' . (int)$admin['adminid'] . '" AND `isemaildomain` = "1"');
$admin['domains_used_new'] = $admin_domains['number_domains'];
if(!isset($admin_resources[$admin['adminid']]))
{
$admin_resources[$admin['adminid']] = Array();
}
if(!isset($admin_resources[$admin['adminid']]['diskspace_used']))
{
$admin_resources[$admin['adminid']]['diskspace_used'] = 0;
}
$admin['diskspace_used_new'] = $admin_resources[$admin['adminid']]['diskspace_used'];
if(!isset($admin_resources[$admin['adminid']]['traffic_used']))
{
$admin_resources[$admin['adminid']]['traffic_used'] = 0;
}
$admin['traffic_used_new'] = $admin_resources[$admin['adminid']]['traffic_used'];
if(!isset($admin_resources[$admin['adminid']]['mysqls_used']))
{
$admin_resources[$admin['adminid']]['mysqls_used'] = 0;
}
$admin['mysqls_used_new'] = $admin_resources[$admin['adminid']]['mysqls_used'];
if(!isset($admin_resources[$admin['adminid']]['ftps_used']))
{
$admin_resources[$admin['adminid']]['ftps_used'] = 0;
}
$admin['ftps_used_new'] = $admin_resources[$admin['adminid']]['ftps_used'];
if(!isset($admin_resources[$admin['adminid']]['emails_used']))
{
$admin_resources[$admin['adminid']]['emails_used'] = 0;
}
$admin['emails_used_new'] = $admin_resources[$admin['adminid']]['emails_used'];
if(!isset($admin_resources[$admin['adminid']]['email_accounts_used']))
{
$admin_resources[$admin['adminid']]['email_accounts_used'] = 0;
}
$admin['email_accounts_used_new'] = $admin_resources[$admin['adminid']]['email_accounts_used'];
if(!isset($admin_resources[$admin['adminid']]['tickets_used']))
{
$admin_resources[$admin['adminid']]['tickets_used'] = 0;
}
$admin['tickets_used_new'] = $admin_resources[$admin['adminid']]['tickets_used'];
if(!isset($admin_resources[$admin['adminid']]['email_forwarders_used']))
{
$admin_resources[$admin['adminid']]['email_forwarders_used'] = 0;
}
$admin['email_forwarders_used_new'] = $admin_resources[$admin['adminid']]['email_forwarders_used'];
if(!isset($admin_resources[$admin['adminid']]['email_quota_used']))
{
$admin_resources[$admin['adminid']]['email_quota_used'] = 0;
}
$admin['email_quota_used_new'] = $admin_resources[$admin['adminid']]['email_quota_used'];
if(!isset($admin_resources[$admin['adminid']]['subdomains_used']))
{
$admin_resources[$admin['adminid']]['subdomains_used'] = 0;
}
$admin['subdomains_used_new'] = $admin_resources[$admin['adminid']]['subdomains_used'];
$db->query('UPDATE `' . TABLE_PANEL_ADMINS . '` SET `customers_used` = "' . (int)$admin['customers_used_new'] . '", `domains_used` = "' . (int)$admin['domains_used_new'] . '", `diskspace_used` = "' . (int)$admin['diskspace_used_new'] . '", `mysqls_used` = "' . (int)$admin['mysqls_used_new'] . '", `emails_used` = "' . (int)$admin['emails_used_new'] . '", `email_accounts_used` = "' . (int)$admin['email_accounts_used_new'] . '", `email_forwarders_used` = "' . (int)$admin['email_forwarders_used_new'] . '", `email_quota_used` = "' . (int)$admin['email_quota_used_new'] . '", `ftps_used` = "' . (int)$admin['ftps_used_new'] . '", `tickets_used` = "' . (int)$admin['tickets_used_new'] . '", `subdomains_used` = "' . (int)$admin['subdomains_used_new'] . '", `traffic_used` = "' . (int)$admin['traffic_used_new'] . '" WHERE `adminid` = "' . (int)$admin['adminid'] . '"');
if($returndebuginfo === true)
{
$returnval['admins'][$admin['adminid']] = $admin;
}
}
return $returnval;
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 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 Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id$
*/
/**
* Function which updates all counters of used ressources in panel_admins and panel_customers
* @param bool Set to true to get an array with debug information
* @return array Contains debug information if parameter 'returndebuginfo' is set to true
*
* @author Florian Lippert <flo@syscp.org>
*/
function updateCounters($returndebuginfo = false)
{
global $db;
$returnval = array();
if($returndebuginfo === true)
{
$returnval = array(
'admins' => array(),
'customers' => array()
);
}
$admin_resources = array();
// Customers
$customers = $db->query('SELECT * FROM `' . TABLE_PANEL_CUSTOMERS . '` ORDER BY `customerid`');
while($customer = $db->fetch_array($customers))
{
if(!isset($admin_resources[$customer['adminid']]))
{
$admin_resources[$customer['adminid']] = Array();
}
if(!isset($admin_resources[$customer['adminid']]['diskspace_used']))
{
$admin_resources[$customer['adminid']]['diskspace_used'] = 0;
}
if(($customer['diskspace'] / 1024) != '-1')
{
$admin_resources[$customer['adminid']]['diskspace_used']+= intval_ressource($customer['diskspace']);
}
if(!isset($admin_resources[$customer['adminid']]['traffic_used']))
{
$admin_resources[$customer['adminid']]['traffic_used'] = 0;
}
$admin_resources[$customer['adminid']]['traffic_used']+= $customer['traffic_used'];
if(!isset($admin_resources[$customer['adminid']]['mysqls_used']))
{
$admin_resources[$customer['adminid']]['mysqls_used'] = 0;
}
if($customer['mysqls'] != '-1')
{
$admin_resources[$customer['adminid']]['mysqls_used']+= intval_ressource($customer['mysqls']);
}
if(!isset($admin_resources[$customer['adminid']]['ftps_used']))
{
$admin_resources[$customer['adminid']]['ftps_used'] = 0;
}
if($customer['ftps'] != '-1')
{
$admin_resources[$customer['adminid']]['ftps_used']+= intval_ressource($customer['ftps']);
}
if(!isset($admin_resources[$customer['adminid']]['tickets_used']))
{
$admin_resources[$customer['adminid']]['tickets_used'] = 0;
}
if($customer['tickets'] != '-1')
{
$admin_resources[$customer['adminid']]['tickets_used']+= intval_ressource($customer['tickets']);
}
if(!isset($admin_resources[$customer['adminid']]['emails_used']))
{
$admin_resources[$customer['adminid']]['emails_used'] = 0;
}
if($customer['emails'] != '-1')
{
$admin_resources[$customer['adminid']]['emails_used']+= intval_ressource($customer['emails']);
}
if(!isset($admin_resources[$customer['adminid']]['email_accounts_used']))
{
$admin_resources[$customer['adminid']]['email_accounts_used'] = 0;
}
if($customer['email_accounts'] != '-1')
{
$admin_resources[$customer['adminid']]['email_accounts_used']+= intval_ressource($customer['email_accounts']);
}
if(!isset($admin_resources[$customer['adminid']]['email_forwarders_used']))
{
$admin_resources[$customer['adminid']]['email_forwarders_used'] = 0;
}
if($customer['email_forwarders'] != '-1')
{
$admin_resources[$customer['adminid']]['email_forwarders_used']+= intval_ressource($customer['email_forwarders']);
}
if(!isset($admin_resources[$customer['adminid']]['email_quota_used']))
{
$admin_resources[$customer['adminid']]['email_quota_used'] = 0;
}
if($customer['email_quota'] != '-1')
{
$admin_resources[$customer['adminid']]['email_quota_used']+= intval_ressource($customer['email_quota']);
}
if(!isset($admin_resources[$customer['adminid']]['subdomains_used']))
{
$admin_resources[$customer['adminid']]['subdomains_used'] = 0;
}
if($customer['subdomains'] != '-1')
{
$admin_resources[$customer['adminid']]['subdomains_used']+= intval_ressource($customer['subdomains']);
}
$customer_mysqls = $db->query_first('SELECT COUNT(*) AS `number_mysqls` FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['mysqls_used_new'] = (int)$customer_mysqls['number_mysqls'];
$customer_emails = $db->query_first('SELECT COUNT(*) AS `number_emails` FROM `' . TABLE_MAIL_VIRTUAL . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['emails_used_new'] = (int)$customer_emails['number_emails'];
$customer_emails_result = $db->query('SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `' . TABLE_MAIL_VIRTUAL . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '" ');
$customer_email_forwarders = 0;
$customer_email_accounts = 0;
while($customer_emails_row = $db->fetch_array($customer_emails_result))
{
if($customer_emails_row['destination'] != '')
{
$customer_emails_row['destination'] = explode(' ', makeCorrectDestination($customer_emails_row['destination']));
$customer_email_forwarders+= count($customer_emails_row['destination']);
if(in_array($customer_emails_row['email_full'], $customer_emails_row['destination']))
{
$customer_email_forwarders-= 1;
$customer_email_accounts++;
}
}
}
$customer['email_accounts_used_new'] = $customer_email_accounts;
$customer['email_forwarders_used_new'] = $customer_email_forwarders;
$customer_ftps = $db->query_first('SELECT COUNT(*) AS `number_ftps` FROM `' . TABLE_FTP_USERS . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['ftps_used_new'] = ((int)$customer_ftps['number_ftps'] - 1);
$customer_tickets = $db->query_first('SELECT COUNT(*) AS `number_tickets` FROM `' . TABLE_PANEL_TICKETS . '` WHERE `answerto` = "0" AND `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['tickets_used_new'] = (int)$customer_tickets['number_tickets'];
$customer_subdomains = $db->query_first('SELECT COUNT(*) AS `number_subdomains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '" AND `parentdomainid` <> "0"');
$customer['subdomains_used_new'] = (int)$customer_subdomains['number_subdomains'];
$customer_email_quota = $db->query_first('SELECT SUM(`quota`) AS `email_quota` FROM `' . TABLE_MAIL_USERS . '` WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
$customer['email_quota_used_new'] = (int)$customer_email_quota['email_quota'];
$db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used` = "' . (int)$customer['mysqls_used_new'] . '", `emails_used` = "' . (int)$customer['emails_used_new'] . '", `email_accounts_used` = "' . (int)$customer['email_accounts_used_new'] . '", `email_forwarders_used` = "' . (int)$customer['email_forwarders_used_new'] . '", `email_quota_used` = "' . (int)$customer['email_quota_used_new'] . '", `ftps_used` = "' . (int)$customer['ftps_used_new'] . '", `tickets_used` = "' . (int)$customer['tickets_used_new'] . '", `subdomains_used` = "' . (int)$customer['subdomains_used_new'] . '" WHERE `customerid` = "' . (int)$customer['customerid'] . '"');
if($returndebuginfo === true)
{
$returnval['customers'][$customer['customerid']] = $customer;
}
}
// Admins
$admins = $db->query('SELECT * FROM `' . TABLE_PANEL_ADMINS . '` ORDER BY `adminid`');
while($admin = $db->fetch_array($admins))
{
$admin_customers = $db->query_first('SELECT COUNT(*) AS `number_customers` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `adminid` = "' . (int)$admin['adminid'] . '"');
$admin['customers_used_new'] = $admin_customers['number_customers'];
$admin_domains = $db->query_first('SELECT COUNT(*) AS `number_domains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `adminid` = "' . (int)$admin['adminid'] . '" AND `isemaildomain` = "1"');
$admin['domains_used_new'] = $admin_domains['number_domains'];
if(!isset($admin_resources[$admin['adminid']]))
{
$admin_resources[$admin['adminid']] = Array();
}
if(!isset($admin_resources[$admin['adminid']]['diskspace_used']))
{
$admin_resources[$admin['adminid']]['diskspace_used'] = 0;
}
$admin['diskspace_used_new'] = $admin_resources[$admin['adminid']]['diskspace_used'];
if(!isset($admin_resources[$admin['adminid']]['traffic_used']))
{
$admin_resources[$admin['adminid']]['traffic_used'] = 0;
}
$admin['traffic_used_new'] = $admin_resources[$admin['adminid']]['traffic_used'];
if(!isset($admin_resources[$admin['adminid']]['mysqls_used']))
{
$admin_resources[$admin['adminid']]['mysqls_used'] = 0;
}
$admin['mysqls_used_new'] = $admin_resources[$admin['adminid']]['mysqls_used'];
if(!isset($admin_resources[$admin['adminid']]['ftps_used']))
{
$admin_resources[$admin['adminid']]['ftps_used'] = 0;
}
$admin['ftps_used_new'] = $admin_resources[$admin['adminid']]['ftps_used'];
if(!isset($admin_resources[$admin['adminid']]['emails_used']))
{
$admin_resources[$admin['adminid']]['emails_used'] = 0;
}
$admin['emails_used_new'] = $admin_resources[$admin['adminid']]['emails_used'];
if(!isset($admin_resources[$admin['adminid']]['email_accounts_used']))
{
$admin_resources[$admin['adminid']]['email_accounts_used'] = 0;
}
$admin['email_accounts_used_new'] = $admin_resources[$admin['adminid']]['email_accounts_used'];
if(!isset($admin_resources[$admin['adminid']]['tickets_used']))
{
$admin_resources[$admin['adminid']]['tickets_used'] = 0;
}
$admin['tickets_used_new'] = $admin_resources[$admin['adminid']]['tickets_used'];
if(!isset($admin_resources[$admin['adminid']]['email_forwarders_used']))
{
$admin_resources[$admin['adminid']]['email_forwarders_used'] = 0;
}
$admin['email_forwarders_used_new'] = $admin_resources[$admin['adminid']]['email_forwarders_used'];
if(!isset($admin_resources[$admin['adminid']]['email_quota_used']))
{
$admin_resources[$admin['adminid']]['email_quota_used'] = 0;
}
$admin['email_quota_used_new'] = $admin_resources[$admin['adminid']]['email_quota_used'];
if(!isset($admin_resources[$admin['adminid']]['subdomains_used']))
{
$admin_resources[$admin['adminid']]['subdomains_used'] = 0;
}
$admin['subdomains_used_new'] = $admin_resources[$admin['adminid']]['subdomains_used'];
$db->query('UPDATE `' . TABLE_PANEL_ADMINS . '` SET `customers_used` = "' . (int)$admin['customers_used_new'] . '", `domains_used` = "' . (int)$admin['domains_used_new'] . '", `diskspace_used` = "' . (int)$admin['diskspace_used_new'] . '", `mysqls_used` = "' . (int)$admin['mysqls_used_new'] . '", `emails_used` = "' . (int)$admin['emails_used_new'] . '", `email_accounts_used` = "' . (int)$admin['email_accounts_used_new'] . '", `email_forwarders_used` = "' . (int)$admin['email_forwarders_used_new'] . '", `email_quota_used` = "' . (int)$admin['email_quota_used_new'] . '", `ftps_used` = "' . (int)$admin['ftps_used_new'] . '", `tickets_used` = "' . (int)$admin['tickets_used_new'] . '", `subdomains_used` = "' . (int)$admin['subdomains_used_new'] . '", `traffic_used` = "' . (int)$admin['traffic_used_new'] . '" WHERE `adminid` = "' . (int)$admin['adminid'] . '"');
if($returndebuginfo === true)
{
$returnval['admins'][$admin['adminid']] = $admin;
}
}
return $returnval;
}

View File

@@ -12,7 +12,7 @@
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
* @version $Id: $
* @version $Id$
*/
/*