Commit 3ee39be0 authored by mcramer's avatar mcramer

FS#2546 - Update all custom php.ini files for webs on main php.ini change

 - added configuration options to server config (web tab, php section)
 - do not update custom php.inis if md5sum file does not exist
parent 126bdacc
......@@ -81,6 +81,7 @@ add_web_users_to_sshusers_group=y
connect_userid_to_webid=n
connect_userid_to_webid_start=10000
web_folder_protection=y
php_ini_check_minutes=1
[dns]
bind_user=root
......
......@@ -686,6 +686,17 @@ $form["tabs"]['web'] = array(
'width' => '40',
'maxlength' => '4000'
),
'php_ini_check_minutes' => array(
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'default' => '1',
'validators' => array(0 => array('type' => 'NOTEMPTY',
'errmsg' => 'php_ini_check_minutes_error_empty'),
),
'value' => '',
'width' => '10',
'maxlength' => '255'
),
'nginx_cgi_socket' => array(
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
......
......@@ -170,4 +170,7 @@ $wb['enable_ip_wildcard_txt'] = 'IP Adressen Wildcard (*) aktivieren';
$wb['web_folder_protection_txt'] = 'Webverzeichnis unveränderlich machen (erweiterte Attribute)';
$wb['overtraffic_notify_admin_txt'] = 'Überschreiten des Transfer Limits an den Administrator senden';
$wb['overtraffic_notify_client_txt'] = 'Überschreiten des Transfer Limits an den Kunden senden';
$wb['php_ini_check_minutes_txt'] = 'Prüfe System php.ini Dateien auf Änderungen alle';
$wb['php_ini_check_minutes_info_txt'] = 'Minute(n) (0 deaktiviert diese Funktion)';
$wb['php_ini_check_minutes_error_empty'] = 'Der Wert für die Einstellung der php.ini Prüfung ist ungültig.';
?>
......@@ -172,5 +172,8 @@ $wb["overtraffic_notify_admin_txt"] = 'Send overtraffic notification to admin';
$wb["overtraffic_notify_client_txt"] = 'Send overtraffic notification to client';
$wb["v6_prefix_txt"] = 'IPv6 Prefix';
$wb["vhost_rewrite_v6_txt"] = 'Rewrite IPv6 on Mirror';
$wb["v6_prefix_wrong"] = 'Invalid v6 Netmask format.';
$wb["v6_prefix_wrong"] = 'Invalid v6 Netmask format.';
$wb["php_ini_check_minutes_txt"] = 'Check system php.ini files for changes each';
$wb["php_ini_check_minutes_info_txt"] = 'minutes (0 disables checking)';
$wb['php_ini_check_minutes_error_empty'] = 'Invalid value for php.ini checking.';
?>
......@@ -195,6 +195,10 @@
<label for="php_open_basedir">{tmpl_var name='php_open_basedir_txt'}</label>
<input name="php_open_basedir" id="php_open_basedir" value="{tmpl_var name='php_open_basedir'}" size="40" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="php_ini_check_minutes">{tmpl_var name='php_ini_check_minutes_txt'}</label>
<input name="php_ini_check_minutes" id="php_ini_check_minutes" value="{tmpl_var name='php_ini_check_minutes'}" size="40" type="text" class="textInput" /> {tmpl_var name='php_ini_check_minutes_info_txt'}
</div>
</div>
<div class="subsectiontoggle"><span></span>{tmpl_var name='apps_vhost_settings_txt'}<em></em></div>
<div style="display:none;">
......
......@@ -79,6 +79,11 @@ class webserver_plugin {
$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
$fastcgi_config = $app->getconf->get_server_config($conf['server_id'], 'fastcgi');
if($web_config['php_ini_check_minutes'] == 0 || @date('i') % $web_config['php_ini_check_minutes'] != 0) {
$app->log('Info: php.ini change checking not enabled or not in this minute: ' . $web_config['php_ini_check_minutes'],LOGLEVEL_DEBUG);
return; // do not process
}
//** add default php.ini files to check
$check_files[] = array('file' => $web_config['php_ini_path_apache'],
'mode' => 'mod',
......@@ -118,7 +123,12 @@ class webserver_plugin {
$new_php_ini_md5 = array();
$php_ini_md5 = array();
$php_ini_changed = false;
if(file_exists(SCRIPT_PATH . '/php.ini.md5sum')) $php_ini_md5 = unserialize(base64_decode(trim($app->system->file_get_contents(SCRIPT_PATH . '/php.ini.md5sum'))));
$rewrite_ini_files = false;
if(file_exists(SCRIPT_PATH . '/temp/php.ini.md5sum')) {
$rewrite_ini_files = true;
$php_ini_md5 = unserialize(base64_decode(trim($app->system->file_get_contents(SCRIPT_PATH . '/temp/php.ini.md5sum'))));
}
if(!is_array($php_ini_md5)) $php_ini_md5 = array();
$processed = array();
......@@ -139,14 +149,14 @@ class webserver_plugin {
$app->log('Info: PHP.ini changed: ' . $file_path . ', mode ' . $file['mode'] . ' vers ' . $file['php_version'] . '.',LOGLEVEL_DEBUG);
// raise action for this file
$app->plugins->raiseAction('php_ini_changed', $file);
if($rewrite_ini_files == true) $app->plugins->raiseAction('php_ini_changed', $file);
}
$new_php_ini_md5[$file_path] = $file_md5;
}
//** write new md5 sums if something changed
if($php_ini_changed == true) $app->system->file_put_contents(SCRIPT_PATH . '/php.ini.md5sum', base64_encode(serialize($new_php_ini_md5)));
if($php_ini_changed == true) $app->system->file_put_contents(SCRIPT_PATH . '/temp/php.ini.md5sum', base64_encode(serialize($new_php_ini_md5)));
unset($new_php_ini_md5);
unset($php_ini_md5);
unset($processed);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment