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,44 +1,44 @@
<?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 storeSettingApsPhpExtensions($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'aps' && isset($fielddata['varname']) && $fielddata['varname'] == 'php-extension')
{
$newfieldvalue_array = explode(',', $newfieldvalue);
if(in_array('mcrypt', $newfieldvalue_array))
{
$functions = 'mcrypt_encrypt,mcrypt_decrypt';
}
else
{
$functions = '';
}
if($functions != getSetting('aps', 'php-function'))
{
saveSetting('aps', 'php-function', $functions);
}
}
return $returnvalue;
}
<?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 storeSettingApsPhpExtensions($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'aps' && isset($fielddata['varname']) && $fielddata['varname'] == 'php-extension')
{
$newfieldvalue_array = explode(',', $newfieldvalue);
if(in_array('mcrypt', $newfieldvalue_array))
{
$functions = 'mcrypt_encrypt,mcrypt_decrypt';
}
else
{
$functions = '';
}
if($functions != getSetting('aps', 'php-function'))
{
saveSetting('aps', 'php-function', $functions);
}
}
return $returnvalue;
}

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 storeSettingApsWebserverModules($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'aps' && isset($fielddata['varname']) && $fielddata['varname'] == 'webserver-module')
{
$newfieldvalue_array = explode(',', $newfieldvalue);
if(in_array('mod_rewrite', $newfieldvalue_array))
{
// Don't have to guess if we have to remove the leading comma as mod_rewrite is set anyways when we're here...
$newfieldvalue .= ',mod_rewrite.c';
}
if(in_array('htaccess', $newfieldvalue_array))
{
$htaccess = 'htaccess';
}
else
{
$htaccess = '';
}
if($htaccess != getSetting('aps', 'webserver-htaccess'))
{
saveSetting('aps', 'webserver-htaccess', $htaccess);
}
}
return storeSettingField($fieldname, $fielddata, $newfieldvalue);
}
<?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 storeSettingApsWebserverModules($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'aps' && isset($fielddata['varname']) && $fielddata['varname'] == 'webserver-module')
{
$newfieldvalue_array = explode(',', $newfieldvalue);
if(in_array('mod_rewrite', $newfieldvalue_array))
{
// Don't have to guess if we have to remove the leading comma as mod_rewrite is set anyways when we're here...
$newfieldvalue .= ',mod_rewrite.c';
}
if(in_array('htaccess', $newfieldvalue_array))
{
$htaccess = 'htaccess';
}
else
{
$htaccess = '';
}
if($htaccess != getSetting('aps', 'webserver-htaccess'))
{
saveSetting('aps', 'webserver-htaccess', $htaccess);
}
}
return storeSettingField($fieldname, $fielddata, $newfieldvalue);
}

View File

@@ -1,66 +1,66 @@
<?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$
*/
if(!function_exists('sys_get_temp_dir'))
{
/**
* function will return the temporary directory where we can write data
* function exists as a fallback for php versions lower than 5.2.1
* source copied from php.net
*
* @author Sven Skrabal <info@nexpa.de>
*/
function sys_get_temp_dir()
{
// Try to get from environment variable
if(!empty($_ENV['TMP']))
{
return realpath($_ENV['TMP']);
}
elseif(!empty($_ENV['TMPDIR']))
{
return realpath($_ENV['TMPDIR']);
}
elseif(!empty($_ENV['TEMP']))
{
return realpath($_ENV['TEMP']);
}
else
{
// Detect by creating a temporary file
// Try to use system's temporary directory
// as random name shouldn't exist
$temp_file = tempnam(md5(uniqid(rand(), true)), '');
if($temp_file)
{
$temp_dir = realpath(dirname($temp_file));
unlink($temp_file);
return $temp_dir;
}
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$
*/
if(!function_exists('sys_get_temp_dir'))
{
/**
* function will return the temporary directory where we can write data
* function exists as a fallback for php versions lower than 5.2.1
* source copied from php.net
*
* @author Sven Skrabal <info@nexpa.de>
*/
function sys_get_temp_dir()
{
// Try to get from environment variable
if(!empty($_ENV['TMP']))
{
return realpath($_ENV['TMP']);
}
elseif(!empty($_ENV['TMPDIR']))
{
return realpath($_ENV['TMPDIR']);
}
elseif(!empty($_ENV['TEMP']))
{
return realpath($_ENV['TEMP']);
}
else
{
// Detect by creating a temporary file
// Try to use system's temporary directory
// as random name shouldn't exist
$temp_file = tempnam(md5(uniqid(rand(), true)), '');
if($temp_file)
{
$temp_dir = realpath(dirname($temp_file));
unlink($temp_file);
return $temp_dir;
}
else
{
return false;
}
}
}
}

View File

@@ -1,91 +1,91 @@
<?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 correctMysqlUsers($mysql_access_host_array)
{
global $db, $settings, $sql, $sql_root;
foreach($sql_root as $mysql_server => $mysql_server_details)
{
$db_root = new db($mysql_server_details['host'], $mysql_server_details['user'], $mysql_server_details['password'], '');
unset($db_root->password);
$users = array();
$users_result = $db_root->query('SELECT * FROM `mysql`.`user`');
while($users_row = $db_root->fetch_array($users_result))
{
if(!isset($users[$users_row['User']])
|| !is_array($users[$users_row['User']]))
{
$users[$users_row['User']] = array(
'password' => $users_row['Password'],
'hosts' => array()
);
}
$users[$users_row['User']]['hosts'][] = $users_row['Host'];
}
$databases = array(
$sql['db']
);
$databases_result = $db->query('SELECT * FROM `' . TABLE_PANEL_DATABASES . '` WHERE `dbserver` = \'' . $mysql_server . '\'');
while($databases_row = $db->fetch_array($databases_result))
{
$databases[] = $databases_row['databasename'];
}
foreach($databases as $username)
{
if(isset($users[$username])
&& is_array($users[$username])
&& isset($users[$username]['hosts'])
&& is_array($users[$username]['hosts']))
{
$password = $users[$username]['password'];
foreach($mysql_access_host_array as $mysql_access_host)
{
$mysql_access_host = trim($mysql_access_host);
if(!in_array($mysql_access_host, $users[$username]['hosts']))
{
$db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '`.* TO `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` IDENTIFIED BY \'password\'');
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` = \'' . $db_root->escape($password) . '\'');
}
}
foreach($users[$username]['hosts'] as $mysql_access_host)
{
if(!in_array($mysql_access_host, $mysql_access_host_array))
{
$db_root->query('REVOKE ALL PRIVILEGES ON * . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '` . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('DELETE FROM `mysql`.`user` WHERE `User` = "' . $db_root->escape($username) . '" AND `Host` = "' . $db_root->escape($mysql_access_host) . '"');
}
}
}
}
$db_root->query('FLUSH PRIVILEGES');
$db_root->close();
unset($db_root);
}
}
<?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 correctMysqlUsers($mysql_access_host_array)
{
global $db, $settings, $sql, $sql_root;
foreach($sql_root as $mysql_server => $mysql_server_details)
{
$db_root = new db($mysql_server_details['host'], $mysql_server_details['user'], $mysql_server_details['password'], '');
unset($db_root->password);
$users = array();
$users_result = $db_root->query('SELECT * FROM `mysql`.`user`');
while($users_row = $db_root->fetch_array($users_result))
{
if(!isset($users[$users_row['User']])
|| !is_array($users[$users_row['User']]))
{
$users[$users_row['User']] = array(
'password' => $users_row['Password'],
'hosts' => array()
);
}
$users[$users_row['User']]['hosts'][] = $users_row['Host'];
}
$databases = array(
$sql['db']
);
$databases_result = $db->query('SELECT * FROM `' . TABLE_PANEL_DATABASES . '` WHERE `dbserver` = \'' . $mysql_server . '\'');
while($databases_row = $db->fetch_array($databases_result))
{
$databases[] = $databases_row['databasename'];
}
foreach($databases as $username)
{
if(isset($users[$username])
&& is_array($users[$username])
&& isset($users[$username]['hosts'])
&& is_array($users[$username]['hosts']))
{
$password = $users[$username]['password'];
foreach($mysql_access_host_array as $mysql_access_host)
{
$mysql_access_host = trim($mysql_access_host);
if(!in_array($mysql_access_host, $users[$username]['hosts']))
{
$db_root->query('GRANT ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '`.* TO `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` IDENTIFIED BY \'password\'');
$db_root->query('SET PASSWORD FOR `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '` = \'' . $db_root->escape($password) . '\'');
}
}
foreach($users[$username]['hosts'] as $mysql_access_host)
{
if(!in_array($mysql_access_host, $mysql_access_host_array))
{
$db_root->query('REVOKE ALL PRIVILEGES ON * . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('REVOKE ALL PRIVILEGES ON `' . str_replace('_', '\_', $db_root->escape($username)) . '` . * FROM `' . $db_root->escape($username) . '`@`' . $db_root->escape($mysql_access_host) . '`');
$db_root->query('DELETE FROM `mysql`.`user` WHERE `User` = "' . $db_root->escape($username) . '" AND `Host` = "' . $db_root->escape($mysql_access_host) . '"');
}
}
}
}
$db_root->query('FLUSH PRIVILEGES');
$db_root->close();
unset($db_root);
}
}

View File

@@ -1,122 +1,122 @@
<?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$
*/
/**
* Returns an array with all tables with keys which are in the currently selected database
*
* @param db A valid DB-object
* @return array Array with tables and keys
*
* @author Florian Lippert <flo@syscp.org>
*/
function getTables(&$db)
{
// This variable is our return-value
$tables = array();
// The fieldname in the associative array which we get by fetch_array()
$tablefieldname = 'Tables_in_' . $db->database;
// Query for a list of tables in the currently selected database
$tables_result = $db->query('SHOW TABLES');
while($tables_row = $db->fetch_array($tables_result))
{
// Extract tablename
$tablename = $tables_row[$tablefieldname];
// Create sub-array with key tablename
$tables[$tablename] = array();
// Query for a list of indexes of the currently selected table
$keys_result = $db->query('SHOW INDEX FROM ' . $tablename);
while($keys_row = $db->fetch_array($keys_result))
{
// Extract keyname
$keyname = $keys_row['Key_name'];
// If there is aleady a key in our tablename-sub-array with has the same name as our key
// OR if the sequence is not one
// then we have more then index-columns for our keyname
if((isset($tables[$tablename][$keyname]) && $tables[$tablename][$keyname] != '')
|| $keys_row['Seq_in_index'] != '1')
{
// If there is no keyname in the tablename-sub-array set ...
if(!isset($tables[$tablename][$keyname]))
{
// ... then create one
$tables[$tablename][$keyname] = array();
}
// If the keyname-sub-array isn't an array ...
elseif (!is_array($tables[$tablename][$keyname]))
{
// temporary move columname
$tmpkeyvalue = $tables[$tablename][$keyname];
// unset keyname-key
unset($tables[$tablename][$keyname]);
// create new array for keyname-key
$tables[$tablename][$keyname] = array();
// keyindex will be 1 by default, if seq is also 1 we'd better use 0 (this case shouldn't ever occur)
$keyindex = ($keys_row['Seq_in_index'] == '1') ? '0' : '1';
// then move back our tmp columname from above
$tables[$tablename][$keyname][$keyindex] = $tmpkeyvalue;
// end unset the variable afterwards
unset($tmpkeyvalue);
}
// set columname
$tables[$tablename][$keyname][$keys_row['Seq_in_index']] = $keys_row['Column_name'];
}
else
{
// set columname
$tables[$tablename][$keyname] = $keys_row['Column_name'];
}
}
}
return $tables;
}
<?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$
*/
/**
* Returns an array with all tables with keys which are in the currently selected database
*
* @param db A valid DB-object
* @return array Array with tables and keys
*
* @author Florian Lippert <flo@syscp.org>
*/
function getTables(&$db)
{
// This variable is our return-value
$tables = array();
// The fieldname in the associative array which we get by fetch_array()
$tablefieldname = 'Tables_in_' . $db->database;
// Query for a list of tables in the currently selected database
$tables_result = $db->query('SHOW TABLES');
while($tables_row = $db->fetch_array($tables_result))
{
// Extract tablename
$tablename = $tables_row[$tablefieldname];
// Create sub-array with key tablename
$tables[$tablename] = array();
// Query for a list of indexes of the currently selected table
$keys_result = $db->query('SHOW INDEX FROM ' . $tablename);
while($keys_row = $db->fetch_array($keys_result))
{
// Extract keyname
$keyname = $keys_row['Key_name'];
// If there is aleady a key in our tablename-sub-array with has the same name as our key
// OR if the sequence is not one
// then we have more then index-columns for our keyname
if((isset($tables[$tablename][$keyname]) && $tables[$tablename][$keyname] != '')
|| $keys_row['Seq_in_index'] != '1')
{
// If there is no keyname in the tablename-sub-array set ...
if(!isset($tables[$tablename][$keyname]))
{
// ... then create one
$tables[$tablename][$keyname] = array();
}
// If the keyname-sub-array isn't an array ...
elseif (!is_array($tables[$tablename][$keyname]))
{
// temporary move columname
$tmpkeyvalue = $tables[$tablename][$keyname];
// unset keyname-key
unset($tables[$tablename][$keyname]);
// create new array for keyname-key
$tables[$tablename][$keyname] = array();
// keyindex will be 1 by default, if seq is also 1 we'd better use 0 (this case shouldn't ever occur)
$keyindex = ($keys_row['Seq_in_index'] == '1') ? '0' : '1';
// then move back our tmp columname from above
$tables[$tablename][$keyname][$keyindex] = $tmpkeyvalue;
// end unset the variable afterwards
unset($tmpkeyvalue);
}
// set columname
$tables[$tablename][$keyname][$keys_row['Seq_in_index']] = $keys_row['Column_name'];
}
else
{
// set columname
$tables[$tablename][$keyname] = $keys_row['Column_name'];
}
}
}
return $tables;
}

View File

@@ -1,55 +1,55 @@
<?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$
*/
//
// remove_remarks will strip the sql comment lines out of an uploaded sql file
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function remove_remarks($sql)
{
$lines = explode("\n", $sql);
// try to keep mem. use down
$sql = "";
$linecount = count($lines);
$output = "";
for ($i = 0;$i < $linecount;$i++)
{
if(($i != ($linecount - 1))
|| (strlen($lines[$i]) > 0))
{
if(substr($lines[$i], 0, 1) != "#")
{
$output.= $lines[$i] . "\n";
}
else
{
$output.= "\n";
}
// Trading a bit of speed for lower mem. use here.
$lines[$i] = "";
}
}
return $output;
}
<?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$
*/
//
// remove_remarks will strip the sql comment lines out of an uploaded sql file
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function remove_remarks($sql)
{
$lines = explode("\n", $sql);
// try to keep mem. use down
$sql = "";
$linecount = count($lines);
$output = "";
for ($i = 0;$i < $linecount;$i++)
{
if(($i != ($linecount - 1))
|| (strlen($lines[$i]) > 0))
{
if(substr($lines[$i], 0, 1) != "#")
{
$output.= $lines[$i] . "\n";
}
else
{
$output.= "\n";
}
// Trading a bit of speed for lower mem. use here.
$lines[$i] = "";
}
}
return $output;
}

View File

@@ -1,140 +1,140 @@
<?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$
*/
//
// split_sql_file will split an uploaded sql file into single sql statements.
// Note: expects trim() to have already been run on $sql
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function split_sql_file($sql, $delimiter)
{
// Split up our string into "possible" SQL statements.
$tokens = explode($delimiter, $sql);
// try to save mem.
$sql = "";
$output = array();
// we don't actually care about the matches preg gives us.
$matches = array();
// this is faster than calling count($oktens) every time thru the loop.
$token_count = count($tokens);
for ($i = 0;$i < $token_count;$i++)
{
// Don't wanna add an empty string as the last thing in the array.
if(($i != ($token_count - 1))
|| (strlen($tokens[$i] > 0)))
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
// If the number of unescaped quotes is even, then the delimiter did NOT occur inside a string literal.
if(($unescaped_quotes % 2) == 0)
{
// It's a complete sql statement.
$output[] = $tokens[$i];
// save memory.
$tokens[$i] = "";
}
else
{
// incomplete sql statement. keep adding tokens until we have a complete one.
// $temp will hold what we have so far.
$temp = $tokens[$i] . $delimiter;
// save memory..
$tokens[$i] = "";
// Do we have a complete statement yet?
$complete_stmt = false;
for ($j = $i + 1;(!$complete_stmt && ($j < $token_count));$j++)
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
if(($unescaped_quotes % 2) == 1)
{
// odd number of unescaped quotes. In combination with the previous incomplete
// statement(s), we now have a complete statement. (2 odds always make an even)
$output[] = $temp . $tokens[$j];
// save memory.
$tokens[$j] = "";
$temp = "";
// exit the loop.
$complete_stmt = true;
// make sure the outer loop continues at the right point.
$i = $j;
}
else
{
// even number of unescaped quotes. We still don't have a complete statement.
// (1 odd and 1 even always make an odd)
$temp.= $tokens[$j] . $delimiter;
// save memory.
$tokens[$j] = "";
}
}
// for..
}
// else
}
}
return $output;
}
<?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$
*/
//
// split_sql_file will split an uploaded sql file into single sql statements.
// Note: expects trim() to have already been run on $sql
// The whole function has been taken from the phpbb installer, copyright by the phpbb team, phpbb in summer 2004.
//
function split_sql_file($sql, $delimiter)
{
// Split up our string into "possible" SQL statements.
$tokens = explode($delimiter, $sql);
// try to save mem.
$sql = "";
$output = array();
// we don't actually care about the matches preg gives us.
$matches = array();
// this is faster than calling count($oktens) every time thru the loop.
$token_count = count($tokens);
for ($i = 0;$i < $token_count;$i++)
{
// Don't wanna add an empty string as the last thing in the array.
if(($i != ($token_count - 1))
|| (strlen($tokens[$i] > 0)))
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
// If the number of unescaped quotes is even, then the delimiter did NOT occur inside a string literal.
if(($unescaped_quotes % 2) == 0)
{
// It's a complete sql statement.
$output[] = $tokens[$i];
// save memory.
$tokens[$i] = "";
}
else
{
// incomplete sql statement. keep adding tokens until we have a complete one.
// $temp will hold what we have so far.
$temp = $tokens[$i] . $delimiter;
// save memory..
$tokens[$i] = "";
// Do we have a complete statement yet?
$complete_stmt = false;
for ($j = $i + 1;(!$complete_stmt && ($j < $token_count));$j++)
{
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
$unescaped_quotes = $total_quotes - $escaped_quotes;
if(($unescaped_quotes % 2) == 1)
{
// odd number of unescaped quotes. In combination with the previous incomplete
// statement(s), we now have a complete statement. (2 odds always make an even)
$output[] = $temp . $tokens[$j];
// save memory.
$tokens[$j] = "";
$temp = "";
// exit the loop.
$complete_stmt = true;
// make sure the outer loop continues at the right point.
$i = $j;
}
else
{
// even number of unescaped quotes. We still don't have a complete statement.
// (1 odd and 1 even always make an odd)
$temp.= $tokens[$j] . $delimiter;
// save memory.
$tokens[$j] = "";
}
}
// for..
}
// else
}
}
return $output;
}

View File

@@ -1,88 +1,88 @@
<?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$
*/
/**
* Returns an array of found directories
*
* This function checks every found directory if they match either $uid or $gid, if they do
* the found directory is valid. It uses recursive function calls to find subdirectories. Due
* to the recursive behauviour this function may consume much memory.
*
* @param string path The path to start searching in
* @param integer uid The uid which must match the found directories
* @param integer gid The gid which must match the found direcotries
* @param array _fileList recursive transport array !for internal use only!
* @return array Array of found valid pathes
*
* @author Martin Burchert <martin.burchert@syscp.de>
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
*/
function findDirs($path, $uid, $gid)
{
$list = array(
$path
);
$_fileList = array();
while(sizeof($list) > 0)
{
$path = array_pop($list);
$path = makeCorrectDir($path);
if(!is_readable($path))
{
return $_fileList;
}
$dh = opendir($path);
if($dh === false)
{
/*
* this should never be called because we checked
* 'is_readable' before...but we never know what might happen
*/
standard_error('cannotreaddir', $path);
return null;
}
else
{
while(false !== ($file = @readdir($dh)))
{
if($file == '.'
&& (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid))
{
$_fileList[] = makeCorrectDir($path);
}
if(is_dir($path . '/' . $file)
&& $file != '..'
&& $file != '.')
{
array_push($list, $path . '/' . $file);
}
}
@closedir($dh);
}
}
return $_fileList;
}
<?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$
*/
/**
* Returns an array of found directories
*
* This function checks every found directory if they match either $uid or $gid, if they do
* the found directory is valid. It uses recursive function calls to find subdirectories. Due
* to the recursive behauviour this function may consume much memory.
*
* @param string path The path to start searching in
* @param integer uid The uid which must match the found directories
* @param integer gid The gid which must match the found direcotries
* @param array _fileList recursive transport array !for internal use only!
* @return array Array of found valid pathes
*
* @author Martin Burchert <martin.burchert@syscp.de>
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
*/
function findDirs($path, $uid, $gid)
{
$list = array(
$path
);
$_fileList = array();
while(sizeof($list) > 0)
{
$path = array_pop($list);
$path = makeCorrectDir($path);
if(!is_readable($path))
{
return $_fileList;
}
$dh = opendir($path);
if($dh === false)
{
/*
* this should never be called because we checked
* 'is_readable' before...but we never know what might happen
*/
standard_error('cannotreaddir', $path);
return null;
}
else
{
while(false !== ($file = @readdir($dh)))
{
if($file == '.'
&& (fileowner($path . '/' . $file) == $uid || filegroup($path . '/' . $file) == $gid))
{
$_fileList[] = makeCorrectDir($path);
}
if(is_dir($path . '/' . $file)
&& $file != '..'
&& $file != '.')
{
array_push($list, $path . '/' . $file);
}
}
@closedir($dh);
}
}
return $_fileList;
}

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$
*/
/**
* Checks if a given directory is valid for multiple configurations
* or should rather be used as a single file
*
* @param string The dir
* @return bool true if usable as dir, false otherwise
*
* @author Florian Lippert <flo@syscp.org>
*/
function isConfigDir($dir)
{
if(file_exists($dir))
{
if(is_dir($dir))
{
$returnval = true;
}
else
{
$returnval = false;
}
}
else
{
if(substr($dir, -1) == '/')
{
$returnval = true;
}
else
{
$returnval = false;
}
}
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$
*/
/**
* Checks if a given directory is valid for multiple configurations
* or should rather be used as a single file
*
* @param string The dir
* @return bool true if usable as dir, false otherwise
*
* @author Florian Lippert <flo@syscp.org>
*/
function isConfigDir($dir)
{
if(file_exists($dir))
{
if(is_dir($dir))
{
$returnval = true;
}
else
{
$returnval = false;
}
}
else
{
if(substr($dir, -1) == '/')
{
$returnval = true;
}
else
{
$returnval = false;
}
}
return $returnval;
}

View File

@@ -1,42 +1,42 @@
<?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 returns a correct dirname, means to add slashes at the beginning and at the end if there weren't some
*
* @param string The dirname
* @return string The corrected dirname
* @author Florian Lippert <flo@syscp.org>
*/
function makeCorrectDir($dir)
{
if(substr($dir, -1, 1) != '/')
{
$dir.= '/';
}
if(substr($dir, 0, 1) != '/')
{
$dir = '/' . $dir;
}
$dir = makeSecurePath($dir);
return $dir;
}
<?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 returns a correct dirname, means to add slashes at the beginning and at the end if there weren't some
*
* @param string The dirname
* @return string The corrected dirname
* @author Florian Lippert <flo@syscp.org>
*/
function makeCorrectDir($dir)
{
if(substr($dir, -1, 1) != '/')
{
$dir.= '/';
}
if(substr($dir, 0, 1) != '/')
{
$dir = '/' . $dir;
}
$dir = makeSecurePath($dir);
return $dir;
}

View File

@@ -1,39 +1,39 @@
<?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 returns a correct filename, means to add a slash at the beginning if there wasn't one
*
* @param string filename the filename
* @return string the corrected filename
* @author Florian Lippert <flo@syscp.org>
* @author Michael Russ <mr@edvruss.com>
* @author Martin Burchert <eremit@adm1n.de>
*/
function makeCorrectFile($filename)
{
if(substr($filename, 0, 1) != '/')
{
$filename = '/' . $filename;
}
$filename = makeSecurePath($filename);
return $filename;
}
<?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 returns a correct filename, means to add a slash at the beginning if there wasn't one
*
* @param string filename the filename
* @return string the corrected filename
* @author Florian Lippert <flo@syscp.org>
* @author Michael Russ <mr@edvruss.com>
* @author Martin Burchert <eremit@adm1n.de>
*/
function makeCorrectFile($filename)
{
if(substr($filename, 0, 1) != '/')
{
$filename = '/' . $filename;
}
$filename = makeSecurePath($filename);
return $filename;
}

View File

@@ -1,79 +1,79 @@
<?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$
*/
/**
* Returns a valid html tag for the choosen $fieldType for pathes
*
* @param string path The path to start searching in
* @param integer uid The uid which must match the found directories
* @param integer gid The gid which must match the found direcotries
* @param string fieldType Either "Manual" or "Dropdown"
* @return string The html tag for the choosen $fieldType
*
* @author Martin Burchert <martin.burchert@syscp.de>
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
*/
function makePathfield($path, $uid, $gid, $fieldType, $value = '')
{
global $lng;
$value = str_replace($path, '', $value);
$field = '';
if($fieldType == 'Manual')
{
$field = '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />';
}
elseif($fieldType == 'Dropdown')
{
$dirList = findDirs($path, $uid, $gid);
natcasesort($dirList);
if(sizeof($dirList) > 0)
{
if(sizeof(dirList) <= 100)
{
$field = '<select name="path">';
foreach($dirList as $key => $dir)
{
if(strpos($dir, $path) === 0)
{
$dir = makeCorrectDir(substr($dir, strlen($path)));
}
$field.= makeoption($dir, $dir, $value);
}
$field.= '</select>';
}
else
{
$field = $lng['panel']['toomanydirs'];
$field.= '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />';
}
}
else
{
$field = $lng['panel']['dirsmissing'];
$field.= '<input type="hidden" name="path" value="/" />';
}
}
return $field;
}
<?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$
*/
/**
* Returns a valid html tag for the choosen $fieldType for pathes
*
* @param string path The path to start searching in
* @param integer uid The uid which must match the found directories
* @param integer gid The gid which must match the found direcotries
* @param string fieldType Either "Manual" or "Dropdown"
* @return string The html tag for the choosen $fieldType
*
* @author Martin Burchert <martin.burchert@syscp.de>
* @author Manuel Bernhardt <manuel.bernhardt@syscp.de>
*/
function makePathfield($path, $uid, $gid, $fieldType, $value = '')
{
global $lng;
$value = str_replace($path, '', $value);
$field = '';
if($fieldType == 'Manual')
{
$field = '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />';
}
elseif($fieldType == 'Dropdown')
{
$dirList = findDirs($path, $uid, $gid);
natcasesort($dirList);
if(sizeof($dirList) > 0)
{
if(sizeof(dirList) <= 100)
{
$field = '<select name="path">';
foreach($dirList as $key => $dir)
{
if(strpos($dir, $path) === 0)
{
$dir = makeCorrectDir(substr($dir, strlen($path)));
}
$field.= makeoption($dir, $dir, $value);
}
$field.= '</select>';
}
else
{
$field = $lng['panel']['toomanydirs'];
$field.= '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />';
}
}
else
{
$field = $lng['panel']['dirsmissing'];
$field.= '<input type="hidden" name="path" value="/" />';
}
}
return $field;
}

View File

@@ -1,42 +1,42 @@
<?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 returns a secure path, means to remove all multiple dots and slashes
*
* @param string The path
* @return string The corrected path
* @author Florian Lippert <flo@syscp.org>
*/
function makeSecurePath($path)
{
$search = Array(
'#/+#',
'#\.+#',
'#\0+#'
);
$replace = Array(
'/',
'.',
''
);
$path = preg_replace($search, $replace, $path);
return $path;
}
<?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 returns a secure path, means to remove all multiple dots and slashes
*
* @param string The path
* @return string The corrected path
* @author Florian Lippert <flo@syscp.org>
*/
function makeSecurePath($path)
{
$search = Array(
'#/+#',
'#\.+#',
'#\0+#'
);
$replace = Array(
'/',
'.',
''
);
$path = preg_replace($search, $replace, $path);
return $path;
}

View File

@@ -1,86 +1,86 @@
<?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$
*/
/**
* Creates a directory below a users homedir and sets all directories,
* which had to be created below with correct Owner/Group
* (Copied from cron_tasks.php:rev1189 as we'll need this more often in future)
*
* @param string The homedir of the user
* @param string The dir which should be created
* @param int The uid of the user
* @param int The gid of the user
* @return bool true if everything went okay, false if something went wrong
*
* @author Florian Lippert <flo@syscp.org>
* @author Martin Burchert <martin.burchert@syscp.org>
*/
function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid)
{
$returncode = true;
if($homeDir != ''
&& $dirToCreate != '')
{
$homeDir = makeCorrectDir($homeDir);
$dirToCreate = makeCorrectDir($dirToCreate);
if(substr($dirToCreate, 0, strlen($homeDir)) == $homeDir)
{
$subdir = substr($dirToCreate, strlen($homeDir));
}
else
{
$subdir = $dirToCreate;
}
$subdir = makeCorrectDir($subdir);
$subdirlen = strlen($subdir);
$subdirs = array();
array_push($subdirs, $dirToCreate);
$offset = 0;
while($offset < $subdirlen)
{
$offset = strpos($subdir, '/', $offset);
$subdirelem = substr($subdir, 0, $offset);
$offset++;
array_push($subdirs, makeCorrectDir($homeDir . $subdirelem));
}
$subdirs = array_unique($subdirs);
sort($subdirs);
foreach($subdirs as $sdir)
{
if(!is_dir($sdir))
{
$sdir = makeCorrectDir($sdir);
safe_exec('mkdir -p ' . escapeshellarg($sdir));
safe_exec('chown -R ' . (int)$uid . ':' . (int)$gid . ' ' . escapeshellarg($sdir));
}
}
}
else
{
$returncode = false;
}
return $returncode;
}
<?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$
*/
/**
* Creates a directory below a users homedir and sets all directories,
* which had to be created below with correct Owner/Group
* (Copied from cron_tasks.php:rev1189 as we'll need this more often in future)
*
* @param string The homedir of the user
* @param string The dir which should be created
* @param int The uid of the user
* @param int The gid of the user
* @return bool true if everything went okay, false if something went wrong
*
* @author Florian Lippert <flo@syscp.org>
* @author Martin Burchert <martin.burchert@syscp.org>
*/
function mkDirWithCorrectOwnership($homeDir, $dirToCreate, $uid, $gid)
{
$returncode = true;
if($homeDir != ''
&& $dirToCreate != '')
{
$homeDir = makeCorrectDir($homeDir);
$dirToCreate = makeCorrectDir($dirToCreate);
if(substr($dirToCreate, 0, strlen($homeDir)) == $homeDir)
{
$subdir = substr($dirToCreate, strlen($homeDir));
}
else
{
$subdir = $dirToCreate;
}
$subdir = makeCorrectDir($subdir);
$subdirlen = strlen($subdir);
$subdirs = array();
array_push($subdirs, $dirToCreate);
$offset = 0;
while($offset < $subdirlen)
{
$offset = strpos($subdir, '/', $offset);
$subdirelem = substr($subdir, 0, $offset);
$offset++;
array_push($subdirs, makeCorrectDir($homeDir . $subdirelem));
}
$subdirs = array_unique($subdirs);
sort($subdirs);
foreach($subdirs as $sdir)
{
if(!is_dir($sdir))
{
$sdir = makeCorrectDir($sdir);
safe_exec('mkdir -p ' . escapeshellarg($sdir));
safe_exec('chown -R ' . (int)$uid . ':' . (int)$gid . ' ' . escapeshellarg($sdir));
}
}
}
else
{
$returncode = false;
}
return $returncode;
}

