Commit de9ea816 authored by Marius Burkard's avatar Marius Burkard
Browse files

- remove entries customer_viewable != y from select box for admins

- move all updates to onAfterUpdate
- remove server parts that are not needed
parent 695761b4
Pipeline #5516 passed with stage
in 7 minutes and 28 seconds
......@@ -51,7 +51,7 @@ class page_action extends tform_actions {
function onShow() {
global $app, $conf;
if($this->id > 0){
$record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ?", $this->id);
if($record['master_directive_snippets_id'] > 0){
......@@ -59,13 +59,13 @@ class page_action extends tform_actions {
}
unset($record);
}
parent::onShow();
}
function onShowEnd() {
global $app, $conf;
global $app;
$is_master = false;
if($this->id > 0){
if($this->dataRecord['master_directive_snippets_id'] > 0){
......@@ -77,53 +77,52 @@ class page_action extends tform_actions {
}
$app->tpl->setVar("is_master", $is_master);
parent::onShowEnd();
}
function onSubmit() {
public function onAfterUpdate() {
global $app, $conf;
if(isset($this->dataRecord['update_sites']) && $this->dataRecord['update_sites'] === 'y') {
if($this->dataRecord['active'] == 'y' && $this->dataRecord['update_sites'] == 'y') {
if($this->dataRecord['type'] == 'php') {
$rlike = $this->dataRecord['directive_snippets_id'].'|,'.$this->dataRecord['directive_snippets_id'].'|'.$this->dataRecord['directive_snippets_id'].',';
$affected_snippets = $app->db->queryAllRecords('SELECT directive_snippets_id FROM directive_snippets WHERE required_php_snippets RLIKE(?) AND type = ?', $rlike, 'apache');
if(is_array($affected_snippets) && !empty($affected_snippets)) {
foreach($affected_snippets as $snippet) {
$sql_in[] = $snippet['directive_snippets_id'];
}
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id IN ?', $conf['server_id'], $sql_in);
}
} elseif($this->dataRecord['type'] == 'apache') {
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id = ?', $conf['server_id'], $this->dataRecord['directive_snippets_id']);
}
if(is_array($affected_sites) && !empty($affected_sites)) {
foreach($affected_sites as $site) {
$website = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ?', $site['domain_id']);
$app->db->datalogUpdate('web_domain', $website, 'domain_id', $site['domain_id'], true);
}
}
}
}
}
public function onSubmit() {
global $app;
if($this->id > 0){
$record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ?", $this->id);
if($record['master_directive_snippets_id'] > 0){
unset($app->tform->formDef["tabs"]['directive_snippets']['fields']['name'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['type'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['snippet'], $app->tform->formDef["tabs"]['directive_snippets']['fields']['required_php_snippets']);
}
if(isset($this->dataRecord['update_sites'])) {
parent::onSubmit();
} else {
$app->db->query('UPDATE directive_snippets SET name = ?, type = ?, snippet = ?, customer_viewable = ?, required_php_snippets = ?, active = ? WHERE directive_snippets_id = ?', $this->dataRecord['name'], $this->dataRecord['type'], $this->dataRecord['snippet'], $this->dataRecord['customer_viewable'], implode(',', $this->dataRecord['required_php_snippets']), $this->dataRecord['active'], $this->id);
if($_REQUEST["next_tab"] == '') {
$list_name = $_SESSION["s"]["form"]["return_to"];
if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) {
$redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"];
$_SESSION["s"]["form"]["return_to"] = '';
session_write_close();
header($redirect);
} elseif (isset($_SESSION["s"]["form"]["return_to_url"]) && $_SESSION["s"]["form"]["return_to_url"] != '') {
$redirect = $_SESSION["s"]["form"]["return_to_url"];
$_SESSION["s"]["form"]["return_to_url"] = '';
session_write_close();
header("Location: ".$redirect);
exit;
} else {
header("Location: ".$app->tform->formDef['list_default']);
}
exit;
}
}
unset($record);
}
parent::onSubmit();
}
}
$page = new page_action;
$page->onLoad();
?>
$page->onLoad();
\ No newline at end of file
......@@ -17,12 +17,14 @@
</div></tmpl_if>
</div>
<tmpl_if name='is_master'></tmpl_else>
<tmpl_if name='required_php_snippets'>
<div class="form-group php">
<label class="col-sm-3 control-label">{tmpl_var name='required_php_snippets_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='required_php_snippets'}
</div>
</div>
</tmpl_if>
</tmpl_if>
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='customer_viewable_txt'}</label>
......
......@@ -854,11 +854,12 @@ class page_action extends tform_actions {
$directive_snippets_id_select .= '</optgroup>';
}
if($is_admin) {
// it does not make sense to display those for admins as they are NOT applied to vhosts anyway!
/*if($is_admin) {
$directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE active = 'y' AND master_directive_snippets_id = 0 AND type = ? ORDER BY name ASC", $server_type);
} else {
} else {*/
$directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND master_directive_snippets_id = 0 AND type = ? ORDER BY name ASC", $server_type);
}
//}
if(is_array($directive_snippets) && !empty($directive_snippets)){
$directive_snippets_id_select .= '<optgroup label="'.$app->tform->wordbook["select_directive_snippet_txt"].'">';
foreach($directive_snippets as $directive_snippet){
......
......@@ -65,8 +65,7 @@ class web_module {
'aps_package_delete',
'aps_setting_insert',
'aps_setting_update',
'aps_setting_delete',
'directive_snippets_update'
'aps_setting_delete'
);
//* This function is called during ispconfig installation to determine
......@@ -117,7 +116,6 @@ class web_module {
$app->modules->registerTableHook('aps_instances_settings', 'web_module', 'process');
$app->modules->registerTableHook('aps_packages', 'web_module', 'process');
$app->modules->registerTableHook('aps_settings', 'web_module', 'process');
$app->modules->registerTableHook('directive_snippets', 'web_module', 'process');
// Register service
$app->services->registerService('httpd', 'web_module', 'restartHttpd');
......@@ -189,11 +187,6 @@ class web_module {
if($action == 'u') $app->plugins->raiseEvent('aps_setting_update', $data);
if($action == 'd') $app->plugins->raiseEvent('aps_setting_delete', $data);
break;
case 'directive_snippets':
if($action == 'i') $app->plugins->raiseEvent('directive_snippets_insert', $data);
if($action == 'u') $app->plugins->raiseEvent('directive_snippets_update', $data);
if($action == 'd') $app->plugins->raiseEvent('directive_snippets_delete', $data);
break;
} // end switch
} // end function
......@@ -229,7 +222,7 @@ class web_module {
} else {
$cmd = $app->system->getinitcommand($daemon, 'reload');
}
if($web_config['server_type'] == 'nginx'){
$app->log("Checking nginx configuration...", LOGLEVEL_DEBUG);
exec('nginx -t 2>&1', $retval['output'], $retval['retval']);
......@@ -240,16 +233,16 @@ class web_module {
return $retval;
}
}
exec($cmd.' 2>&1', $retval['output'], $retval['retval']);
// if restart failed despite successful syntax check => try again
if($web_config['server_type'] == 'nginx' && $retval['retval'] > 0){
sleep(2);
exec($cmd.' 2>&1', $retval['output'], $retval['retval']);
}
$app->log("Restarting httpd: $cmd", LOGLEVEL_DEBUG);
// nginx: do a syntax check because on some distributions, the init script always returns 0 - even if the syntax is not ok (how stupid is that?)
//if($web_config['server_type'] == 'nginx' && $retval['retval'] == 0){
//exec('nginx -t 2>&1', $retval['output'], $retval['retval']);
......@@ -272,7 +265,7 @@ class web_module {
} else {
$path_parts = pathinfo($init_script);
$initcommand = $app->system->getinitcommand($path_parts['basename'], $action, $path_parts['dirname']);
if($action == 'reload' && $init_script == $conf['init_scripts'].'/'.$web_config['php_fpm_init_script']) {
// we have to do a workaround because of buggy ubuntu fpm reload handling
// @see: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1242376
......@@ -289,7 +282,7 @@ class web_module {
}
*/
unset($tmp);
}
}
}
/*
if($action == 'reload') {
......
......@@ -95,34 +95,6 @@ class apache2_plugin {
$app->plugins->registerEvent('ftp_user_delete', $this->plugin_name, 'ftp_user_delete');
$app->plugins->registerAction('php_ini_changed', $this->plugin_name, 'php_ini_changed');
$app->plugins->registerEvent('directive_snippets_update', $this->plugin_name, 'directive_snippets');
}
function directive_snippets($event_name, $data) {
global $app, $conf;
$snippet = $data['new'];
if($snippet['active'] == 'y' && $snippet['update_sites'] == 'y') {
if($snippet['type'] == 'php') {
$rlike = $snippet['directive_snippets_id'].'|,'.$snippet['directive_snippets_id'].'|'.$snippet['directive_snippets_id'].',';
$affected_snippets = $app->db->queryAllRecords('SELECT directive_snippets_id FROM directive_snippets WHERE required_php_snippets RLIKE(?) AND type = ?', $rlike, 'apache');
if(is_array($affected_snippets) && !empty($affected_snippets)) {
foreach($affected_snippets as $snippet) $sql_in[] = $snippet['directive_snippets_id'];
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id IN ?', $conf['server_id'], $sql_in);
}
}
if($snippet['type'] == 'apache') $affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id = ?', $conf['server_id'], $snippet['directive_snippets_id']);
if(is_array($affected_sites) && !empty($affected_sites)) {
foreach($affected_sites as $site) {
$website = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ?', $site['domain_id']);
$new_data['old'] = $website;
$new_data['new'] = $website;
$this->update('web_domain_update', $new_data);
}
}
}
}
private function get_master_php_ini_content($web_data) {
......
......@@ -90,35 +90,6 @@ class nginx_plugin {
$app->plugins->registerEvent('web_folder_update', $this->plugin_name, 'web_folder_update');
$app->plugins->registerEvent('web_folder_delete', $this->plugin_name, 'web_folder_delete');
$app->plugins->registerEvent('directive_snippets_update', $this->plugin_name, 'directive_snippets');
}
function directive_snippets($event_name, $data) {
global $app, $conf;
$snippet = $data['new'];
if($snippet['active'] == 'y' && $snippet['update_sites'] == 'y') {
if($snippet['type'] == 'php') {
$rlike = $snippet['directive_snippets_id'].'|,'.$snippet['directive_snippets_id'].'|'.$snippet['directive_snippets_id'].',';
$affected_snippets = $app->db->queryAllRecords('SELECT directive_snippets_id FROM directive_snippets WHERE required_php_snippets RLIKE(?) AND type = ?', $rlike, 'nginx');
if(is_array($affected_snippets) && !empty($affected_snippets)) {
foreach($affected_snippets as $snippet) $sql_in[] = $snippet['directive_snippets_id'];
$affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id IN ?', $conf['server_id'], $sql_in);
}
}
if($snippet['type'] == 'nginx') $affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id = ?', $conf['server_id'], $snippet['directive_snippets_id']);
if(is_array($affected_sites) && !empty($affected_sites)) {
foreach($affected_sites as $site) {
$website = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ?', $site['domain_id']);
$new_data['old'] = $website;
$new_data['new'] = $website;
$this->update('web_domain_update', $new_data);
}
}
}
}
// Handle the creation of SSL certificates
......
Supports Markdown
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