even more function to class conversion
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -45,7 +45,7 @@ function validateFormFieldHiddenString($fieldname, $fielddata, $newfieldvalue)
|
||||
if (isset($fielddata['string_type']) && $fielddata['string_type'] == 'mail') {
|
||||
$returnvalue = (filter_var($newfieldvalue, FILTER_VALIDATE_EMAIL) == $newfieldvalue);
|
||||
} elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'url') {
|
||||
$returnvalue = validateUrl($newfieldvalue);
|
||||
$returnvalue = \Froxlor\Validate\Form\Strings::validateUrl($newfieldvalue);
|
||||
} elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'dir') {
|
||||
// add trailing slash to validate path if needed
|
||||
// refs #331
|
||||
@@ -83,4 +83,4 @@ function validateFormFieldHiddenString($fieldname, $fielddata, $newfieldvalue)
|
||||
} else {
|
||||
return $returnvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* 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 Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* this functions validates a given value as ErrorDocument
|
||||
* refs #267
|
||||
*
|
||||
* @param
|
||||
* string error-document-string
|
||||
* @param bool $throw_exception
|
||||
*
|
||||
* @return string error-document-string
|
||||
*
|
||||
*/
|
||||
function correctErrorDocument($errdoc = null, $throw_exception = false)
|
||||
{
|
||||
$idna_convert = new idna_convert_wrapper();
|
||||
|
||||
if ($errdoc !== null && $errdoc != '') {
|
||||
// not a URL
|
||||
if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:') || ! validateUrl($errdoc)) {
|
||||
// a file
|
||||
if (substr($errdoc, 0, 1) != '"') {
|
||||
$errdoc = \Froxlor\FileDir::makeCorrectFile($errdoc);
|
||||
// apache needs a starting-slash (starting at the domains-docroot)
|
||||
if (! substr($errdoc, 0, 1) == '/') {
|
||||
$errdoc = '/' . $errdoc;
|
||||
}
|
||||
} // a string (check for ending ")
|
||||
else {
|
||||
// string won't work for lighty
|
||||
if (Settings::Get('system.webserver') == 'lighttpd') {
|
||||
\Froxlor\UI\Response::standard_error('stringerrordocumentnotvalidforlighty', '', $throw_exception);
|
||||
} elseif (substr($errdoc, - 1) != '"') {
|
||||
$errdoc .= '"';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Settings::Get('system.webserver') == 'lighttpd') {
|
||||
\Froxlor\UI\Response::standard_error('urlerrordocumentnotvalidforlighty', '', $throw_exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errdoc;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
function getLanguages()
|
||||
{
|
||||
$result_stmt = Database::query("SELECT * FROM `" . TABLE_PANEL_LANGUAGE . "` ");
|
||||
$languages_array = array();
|
||||
|
||||
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if (! isset($languages_array[$row['language']]) && ! in_array($row['language'], $languages_array)) {
|
||||
$languages_array[$row['language']] = html_entity_decode($row['language']);
|
||||
}
|
||||
}
|
||||
|
||||
return $languages_array;
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
function loadConfigArrayDir()
|
||||
{
|
||||
|
||||
// Workaround until we use gettext
|
||||
global $lng, $theme;
|
||||
|
||||
// we now use dynamic function parameters
|
||||
// so we can read from more than one directory
|
||||
// and still be valid for old calls
|
||||
$numargs = func_num_args();
|
||||
if ($numargs <= 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// variable that holds all dirs that will
|
||||
// be parsed for inclusion
|
||||
$configdirs = array();
|
||||
// if one of the parameters is an array
|
||||
// we assume that this is a list of
|
||||
// setting-groups to be selected
|
||||
$selection = null;
|
||||
for ($x = 0; $x < $numargs; $x ++) {
|
||||
$arg = func_get_arg($x);
|
||||
if (is_array($arg) && isset($arg[0])) {
|
||||
$selection = $arg;
|
||||
} else {
|
||||
$configdirs[] = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
$data = array();
|
||||
$data_files = array();
|
||||
$has_data = false;
|
||||
|
||||
foreach ($configdirs as $data_dirname) {
|
||||
if (is_dir($data_dirname)) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
$has_data = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($has_data) {
|
||||
sort($data_files);
|
||||
foreach ($data_files as $data_filename) {
|
||||
$data = array_merge_recursive($data, include ($data_filename));
|
||||
}
|
||||
}
|
||||
|
||||
// if we have specific setting-groups
|
||||
// to select, we'll handle this here
|
||||
// (this is for multiserver-client settings)
|
||||
$_data = array();
|
||||
if ($selection != null && is_array($selection) && isset($selection[0])) {
|
||||
$_data['groups'] = array();
|
||||
foreach ($data['groups'] as $group => $data) {
|
||||
if (in_array($group, $selection)) {
|
||||
$_data['groups'][$group] = $data;
|
||||
}
|
||||
}
|
||||
$data = $_data;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* froxlor php error handler
|
||||
*
|
||||
* @param int $errno
|
||||
* @param string $errstr
|
||||
* @param string $errfile
|
||||
* @param int $errline
|
||||
* @param array $errcontext
|
||||
*
|
||||
* @return void|boolean
|
||||
*/
|
||||
function phpErrHandler($errno, $errstr, $errfile, $errline, $errcontext)
|
||||
{
|
||||
if (! (error_reporting() & $errno)) {
|
||||
// This error code is not included in error_reporting
|
||||
return;
|
||||
}
|
||||
|
||||
if (! isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
|
||||
global $theme;
|
||||
|
||||
// fallback
|
||||
if (empty($theme)) {
|
||||
$theme = "Sparkle";
|
||||
}
|
||||
// prevent possible file-path-disclosure
|
||||
$errfile = str_replace(\Froxlor\Froxlor::getInstallDir(), "", $errfile);
|
||||
// if we're not on the shell, output a nicer error-message
|
||||
$err_hint = file_get_contents(\Froxlor\Froxlor::getInstallDir() . '/templates/' . $theme . '/misc/phperrornice.tpl');
|
||||
// replace values
|
||||
$err_hint = str_replace("<TEXT>", '#' . $errno . ' ' . $errstr, $err_hint);
|
||||
$err_hint = str_replace("<DEBUG>", $errfile . ':' . $errline, $err_hint);
|
||||
|
||||
// show
|
||||
echo $err_hint;
|
||||
// return true to ignore php standard error-handler
|
||||
return true;
|
||||
}
|
||||
|
||||
// of on shell, use the php standard error-handler
|
||||
return false;
|
||||
}
|
||||
@@ -1,287 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
use Froxlor\Database\Database;
|
||||
|
||||
/**
|
||||
* 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> (2003-2009)
|
||||
* @author Froxlor team <team@froxlor.org> (2010-)
|
||||
*/
|
||||
function updateCounters($returndebuginfo = false)
|
||||
{
|
||||
$returnval = array();
|
||||
|
||||
if ($returndebuginfo === true) {
|
||||
$returnval = array(
|
||||
'admins' => array(),
|
||||
'customers' => array()
|
||||
);
|
||||
}
|
||||
|
||||
// Customers
|
||||
$customers_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_CUSTOMERS . '` ORDER BY `customerid`');
|
||||
Database::pexecute($customers_stmt);
|
||||
|
||||
$admin_resources = array();
|
||||
while ($customer = $customers_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
$cur_adm = $customer['adminid'];
|
||||
|
||||
// initialize admin-resources array for admin $customer['adminid']
|
||||
if (! isset($admin_resources[$cur_adm])) {
|
||||
$admin_resources[$cur_adm] = array();
|
||||
}
|
||||
|
||||
_addResourceCountEx($admin_resources[$cur_adm], $customer, 'diskspace_used', 'diskspace');
|
||||
_addResourceCountEx($admin_resources[$cur_adm], $customer, 'traffic_used', 'traffic_used'); // !!! yes, USED and USED
|
||||
|
||||
foreach (array(
|
||||
'mysqls',
|
||||
'ftps',
|
||||
'emails',
|
||||
'email_accounts',
|
||||
'email_forwarders',
|
||||
'email_quota',
|
||||
'subdomains'
|
||||
) as $field) {
|
||||
_addResourceCount($admin_resources[$cur_adm], $customer, $field . '_used', $field);
|
||||
}
|
||||
|
||||
$customer_mysqls_stmt = Database::prepare('SELECT COUNT(*) AS `number_mysqls` FROM `' . TABLE_PANEL_DATABASES . '`
|
||||
WHERE `customerid` = :cid');
|
||||
$customer_mysqls = Database::pexecute_first($customer_mysqls_stmt, array(
|
||||
"cid" => $customer['customerid']
|
||||
));
|
||||
$customer['mysqls_used_new'] = (int) $customer_mysqls['number_mysqls'];
|
||||
|
||||
$customer_emails_stmt = Database::prepare('SELECT COUNT(*) AS `number_emails` FROM `' . TABLE_MAIL_VIRTUAL . '`
|
||||
WHERE `customerid` = :cid');
|
||||
$customer_emails = Database::pexecute_first($customer_emails_stmt, array(
|
||||
"cid" => $customer['customerid']
|
||||
));
|
||||
$customer['emails_used_new'] = (int) $customer_emails['number_emails'];
|
||||
|
||||
$customer_emails_result_stmt = Database::prepare('SELECT `email`, `email_full`, `destination`, `popaccountid` AS `number_email_forwarders` FROM `' . TABLE_MAIL_VIRTUAL . '`
|
||||
WHERE `customerid` = :cid');
|
||||
Database::pexecute($customer_emails_result_stmt, array(
|
||||
"cid" => $customer['customerid']
|
||||
));
|
||||
$customer_email_forwarders = 0;
|
||||
$customer_email_accounts = 0;
|
||||
|
||||
while ($customer_emails_row = $customer_emails_result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
if ($customer_emails_row['destination'] != '') {
|
||||
$customer_emails_row['destination'] = explode(' ', \Froxlor\FileDir::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_stmt = Database::prepare('SELECT COUNT(*) AS `number_ftps` FROM `' . TABLE_FTP_USERS . '` WHERE `customerid` = :cid');
|
||||
$customer_ftps = Database::pexecute_first($customer_ftps_stmt, array(
|
||||
"cid" => $customer['customerid']
|
||||
));
|
||||
$customer['ftps_used_new'] = ((int) $customer_ftps['number_ftps'] - 1);
|
||||
|
||||
$customer_subdomains_stmt = Database::prepare('SELECT COUNT(*) AS `number_subdomains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `customerid` = :cid AND `parentdomainid` <> "0"');
|
||||
$customer_subdomains = Database::pexecute_first($customer_subdomains_stmt, array(
|
||||
"cid" => $customer['customerid']
|
||||
));
|
||||
$customer['subdomains_used_new'] = (int) $customer_subdomains['number_subdomains'];
|
||||
|
||||
$customer_email_quota_stmt = Database::prepare('SELECT SUM(`quota`) AS `email_quota` FROM `' . TABLE_MAIL_USERS . '` WHERE `customerid` = :cid');
|
||||
$customer_email_quota = Database::pexecute_first($customer_email_quota_stmt, array(
|
||||
"cid" => $customer['customerid']
|
||||
));
|
||||
$customer['email_quota_used_new'] = (int) $customer_email_quota['email_quota'];
|
||||
|
||||
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_CUSTOMERS . '`
|
||||
SET `mysqls_used` = :mysqls_used,
|
||||
`emails_used` = :emails_used,
|
||||
`email_accounts_used` = :email_accounts_used,
|
||||
`email_forwarders_used` = :email_forwarders_used,
|
||||
`email_quota_used` = :email_quota_used,
|
||||
`ftps_used` = :ftps_used,
|
||||
`subdomains_used` = :subdomains_used
|
||||
WHERE `customerid` = :cid');
|
||||
$params = array(
|
||||
"mysqls_used" => $customer['mysqls_used_new'],
|
||||
"emails_used" => $customer['emails_used_new'],
|
||||
"email_accounts_used" => $customer['email_accounts_used_new'],
|
||||
"email_forwarders_used" => $customer['email_forwarders_used_new'],
|
||||
"email_quota_used" => $customer['email_quota_used_new'],
|
||||
"ftps_used" => $customer['ftps_used_new'],
|
||||
"subdomains_used" => $customer['subdomains_used_new'],
|
||||
"cid" => $customer['customerid']
|
||||
);
|
||||
Database::pexecute($stmt, $params);
|
||||
|
||||
if ($returndebuginfo === true) {
|
||||
$returnval['customers'][$customer['customerid']] = $customer;
|
||||
}
|
||||
}
|
||||
|
||||
// Admins
|
||||
$admins_stmt = Database::prepare('SELECT * FROM `' . TABLE_PANEL_ADMINS . '` ORDER BY `adminid`');
|
||||
Database::pexecute($admins_stmt, array());
|
||||
|
||||
while ($admin = $admins_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$admin_customers_stmt = Database::prepare('SELECT COUNT(*) AS `number_customers` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `adminid` = :aid');
|
||||
$admin_customers = Database::pexecute_first($admin_customers_stmt, array(
|
||||
"aid" => $admin['adminid']
|
||||
));
|
||||
$admin['customers_used_new'] = $admin_customers['number_customers'];
|
||||
|
||||
$admin_domains_stmt = Database::prepare('SELECT COUNT(*) AS `number_domains` FROM `' . TABLE_PANEL_DOMAINS . '` WHERE `adminid` = :aid AND `isemaildomain` = "1"');
|
||||
$admin_domains = Database::pexecute_first($admin_domains_stmt, array(
|
||||
"aid" => $admin['adminid']
|
||||
));
|
||||
$admin['domains_used_new'] = $admin_domains['number_domains'];
|
||||
|
||||
$cur_adm = $admin['adminid'];
|
||||
|
||||
if (! isset($admin_resources[$cur_adm])) {
|
||||
$admin_resources[$cur_adm] = array();
|
||||
}
|
||||
|
||||
foreach (array(
|
||||
'diskspace_used',
|
||||
'traffic_used',
|
||||
'mysqls_used',
|
||||
'ftps_used',
|
||||
'emails_used',
|
||||
'email_accounts_used',
|
||||
'email_forwarders_used',
|
||||
'email_quota_used',
|
||||
'subdomains_used'
|
||||
) as $field) {
|
||||
_initArrField($field, $admin_resources[$cur_adm], 0);
|
||||
$admin[$field . '_new'] = $admin_resources[$cur_adm][$field];
|
||||
}
|
||||
|
||||
$stmt = Database::prepare('UPDATE `' . TABLE_PANEL_ADMINS . '`
|
||||
SET `customers_used` = :customers_used,
|
||||
`domains_used` = :domains_used,
|
||||
`diskspace_used` = :diskspace_used,
|
||||
`mysqls_used` = :mysqls_used,
|
||||
`emails_used` = :emails_used,
|
||||
`email_accounts_used` = :email_accounts_used,
|
||||
`email_forwarders_used` = :email_forwarders_used,
|
||||
`email_quota_used` = :email_quota_used,
|
||||
`ftps_used` = :ftps_used,
|
||||
`subdomains_used` = :subdomains_used,
|
||||
`traffic_used` = :traffic_used
|
||||
WHERE `adminid` = :aid');
|
||||
|
||||
$params = array(
|
||||
"customers_used" => $admin['customers_used_new'],
|
||||
"domains_used" => $admin['domains_used_new'],
|
||||
"diskspace_used" => $admin['diskspace_used_new'],
|
||||
"mysqls_used" => $admin['mysqls_used_new'],
|
||||
"emails_used" => $admin['emails_used_new'],
|
||||
"email_accounts_used" => $admin['email_accounts_used_new'],
|
||||
"email_forwarders_used" => $admin['email_forwarders_used_new'],
|
||||
"email_quota_used" => $admin['email_quota_used_new'],
|
||||
"ftps_used" => $admin['ftps_used_new'],
|
||||
"subdomains_used" => $admin['subdomains_used_new'],
|
||||
"traffic_used" => $admin['traffic_used_new'],
|
||||
"aid" => $admin['adminid']
|
||||
);
|
||||
Database::pexecute($stmt, $params);
|
||||
|
||||
if ($returndebuginfo === true) {
|
||||
$returnval['admins'][$admin['adminid']] = $admin;
|
||||
}
|
||||
}
|
||||
|
||||
return $returnval;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize a field-value of an array if not yet initialized
|
||||
*
|
||||
* @param string $field
|
||||
* @param array $arr
|
||||
* reference
|
||||
* @param int $init_value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _initArrField($field = null, &$arr, $init_value = 0)
|
||||
{
|
||||
if (! isset($arr[$field])) {
|
||||
$arr[$field] = $init_value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if the customer does not have unlimited resources, add the used resources
|
||||
* to the admin-resource-counter
|
||||
*
|
||||
* @param array $arr
|
||||
* reference
|
||||
* @param array $customer_arr
|
||||
* @param string $used_field
|
||||
* @param string $field
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _addResourceCount(&$arr, $customer_arr, $used_field = null, $field = null)
|
||||
{
|
||||
_initArrField($used_field, $arr, 0);
|
||||
if ($customer_arr[$field] != '-1') {
|
||||
$arr[$used_field] += intval($customer_arr[$used_field]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* if the customer does not have unlimited resources, add the used resources
|
||||
* to the admin-resource-counter
|
||||
* Special function wrapper for diskspace and traffic as they need to
|
||||
* be calculated otherwise to get the -1 for unlimited
|
||||
*
|
||||
* @param array $arr
|
||||
* reference
|
||||
* @param array $customer_arr
|
||||
* @param string $used_field
|
||||
* @param string $field
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function _addResourceCountEx(&$arr, $customer_arr, $used_field = null, $field = null)
|
||||
{
|
||||
_initArrField($used_field, $arr, 0);
|
||||
if ($field == 'diskspace' && ($customer_arr[$field] / 1024) != '-1') {
|
||||
$arr[$used_field] += intval($customer_arr[$used_field]);
|
||||
} elseif ($field == 'traffic_used') {
|
||||
$arr[$used_field] += intval($customer_arr[$used_field]);
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* 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 Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function showUpdateStep
|
||||
*
|
||||
* outputs and logs the current
|
||||
* update progress
|
||||
*
|
||||
* @param
|
||||
* string task/status
|
||||
* @param
|
||||
* bool needs_status (if false, a linebreak will be added)
|
||||
*
|
||||
* @return string formatted output and log-entry
|
||||
*/
|
||||
function showUpdateStep($task = null, $needs_status = true)
|
||||
{
|
||||
global $updatelog, $filelog;
|
||||
|
||||
if (! $needs_status)
|
||||
echo "<b>";
|
||||
|
||||
// output
|
||||
echo $task;
|
||||
|
||||
if (! $needs_status) {
|
||||
echo "</b><br />";
|
||||
}
|
||||
|
||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, $task);
|
||||
$filelog->logAction(ADM_ACTION, LOG_WARNING, $task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function lastStepStatus
|
||||
*
|
||||
* outputs [OK] (success), [??] (warning) or [!!] (failure)
|
||||
* of the last update-step
|
||||
*
|
||||
* @param
|
||||
* int status (0 = success, 1 = warning, 2 = failure)
|
||||
*
|
||||
* @return string formatted output and log-entry
|
||||
*/
|
||||
function lastStepStatus($status = -1, $message = '')
|
||||
{
|
||||
global $updatelog, $filelog;
|
||||
|
||||
switch ($status) {
|
||||
|
||||
case 0:
|
||||
$status_sign = ($message != '') ? '[' . $message . ']' : '[OK]';
|
||||
$status_color = 'ok';
|
||||
break;
|
||||
case 1:
|
||||
$status_sign = ($message != '') ? '[' . $message . ']' : '[??]';
|
||||
$status_color = 'warn';
|
||||
break;
|
||||
case 2:
|
||||
$status_sign = ($message != '') ? '[' . $message . ']' : '[!!]';
|
||||
$status_color = 'err';
|
||||
break;
|
||||
default:
|
||||
$status_sign = '[unknown]';
|
||||
$status_color = 'unknown';
|
||||
break;
|
||||
}
|
||||
|
||||
// output
|
||||
echo "<span class=\"update-step update-step-" . $status_color . "\">" . $status_sign . "</span><br />";
|
||||
|
||||
if ($status == - 1 || $status == 2) {
|
||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
|
||||
$filelog->logAction(ADM_ACTION, LOG_WARNING, 'Attention - last update task failed!!!');
|
||||
} elseif ($status == 0 || $status == 1) {
|
||||
$filelog->logAction(ADM_ACTION, LOG_WARNING, 'Success');
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
* 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 Froxlor team <team@froxlor.org> (2010-)
|
||||
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
||||
* @package Functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* return an array of all enabled redirect-codes
|
||||
*
|
||||
* @return array array of enabled redirect-codes
|
||||
*/
|
||||
function getRedirectCodesArray()
|
||||
{
|
||||
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
|
||||
$result_stmt = Database::query($sql);
|
||||
|
||||
$codes = array();
|
||||
while ($rc = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$codes[] = $rc;
|
||||
}
|
||||
|
||||
return $codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* return an array of all enabled redirect-codes
|
||||
* for the settings form
|
||||
*
|
||||
* @param bool $add_desc
|
||||
* optional, default true, add the code-description
|
||||
*
|
||||
* @return array array of enabled redirect-codes
|
||||
*/
|
||||
function getRedirectCodes($add_desc = true)
|
||||
{
|
||||
global $lng;
|
||||
|
||||
$sql = "SELECT * FROM `" . TABLE_PANEL_REDIRECTCODES . "` WHERE `enabled` = '1' ORDER BY `id` ASC";
|
||||
$result_stmt = Database::query($sql);
|
||||
|
||||
$codes = array();
|
||||
while ($rc = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$codes[$rc['id']] = $rc['code'];
|
||||
if ($add_desc) {
|
||||
$codes[$rc['id']] .= ' (' . $lng['redirect_desc'][$rc['desc']] . ')';
|
||||
}
|
||||
}
|
||||
|
||||
return $codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the redirect-code for a given
|
||||
* domain-id
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain
|
||||
*
|
||||
* @return string redirect-code
|
||||
*/
|
||||
function getDomainRedirectCode($domainid = 0)
|
||||
{
|
||||
|
||||
// get system default
|
||||
$default = '301';
|
||||
if (Settings::Get('customredirect.enabled') == '1') {
|
||||
$all_codes = getRedirectCodes(false);
|
||||
$_default = $all_codes[Settings::Get('customredirect.default')];
|
||||
$default = ($_default == '---') ? $default : $_default;
|
||||
}
|
||||
$code = $default;
|
||||
if ($domainid > 0) {
|
||||
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `r`.`code` as `redirect`
|
||||
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
|
||||
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
|
||||
");
|
||||
$result = Database::pexecute_first($result_stmt, array(
|
||||
'domainid' => $domainid
|
||||
));
|
||||
|
||||
if (is_array($result) && isset($result['redirect'])) {
|
||||
$code = ($result['redirect'] == '---') ? $default : $result['redirect'];
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the redirect-id for a given
|
||||
* domain-id
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain
|
||||
*
|
||||
* @return integer redirect-code-id
|
||||
*/
|
||||
function getDomainRedirectId($domainid = 0)
|
||||
{
|
||||
$code = 1;
|
||||
if ($domainid > 0) {
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `r`.`id` as `redirect`
|
||||
FROM `" . TABLE_PANEL_REDIRECTCODES . "` `r`, `" . TABLE_PANEL_DOMAINREDIRECTS . "` `rc`
|
||||
WHERE `r`.`id` = `rc`.`rid` and `rc`.`did` = :domainid
|
||||
");
|
||||
$result = Database::pexecute_first($result_stmt, array(
|
||||
'domainid' => $domainid
|
||||
));
|
||||
|
||||
if (is_array($result) && isset($result['redirect'])) {
|
||||
$code = (int) $result['redirect'];
|
||||
}
|
||||
}
|
||||
return $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a redirectcode for a domain
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain to add the code for
|
||||
* @param integer $redirect
|
||||
* selected redirect-id
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function addRedirectToDomain($domainid = 0, $redirect = 1)
|
||||
{
|
||||
if ($domainid > 0) {
|
||||
$ins_stmt = Database::prepare("
|
||||
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
|
||||
");
|
||||
Database::pexecute($ins_stmt, array(
|
||||
'rid' => $redirect,
|
||||
'did' => $domainid
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* updates the redirectcode of a domain
|
||||
* if redirect-code is false, nothing happens
|
||||
*
|
||||
* @param integer $domainid
|
||||
* id of the domain to update
|
||||
* @param integer $redirect
|
||||
* selected redirect-id or false
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function updateRedirectOfDomain($domainid = 0, $redirect = false)
|
||||
{
|
||||
if ($redirect == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($domainid > 0) {
|
||||
$del_stmt = Database::prepare("
|
||||
DELETE FROM `" . TABLE_PANEL_DOMAINREDIRECTS . "` WHERE `did` = :domainid
|
||||
");
|
||||
Database::pexecute($del_stmt, array(
|
||||
'domainid' => $domainid
|
||||
));
|
||||
|
||||
$ins_stmt = Database::prepare("
|
||||
INSERT INTO `" . TABLE_PANEL_DOMAINREDIRECTS . "` SET `rid` = :rid, `did` = :did
|
||||
");
|
||||
Database::pexecute($ins_stmt, array(
|
||||
'rid' => $redirect,
|
||||
'did' => $domainid
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Build Navigation Sidebar
|
||||
*
|
||||
* @param
|
||||
* array navigation data
|
||||
* @param
|
||||
* array userinfo the userinfo of the user
|
||||
* @return string the content of the navigation bar
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function buildNavigation($navigation, $userinfo)
|
||||
{
|
||||
global $theme;
|
||||
|
||||
$returnvalue = '';
|
||||
|
||||
// sanitize user-given input (url-manipulation)
|
||||
if (isset($_GET['page']) && is_array($_GET['page'])) {
|
||||
$_GET['page'] = (string) $_GET['page'][0];
|
||||
}
|
||||
if (isset($_GET['action']) && is_array($_GET['action'])) {
|
||||
$_GET['action'] = (string) $_GET['action'][0];
|
||||
}
|
||||
|
||||
foreach ($navigation as $box) {
|
||||
if ((! isset($box['show_element']) || $box['show_element'] === true) && (! isset($box['required_resources']) || $box['required_resources'] == '' || (isset($userinfo[$box['required_resources']]) && ((int) $userinfo[$box['required_resources']] > 0 || $userinfo[$box['required_resources']] == '-1')))) {
|
||||
$navigation_links = '';
|
||||
foreach ($box['elements'] as $element_id => $element) {
|
||||
if ((! isset($element['show_element']) || $element['show_element'] === true) && (! isset($element['required_resources']) || $element['required_resources'] == '' || (isset($userinfo[$element['required_resources']]) && ((int) $userinfo[$element['required_resources']] > 0 || $userinfo[$element['required_resources']] == '-1')))) {
|
||||
$target = '';
|
||||
$active = '';
|
||||
$navurl = '#';
|
||||
if (isset($element['url']) && trim($element['url']) != '') {
|
||||
// append sid only to local
|
||||
|
||||
if (! preg_match('/^https?\:\/\//', $element['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
|
||||
// generate sid with ? oder &
|
||||
|
||||
if (strpos($element['url'], '?') !== false) {
|
||||
$element['url'] .= '&s=' . $userinfo['hash'];
|
||||
} else {
|
||||
$element['url'] .= '?s=' . $userinfo['hash'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($element['new_window']) && $element['new_window'] == true) {
|
||||
$target = ' target="_blank"';
|
||||
}
|
||||
|
||||
if (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && isset($_GET['action']) && substr_count($element['url'], "action=" . $_GET['action']) > 0) {
|
||||
$active = ' active';
|
||||
} elseif (isset($_GET['page']) && substr_count($element['url'], "page=" . $_GET['page']) > 0 && substr_count($element['url'], basename($_SERVER["SCRIPT_FILENAME"])) > 0 && substr_count($element['url'], "action=") == 0 && ! isset($_GET['action'])) {
|
||||
$active = ' active';
|
||||
}
|
||||
|
||||
$navurl = htmlspecialchars($element['url']);
|
||||
$navlabel = $element['label'];
|
||||
} else {
|
||||
$navlabel = $element['label'];
|
||||
}
|
||||
|
||||
eval("\$navigation_links .= \"" . \Froxlor\UI\Template::getTemplate("navigation_link", 1) . "\";");
|
||||
}
|
||||
}
|
||||
|
||||
if ($navigation_links != '') {
|
||||
$target = '';
|
||||
if (isset($box['url']) && trim($box['url']) != '') {
|
||||
// append sid only to local
|
||||
|
||||
if (! preg_match('/^https?\:\/\//', $box['url']) && (isset($userinfo['hash']) && $userinfo['hash'] != '')) {
|
||||
// generate sid with ? oder &
|
||||
|
||||
if (strpos($box['url'], '?') !== false) {
|
||||
$box['url'] .= '&s=' . $userinfo['hash'];
|
||||
} else {
|
||||
$box['url'] .= '?s=' . $userinfo['hash'];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($box['new_window']) && $box['new_window'] == true) {
|
||||
$target = ' target="_blank"';
|
||||
}
|
||||
|
||||
$navurl = htmlspecialchars($box['url']);
|
||||
$navlabel = $box['label'];
|
||||
} else {
|
||||
$navurl = "#";
|
||||
$navlabel = $box['label'];
|
||||
}
|
||||
|
||||
eval("\$returnvalue .= \"" . \Froxlor\UI\Template::getTemplate("navigation_element", 1) . "\";");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $returnvalue;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns full style user details "Name, Firstname | Company"
|
||||
*
|
||||
* @param
|
||||
* array An array with keys firstname, name and company
|
||||
* @return string The full details
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function getCorrectFullUserDetails($userinfo)
|
||||
{
|
||||
$returnval = '';
|
||||
|
||||
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
|
||||
if ($userinfo['company'] == '') {
|
||||
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'];
|
||||
} else {
|
||||
if ($userinfo['name'] != '' && $userinfo['firstname'] != '') {
|
||||
$returnval = $userinfo['name'] . ', ' . $userinfo['firstname'] . ' | ' . $userinfo['company'];
|
||||
} else {
|
||||
$returnval = $userinfo['company'];
|
||||
}
|
||||
}
|
||||
} elseif (isset($userinfo['name'])) {
|
||||
$returnval = $userinfo['name'];
|
||||
}
|
||||
|
||||
return $returnval;
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns correct user salutation, either "Firstname Name" or "Company"
|
||||
*
|
||||
* @param
|
||||
* array An array with keys firstname, name and company
|
||||
* @return string The correct salutation
|
||||
*
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function getCorrectUserSalutation($userinfo)
|
||||
{
|
||||
$returnval = '';
|
||||
|
||||
if (isset($userinfo['firstname']) && isset($userinfo['name']) && isset($userinfo['company'])) {
|
||||
// Always prefer firstname name
|
||||
|
||||
if ($userinfo['company'] != '' && $userinfo['name'] == '' && $userinfo['firstname'] == '') {
|
||||
$returnval = $userinfo['company'];
|
||||
} else {
|
||||
$returnval = $userinfo['firstname'] . ' ' . $userinfo['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $returnval;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a double of the given value which isn't negative.
|
||||
* Returns -1 if the given value was -1.
|
||||
*
|
||||
* @param
|
||||
* any The value
|
||||
* @return double The positive value
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function doubleval_ressource($the_value)
|
||||
{
|
||||
$the_value = doubleval($the_value);
|
||||
|
||||
if ($the_value < 0 && $the_value != '-1') {
|
||||
$the_value *= - 1;
|
||||
}
|
||||
|
||||
return $the_value;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper around html_entity_decode to handle arrays, with the advantage that you
|
||||
* can select which fields should be handled by htmlentities and with advantage,
|
||||
* that you can eliminate all html entities by setting complete=true
|
||||
*
|
||||
* @param
|
||||
* array The subject array
|
||||
* @param
|
||||
* string The fields which should be checked for, separated by spaces
|
||||
* @param
|
||||
* bool Select true to use html_entity_decode_complete instead of html_entity_decode
|
||||
* @param
|
||||
* int See php documentation about this
|
||||
* @param
|
||||
* string See php documentation about this
|
||||
* @return array The array with html_entity_decode'd strings
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function html_entity_decode_array($subject, $fields = '', $complete = false, $quote_style = ENT_COMPAT, $charset = 'UTF-8')
|
||||
{
|
||||
if (is_array($subject)) {
|
||||
if (! is_array($fields)) {
|
||||
$fields = array_trim(explode(' ', $fields));
|
||||
}
|
||||
|
||||
foreach ($subject as $field => $value) {
|
||||
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
|
||||
/**
|
||||
* Just call ourselve to manage multi-dimensional arrays
|
||||
*/
|
||||
|
||||
$subject[$field] = html_entity_decode_array($subject[$field], $fields, $complete, $quote_style, $charset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($complete == true) {
|
||||
$subject = html_entity_decode_complete($subject, $quote_style, $charset);
|
||||
} else {
|
||||
$subject = html_entity_decode($subject, $quote_style, $charset);
|
||||
}
|
||||
}
|
||||
|
||||
return $subject;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calls html_entity_decode in a loop until the result doesn't differ from original anymore
|
||||
*
|
||||
* @param
|
||||
* string The string in which the html entities should be eliminated.
|
||||
* @return string The cleaned string
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function html_entity_decode_complete($string)
|
||||
{
|
||||
global $theme;
|
||||
|
||||
if ($theme == 'Classic') {
|
||||
while ($string != html_entity_decode($string)) {
|
||||
$string = html_entity_decode($string);
|
||||
}
|
||||
} else {
|
||||
while ($string != html_entity_decode($string, ENT_COMPAT | ENT_HTML5, 'UTF-8')) {
|
||||
$string = html_entity_decode($string, ENT_COMPAT | ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper around htmlentities to handle arrays, with the advantage that you
|
||||
* can select which fields should be handled by htmlentities
|
||||
*
|
||||
* @param
|
||||
* array The subject array
|
||||
* @param
|
||||
* string The fields which should be checked for, separated by spaces
|
||||
* @param
|
||||
* int See php documentation about this
|
||||
* @param
|
||||
* string See php documentation about this
|
||||
* @return array The array with htmlentitie'd strings
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function htmlentities_array($subject, $fields = '', $quote_style = ENT_QUOTES, $charset = 'UTF-8')
|
||||
{
|
||||
if (is_array($subject)) {
|
||||
if (! is_array($fields)) {
|
||||
$fields = array_trim(explode(' ', $fields));
|
||||
}
|
||||
|
||||
foreach ($subject as $field => $value) {
|
||||
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
|
||||
/**
|
||||
* Just call ourselve to manage multi-dimensional arrays
|
||||
*/
|
||||
|
||||
$subject[$field] = htmlentities_array($subject[$field], $fields, $quote_style, $charset);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$subject = htmlentities($subject, $quote_style, $charset);
|
||||
}
|
||||
|
||||
return $subject;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Replaces Strings in an array, with the advantage that you
|
||||
* can select which fields should be str_replace'd
|
||||
*
|
||||
* @param
|
||||
* mixed String or array of strings to search for
|
||||
* @param
|
||||
* mixed String or array to replace with
|
||||
* @param
|
||||
* array The subject array
|
||||
* @param
|
||||
* string The fields which should be checked for, separated by spaces
|
||||
* @return array The str_replace'd array
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function str_replace_array($search, $replace, $subject, $fields = '')
|
||||
{
|
||||
if (is_array($subject)) {
|
||||
$fields = array_trim(explode(' ', $fields));
|
||||
foreach ($subject as $field => $value) {
|
||||
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
|
||||
$subject[$field] = str_replace($search, $replace, $subject[$field]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$subject = str_replace($search, $replace, $subject);
|
||||
}
|
||||
|
||||
return $subject;
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper around stripslashes to handle arrays, with the advantage that you
|
||||
* can select which fields should be handled by htmlentities and with advantage,
|
||||
* that you can eliminate all slashes by setting complete=true
|
||||
*
|
||||
* @param
|
||||
* array The subject array
|
||||
* @param
|
||||
* int See php documentation about this
|
||||
* @param
|
||||
* string See php documentation about this
|
||||
* @param
|
||||
* string The fields which should be checked for, separated by spaces
|
||||
* @param
|
||||
* bool Select true to use stripslashes_complete instead of stripslashes
|
||||
* @return array The array with stripslashe'd strings
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function stripslashes_array($subject, $fields = '', $complete = false)
|
||||
{
|
||||
if (is_array($subject)) {
|
||||
if (! is_array($fields)) {
|
||||
$fields = array_trim(explode(' ', $fields));
|
||||
}
|
||||
|
||||
foreach ($subject as $field => $value) {
|
||||
if ((! is_array($fields) || empty($fields)) || (is_array($fields) && ! empty($fields) && in_array($field, $fields))) {
|
||||
/**
|
||||
* Just call ourselve to manage multi-dimensional arrays
|
||||
*/
|
||||
|
||||
$subject[$field] = stripslashes_array($subject[$field], $fields, $complete);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($complete == true) {
|
||||
$subject = stripslashes_complete($subject);
|
||||
} else {
|
||||
$subject = stripslashes($subject);
|
||||
}
|
||||
}
|
||||
|
||||
return $subject;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Calls stripslashes in a loop until the result doesn't differ from original anymore
|
||||
*
|
||||
* @param
|
||||
* string The string in which the slashes should be eliminated.
|
||||
* @return string The cleaned string
|
||||
* @author Florian Lippert <flo@syscp.org>
|
||||
*/
|
||||
function stripslashes_complete($string)
|
||||
{
|
||||
while ($string != stripslashes($string)) {
|
||||
$string = stripslashes($string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?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
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a valid from/to - mailheader (remove carriage-returns)
|
||||
*
|
||||
* @param
|
||||
* string The name of the recipient
|
||||
* @param
|
||||
* string The mailaddress
|
||||
* @return string A valid header-entry
|
||||
* @author Florian Aders <eleras@syscp.org>
|
||||
*/
|
||||
function buildValidMailFrom($name, $mailaddress)
|
||||
{
|
||||
$mailfrom = str_replace(array(
|
||||
"\r",
|
||||
"\n"
|
||||
), '', $name) . ' <' . str_replace(array(
|
||||
"\r",
|
||||
"\n"
|
||||
), '', $mailaddress) . '>';
|
||||
return $mailfrom;
|
||||
}
|
||||
Reference in New Issue
Block a user