View File

@@ -1,117 +1,117 @@
<?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$
*/
/**
* Wrapper around the exec command.
*
* @author Martin Burchert <eremit@adm1n.de>
* @version 1.2
* @param string exec_string String to be executed
* @return string The result of the exec()
*
* History:
* 1.0 : Initial Version
* 1.1 : Added |,&,>,<,`,*,$,~,? as security breaks.
* 1.2 : Removed * as security break
*/
function safe_exec($exec_string, &$return_value = false)
{
global $settings;
//
// define allowed system commands
//
$allowed_commands = array(
'touch',
'chown',
'mkdir',
'webalizer',
'cp',
'du',
'chmod',
'chattr',
$settings['system']['apachereload_command'],
$settings['system']['bindreload_command'],
$settings['dkim']['dkimrestart_command'],
$settings['system']['awstats_updateall_command'],
'openssl',
'unzip',
'php',
'rm'
);
//
// check for ; in execute command
//
if((stristr($exec_string, ';'))
or (stristr($exec_string, '|'))
or (stristr($exec_string, '&'))
or (stristr($exec_string, '>'))
or (stristr($exec_string, '<'))
or (stristr($exec_string, '`'))
or (stristr($exec_string, '$'))
or (stristr($exec_string, '~'))
or (stristr($exec_string, '?')))
{
die('SECURITY CHECK FAILED!' . "\n" . 'The execute string "' . htmlspecialchars($exec_string) . '" is a possible security risk!' . "\n" . 'Please check your whole server for security problems by hand!' . "\n");
}
//
// check if command is allowed here
//
$ok = false;
foreach($allowed_commands as $allowed_command)
{
if(strpos($exec_string, $allowed_command) == 0
&& (strlen($exec_string) === ($allowed_command_pos = strlen($allowed_command)) || substr($exec_string, $allowed_command_pos, 1) === ' '))
{
$ok = true;
}
}
if(!$ok)
{
die('SECURITY CHECK FAILED!' . "\n" . 'Your command "' . htmlspecialchars($exec_string) . '" is not allowed!' . "\n" . 'Please check your whole server for security problems by hand!' . "\n");
}
//
// execute the command and return output
//
// --- martin @ 08.08.2005 -------------------------------------------------------
// fixing usage of uninitialised variable
$return = '';
// -------------------------------------------------------------------------------
if($return_value == false)
{
exec($exec_string, $return);
}
else
{
exec($exec_string, $return, $return_value);
}
return $return;
}
<?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$
*/
/**
* Wrapper around the exec command.
*
* @author Martin Burchert <eremit@adm1n.de>
* @version 1.2
* @param string exec_string String to be executed
* @return string The result of the exec()
*
* History:
* 1.0 : Initial Version
* 1.1 : Added |,&,>,<,`,*,$,~,? as security breaks.
* 1.2 : Removed * as security break
*/
function safe_exec($exec_string, &$return_value = false)
{
global $settings;
//
// define allowed system commands
//
$allowed_commands = array(
'touch',
'chown',
'mkdir',
'webalizer',
'cp',
'du',
'chmod',
'chattr',
$settings['system']['apachereload_command'],
$settings['system']['bindreload_command'],
$settings['dkim']['dkimrestart_command'],
$settings['system']['awstats_updateall_command'],
'openssl',
'unzip',
'php',
'rm'
);
//
// check for ; in execute command
//
if((stristr($exec_string, ';'))
or (stristr($exec_string, '|'))
or (stristr($exec_string, '&'))
or (stristr($exec_string, '>'))
or (stristr($exec_string, '<'))
or (stristr($exec_string, '`'))
or (stristr($exec_string, '$'))
or (stristr($exec_string, '~'))
or (stristr($exec_string, '?')))
{
die('SECURITY CHECK FAILED!' . "\n" . 'The execute string "' . htmlspecialchars($exec_string) . '" is a possible security risk!' . "\n" . 'Please check your whole server for security problems by hand!' . "\n");
}
//
// check if command is allowed here
//
$ok = false;
foreach($allowed_commands as $allowed_command)
{
if(strpos($exec_string, $allowed_command) == 0
&& (strlen($exec_string) === ($allowed_command_pos = strlen($allowed_command)) || substr($exec_string, $allowed_command_pos, 1) === ' '))
{
$ok = true;
}
}
if(!$ok)
{
die('SECURITY CHECK FAILED!' . "\n" . 'Your command "' . htmlspecialchars($exec_string) . '" is not allowed!' . "\n" . 'Please check your whole server for security problems by hand!' . "\n");
}
//
// execute the command and return output
//
// --- martin @ 08.08.2005 -------------------------------------------------------
// fixing usage of uninitialised variable
$return = '';
// -------------------------------------------------------------------------------
if($return_value == false)
{
exec($exec_string, $return);
}
else
{
exec($exec_string, $return, $return_value);
}
return $return;
}

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 getFormFieldDataBool($fieldname, $fielddata, $input)
{
if(isset($input[$fieldname]) && ($input[$fieldname] === '1' || $input[$fieldname] === 1 || $input[$fieldname] === true || strtolower($input[$fieldname]) === 'yes' || strtolower($input[$fieldname]) === 'ja'))
{
$newfieldvalue = '1';
}
else
{
$newfieldvalue = '0';
}
return $newfieldvalue;
}
<?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 getFormFieldDataBool($fieldname, $fielddata, $input)
{
if(isset($input[$fieldname]) && ($input[$fieldname] === '1' || $input[$fieldname] === 1 || $input[$fieldname] === true || strtolower($input[$fieldname]) === 'yes' || strtolower($input[$fieldname]) === 'ja'))
{
$newfieldvalue = '1';
}
else
{
$newfieldvalue = '0';
}
return $newfieldvalue;
}

View File

@@ -1,26 +1,26 @@
<?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 getFormFieldOutputBool($fieldname, $fielddata)
{
$label = $fielddata['label'];
$boolswitch = makeYesNo($fieldname, '1', '0', $fielddata['value']);
eval("\$returnvalue = \"" . getTemplate("formfields/bool", true) . "\";");
return $returnvalue;
}
<?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 getFormFieldOutputBool($fieldname, $fielddata)
{
$label = $fielddata['label'];
$boolswitch = makeYesNo($fieldname, '1', '0', $fielddata['value']);
eval("\$returnvalue = \"" . getTemplate("formfields/bool", true) . "\";");
return $returnvalue;
}

View File

@@ -1,30 +1,30 @@
<?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 validateFormFieldBool($fieldname, $fielddata, $newfieldvalue)
{
if($newfieldvalue === '1' || $newfieldvalue === 1 || $newfieldvalue === true || strtolower($newfieldvalue) === 'yes' || strtolower($newfieldvalue) === 'ja' || $newfieldvalue === '0' || $newfieldvalue === 0 || $newfieldvalue === false || strtolower($newfieldvalue) === 'no' || strtolower($newfieldvalue) === 'nein' || strtolower($newfieldvalue) === '')
{
return true;
}
else
{
return 'noboolean';
}
}
<?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 validateFormFieldBool($fieldname, $fielddata, $newfieldvalue)
{
if($newfieldvalue === '1' || $newfieldvalue === 1 || $newfieldvalue === true || strtolower($newfieldvalue) === 'yes' || strtolower($newfieldvalue) === 'ja' || $newfieldvalue === '0' || $newfieldvalue === 0 || $newfieldvalue === false || strtolower($newfieldvalue) === 'no' || strtolower($newfieldvalue) === 'nein' || strtolower($newfieldvalue) === '')
{
return true;
}
else
{
return 'noboolean';
}
}

View File

@@ -1,25 +1,25 @@
<?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$
*/
if(!defined('FORMFIELDS_PLAUSIBILITY_CHECK_OK'))
define('FORMFIELDS_PLAUSIBILITY_CHECK_OK', 0);
if(!defined('FORMFIELDS_PLAUSIBILITY_CHECK_ERROR'))
define('FORMFIELDS_PLAUSIBILITY_CHECK_ERROR', 1);
if(!defined('FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION'))
define('FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION', 2);
<?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$
*/
if(!defined('FORMFIELDS_PLAUSIBILITY_CHECK_OK'))
define('FORMFIELDS_PLAUSIBILITY_CHECK_OK', 0);
if(!defined('FORMFIELDS_PLAUSIBILITY_CHECK_ERROR'))
define('FORMFIELDS_PLAUSIBILITY_CHECK_ERROR', 1);
if(!defined('FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION'))
define('FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION', 2);

