finally removed super-old syscp-update-procedures, we now require the last available syscp for upgrading; migrate some functions to PDO database class, refs #1287

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-11-03 10:54:43 +01:00
parent c9d91d178b
commit e549ab2cbb
21 changed files with 223 additions and 3049 deletions

View File

@@ -1,82 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Install
*
*/
/**
* We need those defines, because the tables.inc.php doesn't have them.
*/
define('TABLE_POSTFIX_TRANSPORT', 'postfix_transport');
define('TABLE_POSTFIX_USERS', 'postfix_users');
define('TABLE_POSTFIX_VIRTUAL', 'postfix_virtual');
define('TABLE_PROFTPD_GROUPS', 'proftpd_groups');
define('TABLE_PROFTPD_USERS', 'proftpd_users');
if($settings['panel']['version'] == '1.0.10')
{
// Drop/Rename postfix_ tables
$db->query("DROP TABLE IF EXISTS `" . TABLE_POSTFIX_TRANSPORT . "`");
$db->query("ALTER TABLE `" . TABLE_POSTFIX_USERS . "` RENAME `" . TABLE_MAIL_USERS . "` ");
$db->query("ALTER TABLE `" . TABLE_POSTFIX_VIRTUAL . "` RENAME `" . TABLE_MAIL_VIRTUAL . "` ");
// Rename proftpd_ tables
$db->query("ALTER TABLE `" . TABLE_PROFTPD_USERS . "` RENAME `" . TABLE_FTP_USERS . "` ");
$db->query("ALTER TABLE `" . TABLE_PROFTPD_GROUPS . "` RENAME `" . TABLE_FTP_GROUPS . "` ");
// Adding tables
$db->query("DROP TABLE IF EXISTS `" . TABLE_PANEL_HTACCESS . "`;");
$db->query("CREATE TABLE `" . TABLE_PANEL_HTACCESS . "` (" . " `id` int(11) unsigned NOT NULL auto_increment," . " `customerid` int(11) unsigned NOT NULL default '0'," . " `path` varchar(255) NOT NULL default ''," . " `options_indexes` tinyint(1) NOT NULL default '0'," . " PRIMARY KEY (`id`)" . ") ENGINE=MyISAM ;");
$db->query("DROP TABLE IF EXISTS `" . TABLE_PANEL_ADMINS . "`;");
$db->query("CREATE TABLE `" . TABLE_PANEL_ADMINS . "` (" . " `adminid` int(11) unsigned NOT NULL auto_increment," . " `loginname` varchar(50) NOT NULL default ''," . " `password` varchar(50) NOT NULL default ''," . " `name` varchar(255) NOT NULL default ''," . " `email` varchar(255) NOT NULL default ''," . " `customers` int(15) NOT NULL default '0'," . " `customers_used` int(15) NOT NULL default '0'," . " `customers_see_all` tinyint(1) NOT NULL default '0'," . " `domains` int(15) NOT NULL default '0'," . " `domains_used` int(15) NOT NULL default '0'," . " `domains_see_all` tinyint(1) NOT NULL default '0'," . " `change_serversettings` tinyint(1) NOT NULL default '0'," . " `diskspace` int(15) NOT NULL default '0'," . " `diskspace_used` int(15) NOT NULL default '0'," . " `mysqls` int(15) NOT NULL default '0'," . " `mysqls_used` int(15) NOT NULL default '0'," . " `emails` int(15) NOT NULL default '0'," . " `emails_used` int(15) NOT NULL default '0'," . " `email_forwarders` int(15) NOT NULL default '0'," . " `email_forwarders_used` int(15) NOT NULL default '0'," . " `ftps` int(15) NOT NULL default '0'," . " `ftps_used` int(15) NOT NULL default '0'," . " `subdomains` int(15) NOT NULL default '0'," . " `subdomains_used` int(15) NOT NULL default '0'," . " `traffic` int(15) NOT NULL default '0'," . " `traffic_used` int(15) NOT NULL default '0'," . " `deactivated` tinyint(1) NOT NULL default '0'," . " `lastlogin_succ` int(11) unsigned NOT NULL default '0'," . " `lastlogin_fail` int(11) unsigned NOT NULL default '0'," . " `loginfail_count` int(11) unsigned NOT NULL default '0'," . " PRIMARY KEY (`adminid`)" . ") ENGINE=MyISAM ;");
// Insert Admin user
if(!isset($adminusername)
|| $adminusername == '')
{
$adminusername = 'admin';
$adminpassword = 'admin';
}
$db->query("INSERT INTO `" . TABLE_PANEL_ADMINS . "` (`loginname`, `password`, `name`, `email`, `customers`, `customers_used`, `customers_see_all`, `domains`, `domains_used`, `domains_see_all`, `change_serversettings`, `diskspace`, `diskspace_used`, `mysqls`, `mysqls_used`, `emails`, `emails_used`, `email_forwarders`, `email_forwarders_used`, `ftps`, `ftps_used`, `subdomains`, `subdomains_used`, `traffic`, `traffic_used`, `deactivated`) VALUES ('" . $db->escape($adminusername) . "', '" . md5($adminpassword) . "', 'Siteadmin', 'admin@servername', -1, 0, 1, -1, 0, 1, 1, -1024, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1048576, 0, 0);");
// Alter Tables
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `adminid` INT( 11 ) UNSIGNED NOT NULL ," . "ADD `lastlogin_succ` INT( 11 ) UNSIGNED NOT NULL ," . "ADD `lastlogin_fail` INT( 11 ) UNSIGNED NOT NULL ," . "ADD `loginfail_count` INT( 11 ) UNSIGNED NOT NULL ;");
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD INDEX ( `adminid` ) ;");
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `adminid` = '1'");
$db->query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` ADD `adminid` INT( 11 ) UNSIGNED NOT NULL ," . "ADD `iswildcarddomain` TINYINT( 1 ) NOT NULL ," . "ADD `speciallogfile` TINYINT( 1 ) NOT NULL ;");
$db->query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` ADD INDEX ( `adminid` ) ;");
$db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `adminid` = '1'");
$db->query("ALTER TABLE `" . TABLE_PANEL_SESSIONS . "` CHANGE `customerid` `userid` INT( 11 ) UNSIGNED DEFAULT '0' NOT NULL ");
$db->query("ALTER TABLE `" . TABLE_MAIL_USERS . "` CHANGE `password` `password_enc` VARCHAR( 128 ) NOT NULL ");
$db->query("ALTER TABLE `" . TABLE_MAIL_USERS . "` ADD `password` VARCHAR( 128 ) NOT NULL AFTER `email` ;");
$db->query("INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (24, 'login', 'maxloginattempts', '3');");
$db->query("INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (25, 'login', 'deactivatetime', '900');");
$db->query("INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (26, 'panel', 'webmail_url', '');");
$db->query("INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (27, 'panel', 'webftp_url', '');");
$db->query("INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (28, 'panel', 'standardlanguage', 'german');");
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `varname`='ipaddress' WHERE `settinggroup`='system' AND `varname`='ipadress'");
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.2.0' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.2.0';
}
?>

