remove unused upgrade procedures, migrated a few minor functions and files to PDO database, fixed FROXLOR_INSTALL_DIR define for master-cronjob, fixes #1294
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -19,10 +19,6 @@
|
||||
|
||||
define('AREA', 'admin');
|
||||
|
||||
/**
|
||||
* Include our init.php, which manages Sessions, Language etc.
|
||||
*/
|
||||
|
||||
$need_db_sql_data = true;
|
||||
$need_root_db_sql_data = true;
|
||||
require ("./lib/init.php");
|
||||
|
||||
@@ -22,7 +22,9 @@ showUpdateStep("Upgrading SysCP ".$settings['panel']['version']." to Froxlor ".
|
||||
updateToVersion($updateto);
|
||||
|
||||
// add field frontend
|
||||
$db->query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('panel','frontend','".$frontend."')");
|
||||
Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` SET
|
||||
`settinggroup` = 'panel',
|
||||
`varname` = 'frontend',
|
||||
`value` = 'froxlor'"
|
||||
);
|
||||
$settings['panel']['frontend'] = $frontend;
|
||||
|
||||
?>
|
||||
|
||||
@@ -35,72 +35,14 @@ try {
|
||||
* since froxlor, we have to check if there's still someone
|
||||
* out there using syscp and needs to upgrade
|
||||
*/
|
||||
if(!isFroxlor())
|
||||
{
|
||||
/**
|
||||
* First case: We are updating from a version < 1.0.10
|
||||
*/
|
||||
|
||||
if(!isset($settings['panel']['version'])
|
||||
|| (substr($settings['panel']['version'], 0, 3) == '1.0' && $settings['panel']['version'] != '1.0.10'))
|
||||
{
|
||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.0 to 1.0.10");
|
||||
include_once (makeCorrectFile(dirname(__FILE__).'/updates/syscp/1.0/update_1.0_1.0.10.inc.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Second case: We are updating from version = 1.0.10
|
||||
*/
|
||||
|
||||
if($settings['panel']['version'] == '1.0.10')
|
||||
{
|
||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.0.10 to 1.2-beta1");
|
||||
include_once (makeCorrectFile(dirname(__FILE__).'/updates/syscp/1.0/update_1.0.10_1.2-beta1.inc.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Third case: We are updating from a version > 1.2-beta1
|
||||
*/
|
||||
|
||||
if(substr($settings['panel']['version'], 0, 3) == '1.2')
|
||||
{
|
||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.2-beta1 to 1.2.19");
|
||||
include_once (makeCorrectFile(dirname(__FILE__).'/updates/syscp/1.2/update_1.2-beta1_1.2.19.inc.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 4th case: We are updating from 1.2.19 to 1.2.20 (prolly the last from the 1.2.x series)
|
||||
*/
|
||||
|
||||
if(substr($settings['panel']['version'], 0, 6) == '1.2.19')
|
||||
{
|
||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.2.19 to 1.4");
|
||||
include_once (makeCorrectFile(dirname(__FILE__).'/updates/syscp/1.2/update_1.2.19_1.4.inc.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 5th case: We are updating from a version >= 1.4
|
||||
*/
|
||||
|
||||
if(substr($settings['panel']['version'], 0, 3) == '1.4')
|
||||
{
|
||||
$updatelog->logAction(ADM_ACTION, LOG_WARNING, "Updating from 1.4");
|
||||
include_once (makeCorrectFile(dirname(__FILE__).'/updates/syscp/1.4/update_1.4.inc.php'));
|
||||
}
|
||||
|
||||
if(!isFroxlor()) {
|
||||
/**
|
||||
* Upgrading SysCP to Froxlor-0.9
|
||||
*
|
||||
* when we reach this part, all necessary updates
|
||||
* should have been installes automatically by the
|
||||
* update scripts.
|
||||
*/
|
||||
include_once (makeCorrectFile(dirname(__FILE__).'/updates/froxlor/upgrade_syscp.inc.php'));
|
||||
|
||||
}
|
||||
|
||||
if(isFroxlor())
|
||||
{
|
||||
if (isFroxlor()) {
|
||||
include_once (makeCorrectFile(dirname(__FILE__).'/updates/froxlor/0.9/update_0.9.inc.php'));
|
||||
$filelog->logAction(ADM_ACTION, LOG_WARNING, '--------------- END LOG ---------------');
|
||||
unset($filelog);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php if (!defined('MASTER_CRONJOB')) die('You cannot access this file directly!');
|
||||
|
||||
/**
|
||||
* This file is part of the Froxlor project.
|
||||
@@ -16,7 +16,6 @@
|
||||
* @package Cron
|
||||
*
|
||||
*/
|
||||
|
||||
if(@php_sapi_name() != 'cli'
|
||||
&& @php_sapi_name() != 'cgi'
|
||||
&& @php_sapi_name() != 'cgi-fcgi')
|
||||
@@ -25,8 +24,9 @@ if(@php_sapi_name() != 'cli'
|
||||
}
|
||||
|
||||
// ensure that default timezone is set
|
||||
if(function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get"))
|
||||
{
|
||||
if (function_exists("date_default_timezone_set")
|
||||
&& function_exists("date_default_timezone_get")
|
||||
) {
|
||||
@date_default_timezone_set(@date_default_timezone_get());
|
||||
}
|
||||
|
||||
@@ -38,116 +38,93 @@ $lockfile = $lockdir . $lockfName;
|
||||
// guess the froxlor installation path
|
||||
// normally you should not need to modify this script anymore, if your
|
||||
// froxlor installation isn't in /var/www/froxlor
|
||||
|
||||
define('FROXLOR_INSTALL_DIR', dirname(dirname(__FILE__)));
|
||||
// TODO remove when not needed anymore
|
||||
$pathtophpfiles = dirname(dirname(__FILE__));
|
||||
|
||||
// should the froxlor installation guessing not work correctly,
|
||||
// uncomment the following line, and put your path in there!
|
||||
//$pathtophpfiles = '/var/www/froxlor/';
|
||||
// create and open the lockfile!
|
||||
|
||||
$keepLockFile = false;
|
||||
$debugHandler = fopen($lockfile, 'w');
|
||||
fwrite($debugHandler, 'Setting Lockfile to ' . $lockfile . "\n");
|
||||
fwrite($debugHandler, 'Setting Froxlor installation path to ' . $pathtophpfiles . "\n");
|
||||
|
||||
// open the lockfile directory and scan for existing lockfiles
|
||||
|
||||
$lockDirHandle = opendir($lockdir);
|
||||
|
||||
while($fName = readdir($lockDirHandle))
|
||||
{
|
||||
if($lockFilename == substr($fName, 0, strlen($lockFilename))
|
||||
&& $lockfName != $fName)
|
||||
{
|
||||
// Check if last run jailed out with an exception
|
||||
while ($fName = readdir($lockDirHandle)) {
|
||||
|
||||
if ($lockFilename == substr($fName, 0, strlen($lockFilename))
|
||||
&& $lockfName != $fName
|
||||
) {
|
||||
// Check if last run jailed out with an exception
|
||||
$croncontent = file($lockdir . $fName);
|
||||
$lastline = $croncontent[(count($croncontent) - 1)];
|
||||
|
||||
if($lastline == '=== Keep lockfile because of exception ===')
|
||||
{
|
||||
if ($lastline == '=== Keep lockfile because of exception ===') {
|
||||
fclose($debugHandler);
|
||||
unlink($lockfile);
|
||||
die('Last cron jailed out with an exception. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $fName . '* for more information!' . "\n");
|
||||
}
|
||||
|
||||
// Check if cron is running or has died.
|
||||
|
||||
$check_pid = substr(strstr($fName, "-"), 1);
|
||||
system("kill -CHLD " . (int)$check_pid . " 1> /dev/null 2> /dev/null", $check_pid_return);
|
||||
|
||||
if($check_pid_return == 1)
|
||||
{
|
||||
if ($check_pid_return == 1) {
|
||||
// Result: Existing lockfile/pid isnt running
|
||||
// Most likely it has died
|
||||
//
|
||||
// Action: Remove it and continue
|
||||
//
|
||||
|
||||
fwrite($debugHandler, 'Previous cronjob didn\'t exit clean. PID: ' . $check_pid . "\n");
|
||||
fwrite($debugHandler, 'Removing lockfile: ' . $lockdir . $fName . "\n");
|
||||
unlink($lockdir . $fName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
} else {
|
||||
// Result: A Cronscript with this pid
|
||||
// is still running
|
||||
// Action: remove my own Lock and die
|
||||
//
|
||||
// close the current lockfile
|
||||
|
||||
fclose($debugHandler);
|
||||
|
||||
// ... and delete it
|
||||
|
||||
unlink($lockfile);
|
||||
die('There is already a Cronjob in progress. Exiting...' . "\n" . 'Take a look into the contents of ' . $lockdir . $lockFilename . '* for more information!' . "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes the Usersettings eg. MySQL-Username/Passwort etc.
|
||||
*/
|
||||
|
||||
require ($pathtophpfiles . '/lib/userdata.inc.php');
|
||||
// Includes the Usersettings eg. MySQL-Username/Passwort etc.
|
||||
require FROXLOR_INSTALL_DIR . '/lib/userdata.inc.php';
|
||||
fwrite($debugHandler, 'Userdatas included' . "\n");
|
||||
|
||||
// Legacy sql-root-information
|
||||
if(isset($sql['root_user']) && isset($sql['root_password']) && (!isset($sql_root) || !is_array($sql_root)))
|
||||
{
|
||||
if (isset($sql['root_user'])
|
||||
&& isset($sql['root_password'])
|
||||
&& (!isset($sql_root) || !is_array($sql_root))
|
||||
) {
|
||||
$sql_root = array(0 => array('caption' => 'Default', 'host' => $sql['host'], 'user' => $sql['root_user'], 'password' => $sql['root_password']));
|
||||
unset($sql['root_user']);
|
||||
unset($sql['root_password']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Includes the Functions
|
||||
*/
|
||||
// Includes the Functions
|
||||
require FROXLOR_INSTALL_DIR . '/lib/functions.php';
|
||||
|
||||
require ($pathtophpfiles . '/lib/functions.php');
|
||||
|
||||
/**
|
||||
* Includes the MySQL-Tabledefinitions etc.
|
||||
*/
|
||||
|
||||
require ($pathtophpfiles . '/lib/tables.inc.php');
|
||||
//Includes the MySQL-Tabledefinitions etc.
|
||||
require FROXLOR_INSTALL_DIR . '/lib/tables.inc.php';
|
||||
fwrite($debugHandler, 'Table definitions included' . "\n");
|
||||
|
||||
/**
|
||||
* Includes the MySQL-Connection-Class
|
||||
*/
|
||||
|
||||
//Includes the MySQL-Connection-Class
|
||||
fwrite($debugHandler, 'Database Class has been loaded' . "\n");
|
||||
$db = new db($sql['host'], $sql['user'], $sql['password'], $sql['db']);
|
||||
|
||||
if($db->link_id == 0)
|
||||
{
|
||||
/**
|
||||
* Do not proceed further if no database connection could be established
|
||||
*/
|
||||
|
||||
if ($db->link_id == 0) {
|
||||
// Do not proceed further if no database connection could be established
|
||||
fclose($debugHandler);
|
||||
unlink($lockfile);
|
||||
die('Froxlor can\'t connect to mysqlserver. Please check userdata.inc.php! Exiting...');
|
||||
@@ -157,8 +134,7 @@ fwrite($debugHandler, 'Database-connection established' . "\n");
|
||||
unset($sql);
|
||||
$result = $db->query("SELECT `settingid`, `settinggroup`, `varname`, `value` FROM `" . TABLE_PANEL_SETTINGS . "`");
|
||||
|
||||
while($row = $db->fetch_array($result))
|
||||
{
|
||||
while ($row = $db->fetch_array($result)) {
|
||||
$settings[$row['settinggroup']][$row['varname']] = $row['value'];
|
||||
}
|
||||
|
||||
@@ -170,8 +146,9 @@ fwrite($debugHandler, 'Froxlor settings have been loaded from the database' . "\
|
||||
* if settings['system']['mod_fcgid_ownvhost'] is set, we have to check
|
||||
* whether the permission of the files are still correct
|
||||
*/
|
||||
if((int)$settings['system']['mod_fcgid'] == 1 && (int)$settings['system']['mod_fcgid_ownvhost'] == 1)
|
||||
{
|
||||
if ((int)$settings['system']['mod_fcgid'] == 1
|
||||
&& (int)$settings['system']['mod_fcgid_ownvhost'] == 1
|
||||
) {
|
||||
fwrite($debugHandler, 'Checking froxlor file permissions');
|
||||
$mypath = makeCorrectDir(dirname(dirname(__FILE__))); // /var/www/froxlor, needed for chown
|
||||
$user = $settings['system']['mod_fcgid_httpuser'];
|
||||
@@ -181,17 +158,13 @@ if((int)$settings['system']['mod_fcgid'] == 1 && (int)$settings['system']['mod_f
|
||||
safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath));
|
||||
}
|
||||
|
||||
/**
|
||||
* be sure HTMLPurifier's cache folder is writable
|
||||
*/
|
||||
// be sure HTMLPurifier's cache folder is writable
|
||||
safe_exec('chmod -R 0755 '.escapeshellarg(dirname(__FILE__).'/classes/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer'));
|
||||
/**
|
||||
* end of HTMLPurifier check
|
||||
*/
|
||||
|
||||
|
||||
if (!isset($settings['panel']['version'])
|
||||
|| $settings['panel']['version'] != $version)
|
||||
{
|
||||
|| $settings['panel']['version'] != $version
|
||||
) {
|
||||
/**
|
||||
* Do not proceed further if the Database version is not the same as the script version
|
||||
*/
|
||||
@@ -208,17 +181,9 @@ fwrite($debugHandler, 'Froxlor version and database version are correct' . "\n")
|
||||
|
||||
$cronscriptDebug = ($settings['system']['debug_cron'] == '1') ? true : false;
|
||||
|
||||
/**
|
||||
* Create a new idna converter
|
||||
*/
|
||||
|
||||
// Create a new idna converter
|
||||
$idna_convert = new idna_convert_wrapper();
|
||||
|
||||
/**
|
||||
* Initialize logging
|
||||
*/
|
||||
|
||||
// Initialize logging
|
||||
$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'), $db, $settings);
|
||||
fwrite($debugHandler, 'Logger has been included' . "\n");
|
||||
|
||||
?>
|
||||
|
||||
@@ -15,15 +15,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
/**
|
||||
* Function checkLastGuid
|
||||
*
|
||||
* Checks if the system's last guid
|
||||
* is not higher than the one saved
|
||||
* in froxlor's database.
|
||||
* If it's higher, froxlor needs to
|
||||
* set its last guid to this one
|
||||
* to avoid conflicts with libnss-users
|
||||
* Checks if the system's last guid is not higher than the one saved
|
||||
* in froxlor's database. If it's higher, froxlor needs to
|
||||
* set its last guid to this one to avoid conflicts with libnss-users
|
||||
*
|
||||
* @param int guid (from froxlor database)
|
||||
*
|
||||
@@ -31,7 +28,7 @@
|
||||
*/
|
||||
function checkLastGuid() {
|
||||
|
||||
global $log, $cronlog, $db, $settings, $theme;
|
||||
global $log, $cronlog, $settings;
|
||||
|
||||
$mylog = null;
|
||||
if (isset($cronlog) && $cronlog instanceof FroxlorLogger) {
|
||||
@@ -45,7 +42,8 @@ function checkLastGuid() {
|
||||
$update_to_guid = 0;
|
||||
|
||||
$froxlor_guid = 0;
|
||||
$result = $db->query_first("SELECT MAX(`guid`) as `fguid` FROM `".TABLE_PANEL_CUSTOMERS."`");
|
||||
$result_stmt = Database::query("SELECT MAX(`guid`) as `fguid` FROM `".TABLE_PANEL_CUSTOMERS."`");
|
||||
$result = $result_stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$froxlor_guid = $result['fguid'];
|
||||
|
||||
$g_file = '/etc/group';
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
* 3 - SHA-256 $5$
|
||||
* 4 - SHA-512 $6$
|
||||
*/
|
||||
|
||||
function makeCryptPassword ($password) {
|
||||
|
||||
global $settings;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
define('MASTER_CRONJOB', 1);
|
||||
|
||||
include_once(dirname(__FILE__) . '/../lib/cron_init.php');
|
||||
include_once(dirname(dirname(__FILE__)) . '/lib/cron_init.php');
|
||||
|
||||
$jobs_to_run = includeCronjobs($debugHandler);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user