View File

@@ -1,28 +1,28 @@
<?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 getFormFieldOutputDate($fieldname, $fielddata)
{
if(isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true)
{
$fielddata['value'] = date('Y-m-d', $fielddata['value']);
}
return getFormFieldOutputString($fieldname, $fielddata);
}
<?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 getFormFieldOutputDate($fieldname, $fielddata)
{
if(isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true)
{
$fielddata['value'] = date('Y-m-d', $fielddata['value']);
}
return getFormFieldOutputString($fieldname, $fielddata);
}

View File

@@ -1,28 +1,28 @@
<?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 manipulateFormFieldDataDate($fieldname, $fielddata, $newfieldvalue)
{
if(isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true)
{
$newfieldvalue = strtotime($newfieldvalue);
}
return $newfieldvalue;
}
<?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 manipulateFormFieldDataDate($fieldname, $fielddata, $newfieldvalue)
{
if(isset($fielddata['date_timestamp']) && $fielddata['date_timestamp'] === true)
{
$newfieldvalue = strtotime($newfieldvalue);
}
return $newfieldvalue;
}

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 validateFormFieldDate($fieldname, $fielddata, $newfieldvalue)
{
if($newfieldvalue == '0000-00-00' || preg_match('/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', $newfieldvalue))
{
$returnvalue = true;
}
else
{
$returnvalue = false;
}
return $returnvalue;
}
<?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 validateFormFieldDate($fieldname, $fielddata, $newfieldvalue)
{
if($newfieldvalue == '0000-00-00' || preg_match('/^(19|20)\d\d[-](0[1-9]|1[012])[-](0[1-9]|[12][0-9]|3[01])$/', $newfieldvalue))
{
$returnvalue = true;
}
else
{
$returnvalue = false;
}
return $returnvalue;
}

View File

@@ -1,52 +1,52 @@
<?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 buildForm($form)
{
$fields = '';
if(validateFormDefinition($form))
{
foreach($form['groups'] as $groupname => $groupdetails)
{
if(isset($groupdetails['title']) && $groupdetails['title'] != '')
{
$fields .= getFormGroupOutput($groupname, $groupdetails);
}
if(validateFieldDefinition($groupdetails))
{
// Prefetch form fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
}
// Collect form field output
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$fields .= getFormFieldOutput($fieldname, $fielddetails);
}
}
}
}
return $fields;
}
<?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 buildForm($form)
{
$fields = '';
if(validateFormDefinition($form))
{
foreach($form['groups'] as $groupname => $groupdetails)
{
if(isset($groupdetails['title']) && $groupdetails['title'] != '')
{
$fields .= getFormGroupOutput($groupname, $groupdetails);
}
if(validateFieldDefinition($groupdetails))
{
// Prefetch form fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
}
// Collect form field output
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$fields .= getFormFieldOutput($fieldname, $fielddetails);
}
}
}
}
return $fields;
}

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 checkPlausibilityFormField($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['plausibility_check_method']) && $fielddata['plausibility_check_method'] != '' && function_exists($fielddata['plausibility_check_method']))
{
$returnvalue = call_user_func($fielddata['plausibility_check_method'], $fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues);
}
else
{
$returnvalue = false;
}
return $returnvalue;
}
<?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 checkPlausibilityFormField($fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['plausibility_check_method']) && $fielddata['plausibility_check_method'] != '' && function_exists($fielddata['plausibility_check_method']))
{
$returnvalue = call_user_func($fielddata['plausibility_check_method'], $fieldname, $fielddata, $newfieldvalue, $allnewfieldvalues);
}
else
{
$returnvalue = false;
}
return $returnvalue;
}

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 getFormFieldData($fieldname, $fielddata, $input)
{
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('getFormFieldData' . ucfirst($fielddata['type'])))
{
$newfieldvalue = call_user_func('getFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata, &$input);
}
else
{
if(isset($input[$fieldname]))
{
$newfieldvalue = $input[$fieldname];
}
elseif(isset($fielddata['default']))
{
$newfieldvalue = $fielddata['default'];
}
else
{
$newfieldvalue = false;
}
}
return $newfieldvalue;
}
<?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 getFormFieldData($fieldname, $fielddata, $input)
{
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('getFormFieldData' . ucfirst($fielddata['type'])))
{
$newfieldvalue = call_user_func('getFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata, &$input);
}
else
{
if(isset($input[$fieldname]))
{
$newfieldvalue = $input[$fieldname];
}
elseif(isset($fielddata['default']))
{
$newfieldvalue = $fielddata['default'];
}
else
{
$newfieldvalue = false;
}
}
return $newfieldvalue;
}

View File

@@ -1,50 +1,50 @@
<?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 getFormFieldOutput($fieldname, $fielddata)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('getFormFieldOutput' . ucfirst($fielddata['type'])))
{
if(isset($fielddata['label']) && is_array($fielddata['label']))
{
if(isset($fielddata['label']['title']) && isset($fielddata['label']['description']))
{
$fielddata['label'] = '<b>' . $fielddata['label']['title'] . '</b><br />' . $fielddata['label']['description'];
}
else
{
$fielddata['label'] = implode(' ', $fielddata['label']);
}
}
if(!isset($fielddata['value']))
{
if(isset($fielddata['default']))
{
$fielddata['value'] = $fielddata['default'];
}
else
{
$fielddata['value'] = null;
}
}
$returnvalue = call_user_func('getFormFieldOutput' . ucfirst($fielddata['type']), $fieldname, $fielddata);
}
return $returnvalue;
}
<?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 getFormFieldOutput($fieldname, $fielddata)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('getFormFieldOutput' . ucfirst($fielddata['type'])))
{
if(isset($fielddata['label']) && is_array($fielddata['label']))
{
if(isset($fielddata['label']['title']) && isset($fielddata['label']['description']))
{
$fielddata['label'] = '<b>' . $fielddata['label']['title'] . '</b><br />' . $fielddata['label']['description'];
}
else
{
$fielddata['label'] = implode(' ', $fielddata['label']);
}
}
if(!isset($fielddata['value']))
{
if(isset($fielddata['default']))
{
$fielddata['value'] = $fielddata['default'];
}
else
{
$fielddata['value'] = null;
}
}
$returnvalue = call_user_func('getFormFieldOutput' . ucfirst($fielddata['type']), $fieldname, $fielddata);
}
return $returnvalue;
}

View File

@@ -1,25 +1,25 @@
<?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 getFormGroupOutput($groupname, $groupdetails)
{
global $lng;
eval("\$group = \"" . getTemplate("settings/settings_group") . "\";");
return $group;
}
<?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 getFormGroupOutput($groupname, $groupdetails)
{
global $lng;
eval("\$group = \"" . getTemplate("settings/settings_group") . "\";");
return $group;
}

View File

@@ -1,28 +1,28 @@
<?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 manipulateFormFieldData($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('manipulateFormFieldData' . ucfirst($fielddata['type'])))
{
$newfieldvalue = call_user_func('manipulateFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata, $newfieldvalue);
}
return $newfieldvalue;
}
<?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 manipulateFormFieldData($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('manipulateFormFieldData' . ucfirst($fielddata['type'])))
{
$newfieldvalue = call_user_func('manipulateFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata, $newfieldvalue);
}
return $newfieldvalue;
}

View File

@@ -1,28 +1,28 @@
<?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 prefetchFormFieldData($fieldname, $fielddata)
{
$returnvalue = array();
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('prefetchFormFieldData' . ucfirst($fielddata['type'])))
{
$returnvalue = call_user_func('prefetchFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata);
}
return $returnvalue;
}
<?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 prefetchFormFieldData($fieldname, $fielddata)
{
$returnvalue = array();
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('prefetchFormFieldData' . ucfirst($fielddata['type'])))
{
$returnvalue = call_user_func('prefetchFormFieldData' . ucfirst($fielddata['type']), $fieldname, $fielddata);
}
return $returnvalue;
}

View File

@@ -1,145 +1,145 @@
<?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 processForm($form, $input, $url_params = array())
{
if(validateFormDefinition($form))
{
$submitted_fields = array();
$changed_fields = array();
$saved_fields = array();
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Prefetch form fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
}
}
}
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Validate fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$newfieldvalue = getFormFieldData($fieldname, $fielddetails, &$input);
if($newfieldvalue != $fielddetails['value'])
{
if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true)
{
standard_error($error, $fieldname);
}
else
{
$changed_fields[$fieldname] = $newfieldvalue;
}
}
$submitted_fields[$fieldname] = $newfieldvalue;
}
}
}
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Check fields for plausibility
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
if(($plausibility_check = checkPlausibilityFormField($fieldname, $fielddetails, $submitted_fields[$fieldname], $submitted_fields)) !== false)
{
if(is_array($plausibility_check) && isset($plausibility_check[0]))
{
if($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_OK)
{
// Nothing to do here, everything's okay
}
elseif($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_ERROR)
{
unset($plausibility_check[0]);
$error = $plausibility_check[1];
unset($plausibility_check[1]);
$targetname = implode(' ', $plausibility_check);
standard_error($error, $targetname);
}
elseif($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION)
{
unset($plausibility_check[0]);
$question = $plausibility_check[1];
unset($plausibility_check[1]);
$targetname = implode(' ', $plausibility_check);
if(!isset($input[$question]))
{
if(is_array($url_params) && isset($url_params['filename']))
{
$filename = $url_params['filename'];
unset($url_params['filename']);
}
else
{
$filename = '';
}
ask_yesno($question, $filename, array_merge($url_params, $submitted_fields, array($question => $question)), $targetname);
}
}
else
{
standard_error('plausibilitychecknotunderstood');
}
}
}
}
}
}
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Save fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
if(isset($changed_fields[$fieldname]))
{
if(($saved_field = saveFormField($fieldname, $fielddetails, manipulateFormFieldData($fieldname, $fielddetails, $changed_fields[$fieldname]))) !== false)
{
$saved_fields = array_merge($saved_fields, $saved_field);
}
else
{
standard_error('errorwhensaving', $fieldname);
}
}
}
}
}
// Save form
return saveForm($form, $saved_fields);
}
}
<?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 processForm($form, $input, $url_params = array())
{
if(validateFormDefinition($form))
{
$submitted_fields = array();
$changed_fields = array();
$saved_fields = array();
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Prefetch form fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
}
}
}
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Validate fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
$newfieldvalue = getFormFieldData($fieldname, $fielddetails, &$input);
if($newfieldvalue != $fielddetails['value'])
{
if(($error = validateFormField($fieldname, $fielddetails, $newfieldvalue)) !== true)
{
standard_error($error, $fieldname);
}
else
{
$changed_fields[$fieldname] = $newfieldvalue;
}
}
$submitted_fields[$fieldname] = $newfieldvalue;
}
}
}
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Check fields for plausibility
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
if(($plausibility_check = checkPlausibilityFormField($fieldname, $fielddetails, $submitted_fields[$fieldname], $submitted_fields)) !== false)
{
if(is_array($plausibility_check) && isset($plausibility_check[0]))
{
if($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_OK)
{
// Nothing to do here, everything's okay
}
elseif($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_ERROR)
{
unset($plausibility_check[0]);
$error = $plausibility_check[1];
unset($plausibility_check[1]);
$targetname = implode(' ', $plausibility_check);
standard_error($error, $targetname);
}
elseif($plausibility_check[0] == FORMFIELDS_PLAUSIBILITY_CHECK_QUESTION)
{
unset($plausibility_check[0]);
$question = $plausibility_check[1];
unset($plausibility_check[1]);
$targetname = implode(' ', $plausibility_check);
if(!isset($input[$question]))
{
if(is_array($url_params) && isset($url_params['filename']))
{
$filename = $url_params['filename'];
unset($url_params['filename']);
}
else
{
$filename = '';
}
ask_yesno($question, $filename, array_merge($url_params, $submitted_fields, array($question => $question)), $targetname);
}
}
else
{
standard_error('plausibilitychecknotunderstood');
}
}
}
}
}
}
foreach($form['groups'] as $groupname => $groupdetails)
{
if(validateFieldDefinition($groupdetails))
{
// Save fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails)
{
if(isset($changed_fields[$fieldname]))
{
if(($saved_field = saveFormField($fieldname, $fielddetails, manipulateFormFieldData($fieldname, $fielddetails, $changed_fields[$fieldname]))) !== false)
{
$saved_fields = array_merge($saved_fields, $saved_field);
}
else
{
standard_error('errorwhensaving', $fieldname);
}
}
}
}
}
// Save form
return saveForm($form, $saved_fields);
}
}

View File

@@ -1,23 +1,23 @@
<?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 returnField($fieldname, $fielddata, $newfieldvalue)
{
return array($fieldname => $newfieldvalue);
}
<?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 returnField($fieldname, $fielddata, $newfieldvalue)
{
return array($fieldname => $newfieldvalue);
}

View File

