Skip to content

Commit 7faccfc

Browse files
committed
call verify_php_ini from server_php_{insert,update} events
1 parent 0f7af6d commit 7faccfc

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

server/mods-available/web_module.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class web_module {
5454
'web_backup_insert',
5555
'web_backup_update',
5656
'web_backup_delete',
57+
'server_php_insert',
58+
'server_php_update',
59+
'server_php_delete',
5760
'aps_instance_insert',
5861
'aps_instance_update',
5962
'aps_instance_delete',
@@ -112,6 +115,7 @@ class that contains the function functionname.
112115
$app->modules->registerTableHook('web_folder', 'web_module', 'process');
113116
$app->modules->registerTableHook('web_folder_user', 'web_module', 'process');
114117
$app->modules->registerTableHook('web_backup', 'web_module', 'process');
118+
$app->modules->registerTableHook('server_php', 'web_module', 'process');
115119
$app->modules->registerTableHook('aps_instances', 'web_module', 'process');
116120
$app->modules->registerTableHook('aps_instances_settings', 'web_module', 'process');
117121
$app->modules->registerTableHook('aps_packages', 'web_module', 'process');
@@ -167,6 +171,11 @@ function process($tablename, $action, $data) {
167171
if($action == 'u') $app->plugins->raiseEvent('web_backup_update', $data);
168172
if($action == 'd') $app->plugins->raiseEvent('web_backup_delete', $data);
169173
break;
174+
case 'server_php':
175+
if($action == 'i') $app->plugins->raiseEvent('server_php_insert', $data);
176+
if($action == 'u') $app->plugins->raiseEvent('server_php_update', $data);
177+
if($action == 'd') $app->plugins->raiseEvent('server_php_delete', $data);
178+
break;
170179
case 'aps_instances':
171180
if($action == 'i') $app->plugins->raiseEvent('aps_instance_insert', $data);
172181
if($action == 'u') $app->plugins->raiseEvent('aps_instance_update', $data);

server/plugins-available/webserver_plugin.inc.php

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public function onLoad() {
5454
global $app;
5555

5656
$app->plugins->registerAction('server_plugins_loaded', $this->plugin_name, 'check_phpini_changes');
57+
5758
$app->plugins->registerEvent('server_update', $this->plugin_name, 'server_update');
59+
60+
$app->plugins->registerEvent('server_php_insert', $this->plugin_name, 'server_php_update');
61+
$app->plugins->registerEvent('server_php_update', $this->plugin_name, 'server_php_update');
5862
}
5963

6064
/**
@@ -184,6 +188,36 @@ public function check_phpini_changes() {
184188
unset($processed);
185189
}
186190

191+
/**
192+
* The method runs each php.ini file through verify_php_ini()
193+
*/
194+
function server_php_update($event_name, $data) {
195+
global $app, $conf;
196+
197+
if(isset($data['new']['php_fastcgi_ini_dir'])) {
198+
$php_ini = $data['new']['php_fastcgi_ini_dir'] . '/php.ini';
199+
if(file_exists($php_ini)) {
200+
$this->verify_php_ini(array('file' => $php_ini,
201+
'mode' => 'fast-cgi',
202+
'php_version' => $data['new']['server_php_id'])
203+
);
204+
} else {
205+
$app->log("Cannot verify php.ini, file not found: $php_ini", LOGLEVEL_WARN);
206+
}
207+
}
208+
if(isset($data['new']['php_fpm_ini_dir'])) {
209+
$php_ini = $data['new']['php_fpm_ini_dir'] . '/php.ini';
210+
if(file_exists($php_ini)) {
211+
$this->verify_php_ini(array('file' => $php_ini,
212+
'mode' => 'php-fpm',
213+
'php_version' => $data['new']['server_php_id'])
214+
);
215+
} else {
216+
$app->log("Cannot verify php.ini, file not found: $php_ini", LOGLEVEL_WARN);
217+
}
218+
}
219+
}
220+
187221
/**
188222
* The method checks/sets needed php.ini settings
189223
*/
@@ -281,7 +315,32 @@ function server_update($event_name, $data) {
281315
}
282316
}
283317
}
318+
319+
$check_files = array();
320+
if ($old['php_ini_path_apache'] != $new['php_ini_path_apache']) {
321+
$check_files[] = array('file' => $new['php_ini_path_apache'],
322+
'mode' => 'mod',
323+
'php_version' => 0);
324+
}
325+
326+
if ($old['fastcgi_phpini_path'] != $new['fastcgi_phpini_path']) {
327+
$check_files[] = array('file' => $new['fastcgi_phpini_path'],
328+
'mode' => 'fast-cgi',
329+
'php_version' => 0);
330+
}
331+
if ($old['php_ini_path_cgi'] != $new['php_ini_path_cgi']) {
332+
$check_files[] = array('file' => $new['php_ini_path_cgi'],
333+
'mode' => 'fast-cgi',
334+
'php_version' => 0);
335+
}
336+
if ($old['php_fpm_ini_path'] != $new['php_fpm_ini_path']) {
337+
$check_files[] = array('file' => $web_config['php_fpm_ini_path'],
338+
'mode' => 'php-fpm',
339+
'php_version' => 0);
340+
}
341+
foreach ($check_files as $file) {
342+
$this->verify_php_ini($file);
343+
}
284344
}
285345
}
286346

287-
?>

0 commit comments

Comments
 (0)