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

- removed master_directive_snippet code that was (in 2016) accidently...

- removed master_directive_snippet code that was (in 2016) accidently backported from master but never used
parent 3c53b6b7
Pipeline #5525 passed with stage
in 7 minutes and 27 seconds
......@@ -49,79 +49,32 @@ $app->uses('tpl,tform,tform_actions');
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){
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']);
}
unset($record);
}
parent::onShow();
}
function onShowEnd() {
global $app;
$is_master = false;
if($this->id > 0){
if($this->dataRecord['master_directive_snippets_id'] > 0){
$is_master = true;
$app->tpl->setVar("name", $this->dataRecord['name'], true);
$app->tpl->setVar("type", $this->dataRecord['type'], true);
$app->tpl->setVar("snippet", $this->dataRecord['snippet'], true);
}
}
$app->tpl->setVar("is_master", $is_master);
parent::onShowEnd();
}
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 REGEXP ? 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);
if(isset($this->dataRecord['update_sites']) && $this->dataRecord['update_sites'] === 'y' && $this->dataRecord['active'] === '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 REGEXP ? 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' || $this->dataRecord['type'] === 'nginx') {
$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']);
}
}
}
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(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);
}
}
}
parent::onSubmit();
}
}
$page = new page_action;
......
......@@ -57,8 +57,6 @@ class list_action extends listform_actions {
//* Alternating datarow colors
$this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
$rec['bgcolor'] = $this->DataRowColor;
$rec['is_master'] = $rec['master_directive_snippets_id'];
//* substitute value for select fields
if(is_array($app->listform->listDef['item']) && count($app->listform->listDef['item']) > 0) {
......@@ -79,15 +77,8 @@ class list_action extends listform_actions {
$rec['id'] = $rec[$this->idx_key];
return $rec;
}
}
$list = new list_action;
$list->SQLOrderBy = 'ORDER BY directive_snippets.name';
$list->onLoad();
//$app->listform_actions->SQLExtWhere = 'master_directive_snippets_id = 0';
/*
$app->listform_actions->SQLOrderBy = 'ORDER BY directive_snippets.name';
$app->listform_actions->onLoad();
*/
?>
......@@ -66,7 +66,7 @@ $form["tabs"]['directive_snippets'] = array (
'name' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array (
'validators' => array (
0 => array ( 'type' => 'NOTEMPTY', 'errmsg'=> 'directive_snippets_name_empty'),
1 => array ( 'type' => 'CUSTOM', 'class' => 'validate_server_directive_snippets', 'function' => 'validate_snippet'),
),
......@@ -121,7 +121,7 @@ $form["tabs"]['directive_snippets'] = array (
'formtype' => 'CHECKBOXARRAY',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name",
'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y' ORDER BY name",
'keyfield' => 'directive_snippets_id',
'valuefield' => 'name'
),
......
......@@ -74,7 +74,7 @@ $liste["item"][] = array( 'field' => "type",
'suffix' => "",
'width' => "",
'value' => array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP', 'proxy' => 'Proxy'));
$liste["item"][] = array( 'field' => "customer_viewable",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
......@@ -83,14 +83,3 @@ $liste["item"][] = array( 'field' => "customer_viewable",
'suffix' => "",
'width' => "",
'value' => array('y' => $app->lng('yes_txt'), 'n' => $app->lng('no_txt')));
$liste["item"][] = array( 'field' => "master_directive_snippets_id",
'datatype' => "BOOLEAN",
'formtype' => "SELECT",
'op' => "IS",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array(0 => $app->lng('select_directive_snippet_txt'), 1 => $app->lng('select_master_directive_snippet_txt')));
?>
<div class="form-group">
<label for="name" class="col-sm-3 control-label">{tmpl_var name='name_txt'}</label>
<tmpl_if name='is_master'><div class="col-sm-9 col-text">{tmpl_var name='name'}</div></tmpl_else><div class="col-sm-9"><input type="text" name="name" id="name" value="{tmpl_var name='name'}" class="form-control" /></div></tmpl_if>
<div class="col-sm-9"><input type="text" name="name" id="name" value="{tmpl_var name='name'}" class="form-control" /></div>
</div>
<div class="form-group">
<label for="type" class="col-sm-3 control-label">{tmpl_var name='type_txt'}</label>
<tmpl_if name='is_master'><div class="col-sm-9 col-text">{tmpl_var name='type'}</div></tmpl_else><div class="col-sm-9"><select name="type" id="type" class="form-control">
<div class="col-sm-9"><select name="type" id="type" class="form-control">
{tmpl_var name='type'}
</select></div></tmpl_if>
</select></div>
</div>
<div class="form-group">
<label for="snippet" class="col-sm-3 control-label">{tmpl_var name='snippet_txt'}</label>
<tmpl_if name='is_master'><div class="col-sm-9 col-text"><pre>{tmpl_var name='snippet'}</pre></div></tmpl_else><div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea>
<div class="col-sm-9"><textarea class="form-control" name="snippet" id="snippet" rows='10' cols='50'>{tmpl_var name='snippet'}</textarea>
&nbsp; Nginx {tmpl_var name='variables_txt'}: <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOMAIN}</a>, <a href="javascript:void(0);" class="addPlaceholder">{FASTCGIPASS}</a>, <a href="javascript:void(0);" class="addPlaceholder">{PHPFALLBACKFASTCGIPASS}</a><br />
&nbsp; Apache {tmpl_var name='variables_txt'}: <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOCROOT_CLIENT}</a>, <a href="javascript:void(0);" class="addPlaceholder">{DOMAIN}</a> <br />
&nbsp; PHP {tmpl_var name='variables_txt'}: <a href="javascript:void(0);" class="addPlaceholder">{WEBROOT}</a>
</div></tmpl_if>
</div>
</div>
<tmpl_if name='is_master'></tmpl_else>
<tmpl_if name='required_php_snippets'>
<div class="form-group php">
<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">
<div class="form-group">
<label class="col-sm-3 control-label">{tmpl_var name='customer_viewable_txt'}</label>
<div class="col-sm-9">
{tmpl_var name='customer_viewable'}
......
......@@ -17,7 +17,6 @@
<th data-column="name"><tmpl_var name="name_txt"></th>
<th data-column="type"><tmpl_var name="type_txt"></th>
<th data-column="customer_viewable"><tmpl_var name="customer_viewable_txt"></th>
<th data-column="master_directive_snippets_id"><tmpl_var name="master_directive_snippets_id_txt"></th>
<th class="small-col text-right">{tmpl_var name='search_limit'}</th>
</tr>
<tr>
......@@ -25,7 +24,6 @@
<td><input class="form-control" type="text" name="search_name" value="{tmpl_var name='search_name'}" /></td>
<td><select class="form-control" name="search_type">{tmpl_var name='search_type'}</select></td>
<td><select class="form-control" name="search_customer_viewable">{tmpl_var name='search_customer_viewable'}</select></td>
<td><select class="form-control" name="search_master_directive_snippets_id">{tmpl_var name='search_master_directive_snippets_id'}</select></td>
<td class="text-right">
<button type="button" class="btn btn-default formbutton-default formbutton-narrow" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" data-submit-form="pageForm" data-form-action="admin/directive_snippets_list.php"><span class="icon icon-filter"></span></button>
</td>
......@@ -38,22 +36,21 @@
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="name"}</a></td>
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="type"}</a></td>
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="customer_viewable"}</a></td>
<td><a href="#" data-load-content="admin/directive_snippets_edit.php?id={tmpl_var name='id'}">{tmpl_var name="master_directive_snippets_id"}</a></td>
<td class="text-right">
<tmpl_if name='is_master'></tmpl_else><a class="btn btn-default formbutton-danger formbutton-narrow" href="javascript: ISPConfig.confirm_action('admin/directive_snippets_del.php?id={tmpl_var name='id'}&_csrf_id={tmpl_var name='csrf_id'}&_csrf_key={tmpl_var name='csrf_key'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span class="icon icon-delete"></span></a></tmpl_if>
<a class="btn btn-default formbutton-danger formbutton-narrow" href="javascript: ISPConfig.confirm_action('admin/directive_snippets_del.php?id={tmpl_var name='id'}&_csrf_id={tmpl_var name='csrf_id'}&_csrf_key={tmpl_var name='csrf_key'}&phpsessid={tmpl_var name='phpsessid'}','{tmpl_var name='delete_confirmation'}');"><span class="icon icon-delete"></span></a>
</td>
</tr>
</tmpl_loop>
<tmpl_unless name="records">
<tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td colspan="6">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
<td colspan="5">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
</tr>
</tmpl_unless>
</tbody>
<tfoot>
<tr>
<td colspan="6"><tmpl_var name="paging"></td>
<td colspan="5"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
......
......@@ -203,11 +203,9 @@ if ($type == 'getdirectivesnippet') {
$web_config = $app->getconf->get_server_config($server_id, 'web');
if (!empty($web_config['server_type'])) $server_type = $web_config['server_type'];
$m_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);
$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);
$snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND type = ? ORDER BY name ASC", $server_type);
$json = json_encode(array('m_snippets' => $m_snippets, 'snippets' => $snippets));
$json = json_encode(array('snippets' => $snippets));
}
if($type == 'getclientssldata'){
......@@ -216,7 +214,7 @@ if($type == 'getclientssldata'){
$client = $app->db->queryOneRecord("SELECT company_name,contact_firstname, contact_name, street, zip, city, telephone, mobile,fax, country, state, email FROM client WHERE client_id = ?",$sys_group['client_id']);
if(is_array($client) && !empty($client)){
if($client['telephone'] == '' && $client['mobile'] != '') $client['telephone'] = $client['mobile'];
$fname = '';
$lname = '';
$parts = preg_split("/\s+/", $client['contact_name']);
......
......@@ -420,18 +420,6 @@
function reloadDirectiveSnippets() {
jQuery.getJSON('sites/ajax_get_json.php'+ '?' + Math.round(new Date().getTime()), {server_id : serverId, type : "getdirectivesnippet"}, function(data) {
var options = '<option value="0">-</option>';
options += "<optgroup label=\"{tmpl_var name='select_master_directive_snippet_txt'}\">";
for (var i = 0, len = data['m_snippets'].length; i < len; i++) {
var isSelected = '';
if ($('#directive_snippets_id').val() == i + 1) {
isSelected = 'selected="selected"';
}
options += '<option ' + isSelected + ' value="' + data['m_snippets'][i]['directive_snippets_id'] + '">' + data['m_snippets'][i]['name'] + '</option>';
}
options += '</optgroup>';
options += "<optgroup label=\"{tmpl_var name='select_directive_snippet_txt'}\">";
for (var i = 0, len = data['snippets'].length; i < len; i++) {
var isSelected = '';
......
......@@ -419,17 +419,8 @@ class page_action extends tform_actions {
if($sites_config['reseller_can_use_options']) {
// Directive Snippets
$php_directive_snippets_txt = '';
$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){
$php_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($php_directive_snippets as $php_directive_snippet){
$php_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $php_directive_snippet['snippet'] . PHP_EOL;
$php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$php_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($php_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$php_directive_snippets_txt .= '<br><br>';
}
$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' ORDER BY name");
if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){
$php_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($php_directive_snippets as $php_directive_snippet){
......@@ -442,17 +433,7 @@ class page_action extends tform_actions {
if($server_type == 'apache'){
$apache_directive_snippets_txt = '';
$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){
$apache_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($apache_directive_snippets as $apache_directive_snippet){
$apache_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $apache_directive_snippet['snippet'] . PHP_EOL;
$apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$apache_directive_snippet['name'].']<pre class="addPlaceholderContent" style="display:none;">'.htmlentities($apache_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$apache_directive_snippets_txt .= '<br><br>';
}
$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' ORDER BY name");
if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){
$apache_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($apache_directive_snippets as $apache_directive_snippet){
......@@ -466,17 +447,7 @@ class page_action extends tform_actions {
if($server_type == 'nginx'){
$nginx_directive_snippets_txt = '';
$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){
$nginx_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($nginx_directive_snippets as $nginx_directive_snippet){
$nginx_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $nginx_directive_snippet['snippet'] . PHP_EOL;
$nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$app->functions->htmlentities($nginx_directive_snippet['name']).']<pre class="addPlaceholderContent" style="display:none;">'.$app->functions->htmlentities($nginx_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$nginx_directive_snippets_txt .= '<br><br>';
}
$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' ORDER BY name");
if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){
$nginx_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($nginx_directive_snippets as $nginx_directive_snippet){
......@@ -489,17 +460,7 @@ class page_action extends tform_actions {
}
$proxy_directive_snippets_txt = '';
$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
$proxy_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($proxy_directive_snippets as $proxy_directive_snippet){
$proxy_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $proxy_directive_snippet['snippet'] . PHP_EOL;
$proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$app->functions->htmlentities($proxy_directive_snippet['name']).']<pre class="addPlaceholderContent" style="display:none;">'.$app->functions->htmlentities($proxy_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$proxy_directive_snippets_txt .= '<br><br>';
}
$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' ORDER BY name");
if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
$proxy_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($proxy_directive_snippets as $proxy_directive_snippet){
......@@ -633,17 +594,7 @@ class page_action extends tform_actions {
// Directive Snippets
$php_directive_snippets_txt = '';
$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){
$php_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($php_directive_snippets as $php_directive_snippet){
$php_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $php_directive_snippet['snippet'] . PHP_EOL;
$php_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$app->functions->htmlentities($php_directive_snippet['name']).']<pre class="addPlaceholderContent" style="display:none;">'.$app->functions->htmlentities($php_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$php_directive_snippets_txt .= '<br><br>';
}
$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y' ORDER BY name");
if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){
$php_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($php_directive_snippets as $php_directive_snippet){
......@@ -656,17 +607,7 @@ class page_action extends tform_actions {
if($server_type == 'apache'){
$apache_directive_snippets_txt = '';
$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){
$apache_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($apache_directive_snippets as $apache_directive_snippet){
$apache_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $apache_directive_snippet['snippet'] . PHP_EOL;
$apache_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$app->functions->htmlentities($apache_directive_snippet['name']).']<pre class="addPlaceholderContent" style="display:none;">'.$app->functions->htmlentities($apache_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$apache_directive_snippets_txt .= '<br><br>';
}
$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y' ORDER BY name");
if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){
$apache_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($apache_directive_snippets as $apache_directive_snippet){
......@@ -680,17 +621,7 @@ class page_action extends tform_actions {
if($server_type == 'nginx'){
$nginx_directive_snippets_txt = '';
$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){
$nginx_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($nginx_directive_snippets as $nginx_directive_snippet){
$nginx_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $nginx_directive_snippet['snippet'] . PHP_EOL;
$nginx_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$app->functions->htmlentities($nginx_directive_snippet['name']).']<pre class="addPlaceholderContent" style="display:none;">'.$app->functions->htmlentities($nginx_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$nginx_directive_snippets_txt .= '<br><br>';
}
$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y' ORDER BY name");
if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){
$nginx_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($nginx_directive_snippets as $nginx_directive_snippet){
......@@ -703,17 +634,7 @@ class page_action extends tform_actions {
}
$proxy_directive_snippets_txt = '';
$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id > 0 ORDER BY name");
if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
$proxy_directive_snippets_txt .= $app->tform->wordbook["select_master_directive_snippet_txt"].'<br>';
foreach($proxy_directive_snippets as $proxy_directive_snippet){
$proxy_directive_snippet['snippet'] = PHP_EOL . PHP_EOL . $proxy_directive_snippet['snippet'] . PHP_EOL;
$proxy_directive_snippets_txt .= '<a href="javascript:void(0);" class="addPlaceholderContent">['.$app->functions->htmlentities($proxy_directive_snippet['name']).']<pre class="addPlaceholderContent" style="display:none;">'.$app->functions->htmlentities($proxy_directive_snippet['snippet']).'</pre></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
$proxy_directive_snippets_txt .= '<br><br>';
}
$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' AND master_directive_snippets_id = 0 ORDER BY name");
$proxy_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'proxy' AND active = 'y' ORDER BY name");
if(is_array($proxy_directive_snippets) && !empty($proxy_directive_snippets)){
$proxy_directive_snippets_txt .= $app->tform->wordbook["select_directive_snippet_txt"].'<br>';
foreach($proxy_directive_snippets as $proxy_directive_snippet){
......@@ -845,20 +766,11 @@ class page_action extends tform_actions {
$server_type = $app->getconf->get_server_config($server_id, 'web');
$server_type = $server_type['server_type'];
$m_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($m_directive_snippets) && !empty($m_directive_snippets)){
$directive_snippets_id_select .= '<optgroup label="'.$app->tform->wordbook["select_master_directive_snippet_txt"].'">';
foreach($m_directive_snippets as $m_directive_snippet){
$directive_snippets_id_select .= '<option value="'.$m_directive_snippet['directive_snippets_id'].'"'.($this->dataRecord['directive_snippets_id'] == $m_directive_snippet['directive_snippets_id']? ' selected="selected"' : '').'>'.$app->functions->htmlentities($m_directive_snippet['name']).'</option>';
}
$directive_snippets_id_select .= '</optgroup>';
}
// 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);
$directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE active = 'y' AND type = ? ORDER BY name ASC", $server_type);
} 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);
$directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' 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"].'">';
......@@ -880,8 +792,7 @@ class page_action extends tform_actions {
$this->dataRecord['folder_directive_snippets'] = trim($this->dataRecord['folder_directive_snippets']);
}
$master_directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND snippet LIKE '%{FOLDER}%' AND master_directive_snippets_id > 0 AND type = ? ORDER BY name ASC", $server_type);
$c_directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND snippet LIKE '%{FOLDER}%' AND master_directive_snippets_id = 0 AND type = ? ORDER BY name ASC", $server_type);
$c_directive_snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND active = 'y' AND snippet LIKE '%{FOLDER}%' AND type = ? ORDER BY name ASC", $server_type);
$folder_directive_snippets = array();
$this->dataRecord['folder_directive_snippets'] = str_replace("\r\n", "\n", $this->dataRecord['folder_directive_snippets']);
......@@ -898,14 +809,6 @@ class page_action extends tform_actions {
if(trim($folder_directive_snippets_lines[$i]) != ''){
list($folder_directive_snippets[$i]['folder_directive_snippets_folder'], $selected_snippet) = explode(':', trim($folder_directive_snippets_lines[$i]));
$folder_directive_snippets[$i]['folder_directive_snippets_id'] = '<option value="0">-</option>';
if(is_array($master_directive_snippets) && !empty($master_directive_snippets)){
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '<optgroup label="'.$app->tform->wordbook["select_master_directive_snippet_txt"].'">';
foreach($master_directive_snippets as $master_directive_snippet){
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '<option value="'.$master_directive_snippet['directive_snippets_id'].'"'.($master_directive_snippet['directive_snippets_id'] == $selected_snippet ? ' selected="selected"' : '').'>'.$master_directive_snippet['name'].'</option>';
}
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '</optgroup>';
}
if(is_array($c_directive_snippets) && !empty($c_directive_snippets)){
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '<optgroup label="'.$app->tform->wordbook["select_directive_snippet_txt"].'">';
foreach($c_directive_snippets as $c_directive_snippet){
......@@ -916,14 +819,6 @@ class page_action extends tform_actions {
} else {
$folder_directive_snippets[$i]['folder_directive_snippets_folder'] = '';
$folder_directive_snippets[$i]['folder_directive_snippets_id'] = '<option value="0">-</option>';
if(is_array($master_directive_snippets) && !empty($master_directive_snippets)){
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '<optgroup label="'.$app->tform->wordbook["select_master_directive_snippet_txt"].'">';
foreach($master_directive_snippets as $master_directive_snippet){
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '<option value="'.$master_directive_snippet['directive_snippets_id'].'">'.$master_directive_snippet['name'].'</option>';
}
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '</optgroup>';
}
if(is_array($c_directive_snippets) && !empty($c_directive_snippets)){
$folder_directive_snippets[$i]['folder_directive_snippets_id'] .= '<optgroup label="'.$app->tform->wordbook["select_directive_snippet_txt"].'">';
foreach($c_directive_snippets as $c_directive_snippet){
......
......@@ -3236,7 +3236,7 @@ class apache2_plugin {
foreach($required_php_snippets as $required_php_snippet){
$required_php_snippet = intval($required_php_snippet);
if($required_php_snippet > 0){
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE ".($snippet['master_directive_snippets_id'] > 0 ? 'master_' : '')."directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet['snippet'] = trim($php_snippet['snippet']);
if($php_snippet['snippet'] != ''){
$custom_php_ini_settings .= "\n".$php_snippet['snippet'];
......@@ -3409,7 +3409,7 @@ class apache2_plugin {
foreach($required_php_snippets as $required_php_snippet){
$required_php_snippet = intval($required_php_snippet);
if($required_php_snippet > 0){
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE ".($snippet['master_directive_snippets_id'] > 0 ? 'master_' : '')."directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet['snippet'] = trim($php_snippet['snippet']);
if($php_snippet['snippet'] != ''){
$custom_php_ini_settings .= "\n".$php_snippet['snippet'];
......
......@@ -2800,7 +2800,7 @@ class nginx_plugin {
foreach($required_php_snippets as $required_php_snippet){
$required_php_snippet = intval($required_php_snippet);
if($required_php_snippet > 0){
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE ".($snippet['master_directive_snippets_id'] > 0 ? 'master_' : '')."directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet['snippet'] = trim($php_snippet['snippet']);
if($php_snippet['snippet'] != ''){
$custom_php_ini_settings .= "\n".$php_snippet['snippet'];
......@@ -2987,7 +2987,7 @@ class nginx_plugin {
foreach($required_php_snippets as $required_php_snippet){
$required_php_snippet = intval($required_php_snippet);
if($required_php_snippet > 0){
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE ".($snippet['master_directive_snippets_id'] > 0 ? 'master_' : '')."directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet);
$php_snippet['snippet'] = trim($php_snippet['snippet']);
if($php_snippet['snippet'] != ''){
$custom_php_ini_settings .= "\n".$php_snippet['snippet'];
......
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