@@ -1,36 +1,36 @@
<?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 saveForm($fielddata, $newfieldvalue)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '' && function_exists($fielddata['save_method']))
{
$returnvalue = call_user_func($fielddata['save_method'], $fielddata, $newfieldvalue);
}
elseif(is_array($fielddata) && !isset($fielddata['save_method']))
{
$returnvalue = true;
}
else
{
$returnvalue = false;
}
return $returnvalue;
}
<?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 saveForm($fielddata, $newfieldvalue)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '' && function_exists($fielddata['save_method']))
{
$returnvalue = call_user_func($fielddata['save_method'], $fielddata, $newfieldvalue);
}
elseif(is_array($fielddata) && !isset($fielddata['save_method']))
{
$returnvalue = true;
}
else
{
$returnvalue = false;
}
return $returnvalue;
}

View File

@@ -1,36 +1,36 @@
<?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 saveFormField($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '' && function_exists($fielddata['save_method']))
{
$returnvalue = call_user_func($fielddata['save_method'], $fieldname, $fielddata, $newfieldvalue);
}
elseif(is_array($fielddata) && !isset($fielddata['save_method']))
{
$returnvalue = array();
}
else
{
$returnvalue = false;
}
return $returnvalue;
}
<?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 saveFormField($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['save_method']) && $fielddata['save_method'] != '' && function_exists($fielddata['save_method']))
{
$returnvalue = call_user_func($fielddata['save_method'], $fieldname, $fielddata, $newfieldvalue);
}
elseif(is_array($fielddata) && !isset($fielddata['save_method']))
{
$returnvalue = array();
}
else
{
$returnvalue = false;
}
return $returnvalue;
}

View File

@@ -1,30 +1,30 @@
<?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 validateFieldDefinition($field)
{
$returnvalue = false;
if(is_array($field) && !empty($field) && isset($field['fields']) && is_array($field['fields']) && !empty($field['fields']))
{
$returnvalue = true;
}
return $returnvalue;
}
<?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 validateFieldDefinition($field)
{
$returnvalue = false;
if(is_array($field) && !empty($field) && isset($field['fields']) && is_array($field['fields']) && !empty($field['fields']))
{
$returnvalue = true;
}
return $returnvalue;
}

View File

@@ -1,30 +1,30 @@
<?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 validateFormDefinition($form)
{
$returnvalue = false;
if(is_array($form) && !empty($form) && isset($form['groups']) && is_array($form['groups']) && !empty($form['groups']))
{
$returnvalue = true;
}
return $returnvalue;
}
<?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 validateFormDefinition($form)
{
$returnvalue = false;
if(is_array($form) && !empty($form) && isset($form['groups']) && is_array($form['groups']) && !empty($form['groups']))
{
$returnvalue = true;
}
return $returnvalue;
}

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 validateFormField($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('validateFormField' . ucfirst($fielddata['type'])))
{
$returnvalue = call_user_func('validateFormField' . ucfirst($fielddata['type']), $fieldname, $fielddata, $newfieldvalue);
}
else
{
$returnvalue = 'validation method not found';
}
return $returnvalue;
}
<?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 validateFormField($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = '';
if(is_array($fielddata) && isset($fielddata['type']) && $fielddata['type'] != '' && function_exists('validateFormField' . ucfirst($fielddata['type'])))
{
$returnvalue = call_user_func('validateFormField' . ucfirst($fielddata['type']), $fieldname, $fielddata, $newfieldvalue);
}
else
{
$returnvalue = 'validation method not found';
}
return $returnvalue;
}

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 getFormFieldOutputHidden($fieldname, $fielddata)
{
$returnvalue = '<input type="hidden" name="' . $fieldname . '" value="' . htmlentities($fielddata['value']) . '" />';
if(isset($fielddata['label']) && $fielddata['label'] != '')
{
$label = $fielddata['label'];
$value = htmlentities($fielddata['value']);
eval("\$returnvalue .= \"" . getTemplate("formfields/hidden", true) . "\";");
}
return $returnvalue;
}
<?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 getFormFieldOutputHidden($fieldname, $fielddata)
{
$returnvalue = '<input type="hidden" name="' . $fieldname . '" value="' . htmlentities($fielddata['value']) . '" />';
if(isset($fielddata['label']) && $fielddata['label'] != '')
{
$label = $fielddata['label'];
$value = htmlentities($fielddata['value']);
eval("\$returnvalue .= \"" . getTemplate("formfields/hidden", true) . "\";");
}
return $returnvalue;
}

View File

@@ -1,31 +1,31 @@
<?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 validateFormFieldHidden($fieldname, $fielddata, $newfieldvalue)
{
if($newfieldvalue === $fielddata['value'])
{
return true;
}
else
{
// TODO: Throw some error that actually makes sense - false would just throw unknown error
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 validateFormFieldHidden($fieldname, $fielddata, $newfieldvalue)
{
if($newfieldvalue === $fielddata['value'])
{
return true;
}
else
{
// TODO: Throw some error that actually makes sense - false would just throw unknown error
return false;
}
}

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 getFormFieldDataInt($fieldname, $fielddata, $input)
{
if(isset($input[$fieldname]))
{
$newfieldvalue = (int)$input[$fieldname];
}
else
{
$newfieldvalue = (int)$fielddata['default'];
}
return $newfieldvalue;
}
<?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 getFormFieldDataInt($fieldname, $fielddata, $input)
{
if(isset($input[$fieldname]))
{
$newfieldvalue = (int)$input[$fieldname];
}
else
{
$newfieldvalue = (int)$fielddata['default'];
}
return $newfieldvalue;
}

View File

@@ -1,23 +1,23 @@
<?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 getFormFieldOutputInt($fieldname, $fielddata)
{
return getFormFieldOutputString($fieldname, $fielddata);
}
<?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 getFormFieldOutputInt($fieldname, $fielddata)
{
return getFormFieldOutputString($fieldname, $fielddata);
}

View File

@@ -1,33 +1,33 @@
<?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 validateFormFieldInt($fieldname, $fielddata, $newfieldvalue)
{
if(isset($fielddata['int_min']) && (int)$newfieldvalue < (int)$fielddata['int_min'])
{
return('intvaluetoolow');
}
if(isset($fielddata['int_max']) && (int)$newfieldvalue > (int)$fielddata['int_max'])
{
return('intvaluetoohigh');
}
return true;
}
<?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 validateFormFieldInt($fieldname, $fielddata, $newfieldvalue)
{
if(isset($fielddata['int_min']) && (int)$newfieldvalue < (int)$fielddata['int_min'])
{
return('intvaluetoolow');
}
if(isset($fielddata['int_max']) && (int)$newfieldvalue > (int)$fielddata['int_max'])
{
return('intvaluetoohigh');
}
return true;
}

View File

@@ -1,25 +1,25 @@
<?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 getFormFieldOutputLabel($fieldname, $fielddata)
{
$label = $fielddata['label'];
eval("\$returnvalue = \"" . getTemplate("formfields/label", true) . "\";");
return $returnvalue;
}
<?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 getFormFieldOutputLabel($fieldname, $fielddata)
{
$label = $fielddata['label'];
eval("\$returnvalue = \"" . getTemplate("formfields/label", true) . "\";");
return $returnvalue;
}

View File

@@ -1,26 +1,26 @@
<?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 validateFormFieldLabel($fieldname, $fielddata, $newfieldvalue)
{
// Return false, in case we happen to have that field in our $input array, so someone doesn't get the chance to save crap to our database
// TODO: Throw some error that actually makes sense - false would just throw unknown error
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 validateFormFieldLabel($fieldname, $fielddata, $newfieldvalue)
{
// Return false, in case we happen to have that field in our $input array, so someone doesn't get the chance to save crap to our database
// TODO: Throw some error that actually makes sense - false would just throw unknown error
return false;
}

View File

@@ -1,37 +1,37 @@
<?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 getFormFieldDataOption($fieldname, $fielddata, $input)
{
if(isset($input[$fieldname]))
{
$newfieldvalue = $input[$fieldname];
}
else
{
$newfieldvalue = $fielddata['default'];
}
if(is_array($newfieldvalue))
{
$newfieldvalue = implode(',', $newfieldvalue);
}
return $newfieldvalue;
}
<?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 getFormFieldDataOption($fieldname, $fielddata, $input)
{
if(isset($input[$fieldname]))
{
$newfieldvalue = $input[$fieldname];
}
else
{
$newfieldvalue = $fielddata['default'];
}
if(is_array($newfieldvalue))
{
$newfieldvalue = implode(',', $newfieldvalue);
}
return $newfieldvalue;
}

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$
*/
function getFormFieldOutputOption($fieldname, $fielddata)
{
$returnvalue = '';
if(isset($fielddata['option_options']) && is_array($fielddata['option_options']) && !empty($fielddata['option_options']))
{
if(isset($fielddata['option_mode']) && $fielddata['option_mode'] == 'multiple')
{
$multiple = true;
$fielddata['value'] = explode(',', $fielddata['value']);
}
else
{
$multiple = false;
}
$label = $fielddata['label'];
$options_array = $fielddata['option_options'];
$options = '';
foreach($options_array as $value => $title)
{
$options .= makeoption($title, $value, $fielddata['value']);
}
eval("\$returnvalue = \"" . getTemplate("formfields/option", true) . "\";");
}
return $returnvalue;
}
<?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 getFormFieldOutputOption($fieldname, $fielddata)
{
$returnvalue = '';
if(isset($fielddata['option_options']) && is_array($fielddata['option_options']) && !empty($fielddata['option_options']))
{
if(isset($fielddata['option_mode']) && $fielddata['option_mode'] == 'multiple')
{
$multiple = true;
$fielddata['value'] = explode(',', $fielddata['value']);
}
else
{
$multiple = false;
}
$label = $fielddata['label'];
$options_array = $fielddata['option_options'];
$options = '';
foreach($options_array as $value => $title)
{
$options .= makeoption($title, $value, $fielddata['value']);
}
eval("\$returnvalue = \"" . getTemplate("formfields/option", true) . "\";");
}
return $returnvalue;
}

View File

@@ -1,30 +1,30 @@
<?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 prefetchFormFieldDataOption($fieldname, $fielddata)
{
$returnvalue = array();
if((!isset($fielddata['option_options']) || !is_array($fielddata['option_options']) || empty($fielddata['option_options'])) && (isset($fielddata['option_options_method']) && function_exists($fielddata['option_options_method'])))
{
$returnvalue['options'] = call_user_func($fielddata['option_options_method']);
}
return $returnvalue;
}
<?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 prefetchFormFieldDataOption($fieldname, $fielddata)
{
$returnvalue = array();
if((!isset($fielddata['option_options']) || !is_array($fielddata['option_options']) || empty($fielddata['option_options'])) && (isset($fielddata['option_options_method']) && function_exists($fielddata['option_options_method'])))
{
$returnvalue['options'] = call_user_func($fielddata['option_options_method']);
}
return $returnvalue;
}

View File

@@ -1,45 +1,45 @@
<?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 validateFormFieldOption($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = true;
if(isset($fielddata['option_mode']) && $fielddata['option_mode'] == 'multiple')
{
$options = explode(',', $newfieldvalue);
foreach($options as $option)
{
$returnvalue = ($returnvalue && isset($fielddata['option_options'][$option]));
}
}
else
{
$returnvalue = isset($fielddata['option_options'][$newfieldvalue]);
}
if($returnvalue === true)
{
return true;
}
else
{
return 'not in option';
}
}
<?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 validateFormFieldOption($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = true;
if(isset($fielddata['option_mode']) && $fielddata['option_mode'] == 'multiple')
{
$options = explode(',', $newfieldvalue);
foreach($options as $option)
{
$returnvalue = ($returnvalue && isset($fielddata['option_options'][$option]));
}
}
else
{
$returnvalue = isset($fielddata['option_options'][$newfieldvalue]);
}
if($returnvalue === true)
{
return true;
}
else
{
return 'not in option';
}
}

View File

@@ -1,26 +1,26 @@
<?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 getFormFieldOutputString($fieldname, $fielddata)
{
$label = $fielddata['label'];
$value = htmlentities($fielddata['value']);
eval("\$returnvalue = \"" . getTemplate("formfields/string", true) . "\";");
return $returnvalue;
}
<?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 getFormFieldOutputString($fieldname, $fielddata)
{
$label = $fielddata['label'];
$value = htmlentities($fielddata['value']);
eval("\$returnvalue = \"" . getTemplate("formfields/string", true) . "\";");
return $returnvalue;
}

View File

@@ -1,101 +1,101 @@
<?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 validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
{
if(isset($fielddata['string_delimiter']) && $fielddata['string_delimiter'] != '')
{
$newfieldvalues = explode($fielddata['string_delimiter'], $newfieldvalue);
unset($fielddata['string_delimiter']);
$returnvalue = true;
foreach($newfieldvalues as $single_newfieldvalue)
{
$single_returnvalue = validateFormFieldString($fieldname, $fielddata, $single_newfieldvalue);
if($single_returnvalue !== true)
{
$returnvalue = $single_returnvalue;
break;
}
}
}
else
{
$returnvalue = false;
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);
}
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'dir')
{
$returnvalue = ($newfieldvalue == makeCorrectDir($newfieldvalue));
}
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'file')
{
$returnvalue = ($newfieldvalue == makeCorrectFile($newfieldvalue));
}
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir')
{
$returnvalue = (($newfieldvalue == makeCorrectDir($newfieldvalue)) || ($newfieldvalue == makeCorrectFile($newfieldvalue)));
}
elseif(preg_match('/^[^\r\n\t\f\0]*$/D', $newfieldvalue))
{
$returnvalue = true;
}
if(isset($fielddata['string_regexp']) && $fielddata['string_regexp'] != '')
{
if(preg_match($fielddata['string_regexp'], $newfieldvalue))
{
$returnvalue = true;
}
else
{
$returnvalue = false;
}
}
if(isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === true && $newfieldvalue === '')
{
$returnvalue = true;
}
elseif(isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === false && $newfieldvalue === '')
{
$returnvalue = 'stringmustntbeempty';
}
}
if($returnvalue === true)
{
return true;
}
elseif($returnvalue === false)
{
return 'stringformaterror';
}
else
{
return $returnvalue;
}
}
<?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 validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
{
if(isset($fielddata['string_delimiter']) && $fielddata['string_delimiter'] != '')
{
$newfieldvalues = explode($fielddata['string_delimiter'], $newfieldvalue);
unset($fielddata['string_delimiter']);
$returnvalue = true;
foreach($newfieldvalues as $single_newfieldvalue)
{
$single_returnvalue = validateFormFieldString($fieldname, $fielddata, $single_newfieldvalue);
if($single_returnvalue !== true)
{
$returnvalue = $single_returnvalue;
break;
}
}
}
else
{
$returnvalue = false;
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);
}
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'dir')
{
$returnvalue = ($newfieldvalue == makeCorrectDir($newfieldvalue));
}
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'file')
{
$returnvalue = ($newfieldvalue == makeCorrectFile($newfieldvalue));
}
elseif(isset($fielddata['string_type']) && $fielddata['string_type'] == 'filedir')
{
$returnvalue = (($newfieldvalue == makeCorrectDir($newfieldvalue)) || ($newfieldvalue == makeCorrectFile($newfieldvalue)));
}
elseif(preg_match('/^[^\r\n\t\f\0]*$/D', $newfieldvalue))
{
$returnvalue = true;
}
if(isset($fielddata['string_regexp']) && $fielddata['string_regexp'] != '')
{
if(preg_match($fielddata['string_regexp'], $newfieldvalue))
{
$returnvalue = true;
}
else
{
$returnvalue = false;
}
}
if(isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === true && $newfieldvalue === '')
{
$returnvalue = true;
}
elseif(isset($fielddata['string_emptyallowed']) && $fielddata['string_emptyallowed'] === false && $newfieldvalue === '')
{
$returnvalue = 'stringmustntbeempty';
}
}
if($returnvalue === true)
{
return true;
}
elseif($returnvalue === false)
{
return 'stringformaterror';
}
else
{
return $returnvalue;
}
}