View File

@@ -1,132 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Install
*
*/
define('TABLE_POSTFIX_TRANSPORT', 'postfix_transport');
define('TABLE_POSTFIX_USERS', 'postfix_users');
define('TABLE_POSTFIX_VIRTUAL', 'postfix_virtual');
define('TABLE_PROFTPD_GROUPS', 'proftpd_groups');
define('TABLE_PROFTPD_USERS', 'proftpd_users');
if(!isset($settings['panel']['version']))
{
$settings['panel']['version'] = '1.0.0';
}
if($settings['panel']['version'] == '1.0.0')
{
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '1.0.1')");
$db->query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` ADD `openbasedir` TINYINT( 1 ) NOT NULL , ADD `safemode` TINYINT( 1 ) NOT NULL");
$db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `openbasedir`='1', `safemode`='1'");
$settings['panel']['version'] = '1.0.1';
}
if($settings['panel']['version'] == '1.0.1')
{
$db->query("ALTER TABLE `" . TABLE_POSTFIX_USERS . "` ADD `domainid` INT( 11 ) NOT NULL AFTER `postfix`");
$db->query("ALTER TABLE `" . TABLE_POSTFIX_VIRTUAL . "` ADD `domainid` INT( 11 ) NOT NULL AFTER `destination`");
$result = $db->query("SELECT `id`, `domain` FROM `" . TABLE_PANEL_DOMAINS . "`");
while($row = $db->fetch_array($result))
{
$db->query("UPDATE `" . TABLE_POSTFIX_USERS . "` SET `domainid`='" . (int)$row['id'] . "' WHERE `email` LIKE '%@" . $db->escape($row['domain']) . "'");
$db->query("UPDATE `" . TABLE_POSTFIX_VIRTUAL . "` SET `domainid`='" . (int)$row['id'] . "' WHERE `email` LIKE '%@" . $db->escape($row['domain']) . "'");
}
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `createstdsubdomain` TINYINT( 1 ) NOT NULL AFTER `documentroot`");
inserttask('1');
inserttask('4');
$hostname = explode('@', $settings['panel']['adminmail']);
$hostname = $hostname[1];
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (23, 'system', 'hostname', '" . $db->escape($hostname) . "')");
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.2' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.2';
}
if($settings['panel']['version'] == '1.0.2')
{
$db->query("ALTER TABLE `" . TABLE_PANEL_SESSIONS . "` ADD `language` VARCHAR( 64 ) NOT NULL AFTER `lastactivity` ;");
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.3' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.3';
}
if($settings['panel']['version'] == '1.0.3')
{
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.4' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.4';
}
if($settings['panel']['version'] == '1.0.4')
{
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.5' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.5';
}
if($settings['panel']['version'] == '1.0.5')
{
$db->query("ALTER TABLE `" . TABLE_PANEL_CUSTOMERS . "` ADD `deactivated` TINYINT( 1 ) NOT NULL ;");
$db->query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` ADD `deactivated` TINYINT( 1 ) NOT NULL ;");
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.6' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.6';
}
if($settings['panel']['version'] == '1.0.6')
{
$db->query("ALTER TABLE `" . TABLE_POSTFIX_VIRTUAL . "` ADD `popaccountid` INT( 11 ) NOT NULL ;");
$result = $db->query("SELECT `id`, `email` FROM `" . TABLE_POSTFIX_USERS . "`");
while($row = $db->fetch_array($result))
{
$db->query("UPDATE `" . TABLE_POSTFIX_VIRTUAL . "` SET `popaccountid`='" . (int)$row['id'] . "' WHERE `email` = '" . $db->escape(str_replace($settings['email']['catchallkeyword'], '', $row['email'])) . "' AND `destination` = '" . $db->escape($row['email']) . "'");
}
$result = $db->query("SELECT `id`, `email`, `destination` FROM `" . TABLE_POSTFIX_VIRTUAL . "` WHERE `popaccountid` = '0'");
while($row = $db->fetch_array($result))
{
if(str_replace($settings['email']['catchallkeyword'], '', $row['email']) != $row['email'])
{
$db->query("UPDATE `" . TABLE_POSTFIX_VIRTUAL . "` SET `email` = '" . $db->escape(str_replace($settings['email']['catchallkeyword'], '', $row['email'])) . "' WHERE `id` = '" . (int)$row['id'] . "'");
}
}
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.7' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.7';
}
if($settings['panel']['version'] == '1.0.7')
{
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.8' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.8';
}
if($settings['panel']['version'] == '1.0.8')
{
$db->query("ALTER TABLE `" . TABLE_PANEL_DATABASES . "` DROP `password` ;");
$db->query("ALTER TABLE `" . TABLE_PANEL_DOMAINS . "` ADD `specialsettings` TEXT NOT NULL AFTER `safemode` ;");
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.9' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.9';
}
if($settings['panel']['version'] == '1.0.9')
{
$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value`='1.0.10' WHERE `settinggroup`='panel' AND `varname`='version'");
$settings['panel']['version'] = '1.0.10';
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,120 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Install
*
*/
if($settings['panel']['version'] == '1.4')
{
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.4 to 1.4-svn1");
// Going to fix the stuff the update 1.2.19-svn42 to 1.2.19-svn43 broke
$result = $db->query("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `documentroot` LIKE 'http%';");
while($row = $db->fetch_array($result))
{
if(preg_match("#(https?)://?(.*)#i", $row['documentroot'], $matches))
{
$row['documentroot'] = $matches[1] . "://" . $matches[2];
$db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `documentroot` = '" . $db->escape($row['documentroot']) . "' WHERE `id` = '" . $row['id'] . "';");
}
}
// set new version
$query = 'UPDATE `%s` SET `value` = \'1.4-svn1\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
$query = sprintf($query, TABLE_PANEL_SETTINGS);
$db->query($query);
$settings['panel']['version'] = '1.4-svn1';
}
if($settings['panel']['version'] == '1.4-svn1')
{
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.4-svn1 to 1.4.1");
// set new version
$query = 'UPDATE `%s` SET `value` = \'1.4.1\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
$query = sprintf($query, TABLE_PANEL_SETTINGS);
$db->query($query);
$settings['panel']['version'] = '1.4.1';
}
if($settings['panel']['version'] == '1.4.1')
{
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.4.1 to 1.4.1-svn1");
// give at least ONE admin the permission to edit phpsettings, bug #1031
$cntCanEditPHP = $db->query_first("SELECT COUNT(`caneditphpsettings`) as `cnt` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `caneditphpsettings` = '1'");
if($cntCanEditPHP['cnt'] <= 0)
{
// none of the admins can edit php-settings,
//so we give those who can edit serversettings the right to edit php-settings
$db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `caneditphpsettings` = '1' WHERE `change_serversettings` = '1'");
}
// set new version
$query = 'UPDATE `%s` SET `value` = \'1.4.1-svn1\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
$query = sprintf($query, TABLE_PANEL_SETTINGS);
$db->query($query);
$settings['panel']['version'] = '1.4.1-svn1';
}
if($settings['panel']['version'] == '1.4.1-svn1')
{
$updateto = '1.4.1-svn2';
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from " . $settings['panel']['version'] . " to " . $updateto);
// set new version
$query = 'UPDATE `%s` SET `value` = \'' . $updateto . '\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
$query = sprintf($query, TABLE_PANEL_SETTINGS);
$db->query($query);
$settings['panel']['version'] = $updateto;
}
if($settings['panel']['version'] == '1.4.1-svn2')
{
$updateto = '1.4.1-svn3';
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from " . $settings['panel']['version'] . " to " . $updateto);
// set new version
$query = 'UPDATE `%s` SET `value` = \'' . $updateto . '\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
$query = sprintf($query, TABLE_PANEL_SETTINGS);
$db->query($query);
$settings['panel']['version'] = $updateto;
}
if($settings['panel']['version'] == '1.4.1-svn3')
{
$updateto = '1.4.2';
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from " . $settings['panel']['version'] . " to " . $updateto);
// set new version
$query = 'UPDATE `%s` SET `value` = \'' . $updateto . '\' WHERE `settinggroup` = \'panel\' AND `varname` = \'version\'';
$query = sprintf($query, TABLE_PANEL_SETTINGS);
$db->query($query);
$settings['panel']['version'] = $updateto;
}
?>

View File

@@ -1,122 +0,0 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions
*
*/
/**
* Returns 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

@@ -24,7 +24,7 @@
*/ */
function maildirExists($result = null) function maildirExists($result = null)
{ {
global $settings, $theme; global $settings;
if(is_array($result)) if(is_array($result))
{ {

View File

@@ -26,7 +26,7 @@
*/ */
function makeChownWithNewStats($row) function makeChownWithNewStats($row)
{ {
global $settings, $theme; global $settings;
// get correct user // get correct user
if($settings['system']['mod_fcgid'] == '1' && isset($row['deactivated']) && $row['deactivated'] == '0') if($settings['system']['mod_fcgid'] == '1' && isset($row['deactivated']) && $row['deactivated'] == '0')

View File

@@ -34,7 +34,7 @@
function makePathfield($path, $uid, $gid, $fieldType, $value = '', $dom = false) function makePathfield($path, $uid, $gid, $fieldType, $value = '', $dom = false)
{ {
global $lng, $theme; global $lng;
$value = str_replace($path, '', $value); $value = str_replace($path, '', $value);
$field = array(); $field = array();

View File

@@ -20,101 +20,33 @@
/** /**
* Wrapper around the exec command. * Wrapper around the exec command.
* *
* @author Martin Burchert <eremit@adm1n.de>
* @version 1.2
* @param string exec_string String to be executed * @param string exec_string String to be executed
*
* @return string The result of the exec() * @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) {
function safe_exec($exec_string, &$return_value = false) // check for bad signs in execute command
{ if ((stristr($exec_string, ';'))
global $settings, $theme; || (stristr($exec_string, '|'))
|| (stristr($exec_string, '&'))
// || (stristr($exec_string, '>'))
// define allowed system commands || (stristr($exec_string, '<'))
// || (stristr($exec_string, '`'))
|| (stristr($exec_string, '$'))
$allowed_commands = array( || (stristr($exec_string, '~'))
'touch', || (stristr($exec_string, '?'))
'chown', ) {
'mkdir',
'webalizer',
'cp',
'du',
'chmod',
'chattr',
'chflags', /* freebsd equivalent to linux' chattr */
$settings['system']['apachereload_command'],
$settings['system']['bindreload_command'],
$settings['dkim']['dkimrestart_command'],
'openssl',
'unzip',
'php',
'rm',
'awstats_buildstaticpages.pl',
'ln'
);
//
// 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"); 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");
} }
/*
* This is not needed anymore, we allow all commands and just check for pipes and stuff
//
// 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 // execute the command and return output
//
// --- martin @ 08.08.2005 -------------------------------------------------------
// fixing usage of uninitialised variable
$return = ''; $return = '';
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
if ($return_value == false) {
if($return_value == false)
{
exec($exec_string, $return); exec($exec_string, $return);
} } else {
else
{
exec($exec_string, $return, $return_value); exec($exec_string, $return, $return_value);
} }

View File

@@ -25,18 +25,26 @@
* *
* @return null * @return null
*/ */
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) {
{
global $db, $settings, $pathtophpfiles, $theme; global $settings;
if ($force if ($force
|| (int)$settings['system']['store_index_file_subs'] == 1 || (int)$settings['system']['store_index_file_subs'] == 1
) { ) {
$result = $db->query("SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login` FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a` ON `c`.`adminid` = `a`.`adminid` INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t` ON `a`.`adminid` = `t`.`adminid` WHERE `varname` = 'index_html' AND `c`.`loginname` = '" . $db->escape($loginname) . "'"); $result_stmt = Database::prepare("
SELECT `t`.`value`, `c`.`email` AS `customer_email`, `a`.`email` AS `admin_email`, `c`.`loginname` AS `customer_login`, `a`.`loginname` AS `admin_login`
if($db->num_rows($result) > 0) FROM `" . TABLE_PANEL_CUSTOMERS . "` AS `c` INNER JOIN `" . TABLE_PANEL_ADMINS . "` AS `a`
{ ON `c`.`adminid` = `a`.`adminid`
$template = $db->fetch_array($result); INNER JOIN `" . TABLE_PANEL_TEMPLATES . "` AS `t`
ON `a`.`adminid` = `t`.`adminid`
WHERE `varname` = 'index_html' AND `c`.`loginname` = :loginname");
Database::pexecute($result_stmt, array('loginname' => $loginname));
if (Database::num_rows() > 0) {
$template = $result_stmt->fetch(PDO::FETCH_ASSOC);
$replace_arr = array( $replace_arr = array(
'SERVERNAME' => $settings['system']['hostname'], 'SERVERNAME' => $settings['system']['hostname'],
'CUSTOMER' => $template['customer_login'], 'CUSTOMER' => $template['customer_login'],
@@ -44,6 +52,7 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
'CUSTOMER_EMAIL' => $template['customer_email'], 'CUSTOMER_EMAIL' => $template['customer_email'],
'ADMIN_EMAIL' => $template['admin_email'] 'ADMIN_EMAIL' => $template['admin_email']
); );
$htmlcontent = replace_variables($template['value'], $replace_arr); $htmlcontent = replace_variables($template['value'], $replace_arr);
$indexhtmlpath = makeCorrectFile($destination . '/index.' . $settings['system']['index_file_extension']); $indexhtmlpath = makeCorrectFile($destination . '/index.' . $settings['system']['index_file_extension']);
$index_html_handler = fopen($indexhtmlpath, 'w'); $index_html_handler = fopen($indexhtmlpath, 'w');
@@ -52,14 +61,13 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
if ($logger !== null) { if ($logger !== null) {
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . $settings['system']['index_file_extension'] . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath)); $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Creating \'index.' . $settings['system']['index_file_extension'] . '\' for Customer \'' . $template['customer_login'] . '\' based on template in directory ' . escapeshellarg($indexhtmlpath));
} }
}
else } else {
{
$destination = makeCorrectDir($destination); $destination = makeCorrectDir($destination);
if ($logger !== null) { if ($logger !== null) {
$logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); $logger->logAction(CRON_ACTION, LOG_NOTICE, 'Running: cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
} }
safe_exec('cp -a ' . $pathtophpfiles . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination)); safe_exec('cp -a ' . FROXLOR_INSTALL_DIR . '/templates/misc/standardcustomer/* ' . escapeshellarg($destination));
} }
} }
return; return;

View File

@@ -15,56 +15,48 @@
* *
*/ */
/* /**
* this functions validates a given value as ErrorDocument * this functions validates a given value as ErrorDocument
* refs #267 * refs #267
* *
* @param string error-document-string * @param string error-document-string
* *
* @return string error-document-string * @return string error-document-string
* *
*/ */
function correctErrorDocument($errdoc = null) function correctErrorDocument($errdoc = null) {
{
global $settings, $idna_convert, $theme;
if($errdoc !== null && $errdoc != '') global $settings, $idna_convert;
{
// not a URL if ($errdoc !== null && $errdoc != '') {
if((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:' // not a URL
&& strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:') if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:'
|| !validateUrl($idna_convert->encode($errdoc))) && strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:')
{ || !validateUrl($idna_convert->encode($errdoc))
// a file ) {
if(substr($errdoc, 0, 1) != '"') // a file
{ if (substr($errdoc, 0, 1) != '"') {
$errdoc = makeCorrectFile($errdoc); $errdoc = makeCorrectFile($errdoc);
// apache needs a starting-slash (starting at the domains-docroot) // apache needs a starting-slash (starting at the domains-docroot)
if(!substr($errdoc, 0, 1) == '/') { if (!substr($errdoc, 0, 1) == '/') {
$errdoc = '/'.$errdoc; $errdoc = '/'.$errdoc;
} }
} }
// a string (check for ending ") // a string (check for ending ")
else else {
{ // string won't work for lighty
// string won't work for lighty if ($settings['system']['webserver'] == 'lighttpd') {
if($settings['system']['webserver'] == 'lighttpd') standard_error('stringerrordocumentnotvalidforlighty');
{
standard_error('stringerrordocumentnotvalidforlighty'); } elseif(substr($errdoc, -1) != '"') {
} $errdoc .= '"';
elseif(substr($errdoc, -1) != '"') }
{ }
$errdoc .= '"'; } else {
} if ($settings['system']['webserver'] == 'lighttpd') {
} standard_error('urlerrordocumentnotvalidforlighty');
} }
else }
{ }
if($settings['system']['webserver'] == 'lighttpd') return $errdoc;
{ }
standard_error('urlerrordocumentnotvalidforlighty');
}
}
}
return $errdoc;
}

