|
49 | 49 |
|
50 | 50 | class page_action extends tform_actions { |
51 | 51 |
|
52 | | - function onShow() { |
53 | | - global $app, $conf; |
54 | | - |
55 | | - if($this->id > 0){ |
56 | | - $record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ?", $this->id); |
57 | | - if($record['master_directive_snippets_id'] > 0){ |
58 | | - 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']); |
59 | | - } |
60 | | - unset($record); |
61 | | - } |
62 | | - |
63 | | - parent::onShow(); |
64 | | - } |
65 | | - |
66 | | - function onShowEnd() { |
67 | | - global $app; |
68 | | - |
69 | | - $is_master = false; |
70 | | - if($this->id > 0){ |
71 | | - if($this->dataRecord['master_directive_snippets_id'] > 0){ |
72 | | - $is_master = true; |
73 | | - $app->tpl->setVar("name", $this->dataRecord['name'], true); |
74 | | - $app->tpl->setVar("type", $this->dataRecord['type'], true); |
75 | | - $app->tpl->setVar("snippet", $this->dataRecord['snippet'], true); |
76 | | - } |
77 | | - } |
78 | | - |
79 | | - $app->tpl->setVar("is_master", $is_master); |
80 | | - |
81 | | - parent::onShowEnd(); |
82 | | - } |
83 | 52 |
|
84 | 53 | public function onAfterUpdate() { |
85 | 54 | global $app, $conf; |
86 | 55 |
|
87 | | - if(isset($this->dataRecord['update_sites']) && $this->dataRecord['update_sites'] === 'y') { |
88 | | - if($this->dataRecord['active'] === 'y' && $this->dataRecord['update_sites'] === 'y') { |
89 | | - if($this->dataRecord['type'] === 'php') { |
90 | | - $rlike = $this->dataRecord['directive_snippets_id'].'|,'.$this->dataRecord['directive_snippets_id'].'|'.$this->dataRecord['directive_snippets_id'].','; |
91 | | - $affected_snippets = $app->db->queryAllRecords('SELECT directive_snippets_id FROM directive_snippets WHERE required_php_snippets REGEXP ? AND type = ?', $rlike, 'apache'); |
92 | | - if(is_array($affected_snippets) && !empty($affected_snippets)) { |
93 | | - foreach($affected_snippets as $snippet) { |
94 | | - $sql_in[] = $snippet['directive_snippets_id']; |
95 | | - } |
96 | | - $affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id IN ?', $conf['server_id'], $sql_in); |
97 | | - } |
98 | | - } elseif($this->dataRecord['type'] === 'apache') { |
99 | | - $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']); |
100 | | - } |
101 | | - |
102 | | - if(is_array($affected_sites) && !empty($affected_sites)) { |
103 | | - foreach($affected_sites as $site) { |
104 | | - $website = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ?', $site['domain_id']); |
105 | | - $app->db->datalogUpdate('web_domain', $website, 'domain_id', $site['domain_id'], true); |
| 56 | + if(isset($this->dataRecord['update_sites']) && $this->dataRecord['update_sites'] === 'y' && $this->dataRecord['active'] === 'y') { |
| 57 | + if($this->dataRecord['type'] === 'php') { |
| 58 | + $rlike = $this->dataRecord['directive_snippets_id'].'|,'.$this->dataRecord['directive_snippets_id'].'|'.$this->dataRecord['directive_snippets_id'].','; |
| 59 | + $affected_snippets = $app->db->queryAllRecords('SELECT directive_snippets_id FROM directive_snippets WHERE required_php_snippets REGEXP ? AND type = ?', $rlike, 'apache'); |
| 60 | + if(is_array($affected_snippets) && !empty($affected_snippets)) { |
| 61 | + foreach($affected_snippets as $snippet) { |
| 62 | + $sql_in[] = $snippet['directive_snippets_id']; |
106 | 63 | } |
| 64 | + $affected_sites = $app->db->queryAllRecords('SELECT domain_id FROM web_domain WHERE server_id = ? AND directive_snippets_id IN ?', $conf['server_id'], $sql_in); |
107 | 65 | } |
| 66 | + } elseif($this->dataRecord['type'] === 'apache' || $this->dataRecord['type'] === 'nginx') { |
| 67 | + $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']); |
108 | 68 | } |
109 | | - } |
110 | | - } |
111 | | - |
112 | | - public function onSubmit() { |
113 | | - global $app; |
114 | 69 |
|
115 | | - if($this->id > 0){ |
116 | | - $record = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ?", $this->id); |
117 | | - if($record['master_directive_snippets_id'] > 0){ |
118 | | - 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']); |
| 70 | + if(is_array($affected_sites) && !empty($affected_sites)) { |
| 71 | + foreach($affected_sites as $site) { |
| 72 | + $website = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ?', $site['domain_id']); |
| 73 | + $app->db->datalogUpdate('web_domain', $website, 'domain_id', $site['domain_id'], true); |
| 74 | + } |
119 | 75 | } |
120 | 76 | } |
121 | | - |
122 | | - parent::onSubmit(); |
123 | 77 | } |
124 | | - |
125 | 78 | } |
126 | 79 |
|
127 | 80 | $page = new page_action; |
|
0 commit comments