View File

@@ -1,26 +1,26 @@
<?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 getFormFieldOutputText($fieldname, $fielddata)
{
$label = $fielddata['label'];
$value = htmlentities($fielddata['value']);
eval("\$returnvalue = \"" . getTemplate("formfields/text", true) . "\";");
return $returnvalue;
}
<?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 getFormFieldOutputText($fieldname, $fielddata)
{
$label = $fielddata['label'];
$value = htmlentities($fielddata['value']);
eval("\$returnvalue = \"" . getTemplate("formfields/text", true) . "\";");
return $returnvalue;
}

View File

@@ -1,30 +1,30 @@
<?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 validateFormFieldText($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = 'stringformaterror';
if(preg_match('/^[^\0]*$/', $newfieldvalue))
{
$returnvalue = true;
}
return $returnvalue;
}
<?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 validateFormFieldText($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = 'stringformaterror';
if(preg_match('/^[^\0]*$/', $newfieldvalue))
{
$returnvalue = true;
}
return $returnvalue;
}

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$
*/
/*

View File

@@ -1,29 +1,29 @@
<?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$
*/
if(!defined('USR_ACTION'))
define('USR_ACTION', '10');
if(!defined('RES_ACTION'))
define('RES_ACTION', '20');
if(!defined('ADM_ACTION'))
define('ADM_ACTION', '30');
if(!defined('CRON_ACTION'))
define('CRON_ACTION', '40');
if(!defined('LOG_ERROR'))
define('LOG_ERROR', '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$
*/
if(!defined('USR_ACTION'))
define('USR_ACTION', '10');
if(!defined('RES_ACTION'))
define('RES_ACTION', '20');
if(!defined('ADM_ACTION'))
define('ADM_ACTION', '30');
if(!defined('CRON_ACTION'))
define('CRON_ACTION', '40');
if(!defined('LOG_ERROR'))
define('LOG_ERROR', '99');

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$
*/
/**
* Prints Question on screen
*
* @param string The question
* @param string File which will be called with POST if user clicks yes
* @param array Values which will be given to $yesfile. Format: array(variable1=>value1, variable2=>value2, variable3=>value3)
* @param string Name of the target eg Domain or eMail address etc.
* @author Florian Lippert <flo@syscp.org>
*/
function ask_yesno($text, $yesfile, $params = array(), $targetname = '')
{
global $userinfo, $db, $s, $header, $footer, $lng;
/*
// For compatibility reasons (if $params contains a string like "field1=value1;field2=value2") this will convert it into a usable array
if(!is_array($params))
{
$params_tmp=explode(';',$params);
unset($params);
$params=array();
while(list(,$param_tmp)=each($params_tmp))
{
$param_tmp=explode('=',$param_tmp);
$params[$param_tmp[0]]=$param_tmp[1];
}
}
*/
$hiddenparams = '';
if(is_array($params))
{
foreach($params as $field => $value)
{
$hiddenparams.= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
}
}
if(isset($lng['question'][$text]))
{
$text = $lng['question'][$text];
}
$text = strtr($text, array('%s' => $targetname));
eval("echo \"" . getTemplate('misc/question_yesno', '1') . "\";");
exit;
}
function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $params = array(), $targetname = '')
{
global $userinfo, $db, $s, $header, $footer, $lng;
$hiddenparams = '';
if(is_array($params))
{
foreach($params as $field => $value)
{
$hiddenparams.= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
}
}
if(isset($lng['question'][$text]))
{
$text = $lng['question'][$text];
}
if(isset($lng['question'][$chk_text]))
{
$chk_text = $lng['question'][$chk_text];
}
$checkbox = makecheckbox('delete_userfiles', $chk_text, '1', false, '0', true, true);
$text = strtr($text, array('%s' => $targetname));
eval("echo \"" . getTemplate('misc/question_yesno_checkbox', '1') . "\";");
exit;
}
<?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$
*/
/**
* Prints Question on screen
*
* @param string The question
* @param string File which will be called with POST if user clicks yes
* @param array Values which will be given to $yesfile. Format: array(variable1=>value1, variable2=>value2, variable3=>value3)
* @param string Name of the target eg Domain or eMail address etc.
* @author Florian Lippert <flo@syscp.org>
*/
function ask_yesno($text, $yesfile, $params = array(), $targetname = '')
{
global $userinfo, $db, $s, $header, $footer, $lng;
/*
// For compatibility reasons (if $params contains a string like "field1=value1;field2=value2") this will convert it into a usable array
if(!is_array($params))
{
$params_tmp=explode(';',$params);
unset($params);
$params=array();
while(list(,$param_tmp)=each($params_tmp))
{
$param_tmp=explode('=',$param_tmp);
$params[$param_tmp[0]]=$param_tmp[1];
}
}
*/
$hiddenparams = '';
if(is_array($params))
{
foreach($params as $field => $value)
{
$hiddenparams.= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
}
}
if(isset($lng['question'][$text]))
{
$text = $lng['question'][$text];
}
$text = strtr($text, array('%s' => $targetname));
eval("echo \"" . getTemplate('misc/question_yesno', '1') . "\";");
exit;
}
function ask_yesno_withcheckbox($text, $chk_text, $yesfile, $params = array(), $targetname = '')
{
global $userinfo, $db, $s, $header, $footer, $lng;
$hiddenparams = '';
if(is_array($params))
{
foreach($params as $field => $value)
{
$hiddenparams.= '<input type="hidden" name="' . htmlspecialchars($field) . '" value="' . htmlspecialchars($value) . '" />' . "\n";
}
}
if(isset($lng['question'][$text]))
{
$text = $lng['question'][$text];
}
if(isset($lng['question'][$chk_text]))
{
$chk_text = $lng['question'][$chk_text];
}
$checkbox = makecheckbox('delete_userfiles', $chk_text, '1', false, '0', true, true);
$text = strtr($text, array('%s' => $targetname));
eval("echo \"" . getTemplate('misc/question_yesno_checkbox', '1') . "\";");
exit;
}

View File

@@ -1,122 +1,122 @@
<?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$
*/
/**
* 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)
{
$returnvalue = '';
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'))))
{
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'];
}
}
$target = '';
if(isset($element['new_window']) && $element['new_window'] == true)
{
$target = ' target="_blank"';
}
$completeLink = '<a href="' . htmlspecialchars($element['url']) . '"' . $target . ' class="menu">' . $element['label'] . '</a>';
}
else
{
$completeLink = $element['label'];
}
eval("\$navigation_links .= \"" . getTemplate("navigation_link", 1) . "\";");
}
}
if($navigation_links != '')
{
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'];
}
}
$target = '';
if(isset($box['new_window']) && $box['new_window'] == true)
{
$target = ' target="_blank"';
}
$completeLink = '<a href="' . htmlspecialchars($box['url']) . '"' . $target . ' class="menu">' . $box['label'] . '</a>';
}
else
{
$completeLink = $box['label'];
}
eval("\$returnvalue .= \"" . getTemplate("navigation_element", 1) . "\";");
}
}
}
return $returnvalue;
}
<?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$
*/
/**
* 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)
{
$returnvalue = '';
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'))))
{
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'];
}
}
$target = '';
if(isset($element['new_window']) && $element['new_window'] == true)
{
$target = ' target="_blank"';
}
$completeLink = '<a href="' . htmlspecialchars($element['url']) . '"' . $target . ' class="menu">' . $element['label'] . '</a>';
}
else
{
$completeLink = $element['label'];
}
eval("\$navigation_links .= \"" . getTemplate("navigation_link", 1) . "\";");
}
}
if($navigation_links != '')
{
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'];
}
}
$target = '';
if(isset($box['new_window']) && $box['new_window'] == true)
{
$target = ' target="_blank"';
}
$completeLink = '<a href="' . htmlspecialchars($box['url']) . '"' . $target . ' class="menu">' . $box['label'] . '</a>';
}
else
{
$completeLink = $box['label'];
}
eval("\$returnvalue .= \"" . getTemplate("navigation_element", 1) . "\";");
}
}
}
return $returnvalue;
}

View File

@@ -1,54 +1,54 @@
<?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$
*/
/**
* 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'];
}
}
}
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$
*/
/**
* 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'];
}
}
}
return $returnval;
}

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$
*/
/**
* 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;
}
<?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$
*/
/**
* 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;
}

View File

@@ -1,63 +1,63 @@
<?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$
*/
/**
* Get template from filesystem
*
* @param string Templatename
* @param string noarea If area should be used to get template
* @return string The Template
* @author Florian Lippert <flo@syscp.org>
*/
function getTemplate($template, $noarea = 0)
{
global $templatecache;
if($noarea != 1)
{
$template = AREA . '/' . $template;
}
if(!isset($templatecache[$template]))
{
$filename = './templates/' . $template . '.tpl';
if(file_exists($filename)
&& is_readable($filename))
{
$templatefile = addcslashes(file_get_contents($filename), '"\\');
// loop through template more than once in case we have an "if"-statement in another one
while(preg_match('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', $templatefile))
{
$templatefile = preg_replace('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', '".( ($1) ? ("$2") : ("$4") )."', $templatefile);
}
}
else
{
$templatefile = 'TEMPLATE NOT FOUND: ' . $filename;
}
$templatecache[$template] = $templatefile;
}
return $templatecache[$template];
}
<?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$
*/
/**
* Get template from filesystem
*
* @param string Templatename
* @param string noarea If area should be used to get template
* @return string The Template
* @author Florian Lippert <flo@syscp.org>
*/
function getTemplate($template, $noarea = 0)
{
global $templatecache;
if($noarea != 1)
{
$template = AREA . '/' . $template;
}
if(!isset($templatecache[$template]))
{
$filename = './templates/' . $template . '.tpl';
if(file_exists($filename)
&& is_readable($filename))
{
$templatefile = addcslashes(file_get_contents($filename), '"\\');
// loop through template more than once in case we have an "if"-statement in another one
while(preg_match('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', $templatefile))
{
$templatefile = preg_replace('/<if[ \t]*(.*)>(.*)(<\/if>|<else>(.*)<\/if>)/Uis', '".( ($1) ? ("$2") : ("$4") )."', $templatefile);
}
}
else
{
$templatefile = 'TEMPLATE NOT FOUND: ' . $filename;
}
$templatecache[$template] = $templatefile;
}
return $templatecache[$template];
}

View File

