added new configio-class to reduce the duplicate code of removing config-files for the webservers (it's all pretty much the same), CAUTION: very untested
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -37,12 +37,11 @@ $cronlog->logAction(CRON_ACTION, LOG_INFO, "Searching for tasks to do");
|
||||
$result_tasks = $db->query("SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` ORDER BY `id` ASC");
|
||||
$resultIDs = array();
|
||||
|
||||
while($row = $db->fetch_array($result_tasks))
|
||||
{
|
||||
while ($row = $db->fetch_array($result_tasks)) {
|
||||
|
||||
$resultIDs[] = $row['id'];
|
||||
|
||||
if($row['data'] != '')
|
||||
{
|
||||
if ($row['data'] != '') {
|
||||
$row['data'] = unserialize($row['data']);
|
||||
}
|
||||
|
||||
@@ -50,140 +49,42 @@ while($row = $db->fetch_array($result_tasks))
|
||||
* TYPE=1 MEANS TO REBUILD APACHE VHOSTS.CONF
|
||||
*/
|
||||
|
||||
if($row['type'] == '1')
|
||||
{
|
||||
//dhr: cleanout froxlor-generated awstats configs prior to re-creation
|
||||
if ($settings['system']['awstats_enabled'] == '1')
|
||||
{
|
||||
$awstatsclean['header'] = "## GENERATED BY FROXLOR\n";
|
||||
$awstatsclean['headerold'] = "## GENERATED BY SYSCP\n";
|
||||
$awstatsclean['path'] = $settings['system']['awstats_conf'];
|
||||
if ($row['type'] == '1') {
|
||||
|
||||
/**
|
||||
* dont do anyting if the directory not exists
|
||||
* (e.g. awstats not installed yet or whatever)
|
||||
* fixes #45
|
||||
*/
|
||||
if (is_dir($awstatsclean['path']))
|
||||
{
|
||||
$awstatsclean['dir'] = dir($awstatsclean['path']);
|
||||
while($awstatsclean['entry'] = $awstatsclean['dir']->read()) {
|
||||
$awstatsclean['fullentry'] = makeCorrectFile($awstatsclean['path'].'/'.$awstatsclean['entry']);
|
||||
/**
|
||||
* dont do anything if the file does not exist
|
||||
*/
|
||||
if (file_exists($awstatsclean['fullentry']))
|
||||
{
|
||||
$awstatsclean['fh'] = fopen($awstatsclean['fullentry'], 'r');
|
||||
$awstatsclean['headerRead'] = fgets($awstatsclean['fh'], strlen($awstatsclean['header'])+1);
|
||||
fclose($awstatsclean['fh']);
|
||||
if($awstatsclean['headerRead'] == $awstatsclean['header'] || $awstatsclean['headerRead'] == $awstatsclean['headerold']) {
|
||||
$awstats_conf_file = makeCorrectFile($awstatsclean['fullentry']);
|
||||
$cronlog->logAction(CRON_ACTION, LOG_INFO, "Removing awstats configuration ".$awstats_conf_file." for re-creation");
|
||||
@unlink($awstats_conf_file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "File '".$awstatsclean['fullentry']."' could not be found, please check if you followed all the instructions on the configuration page");
|
||||
}
|
||||
// get configuration-I/O object
|
||||
$configio = new ConfigIO($settings);
|
||||
// clean up old configs
|
||||
$configio->cleanUp();
|
||||
|
||||
if (!isset($webserver)) {
|
||||
if ($settings['system']['webserver'] == "apache2") {
|
||||
$websrv = 'apache';
|
||||
if ($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1) {
|
||||
$websrv .= '_fcgid';
|
||||
}
|
||||
} elseif ($settings['system']['webserver'] == "lighttpd") {
|
||||
$websrv = 'lighttpd';
|
||||
if ($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1) {
|
||||
$websrv .= '_fcgid';
|
||||
}
|
||||
} elseif($settings['system']['webserver'] == "nginx") {
|
||||
$websrv = 'nginx';
|
||||
if ($settings['phpfpm']['enabled'] == 1) {
|
||||
$websrv .= '_phpfpm';
|
||||
}
|
||||
}
|
||||
unset($awstatsclean);
|
||||
}
|
||||
//end dhr
|
||||
|
||||
// clear fcgid - starter files prior to re-creation to keep it clean, #367
|
||||
if ($settings['system']['mod_fcgid'] == '1')
|
||||
{
|
||||
$configdir = makeCorrectDir($settings['system']['mod_fcgid_configdir']);
|
||||
|
||||
if (is_dir($configdir))
|
||||
{
|
||||
$its = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($configdir)
|
||||
);
|
||||
|
||||
// iterate through all subdirs,
|
||||
// look for php-fcgi-starter files
|
||||
// and take immutable-flag away from them
|
||||
// so we can delete them :)
|
||||
foreach ($its as $fullFileName => $it )
|
||||
{
|
||||
if ($it->isFile() && $it->getFilename() == 'php-fcgi-starter')
|
||||
{
|
||||
removeImmutable($its->getPathname());
|
||||
}
|
||||
}
|
||||
// now get rid of old stuff
|
||||
//(but append /* so we don't delete the directory)
|
||||
$configdir.='/*';
|
||||
safe_exec('rm -rf '. makeCorrectFile($configdir));
|
||||
}
|
||||
$webserver = new $websrv($db, $cronlog, $debugHandler, $idna_convert, $settings);
|
||||
}
|
||||
|
||||
// clear php-fpm-configurations prior to re-creation to keep it clean
|
||||
if ($settings['phpfpm']['enabled'] == '1')
|
||||
{
|
||||
$configdir = makeCorrectDir($settings['phpfpm']['configdir']);
|
||||
|
||||
if (is_dir($configdir))
|
||||
{
|
||||
// now get rid of old stuff
|
||||
//(but append /* so we don't delete the directory)
|
||||
$configdir.='/*';
|
||||
safe_exec('rm -rf '. makeCorrectFile($configdir));
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($webserver))
|
||||
{
|
||||
if($settings['system']['webserver'] == "apache2")
|
||||
{
|
||||
if($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1)
|
||||
{
|
||||
$webserver = new apache_fcgid($db, $cronlog, $debugHandler, $idna_convert, $settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
$webserver = new apache($db, $cronlog, $debugHandler, $idna_convert, $settings);
|
||||
}
|
||||
}
|
||||
elseif($settings['system']['webserver'] == "lighttpd")
|
||||
{
|
||||
if($settings['system']['mod_fcgid'] == 1 || $settings['phpfpm']['enabled'] == 1)
|
||||
{
|
||||
$webserver = new lighttpd_fcgid($db, $cronlog, $debugHandler, $idna_convert, $settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
$webserver = new lighttpd($db, $cronlog, $debugHandler, $idna_convert, $settings);
|
||||
}
|
||||
}
|
||||
elseif($settings['system']['webserver'] == "nginx")
|
||||
{
|
||||
if($settings['phpfpm']['enabled'] == 1)
|
||||
{
|
||||
$webserver = new nginx_phpfpm($db, $cronlog, $debugHandler, $idna_convert, $settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
$webserver = new nginx($db, $cronlog, $debugHandler, $idna_convert, $settings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($webserver))
|
||||
{
|
||||
if (isset($webserver)) {
|
||||
$webserver->createIpPort();
|
||||
$webserver->createVirtualHosts();
|
||||
$webserver->createFileDirOptions();
|
||||
$webserver->writeConfigs();
|
||||
$webserver->createOwnVhostStarter();
|
||||
$webserver->reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
echo "Please check you Webserver settings\n";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user