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:
@@ -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;
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
function maildirExists($result = null)
|
||||
{
|
||||
global $settings, $theme;
|
||||
global $settings;
|
||||
|
||||
if(is_array($result))
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
*/
|
||||
function makeChownWithNewStats($row)
|
||||
{
|
||||
global $settings, $theme;
|
||||
global $settings;
|
||||
|
||||
// get correct user
|
||||
if($settings['system']['mod_fcgid'] == '1' && isset($row['deactivated']) && $row['deactivated'] == '0')
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
function makePathfield($path, $uid, $gid, $fieldType, $value = '', $dom = false)
|
||||
{
|
||||
global $lng, $theme;
|
||||
global $lng;
|
||||
|
||||
$value = str_replace($path, '', $value);
|
||||
$field = array();
|
||||
|
||||
@@ -20,101 +20,33 @@
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
function safe_exec($exec_string, &$return_value = false)
|
||||
{
|
||||
global $settings, $theme;
|
||||
|
||||
//
|
||||
// define allowed system commands
|
||||
//
|
||||
|
||||
$allowed_commands = array(
|
||||
'touch',
|
||||
'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, '?')))
|
||||
{
|
||||
// check for bad signs in execute command
|
||||
if ((stristr($exec_string, ';'))
|
||||
|| (stristr($exec_string, '|'))
|
||||
|| (stristr($exec_string, '&'))
|
||||
|| (stristr($exec_string, '>'))
|
||||
|| (stristr($exec_string, '<'))
|
||||
|| (stristr($exec_string, '`'))
|
||||
|| (stristr($exec_string, '$'))
|
||||
|| (stristr($exec_string, '~'))
|
||||
|| (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");
|
||||
}
|
||||
|
||||
/*
|
||||
* 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
|
||||
//
|
||||
// --- martin @ 08.08.2005 -------------------------------------------------------
|
||||
// fixing usage of uninitialised variable
|
||||
|
||||
$return = '';
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
|
||||
if($return_value == false)
|
||||
{
|
||||
if ($return_value == false) {
|
||||
exec($exec_string, $return);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
exec($exec_string, $return, $return_value);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,18 +25,26 @@
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false)
|
||||
{
|
||||
global $db, $settings, $pathtophpfiles, $theme;
|
||||
function storeDefaultIndex($loginname = null, $destination = null, $logger = null, $force = false) {
|
||||
|
||||
global $settings;
|
||||
|
||||
if ($force
|
||||
|| (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) . "'");
|
||||
|
||||
if($db->num_rows($result) > 0)
|
||||
{
|
||||
$template = $db->fetch_array($result);
|
||||
$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`
|
||||
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` = :loginname");
|
||||
Database::pexecute($result_stmt, array('loginname' => $loginname));
|
||||
|
||||
if (Database::num_rows() > 0) {
|
||||
|
||||
$template = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
$replace_arr = array(
|
||||
'SERVERNAME' => $settings['system']['hostname'],
|
||||
'CUSTOMER' => $template['customer_login'],
|
||||
@@ -44,6 +52,7 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
|
||||
'CUSTOMER_EMAIL' => $template['customer_email'],
|
||||
'ADMIN_EMAIL' => $template['admin_email']
|
||||
);
|
||||
|
||||
$htmlcontent = replace_variables($template['value'], $replace_arr);
|
||||
$indexhtmlpath = makeCorrectFile($destination . '/index.' . $settings['system']['index_file_extension']);
|
||||
$index_html_handler = fopen($indexhtmlpath, 'w');
|
||||
@@ -52,14 +61,13 @@ function storeDefaultIndex($loginname = null, $destination = null, $logger = nul
|
||||
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));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
} else {
|
||||
$destination = makeCorrectDir($destination);
|
||||
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;
|
||||
|
||||
@@ -15,56 +15,48 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* this functions validates a given value as ErrorDocument
|
||||
* refs #267
|
||||
*
|
||||
*
|
||||
* @param string error-document-string
|
||||
*
|
||||
*
|
||||
* @return string error-document-string
|
||||
*
|
||||
*
|
||||
*/
|
||||
function correctErrorDocument($errdoc = null)
|
||||
{
|
||||
global $settings, $idna_convert, $theme;
|
||||
function correctErrorDocument($errdoc = null) {
|
||||
|
||||
if($errdoc !== null && $errdoc != '')
|
||||
{
|
||||
// not a URL
|
||||
if((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:'
|
||||
&& strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:')
|
||||
|| !validateUrl($idna_convert->encode($errdoc)))
|
||||
{
|
||||
// a file
|
||||
if(substr($errdoc, 0, 1) != '"')
|
||||
{
|
||||
$errdoc = makeCorrectFile($errdoc);
|
||||
// apache needs a starting-slash (starting at the domains-docroot)
|
||||
if(!substr($errdoc, 0, 1) == '/') {
|
||||
$errdoc = '/'.$errdoc;
|
||||
}
|
||||
}
|
||||
// a string (check for ending ")
|
||||
else
|
||||
{
|
||||
// string won't work for lighty
|
||||
if($settings['system']['webserver'] == 'lighttpd')
|
||||
{
|
||||
standard_error('stringerrordocumentnotvalidforlighty');
|
||||
}
|
||||
elseif(substr($errdoc, -1) != '"')
|
||||
{
|
||||
$errdoc .= '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($settings['system']['webserver'] == 'lighttpd')
|
||||
{
|
||||
standard_error('urlerrordocumentnotvalidforlighty');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errdoc;
|
||||
}
|
||||
global $settings, $idna_convert;
|
||||
|
||||
if ($errdoc !== null && $errdoc != '') {
|
||||
// not a URL
|
||||
if ((strtoupper(substr($errdoc, 0, 5)) != 'HTTP:'
|
||||
&& strtoupper(substr($errdoc, 0, 6)) != 'HTTPS:')
|
||||
|| !validateUrl($idna_convert->encode($errdoc))
|
||||
) {
|
||||
// a file
|
||||
if (substr($errdoc, 0, 1) != '"') {
|
||||
$errdoc = makeCorrectFile($errdoc);
|
||||
// apache needs a starting-slash (starting at the domains-docroot)
|
||||
if (!substr($errdoc, 0, 1) == '/') {
|
||||
$errdoc = '/'.$errdoc;
|
||||
}
|
||||
}
|
||||
// a string (check for ending ")
|
||||
else {
|
||||
// string won't work for lighty
|
||||
if ($settings['system']['webserver'] == 'lighttpd') {
|
||||
standard_error('stringerrordocumentnotvalidforlighty');
|
||||
|
||||
} elseif(substr($errdoc, -1) != '"') {
|
||||
$errdoc .= '"';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($settings['system']['webserver'] == 'lighttpd') {
|
||||
standard_error('urlerrordocumentnotvalidforlighty');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $errdoc;
|
||||
}
|
||||
|
||||
@@ -22,50 +22,49 @@
|
||||
*
|
||||
* @return array array of cron-files which are to be executed
|
||||
*/
|
||||
function getNextCronjobs()
|
||||
{
|
||||
global $db, $theme;
|
||||
function getNextCronjobs() {
|
||||
|
||||
$query = "SELECT `id`, `cronfile` FROM `".TABLE_PANEL_CRONRUNS."` WHERE `interval` <> '0' AND `isactive` = '1' AND (";
|
||||
|
||||
$intervals = getIntervalOptions();
|
||||
|
||||
$x = 0;
|
||||
foreach($intervals as $name => $ival)
|
||||
{
|
||||
|
||||
foreach($intervals as $name => $ival) {
|
||||
|
||||
if($name == '0') continue;
|
||||
|
||||
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 {
|
||||
$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++;
|
||||
}
|
||||
|
||||
$query.= ');';
|
||||
|
||||
$result = $db->query($query);
|
||||
$result = Database::query($query);
|
||||
|
||||
$cron_files = array();
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
// Update lastrun-timestamp
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$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;
|
||||
}
|
||||
|
||||
function includeCronjobs($debugHandler) {
|
||||
|
||||
function includeCronjobs($debugHandler, $pathtophpfiles)
|
||||
{
|
||||
global $settings, $theme, $cronlog;
|
||||
global $cronlog;
|
||||
|
||||
$cronjobs = getNextCronjobs();
|
||||
|
||||
$jobs_to_run = array();
|
||||
$cron_path = makeCorrectDir($pathtophpfiles.'/scripts/jobs/');
|
||||
$cron_path = makeCorrectDir(FROXLOR_INSTALL_DIR.'/scripts/jobs/');
|
||||
|
||||
if ($cronjobs !== false
|
||||
&& is_array($cronjobs)
|
||||
@@ -85,24 +84,21 @@ function includeCronjobs($debugHandler, $pathtophpfiles)
|
||||
}
|
||||
|
||||
|
||||
function getIntervalOptions()
|
||||
{
|
||||
global $db, $lng, $cronlog, $theme;
|
||||
function getIntervalOptions() {
|
||||
|
||||
global $lng, $cronlog;
|
||||
|
||||
$query = "SELECT DISTINCT `interval` FROM `" . TABLE_PANEL_CRONRUNS . "` ORDER BY `interval` ASC;";
|
||||
$result = $db->query($query);
|
||||
$cron_intervals = array();
|
||||
$result = Database::query($query);
|
||||
|
||||
$cron_intervals = array();
|
||||
$cron_intervals['0'] = $lng['panel']['off'];
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
if(validateSqlInterval($row['interval']))
|
||||
{
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
if (validateSqlInterval($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.");
|
||||
}
|
||||
}
|
||||
@@ -111,19 +107,18 @@ function getIntervalOptions()
|
||||
}
|
||||
|
||||
|
||||
function getCronjobsLastRun()
|
||||
{
|
||||
global $db, $lng, $theme;
|
||||
function getCronjobsLastRun() {
|
||||
|
||||
global $lng;
|
||||
|
||||
$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 = '';
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
$lastrun = $lng['cronjobs']['notyetrun'];
|
||||
if($row['lastrun'] > 0) {
|
||||
if ($row['lastrun'] > 0) {
|
||||
$lastrun = date('d.m.Y H:i:s', $row['lastrun']);
|
||||
}
|
||||
|
||||
@@ -136,97 +131,74 @@ function getCronjobsLastRun()
|
||||
return $cronjobs_last_run;
|
||||
}
|
||||
|
||||
function toggleCronStatus($module = null, $isactive = 0)
|
||||
{
|
||||
global $db, $theme;
|
||||
function toggleCronStatus($module = null, $isactive = 0) {
|
||||
|
||||
if($isactive != 1) {
|
||||
$isactive = 0;
|
||||
}
|
||||
|
||||
$query = "UPDATE `".TABLE_PANEL_CRONRUNS."` SET `isactive` = '".(int)$isactive."' WHERE `module` = '".$module."'";
|
||||
$db->query($query);
|
||||
|
||||
$upd_stmt = Database::prepare("
|
||||
UPDATE `".TABLE_PANEL_CRONRUNS."` SET `isactive` = :active WHERE `module` = :module"
|
||||
);
|
||||
Database::pexecute($upd_stmt, array('active' => $isactive, 'module' => $module));
|
||||
}
|
||||
|
||||
function getOutstandingTasks()
|
||||
{
|
||||
global $db, $lng, $theme;
|
||||
function getOutstandingTasks() {
|
||||
|
||||
global $lng;
|
||||
|
||||
$query = "SELECT * FROM `".TABLE_PANEL_TASKS."` ORDER BY `type` ASC";
|
||||
$result = $db->query($query);
|
||||
$result = Database::query($query);
|
||||
|
||||
$value = '<ul class="cronjobtask">';
|
||||
$tasks = '';
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
if($row['data'] != '')
|
||||
{
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
if ($row['data'] != '') {
|
||||
$row['data'] = unserialize($row['data']);
|
||||
}
|
||||
|
||||
/*
|
||||
* rebuilding webserver-configuration
|
||||
*/
|
||||
if($row['type'] == '1')
|
||||
{
|
||||
// rebuilding webserver-configuration
|
||||
if ($row['type'] == '1') {
|
||||
$task_desc = $lng['tasks']['rebuild_webserverconfig'];
|
||||
}
|
||||
/*
|
||||
* adding new user
|
||||
*/
|
||||
elseif($row['type'] == '2')
|
||||
{
|
||||
// adding new user/
|
||||
elseif ($row['type'] == '2') {
|
||||
$loginname = '';
|
||||
if(is_array($row['data']))
|
||||
{
|
||||
if (is_array($row['data'])) {
|
||||
$loginname = $row['data']['loginname'];
|
||||
}
|
||||
$task_desc = $lng['tasks']['adding_customer'];
|
||||
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
|
||||
}
|
||||
/*
|
||||
* rebuilding bind-configuration
|
||||
*/
|
||||
elseif($row['type'] == '4')
|
||||
{
|
||||
// rebuilding bind-configuration
|
||||
elseif ($row['type'] == '4') {
|
||||
$task_desc = $lng['tasks']['rebuild_bindconfig'];
|
||||
}
|
||||
/*
|
||||
* creating ftp-user directory
|
||||
*/
|
||||
elseif($row['type'] == '5')
|
||||
{
|
||||
// creating ftp-user directory
|
||||
elseif ($row['type'] == '5') {
|
||||
$task_desc = $lng['tasks']['creating_ftpdir'];
|
||||
}
|
||||
/*
|
||||
* deleting user-files
|
||||
*/
|
||||
elseif($row['type'] == '6')
|
||||
{
|
||||
// deleting user-files
|
||||
elseif ($row['type'] == '6') {
|
||||
$loginname = '';
|
||||
if(is_array($row['data']))
|
||||
{
|
||||
if (is_array($row['data'])) {
|
||||
$loginname = $row['data']['loginname'];
|
||||
}
|
||||
$task_desc = $lng['tasks']['deleting_customerfiles'];
|
||||
$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'];
|
||||
}
|
||||
/*
|
||||
* Set FS - quota
|
||||
*/
|
||||
elseif($row['type'] == '10')
|
||||
{
|
||||
// Set FS - quota
|
||||
elseif ($row['type'] == '10') {
|
||||
$task_desc = $lng['tasks']['diskspace_set_quota'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$task_desc = "ERROR: Unknown task type '".$row['type'].
|
||||
"'";
|
||||
// unknown
|
||||
else {
|
||||
$task_desc = "ERROR: Unknown task type '".$row['type']."'";
|
||||
}
|
||||
|
||||
if($task_desc != '') {
|
||||
@@ -235,50 +207,31 @@ function getOutstandingTasks()
|
||||
}
|
||||
|
||||
$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))
|
||||
{
|
||||
/*
|
||||
* install
|
||||
*/
|
||||
if($row2['Task'] == '1')
|
||||
{
|
||||
while ($row2 = $result2->fetch(PDO::FETCH_ASSOC)) {
|
||||
// install
|
||||
if ($row2['Task'] == '1') {
|
||||
$task_desc = $lng['tasks']['aps_task_install'];
|
||||
}
|
||||
/*
|
||||
* remove
|
||||
*/
|
||||
elseif($row2['Task'] == '2')
|
||||
{
|
||||
// remove
|
||||
elseif ($row2['Task'] == '2') {
|
||||
$task_desc = $lng['tasks']['aps_task_remove'];
|
||||
}
|
||||
/*
|
||||
* reconfigure
|
||||
*/
|
||||
elseif($row2['Task'] == '3')
|
||||
{
|
||||
// reconfigure
|
||||
elseif ($row2['Task'] == '3') {
|
||||
$task_desc = $lng['tasks']['aps_task_reconfigure'];
|
||||
}
|
||||
/*
|
||||
* upgrade
|
||||
*/
|
||||
elseif($row2['Task'] == '4')
|
||||
{
|
||||
// upgrade
|
||||
elseif ($row2['Task'] == '4') {
|
||||
$task_desc = $lng['tasks']['aps_task_upgrade'];
|
||||
}
|
||||
/*
|
||||
* system update
|
||||
*/
|
||||
elseif($row2['Task'] == '5')
|
||||
{
|
||||
// system update
|
||||
elseif ($row2['Task'] == '5') {
|
||||
$task_desc = $lng['tasks']['aps_task_sysupdate'];
|
||||
}
|
||||
/*
|
||||
* system download
|
||||
*/
|
||||
elseif($row2['Task'] == '6')
|
||||
{
|
||||
// system download
|
||||
elseif ($row2['Task'] == '6') {
|
||||
$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>';
|
||||
} else {
|
||||
$value .= $tasks;
|
||||
|
||||
@@ -26,13 +26,11 @@
|
||||
* @param hostAliases
|
||||
* @return null
|
||||
*/
|
||||
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array()) {
|
||||
|
||||
function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot, $awstats_params = array())
|
||||
{
|
||||
global $pathtophpfiles, $settings, $theme;
|
||||
global $settings;
|
||||
|
||||
// Generation header
|
||||
|
||||
$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";
|
||||
|
||||
@@ -49,7 +47,6 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
|
||||
}
|
||||
|
||||
// These are the variables we will replace
|
||||
|
||||
$regex = array(
|
||||
'/\{LOG_FILE\}/',
|
||||
'/\{SITE_DOMAIN\}/',
|
||||
@@ -67,9 +64,7 @@ function createAWStatsConf($logFile, $siteDomain, $hostAliases, $customerDocroot
|
||||
|
||||
// File names
|
||||
$domain_file = makeCorrectFile($settings['system']['awstats_conf'].'/awstats.' . $siteDomain . '.conf');
|
||||
$model_file = dirname(dirname(dirname(dirname(__FILE__))));
|
||||
$model_file.= '/templates/misc/awstatsmodel/awstats.froxlor.model.conf';
|
||||
|
||||
$model_file = FROXLOR_INSTALL_DIR.'/templates/misc/awstatsmodel/awstats.froxlor.model.conf';
|
||||
$model_file = makeCorrectFile($model_file);
|
||||
|
||||
// Test if the file exists
|
||||
|
||||
@@ -20,27 +20,29 @@
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @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.= ' 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
|
||||
{
|
||||
|
||||
} 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;
|
||||
|
||||
@@ -15,25 +15,27 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* Function customerHasPerlEnabled
|
||||
*
|
||||
* returns true or false whether perl is
|
||||
* enabled for the given customer
|
||||
*
|
||||
* @param int customer-id
|
||||
* @param int customer-id
|
||||
*
|
||||
* @return boolean
|
||||
* @return boolean
|
||||
*/
|
||||
function customerHasPerlEnabled($cid = 0)
|
||||
{
|
||||
global $db, $theme;
|
||||
function customerHasPerlEnabled($cid = 0) {
|
||||
|
||||
if($cid > 0)
|
||||
{
|
||||
$result = $db->query_first("SELECT `perlenabled` FROM `".TABLE_PANEL_CUSTOMERS."` WHERE `customerid` = '".(int)$cid."'");
|
||||
if(is_array($result)
|
||||
&& isset($result['perlenabled'])
|
||||
if ($cid > 0) {
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `perlenabled` FROM `".TABLE_PANEL_CUSTOMERS."` WHERE `customerid` = :cid"
|
||||
);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -23,13 +23,16 @@
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function domainHasMainSubDomains($id = 0)
|
||||
{
|
||||
global $db, $theme;
|
||||
function domainHasMainSubDomains($id = 0) {
|
||||
|
||||
$sql = "SELECT COUNT(`id`) as `mainsubs` FROM `".TABLE_PANEL_DOMAINS."` WHERE `ismainbutsubto` = '".(int)$id."'";
|
||||
$result = $db->query_first($sql);
|
||||
if(isset($result['mainsubs'])
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT COUNT(`id`) as `mainsubs` FROM `".TABLE_PANEL_DOMAINS."`
|
||||
WHERE `ismainbutsubto` = :id"
|
||||
);
|
||||
Database::pexecute($result_stmt, array('id' => $id));
|
||||
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (isset($result['mainsubs'])
|
||||
&& $result['mainsubs'] > 0
|
||||
) {
|
||||
return true;
|
||||
@@ -45,13 +48,15 @@ function domainHasMainSubDomains($id = 0)
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function domainMainToSubExists($id = 0)
|
||||
{
|
||||
global $db, $theme;
|
||||
function domainMainToSubExists($id = 0) {
|
||||
|
||||
$sql = "SELECT `id` FROM `".TABLE_PANEL_DOMAINS."` WHERE `id` = '".(int)$id."'";
|
||||
$result = $db->query_first($sql);
|
||||
if(isset($result['id'])
|
||||
$result_stmt = Database::prepare("
|
||||
SELECT `id` FROM `".TABLE_PANEL_DOMAINS."` WHERE `id` = :id"
|
||||
);
|
||||
Database::pexecute($result_stmt, array('id' => $id));
|
||||
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (isset($result['id'])
|
||||
&& $result['id'] > 0
|
||||
) {
|
||||
return true;
|
||||
|
||||
@@ -18,15 +18,25 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check whether a given domain has an ssl-ip/port assigned
|
||||
*
|
||||
* @param int $domainid
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
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 false;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
function getAdmins($limit_resource = '')
|
||||
{
|
||||
function getAdmins($limit_resource = '') {
|
||||
|
||||
global $db, $theme;
|
||||
|
||||
$additional_conditions = '';
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
*
|
||||
* @copyright (c) the authors
|
||||
* @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
|
||||
* @package Functions
|
||||
*
|
||||
@@ -21,6 +23,8 @@
|
||||
* @return string encrypted password
|
||||
*
|
||||
* @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)
|
||||
* 1 - MD5 $1$
|
||||
|
||||
Reference in New Issue
Block a user