diff --git a/server/mods-available/web_module.inc.php b/server/mods-available/web_module.inc.php index 12ad81ef9cd38db186728d0517e8a73422f03904..6019100ed76a01f59db4f82de24afd595798f117 100644 --- a/server/mods-available/web_module.inc.php +++ b/server/mods-available/web_module.inc.php @@ -54,6 +54,9 @@ class web_module { 'web_backup_insert', 'web_backup_update', 'web_backup_delete', + 'server_php_insert', + 'server_php_update', + 'server_php_delete', 'aps_instance_insert', 'aps_instance_update', 'aps_instance_delete', @@ -112,6 +115,7 @@ class web_module { $app->modules->registerTableHook('web_folder', 'web_module', 'process'); $app->modules->registerTableHook('web_folder_user', 'web_module', 'process'); $app->modules->registerTableHook('web_backup', 'web_module', 'process'); + $app->modules->registerTableHook('server_php', 'web_module', 'process'); $app->modules->registerTableHook('aps_instances', 'web_module', 'process'); $app->modules->registerTableHook('aps_instances_settings', 'web_module', 'process'); $app->modules->registerTableHook('aps_packages', 'web_module', 'process'); @@ -167,6 +171,11 @@ class web_module { if($action == 'u') $app->plugins->raiseEvent('web_backup_update', $data); if($action == 'd') $app->plugins->raiseEvent('web_backup_delete', $data); break; + case 'server_php': + if($action == 'i') $app->plugins->raiseEvent('server_php_insert', $data); + if($action == 'u') $app->plugins->raiseEvent('server_php_update', $data); + if($action == 'd') $app->plugins->raiseEvent('server_php_delete', $data); + break; case 'aps_instances': if($action == 'i') $app->plugins->raiseEvent('aps_instance_insert', $data); if($action == 'u') $app->plugins->raiseEvent('aps_instance_update', $data); diff --git a/server/plugins-available/webserver_plugin.inc.php b/server/plugins-available/webserver_plugin.inc.php index b39ac65da8753f2960bcf99dd9ef651ea91d246b..7d307233d8ed6ef8bbd65323eb1f5d2276158760 100644 --- a/server/plugins-available/webserver_plugin.inc.php +++ b/server/plugins-available/webserver_plugin.inc.php @@ -54,7 +54,11 @@ class webserver_plugin { global $app; $app->plugins->registerAction('server_plugins_loaded', $this->plugin_name, 'check_phpini_changes'); + $app->plugins->registerEvent('server_update', $this->plugin_name, 'server_update'); + + $app->plugins->registerEvent('server_php_insert', $this->plugin_name, 'server_php_update'); + $app->plugins->registerEvent('server_php_update', $this->plugin_name, 'server_php_update'); } /** @@ -184,6 +188,36 @@ class webserver_plugin { unset($processed); } + /** + * The method runs each php.ini file through verify_php_ini() + */ + function server_php_update($event_name, $data) { + global $app, $conf; + + if(isset($data['new']['php_fastcgi_ini_dir'])) { + $php_ini = $data['new']['php_fastcgi_ini_dir'] . '/php.ini'; + if(file_exists($php_ini)) { + $this->verify_php_ini(array('file' => $php_ini, + 'mode' => 'fast-cgi', + 'php_version' => $data['new']['server_php_id']) + ); + } else { + $app->log("Cannot verify php.ini, file not found: $php_ini", LOGLEVEL_WARN); + } + } + if(isset($data['new']['php_fpm_ini_dir'])) { + $php_ini = $data['new']['php_fpm_ini_dir'] . '/php.ini'; + if(file_exists($php_ini)) { + $this->verify_php_ini(array('file' => $php_ini, + 'mode' => 'php-fpm', + 'php_version' => $data['new']['server_php_id']) + ); + } else { + $app->log("Cannot verify php.ini, file not found: $php_ini", LOGLEVEL_WARN); + } + } + } + /** * The method checks/sets needed php.ini settings */ @@ -281,7 +315,32 @@ class webserver_plugin { } } } + + $check_files = array(); + if ($old['php_ini_path_apache'] != $new['php_ini_path_apache']) { + $check_files[] = array('file' => $new['php_ini_path_apache'], + 'mode' => 'mod', + 'php_version' => 0); + } + + if ($old['fastcgi_phpini_path'] != $new['fastcgi_phpini_path']) { + $check_files[] = array('file' => $new['fastcgi_phpini_path'], + 'mode' => 'fast-cgi', + 'php_version' => 0); + } + if ($old['php_ini_path_cgi'] != $new['php_ini_path_cgi']) { + $check_files[] = array('file' => $new['php_ini_path_cgi'], + 'mode' => 'fast-cgi', + 'php_version' => 0); + } + if ($old['php_fpm_ini_path'] != $new['php_fpm_ini_path']) { + $check_files[] = array('file' => $web_config['php_fpm_ini_path'], + 'mode' => 'php-fpm', + 'php_version' => 0); + } + foreach ($check_files as $file) { + $this->verify_php_ini($file); + } } } -?>