View File

@@ -22,50 +22,49 @@
* *
* @return array array of cron-files which are to be executed * @return array array of cron-files which are to be executed
*/ */
function getNextCronjobs() function getNextCronjobs() {
{
global $db, $theme;
$query = "SELECT `id`, `cronfile` FROM `".TABLE_PANEL_CRONRUNS."` WHERE `interval` <> '0' AND `isactive` = '1' AND ("; $query = "SELECT `id`, `cronfile` FROM `".TABLE_PANEL_CRONRUNS."` WHERE `interval` <> '0' AND `isactive` = '1' AND (";
$intervals = getIntervalOptions(); $intervals = getIntervalOptions();
$x = 0; $x = 0;
foreach($intervals as $name => $ival)
{ foreach($intervals as $name => $ival) {
if($name == '0') continue; if($name == '0') continue;
if($x == 0) { if($x == 0) {
$query.= '(UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL '.$ival.')) <= UNIX_TIMESTAMP() AND `interval`=\''.$ival.'\')'; $query.= "(UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL ".$ival.")) <= UNIX_TIMESTAMP() AND `interval` = '".$ival."')";
} else { } else {
$query.= ' OR (UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL '.$ival.')) <= UNIX_TIMESTAMP() AND `interval`=\''.$ival.'\')'; $query.= " OR (UNIX_TIMESTAMP(DATE_ADD(FROM_UNIXTIME(`lastrun`), INTERVAL ".$ival.")) <= UNIX_TIMESTAMP() AND `interval` = '".$ival."')";
} }
$x++; $x++;
} }
$query.= ');'; $query.= ');';
$result = $db->query($query); $result = Database::query($query);
$cron_files = array(); $cron_files = array();
while($row = $db->fetch_array($result)) // Update lastrun-timestamp
{ while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$cron_files[] = $row['cronfile']; $cron_files[] = $row['cronfile'];
$db->query("UPDATE `".TABLE_PANEL_CRONRUNS."` SET `lastrun` = UNIX_TIMESTAMP() WHERE `id` ='".(int)$row['id']."';"); $upd_stmt = Database::prepare("
UPDATE `".TABLE_PANEL_CRONRUNS."` SET `lastrun` = UNIX_TIMESTAMP() WHERE `id` = :id;"
);
Database::pexecute($upd_stmt, array('id' => $row['id']));
} }
return $cron_files; return $cron_files;
} }
function includeCronjobs($debugHandler) {
function includeCronjobs($debugHandler, $pathtophpfiles) global $cronlog;
{
global $settings, $theme, $cronlog;
$cronjobs = getNextCronjobs(); $cronjobs = getNextCronjobs();
$jobs_to_run = array(); $jobs_to_run = array();
$cron_path = makeCorrectDir($pathtophpfiles.'/scripts/jobs/'); $cron_path = makeCorrectDir(FROXLOR_INSTALL_DIR.'/scripts/jobs/');
if ($cronjobs !== false if ($cronjobs !== false
&& is_array($cronjobs) && is_array($cronjobs)
@@ -85,24 +84,21 @@ function includeCronjobs($debugHandler, $pathtophpfiles)
} }
function getIntervalOptions() function getIntervalOptions() {
{
global $db, $lng, $cronlog, $theme; global $lng, $cronlog;
$query = "SELECT DISTINCT `interval` FROM `" . TABLE_PANEL_CRONRUNS . "` ORDER BY `interval` ASC;"; $query = "SELECT DISTINCT `interval` FROM `" . TABLE_PANEL_CRONRUNS . "` ORDER BY `interval` ASC;";
$result = $db->query($query); $result = Database::query($query);
$cron_intervals = array();
$cron_intervals = array();
$cron_intervals['0'] = $lng['panel']['off']; $cron_intervals['0'] = $lng['panel']['off'];
while($row = $db->fetch_array($result)) while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
{
if(validateSqlInterval($row['interval'])) if (validateSqlInterval($row['interval'])) {
{
$cron_intervals[$row['interval']] = $row['interval']; $cron_intervals[$row['interval']] = $row['interval'];
} } else {
else
{
$cronlog->logAction(CRON_ACTION, LOG_ERROR, "Invalid SQL-Interval ".$row['interval']." detected. Please fix this in the database."); $cronlog->logAction(CRON_ACTION, LOG_ERROR, "Invalid SQL-Interval ".$row['interval']." detected. Please fix this in the database.");
} }
} }
@@ -111,19 +107,18 @@ function getIntervalOptions()
} }
function getCronjobsLastRun() function getCronjobsLastRun() {
{
global $db, $lng, $theme; global $lng;
$query = "SELECT `lastrun`, `desc_lng_key` FROM `".TABLE_PANEL_CRONRUNS."` WHERE `isactive` = '1' ORDER BY `cronfile` ASC"; $query = "SELECT `lastrun`, `desc_lng_key` FROM `".TABLE_PANEL_CRONRUNS."` WHERE `isactive` = '1' ORDER BY `cronfile` ASC";
$result = $db->query($query); $result = Database::query($query);
$cronjobs_last_run = ''; $cronjobs_last_run = '';
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
while($row = $db->fetch_array($result))
{
$lastrun = $lng['cronjobs']['notyetrun']; $lastrun = $lng['cronjobs']['notyetrun'];
if($row['lastrun'] > 0) { if ($row['lastrun'] > 0) {
$lastrun = date('d.m.Y H:i:s', $row['lastrun']); $lastrun = date('d.m.Y H:i:s', $row['lastrun']);
} }
@@ -136,97 +131,74 @@ function getCronjobsLastRun()
return $cronjobs_last_run; return $cronjobs_last_run;
} }
function toggleCronStatus($module = null, $isactive = 0) function toggleCronStatus($module = null, $isactive = 0) {
{
global $db, $theme;
if($isactive != 1) { if($isactive != 1) {
$isactive = 0; $isactive = 0;
} }
$query = "UPDATE `".TABLE_PANEL_CRONRUNS."` SET `isactive` = '".(int)$isactive."' WHERE `module` = '".$module."'"; $upd_stmt = Database::prepare("
$db->query($query); UPDATE `".TABLE_PANEL_CRONRUNS."` SET `isactive` = :active WHERE `module` = :module"
);
Database::pexecute($upd_stmt, array('active' => $isactive, 'module' => $module));
} }
function getOutstandingTasks() function getOutstandingTasks() {
{
global $db, $lng, $theme; global $lng;
$query = "SELECT * FROM `".TABLE_PANEL_TASKS."` ORDER BY `type` ASC"; $query = "SELECT * FROM `".TABLE_PANEL_TASKS."` ORDER BY `type` ASC";
$result = $db->query($query); $result = Database::query($query);
$value = '<ul class="cronjobtask">'; $value = '<ul class="cronjobtask">';
$tasks = ''; $tasks = '';
while($row = $db->fetch_array($result)) while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
{
if($row['data'] != '') if ($row['data'] != '') {
{
$row['data'] = unserialize($row['data']); $row['data'] = unserialize($row['data']);
} }
/* // rebuilding webserver-configuration
* rebuilding webserver-configuration if ($row['type'] == '1') {
*/
if($row['type'] == '1')
{
$task_desc = $lng['tasks']['rebuild_webserverconfig']; $task_desc = $lng['tasks']['rebuild_webserverconfig'];
} }
/* // adding new user/
* adding new user elseif ($row['type'] == '2') {
*/
elseif($row['type'] == '2')
{
$loginname = ''; $loginname = '';
if(is_array($row['data'])) if (is_array($row['data'])) {
{
$loginname = $row['data']['loginname']; $loginname = $row['data']['loginname'];
} }
$task_desc = $lng['tasks']['adding_customer']; $task_desc = $lng['tasks']['adding_customer'];
$task_desc = str_replace('%loginname%', $loginname, $task_desc); $task_desc = str_replace('%loginname%', $loginname, $task_desc);
} }
/* // rebuilding bind-configuration
* rebuilding bind-configuration elseif ($row['type'] == '4') {
*/
elseif($row['type'] == '4')
{
$task_desc = $lng['tasks']['rebuild_bindconfig']; $task_desc = $lng['tasks']['rebuild_bindconfig'];
} }
/* // creating ftp-user directory
* creating ftp-user directory elseif ($row['type'] == '5') {
*/
elseif($row['type'] == '5')
{
$task_desc = $lng['tasks']['creating_ftpdir']; $task_desc = $lng['tasks']['creating_ftpdir'];
} }
/* // deleting user-files
* deleting user-files elseif ($row['type'] == '6') {
*/
elseif($row['type'] == '6')
{
$loginname = ''; $loginname = '';
if(is_array($row['data'])) if (is_array($row['data'])) {
{
$loginname = $row['data']['loginname']; $loginname = $row['data']['loginname'];
} }
$task_desc = $lng['tasks']['deleting_customerfiles']; $task_desc = $lng['tasks']['deleting_customerfiles'];
$task_desc = str_replace('%loginname%', $loginname, $task_desc); $task_desc = str_replace('%loginname%', $loginname, $task_desc);
} }
elseif($row['type'] == '7') // deleteing email-account
{ elseif ($row['type'] == '7') {
$task_desc = $lng['tasks']['remove_emailacc_files']; $task_desc = $lng['tasks']['remove_emailacc_files'];
} }
/* // Set FS - quota
* Set FS - quota elseif ($row['type'] == '10') {
*/
elseif($row['type'] == '10')
{
$task_desc = $lng['tasks']['diskspace_set_quota']; $task_desc = $lng['tasks']['diskspace_set_quota'];
} }
else // unknown
{ else {
$task_desc = "ERROR: Unknown task type '".$row['type']. $task_desc = "ERROR: Unknown task type '".$row['type']."'";
"'";
} }
if($task_desc != '') { if($task_desc != '') {
@@ -235,50 +207,31 @@ function getOutstandingTasks()
} }
$query2 = "SELECT DISTINCT `Task` FROM `".TABLE_APS_TASKS."` ORDER BY `Task` ASC"; $query2 = "SELECT DISTINCT `Task` FROM `".TABLE_APS_TASKS."` ORDER BY `Task` ASC";
$result2 = $db->query($query2); $result2 = Database::query($query2);
while($row2 = $db->fetch_array($result2)) while ($row2 = $result2->fetch(PDO::FETCH_ASSOC)) {
{ // install
/* if ($row2['Task'] == '1') {
* install
*/
if($row2['Task'] == '1')
{
$task_desc = $lng['tasks']['aps_task_install']; $task_desc = $lng['tasks']['aps_task_install'];
} }
/* // remove
* remove elseif ($row2['Task'] == '2') {
*/
elseif($row2['Task'] == '2')
{
$task_desc = $lng['tasks']['aps_task_remove']; $task_desc = $lng['tasks']['aps_task_remove'];
} }
/* // reconfigure
* reconfigure elseif ($row2['Task'] == '3') {
*/
elseif($row2['Task'] == '3')
{
$task_desc = $lng['tasks']['aps_task_reconfigure']; $task_desc = $lng['tasks']['aps_task_reconfigure'];
} }
/* // upgrade
* upgrade elseif ($row2['Task'] == '4') {
*/
elseif($row2['Task'] == '4')
{
$task_desc = $lng['tasks']['aps_task_upgrade']; $task_desc = $lng['tasks']['aps_task_upgrade'];
} }
/* // system update
* system update elseif ($row2['Task'] == '5') {
*/
elseif($row2['Task'] == '5')
{
$task_desc = $lng['tasks']['aps_task_sysupdate']; $task_desc = $lng['tasks']['aps_task_sysupdate'];
} }
/* // system download
* system download elseif ($row2['Task'] == '6') {
*/
elseif($row2['Task'] == '6')
{
$task_desc = $lng['tasks']['aps_task_sysdownload']; $task_desc = $lng['tasks']['aps_task_sysdownload'];
} }
@@ -287,7 +240,7 @@ function getOutstandingTasks()
} }
} }
if(trim($tasks) == '') { if (trim($tasks) == '') {
$value .= '<li>'.$lng['tasks']['noneoutstanding'].'</li>'; $value .= '<li>'.$lng['tasks']['noneoutstanding'].'</li>';
} else { } else {
$value .= $tasks; $value .= $tasks;

View File

@@ -26,13 +26,11 @@
* @param hostAliases * @param hostAliases
* @return null * @return null
*/ */
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) {
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) global $settings;
{
global $pathtophpfiles, $settings, $theme;
// Generation header // Generation header
$header = "## GENERATED BY FROXLOR\n"; $header = "## GENERATED BY FROXLOR\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"; $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";
@@ -49,7 +47,6 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
} }
// These are the variables we will replace // These are the variables we will replace
$regex = array( $regex = array(
'/\{LOG_FILE\}/', '/\{LOG_FILE\}/',
'/\{SITE_DOMAIN\}/', '/\{SITE_DOMAIN\}/',
@@ -67,9 +64,7 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
// File names // File names
$domain_file = makeCorrectFile($settings['system']['awstats_conf'].'/awstats.' . $siteDomain . '.conf'); $domain_file = makeCorrectFile($settings['system']['awstats_conf'].'/awstats.' . $siteDomain . '.conf');
$model_file = dirname(dirname(dirname(dirname(__FILE__)))); $model_file = FROXLOR_INSTALL_DIR.'/templates/misc/awstatsmodel/awstats.froxlor.model.conf';
$model_file.= '/templates/misc/awstatsmodel/awstats.froxlor.model.conf';
$model_file = makeCorrectFile($model_file); $model_file = makeCorrectFile($model_file);
// Test if the file exists // Test if the file exists

View File

@@ -20,27 +20,29 @@
/** /**
* This function generates the VHost configuration for AWStats * This function generates the VHost configuration for AWStats
* This will enable the /awstats url and enable security on these folders * 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 * @author Berend Dekens
*
* @param siteDomain Name of the domain we want stats for
*
* @return String with configuration for use in vhost file
*/ */
function createAWStatsVhost($siteDomain, $settings = null) {
if ($settings['system']['mod_fcgid'] != '1') {
function createAWStatsVhost($siteDomain, $settings = null)
{
if($settings['system']['mod_fcgid'] != '1')
{
$vhosts_file = ' # AWStats statistics' . "\n"; $vhosts_file = ' # AWStats statistics' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\n"; $vhosts_file.= ' RewriteEngine On' . "\n";
$vhosts_file.= ' RewriteRule ^/awstats(/.*)?$ /awstats/awstats.pl?config=' . $siteDomain . ' [L,PT]' . "\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"; $vhosts_file.= ' RewriteRule ^/awstats.pl(.*)$ /awstats/awstats.pl$1 [QSA,L,PT]' . "\n";
}
else } else {
{
$vhosts_file = ' <IfModule mod_proxy.c>' . "\n"; $vhosts_file = ' <IfModule mod_proxy.c>' . "\n";
$vhosts_file.= ' RewriteEngine On' . "\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.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.= ' RewriteRule awstats$ http://' . $settings['system']['hostname'] . '/cgi-bin/awstats.pl?config=' . $siteDomain . ' [R,P]' . "\n";
$vhosts_file.= ' </IfModule>' . "\n"; $vhosts_file.= ' </IfModule>' . "\n";
} }
return $vhosts_file; return $vhosts_file;

View File

@@ -15,25 +15,27 @@
* *
*/ */
/* /**
* Function customerHasPerlEnabled * Function customerHasPerlEnabled
* *
* returns true or false whether perl is * returns true or false whether perl is
* enabled for the given customer * enabled for the given customer
* *
* @param int customer-id * @param int customer-id
* *
* @return boolean * @return boolean
*/ */
function customerHasPerlEnabled($cid = 0) function customerHasPerlEnabled($cid = 0) {
{
global $db, $theme;
if($cid > 0) if ($cid > 0) {
{ $result_stmt = Database::prepare("
$result = $db->query_first("SELECT `perlenabled` FROM `".TABLE_PANEL_CUSTOMERS."` WHERE `customerid` = '".(int)$cid."'"); SELECT `perlenabled` FROM `".TABLE_PANEL_CUSTOMERS."` WHERE `customerid` = :cid"
if(is_array($result) );
&& isset($result['perlenabled']) Database::pexecute($result_stmt, array('cid' => $cid));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (is_array($result)
&& isset($result['perlenabled'])
) { ) {
return ($result['perlenabled'] == '1') ? true : false; return ($result['perlenabled'] == '1') ? true : false;
} }

View File

@@ -23,13 +23,16 @@
* *
* @return boolean * @return boolean
*/ */
function domainHasMainSubDomains($id = 0) function domainHasMainSubDomains($id = 0) {
{
global $db, $theme;
$sql = "SELECT COUNT(`id`) as `mainsubs` FROM `".TABLE_PANEL_DOMAINS."` WHERE `ismainbutsubto` = '".(int)$id."'"; $result_stmt = Database::prepare("
$result = $db->query_first($sql); SELECT COUNT(`id`) as `mainsubs` FROM `".TABLE_PANEL_DOMAINS."`
if(isset($result['mainsubs']) WHERE `ismainbutsubto` = :id"
);
Database::pexecute($result_stmt, array('id' => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['mainsubs'])
&& $result['mainsubs'] > 0 && $result['mainsubs'] > 0
) { ) {
return true; return true;
@@ -45,13 +48,15 @@ function domainHasMainSubDomains($id = 0)
* *
* @return boolean * @return boolean
*/ */
function domainMainToSubExists($id = 0) function domainMainToSubExists($id = 0) {
{
global $db, $theme;
$sql = "SELECT `id` FROM `".TABLE_PANEL_DOMAINS."` WHERE `id` = '".(int)$id."'"; $result_stmt = Database::prepare("
$result = $db->query_first($sql); SELECT `id` FROM `".TABLE_PANEL_DOMAINS."` WHERE `id` = :id"
if(isset($result['id']) );
Database::pexecute($result_stmt, array('id' => $id));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (isset($result['id'])
&& $result['id'] > 0 && $result['id'] > 0
) { ) {
return true; return true;

View File

@@ -18,15 +18,25 @@
* *
*/ */
/**
* Check whether a given domain has an ssl-ip/port assigned
*
* @param int $domainid
*
* @return boolean
*/
function domainHasSslIpPort($domainid = 0) { function domainHasSslIpPort($domainid = 0) {
global $db;
$result = $db->query_first("
SELECT `dt`.* FROM `".TABLE_DOMAINTOIP."` `dt`, `".TABLE_PANEL_IPSANDPORTS."` `iap`
WHERE `dt`.`id_ipandports` = `iap`.`id` AND `iap`.`ssl` = '1' AND `dt`.`id_domain` = '".(int)$domainid."';
");
if (is_array($result) && isset($result['id_ipandports'])) { $result_stmt = Database::prepare("
SELECT `dt`.* FROM `".TABLE_DOMAINTOIP."` `dt`, `".TABLE_PANEL_IPSANDPORTS."` `iap`
WHERE `dt`.`id_ipandports` = `iap`.`id` AND `iap`.`ssl` = '1' AND `dt`.`id_domain` = :domainid;"
);
Database::pexecute($result_stmt, array('domainid' => $domainid));
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
if (is_array($result)
&& isset($result['id_ipandports'])
) {
return true; return true;
} }
return false; return false;

View File

@@ -17,8 +17,8 @@
* *
*/ */
function getAdmins($limit_resource = '') function getAdmins($limit_resource = '') {
{
global $db, $theme; global $db, $theme;
$additional_conditions = ''; $additional_conditions = '';

View File

@@ -10,6 +10,8 @@
* *
* @copyright (c) the authors * @copyright (c) the authors
* @author Michal Wojcik <m.wojcik@sonet3.pl> * @author Michal Wojcik <m.wojcik@sonet3.pl>
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Functions * @package Functions
* *
@@ -21,6 +23,8 @@
* @return string encrypted password * @return string encrypted password
* *
* @author Michal Wojcik <m.wojcik@sonet3.pl> * @author Michal Wojcik <m.wojcik@sonet3.pl>
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* *
* 0 - default crypt (depenend on system configuration) * 0 - default crypt (depenend on system configuration)
* 1 - MD5 $1$ * 1 - MD5 $1$

View File

@@ -19,7 +19,7 @@ define('MASTER_CRONJOB', 1);
include_once(dirname(__FILE__) . '/../lib/cron_init.php'); include_once(dirname(__FILE__) . '/../lib/cron_init.php');
$jobs_to_run = includeCronjobs($debugHandler, $pathtophpfiles); $jobs_to_run = includeCronjobs($debugHandler);
/** /**
* check for --help * check for --help