@@ -1,64 +1,64 @@
<?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$
*/
/**
* Return HTML Code for a checkbox
*
* @param string The fieldname
* @param string The captions
* @param string The Value which will be returned
* @param bool Add a <br /> at the end of the checkbox
* @param string Values which will be selected by default
* @param bool Whether the title may contain html or not
* @param bool Whether the value may contain html or not
* @return string HTML Code
* @author Michael Kaufmann <mkaufmann@nutime.de>
*/
function makecheckbox($name, $title, $value, $break = false, $selvalue = NULL, $title_trusted = false, $value_trusted = false)
{
if($selvalue !== NULL
&& $value == $selvalue)
{
$checked = 'checked="checked"';
}
else
{
$checked = '';
}
if(!$title_trusted)
{
$title = htmlspecialchars($title);
}
if(!$value_trusted)
{
$value = htmlspecialchars($value);
}
$checkbox = '<input type="checkbox" name="' . $name . '" value="' . $value . '" ' . $checked . ' />&nbsp;' . $title;
if($break)
{
$checkbox.= '<br />';
}
return $checkbox;
}
<?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$
*/
/**
* Return HTML Code for a checkbox
*
* @param string The fieldname
* @param string The captions
* @param string The Value which will be returned
* @param bool Add a <br /> at the end of the checkbox
* @param string Values which will be selected by default
* @param bool Whether the title may contain html or not
* @param bool Whether the value may contain html or not
* @return string HTML Code
* @author Michael Kaufmann <mkaufmann@nutime.de>
*/
function makecheckbox($name, $title, $value, $break = false, $selvalue = NULL, $title_trusted = false, $value_trusted = false)
{
if($selvalue !== NULL
&& $value == $selvalue)
{
$checked = 'checked="checked"';
}
else
{
$checked = '';
}
if(!$title_trusted)
{
$title = htmlspecialchars($title);
}
if(!$value_trusted)
{
$value = htmlspecialchars($value);
}
$checkbox = '<input type="checkbox" name="' . $name . '" value="' . $value . '" ' . $checked . ' />&nbsp;' . $title;
if($break)
{
$checkbox.= '<br />';
}
return $checkbox;
}

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$
*/
/**
* Return HTML Code for an option within a <select>
*
* @param string The caption
* @param string The Value which will be returned
* @param string Values which will be selected by default.
* @param bool Whether the title may contain html or not
* @param bool Whether the value may contain html or not
* @return string HTML Code
* @author Florian Lippert <flo@syscp.org>
*/
function makeoption($title, $value, $selvalue = NULL, $title_trusted = false, $value_trusted = false)
{
if($selvalue !== NULL
&& ((is_array($selvalue) && in_array($value, $selvalue)) || $value == $selvalue))
{
$selected = 'selected="selected"';
}
else
{
$selected = '';
}
if(!$title_trusted)
{
$title = htmlspecialchars($title);
}
if(!$value_trusted)
{
$value = htmlspecialchars($value);
}
$option = '<option value="' . $value . '" ' . $selected . ' >' . $title . '</option>';
return $option;
}
<?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$
*/
/**
* Return HTML Code for an option within a <select>
*
* @param string The caption
* @param string The Value which will be returned
* @param string Values which will be selected by default.
* @param bool Whether the title may contain html or not
* @param bool Whether the value may contain html or not
* @return string HTML Code
* @author Florian Lippert <flo@syscp.org>
*/
function makeoption($title, $value, $selvalue = NULL, $title_trusted = false, $value_trusted = false)
{
if($selvalue !== NULL
&& ((is_array($selvalue) && in_array($value, $selvalue)) || $value == $selvalue))
{
$selected = 'selected="selected"';
}
else
{
$selected = '';
}
if(!$title_trusted)
{
$title = htmlspecialchars($title);
}
if(!$value_trusted)
{
$value = htmlspecialchars($value);
}
$option = '<option value="' . $value . '" ' . $selected . ' >' . $title . '</option>';
return $option;
}

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$
*/
/**
* Returns HTML Code for two radio buttons with two choices: yes and no
*
* @param string Name of HTML-Variable
* @param string Value which will be returned if user chooses yes
* @param string Value which will be returned if user chooses no
* @param string Value which is chosen by default
* @return string HTML Code
* @author Florian Lippert <flo@syscp.org>
*/
function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '')
{
global $lng;
return '<select class="dropdown_noborder" name="' . $name . '"><option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . $lng['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . $lng['panel']['no'] . '</option></select>';
}
<?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$
*/
/**
* Returns HTML Code for two radio buttons with two choices: yes and no
*
* @param string Name of HTML-Variable
* @param string Value which will be returned if user chooses yes
* @param string Value which will be returned if user chooses no
* @param string Value which is chosen by default
* @return string HTML Code
* @author Florian Lippert <flo@syscp.org>
*/
function makeyesno($name, $yesvalue, $novalue = '', $yesselected = '')
{
global $lng;
return '<select class="dropdown_noborder" name="' . $name . '"><option value="' . $yesvalue . '"' . ($yesselected ? ' selected="selected"' : '') . '>' . $lng['panel']['yes'] . '</option><option value="' . $novalue . '"' . ($yesselected ? '' : ' selected="selected"') . '>' . $lng['panel']['no'] . '</option></select>';
}

View File

@@ -1,92 +1,92 @@
<?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$
*/
/**
* Sends an header ( 'Location ...' ) to the browser.
*
* @param string Destination
* @param array Get-Variables
* @param boolean if the target we are creating for a redirect
* should be a relative or an absolute url
*
* @return boolean false if params is not an array
*
* @author Florian Lippert <flo@syscp.org>
* @author Martin Burchert <eremit@syscp.org>
*
* @changes martin@2005-01-29
* - added isRelative parameter
* - speed up the url generation
* - fixed bug #91
*/
function redirectTo($destination, $get_variables = array(), $isRelative = false)
{
$params = array();
if(is_array($get_variables))
{
foreach($get_variables as $key => $value)
{
$params[] = urlencode($key) . '=' . urlencode($value);
}
$params = '?' . implode($params, '&');
if($isRelative)
{
$protocol = '';
$host = '';
$path = './';
}
else
{
if(isset($_SERVER['HTTPS'])
&& strtolower($_SERVER['HTTPS']) == 'on')
{
$protocol = 'https://';
}
else
{
$protocol = 'http://';
}
$host = $_SERVER['HTTP_HOST'];
if(dirname($_SERVER['PHP_SELF']) == '/')
{
$path = '/';
}
else
{
$path = dirname($_SERVER['PHP_SELF']) . '/';
}
}
header('Location: ' . $protocol . $host . $path . $destination . $params);
exit;
}
elseif($get_variables == null)
{
header('Location: ' . $destination);
exit;
}
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$
*/
/**
* Sends an header ( 'Location ...' ) to the browser.
*
* @param string Destination
* @param array Get-Variables
* @param boolean if the target we are creating for a redirect
* should be a relative or an absolute url
*
* @return boolean false if params is not an array
*
* @author Florian Lippert <flo@syscp.org>
* @author Martin Burchert <eremit@syscp.org>
*
* @changes martin@2005-01-29
* - added isRelative parameter
* - speed up the url generation
* - fixed bug #91
*/
function redirectTo($destination, $get_variables = array(), $isRelative = false)
{
$params = array();
if(is_array($get_variables))
{
foreach($get_variables as $key => $value)
{
$params[] = urlencode($key) . '=' . urlencode($value);
}
$params = '?' . implode($params, '&');
if($isRelative)
{
$protocol = '';
$host = '';
$path = './';
}
else
{
if(isset($_SERVER['HTTPS'])
&& strtolower($_SERVER['HTTPS']) == 'on')
{
$protocol = 'https://';
}
else
{
$protocol = 'http://';
}
$host = $_SERVER['HTTP_HOST'];
if(dirname($_SERVER['PHP_SELF']) == '/')
{
$path = '/';
}
else
{
$path = dirname($_SERVER['PHP_SELF']) . '/';
}
}
header('Location: ' . $protocol . $host . $path . $destination . $params);
exit;
}
elseif($get_variables == null)
{
header('Location: ' . $destination);
exit;
}
return false;
}

View File

@@ -1,67 +1,67 @@
<?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$
*/
/**
* Prints one ore more errormessages on screen
*
* @param array Errormessages
* @param string A %s in the errormessage will be replaced by this string.
* @author Florian Lippert <flo@syscp.org>
* @author Ron Brand <ron.brand@web.de>
*/
function standard_error($errors = '', $replacer = '')
{
global $db, $userinfo, $s, $header, $footer, $lng;
$replacer = htmlentities($replacer);
if(!is_array($errors))
{
$errors = array(
$errors
);
}
$error = '';
foreach($errors as $single_error)
{
if(isset($lng['error'][$single_error]))
{
$single_error = $lng['error'][$single_error];
$single_error = strtr($single_error, array('%s' => $replacer));
}
else
{
$error = 'Unknown Error (' . $single_error . '): ' . $replacer;
break;
}
if(empty($error))
{
$error = $single_error;
}
else
{
$error.= ' ' . $single_error;
}
}
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
exit;
}
<?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$
*/
/**
* Prints one ore more errormessages on screen
*
* @param array Errormessages
* @param string A %s in the errormessage will be replaced by this string.
* @author Florian Lippert <flo@syscp.org>
* @author Ron Brand <ron.brand@web.de>
*/
function standard_error($errors = '', $replacer = '')
{
global $db, $userinfo, $s, $header, $footer, $lng;
$replacer = htmlentities($replacer);
if(!is_array($errors))
{
$errors = array(
$errors
);
}
$error = '';
foreach($errors as $single_error)
{
if(isset($lng['error'][$single_error]))
{
$single_error = $lng['error'][$single_error];
$single_error = strtr($single_error, array('%s' => $replacer));
}
else
{
$error = 'Unknown Error (' . $single_error . '): ' . $replacer;
break;
}
if(empty($error))
{
$error = $single_error;
}
else
{
$error.= ' ' . $single_error;
}
}
eval("echo \"" . getTemplate('misc/error', '1') . "\";");
exit;
}

View File

@@ -1,57 +1,57 @@
<?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$
*/
/**
* Prints one ore more errormessages on screen
*
* @param array Errormessages
* @param string A %s in the errormessage will be replaced by this string.
* @author Florian Lippert <flo@syscp.org>
*/
function standard_success($success_message = '', $replacer = '', $params = array())
{
global $s, $header, $footer, $lng;
if(isset($lng['success'][$success_message]))
{
$success_message = strtr($lng['success'][$success_message], array('%s' => htmlentities($replacer)));
}
if(is_array($params) && isset($params['filename']))
{
$redirect_url = $params['filename'] . '?s=' . $s;
unset($params['filename']);
foreach($params as $varname => $value)
{
if($value != '')
{
$redirect_url .= '&amp;' . $varname . '=' . $value;
}
}
}
else
{
$redirect_url = '';
}
eval("echo \"" . getTemplate('misc/success', '1') . "\";");
exit;
}
<?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$
*/
/**
* Prints one ore more errormessages on screen
*
* @param array Errormessages
* @param string A %s in the errormessage will be replaced by this string.
* @author Florian Lippert <flo@syscp.org>
*/
function standard_success($success_message = '', $replacer = '', $params = array())
{
global $s, $header, $footer, $lng;
if(isset($lng['success'][$success_message]))
{
$success_message = strtr($lng['success'][$success_message], array('%s' => htmlentities($replacer)));
}
if(is_array($params) && isset($params['filename']))
{
$redirect_url = $params['filename'] . '?s=' . $s;
unset($params['filename']);
foreach($params as $varname => $value)
{
if($value != '')
{
$redirect_url .= '&amp;' . $varname . '=' . $value;
}
}
}
else
{
$redirect_url = '';
}
eval("echo \"" . getTemplate('misc/success', '1') . "\";");
exit;
}

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 array_merge_prefix($array1, $key_prefix, $array2)
{
if(is_array($array1) && is_array($array2))
{
if($key_prefix != '')
{
foreach($array2 as $key => $value)
{
$array1[$key_prefix . '_' . $key] = $value;
unset($array2[$key]);
}
unset($array2);
return $array1;
}
else
{
return array_merge($array1, $array2);
}
}
else
{
return $array1;
}
}
<?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 array_merge_prefix($array1, $key_prefix, $array2)
{
if(is_array($array1) && is_array($array2))
{
if($key_prefix != '')
{
foreach($array2 as $key => $value)
{
$array1[$key_prefix . '_' . $key] = $value;
unset($array2[$key]);
}
unset($array2);
return $array1;
}
else
{
return array_merge($array1, $array2);
}
}
else
{
return $array1;
}
}

View File

@@ -1,46 +1,46 @@
<?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$
*/
/**
* Returns Array, whose elements have been checked whether thay are empty or not
*
* @param array The array to trim
* @return array The trim'med array
* @author Florian Lippert <flo@syscp.org>
*/
function array_trim($source)
{
$returnval = array();
if(is_array($source))
{
while(list($var, $val) = each($source))
{
if($val != ' '
&& $val != '')$returnval[$var] = $val;
}
}
else
{
$returnval = $source;
}
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$
*/
/**
* Returns Array, whose elements have been checked whether thay are empty or not
*
* @param array The array to trim
* @return array The trim'med array
* @author Florian Lippert <flo@syscp.org>
*/
function array_trim($source)
{
$returnval = array();
if(is_array($source))
{
while(list($var, $val) = each($source))
{
if($val != ' '
&& $val != '')$returnval[$var] = $val;
}
}
else
{
$returnval = $source;
}
return $returnval;
}

View File

@@ -1,40 +1,40 @@
<?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$
*/
/**
* 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;
}
<?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$
*/
/**
* 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;
}

View File

@@ -1,69 +1,69 @@
<?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$
*/
/**
* 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 = 'ISO-8859-1')
{
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;
}
<?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$
*/
/**
* 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 = 'ISO-8859-1')
{
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;
}

View File

@@ -1,36 +1,36 @@
<?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$
*/
/**
* 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)
{
while($string != html_entity_decode($string))
{
$string = html_entity_decode($string);
}
return $string;
}
<?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$
*/
/**
* 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)
{
while($string != html_entity_decode($string))
{
$string = html_entity_decode($string);
}
return $string;
}

View File

@@ -1,60 +1,60 @@
<?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$
*/
/**
* 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_COMPAT, $charset = 'ISO-8859-1')
{
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;
}
<?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$
*/
/**
* 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_COMPAT, $charset = 'ISO-8859-1')
{
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;
}

View File

@@ -1,40 +1,40 @@
<?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$
*/
/**
* Returns an integer of the given value which isn't negative.
* Returns -1 if the given value was -1.
*
* @param any The value
* @return int The positive value
* @author Florian Lippert <flo@syscp.org>
*/
function intval_ressource($the_value)
{
$the_value = intval($the_value);
if($the_value < 0
&& $the_value != '-1')
{
$the_value*= - 1;
}
return $the_value;
}
<?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$
*/
/**
* Returns an integer of the given value which isn't negative.
* Returns -1 if the given value was -1.
*
* @param any The value
* @return int The positive value
* @author Florian Lippert <flo@syscp.org>
*/
function intval_ressource($the_value)
{
$the_value = intval($the_value);
if($the_value < 0
&& $the_value != '-1')
{
$the_value*= - 1;
}
return $the_value;
}

View File

@@ -1,58 +1,58 @@
<?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$
*/
/**
* Replaces all occurences of variables defined in the second argument
* in the first argument with their values.
*
* @param string The string that should be searched for variables
* @param array The array containing the variables with their values
* @return string The submitted string with the variables replaced.
* @author Michael Duergner
*/
function replace_variables($text, $vars)
{
$pattern = "/\{([a-zA-Z0-9\-_]+)\}/";
// --- martin @ 08.08.2005 -------------------------------------------------------
// fixing usage of uninitialised variable
$matches = array();
// -------------------------------------------------------------------------------
if(count($vars) > 0
&& preg_match_all($pattern, $text, $matches))
{
for ($i = 0;$i < count($matches[1]);$i++)
{
$current = $matches[1][$i];
if(isset($vars[$current]))
{
$var = $vars[$current];
$text = str_replace("{" . $current . "}", $var, $text);
}
}
}
$text = str_replace('\n', "\n", $text);
return $text;
}
<?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$
*/
/**
* Replaces all occurences of variables defined in the second argument
* in the first argument with their values.
*
* @param string The string that should be searched for variables
* @param array The array containing the variables with their values
* @return string The submitted string with the variables replaced.
* @author Michael Duergner
*/
function replace_variables($text, $vars)
{
$pattern = "/\{([a-zA-Z0-9\-_]+)\}/";
// --- martin @ 08.08.2005 -------------------------------------------------------
// fixing usage of uninitialised variable
$matches = array();
// -------------------------------------------------------------------------------
if(count($vars) > 0
&& preg_match_all($pattern, $text, $matches))
{
for ($i = 0;$i < count($matches[1]);$i++)
{
$current = $matches[1][$i];
if(isset($vars[$current]))
{
$var = $vars[$current];
$text = str_replace("{" . $current . "}", $var, $text);
}
}
}
$text = str_replace('\n', "\n", $text);
return $text;
}

View File

@@ -1,52 +1,52 @@
<?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$
*/
/**
* 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;
}
<?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$
*/
/**
* 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;
}

View File

@@ -1,69 +1,69 @@
<?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$
*/
/**
* 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;
}
<?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$
*/
/**
* 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;
}

View File

@@ -1,36 +1,36 @@
<?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$
*/
/**
* 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;
}
<?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$
*/
/**
* 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;
}

View File

@@ -1,33 +1,33 @@
<?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 getSetting($settinggroup, $varname)
{
global $settings;
if(isset($settings[$settinggroup]) && is_array($settings[$settinggroup]) && isset($settings[$settinggroup][$varname]))
{
return $settings[$settinggroup][$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 getSetting($settinggroup, $varname)
{
global $settings;
if(isset($settings[$settinggroup]) && is_array($settings[$settinggroup]) && isset($settings[$settinggroup][$varname]))
{
return $settings[$settinggroup][$varname];
}
else
{
return false;
}
}
?>

View File

@@ -1,60 +1,60 @@
<?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 loadSettings($settings_data, $db)
{
$settings = array();
if(is_array($settings_data) && isset($settings_data['groups']) && is_array($settings_data['groups']))
{
foreach($settings_data['groups'] as $settings_part => $settings_part_details)
{
if(is_array($settings_part_details) && isset($settings_part_details['fields']) && is_array($settings_part_details['fields']))
{
foreach($settings_part_details['fields'] as $field_name => $field_details)
{
if(isset($field_details['settinggroup']) && isset($field_details['varname']) && isset($field_details['default']))
{
$row = $db->query_first('SELECT `settinggroup`, `varname`, `value` FROM `' . TABLE_PANEL_SETTINGS . '` WHERE `settinggroup` = \'' . $db->escape($field_details['settinggroup']) . '\' AND `varname` = \'' . $db->escape($field_details['varname']) . '\' ');
if(!empty($row))
{
$varvalue = $row['value'];
}
else
{
$varvalue = $field_details['default'];
}
$settings[$field_details['settinggroup']][$field_details['varname']] = $varvalue;
}
else
{
$varvalue = false;
}
$settings_data['groups'][$settings_part]['fields'][$field_name]['value'] = $varvalue;
}
}
}
}
return $settings;
}
?>
<?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 loadSettings($settings_data, $db)
{
$settings = array();
if(is_array($settings_data) && isset($settings_data['groups']) && is_array($settings_data['groups']))
{
foreach($settings_data['groups'] as $settings_part => $settings_part_details)
{
if(is_array($settings_part_details) && isset($settings_part_details['fields']) && is_array($settings_part_details['fields']))
{
foreach($settings_part_details['fields'] as $field_name => $field_details)
{
if(isset($field_details['settinggroup']) && isset($field_details['varname']) && isset($field_details['default']))
{
$row = $db->query_first('SELECT `settinggroup`, `varname`, `value` FROM `' . TABLE_PANEL_SETTINGS . '` WHERE `settinggroup` = \'' . $db->escape($field_details['settinggroup']) . '\' AND `varname` = \'' . $db->escape($field_details['varname']) . '\' ');
if(!empty($row))
{
$varvalue = $row['value'];
}
else
{
$varvalue = $field_details['default'];
}
$settings[$field_details['settinggroup']][$field_details['varname']] = $varvalue;
}
else
{
$varvalue = false;
}
$settings_data['groups'][$settings_part]['fields'][$field_name]['value'] = $varvalue;
}
}
}
}
return $settings;
}
?>

View File

@@ -1,27 +1,27 @@
<?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 saveSetting($settinggroup, $varname, $newvalue)
{
global $db;
$query = 'UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = \'' . $db->escape($newvalue) . '\' WHERE `settinggroup` = \'' . $db->escape($settinggroup) . '\' AND `varname`=\'' . $db->escape($varname) . '\'';
return $db->query($query);
}
?>
<?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 saveSetting($settinggroup, $varname, $newvalue)
{
global $db;
$query = 'UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = \'' . $db->escape($newvalue) . '\' WHERE `settinggroup` = \'' . $db->escape($settinggroup) . '\' AND `varname`=\'' . $db->escape($varname) . '\'';
return $db->query($query);
}
?>

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$
*/
function storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'defaultip')
{
global $db;
$customerstddomains_result = $db->query('SELECT `standardsubdomain` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `standardsubdomain` <> \'0\'');
$ids = array();
while($customerstddomains_row = $db->fetch_array($customerstddomains_result))
{
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
}
if(count($ids) > 0)
{
$db->query('UPDATE `' . TABLE_PANEL_DOMAINS . '` SET `ipandport`=\'' . (int)$newfieldvalue . '\' WHERE `id` IN (\'' . implode('\',\'', $ids) . '\') AND `ipandport` = \'' . $db->escape(getSetting('system', 'defaultip')) . '\'');
}
inserttask('1');
}
return $returnvalue;
}
?>
<?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 storeSettingDefaultIp($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'defaultip')
{
global $db;
$customerstddomains_result = $db->query('SELECT `standardsubdomain` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `standardsubdomain` <> \'0\'');
$ids = array();
while($customerstddomains_row = $db->fetch_array($customerstddomains_result))
{
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
}
if(count($ids) > 0)
{
$db->query('UPDATE `' . TABLE_PANEL_DOMAINS . '` SET `ipandport`=\'' . (int)$newfieldvalue . '\' WHERE `id` IN (\'' . implode('\',\'', $ids) . '\') AND `ipandport` = \'' . $db->escape(getSetting('system', 'defaultip')) . '\'');
}
inserttask('1');
}
return $returnvalue;
}
?>

View File

@@ -1,59 +1,59 @@
<?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 storeSettingField($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '')
{
if(saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false)
{
return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue);
}
else
{
return false;
}
}
else
{
return false;
}
}
function storeSettingFieldInsertBindTask($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '')
{
if(saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false)
{
inserttask('4');
return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue);
}
else
{
return false;
}
}
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 storeSettingField($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '')
{
if(saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false)
{
return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue);
}
else
{
return false;
}
}
else
{
return false;
}
}
function storeSettingFieldInsertBindTask($fieldname, $fielddata, $newfieldvalue)
{
if(is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] != '' && isset($fielddata['varname']) && $fielddata['varname'] != '')
{
if(saveSetting($fielddata['settinggroup'], $fielddata['varname'], $newfieldvalue) != false)
{
inserttask('4');
return array($fielddata['settinggroup'] . '.' . $fielddata['varname'] => $newfieldvalue);
}
else
{
return false;
}
}
else
{
return false;
}
}
?>

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$
*/
function storeSettingHostname($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'hostname')
{
global $db, $idna_convert;
$newfieldvalue = $idna_convert->encode($newfieldvalue);
$customerstddomains_result = $db->query('SELECT `standardsubdomain` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `standardsubdomain` <> \'0\'');
$ids = array();
while($customerstddomains_row = $db->fetch_array($customerstddomains_result))
{
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
}
if(count($ids) > 0)
{
$db->query('UPDATE `' . TABLE_PANEL_DOMAINS . '` SET `domain` = REPLACE(`domain`, \'' . $db->escape(getSetting('system', 'hostname')) . '\', \'' . $db->escape($newfieldvalue) . '\') WHERE `id` IN (\'' . implode('\',\'', $ids) . '\')');
inserttask('1');
}
}
return $returnvalue;
}
?>
<?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 storeSettingHostname($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'hostname')
{
global $db, $idna_convert;
$newfieldvalue = $idna_convert->encode($newfieldvalue);
$customerstddomains_result = $db->query('SELECT `standardsubdomain` FROM `' . TABLE_PANEL_CUSTOMERS . '` WHERE `standardsubdomain` <> \'0\'');
$ids = array();
while($customerstddomains_row = $db->fetch_array($customerstddomains_result))
{
$ids[] = (int)$customerstddomains_row['standardsubdomain'];
}
if(count($ids) > 0)
{
$db->query('UPDATE `' . TABLE_PANEL_DOMAINS . '` SET `domain` = REPLACE(`domain`, \'' . $db->escape(getSetting('system', 'hostname')) . '\', \'' . $db->escape($newfieldvalue) . '\') WHERE `id` IN (\'' . implode('\',\'', $ids) . '\')');
inserttask('1');
}
}
return $returnvalue;
}
?>

View File

@@ -1,37 +1,37 @@
<?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 storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'ipaddress')
{
$mysql_access_host_array = array_map('trim', explode(',', getSetting('system', 'mysql_access_host')));
$mysql_access_host_array[] = $newfieldvalue;
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
$mysql_access_host = implode(',', $mysql_access_host_array);
correctMysqlUsers($mysql_access_host_array);
saveSetting('system', 'mysql_access_host', $mysql_access_host);
}
return $returnvalue;
}
?>
<?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 storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'ipaddress')
{
$mysql_access_host_array = array_map('trim', explode(',', getSetting('system', 'mysql_access_host')));
$mysql_access_host_array[] = $newfieldvalue;
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
$mysql_access_host = implode(',', $mysql_access_host_array);
correctMysqlUsers($mysql_access_host_array);
saveSetting('system', 'mysql_access_host', $mysql_access_host);
}
return $returnvalue;
}
?>

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 storeSettingMysqlAccessHost($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'mysql_access_host')
{
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
if(in_array('127.0.0.1', $mysql_access_host_array)
&& !in_array('localhost', $mysql_access_host_array))
{
$mysql_access_host_array[] = 'localhost';
}
if(!in_array('127.0.0.1', $mysql_access_host_array)
&& in_array('localhost', $mysql_access_host_array))
{
$mysql_access_host_array[] = '127.0.0.1';
}
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
$newfieldvalue = implode(',', $mysql_access_host_array);
correctMysqlUsers($mysql_access_host_array);
}
return $returnvalue;
}
?>
<?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 storeSettingMysqlAccessHost($fieldname, $fielddata, $newfieldvalue)
{
$returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
if($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'mysql_access_host')
{
$mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
if(in_array('127.0.0.1', $mysql_access_host_array)
&& !in_array('localhost', $mysql_access_host_array))
{
$mysql_access_host_array[] = 'localhost';
}
if(!in_array('127.0.0.1', $mysql_access_host_array)
&& in_array('localhost', $mysql_access_host_array))
{
$mysql_access_host_array[] = '127.0.0.1';
}
$mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
$newfieldvalue = implode(',', $mysql_access_host_array);
correctMysqlUsers($mysql_access_host_array);
}
return $returnvalue;
}
?>

View File

@@ -12,7 +12,7 @@
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Language
* @version $Id: 185.spf.php 106 2010-01-25 10:06:34Z d00p $
* @version $Id$
*/
/*

Some files were not shown because too many files have changed in this diff Show More