Merge branch 'master' of http://git.ispconfig.org/ispconfig/ispconfig3
11 files modified
5 files added
New file |
| | |
| | | ALTER TABLE `directive_snippets` ADD `customer_viewable` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `snippet`; |
| | | ALTER TABLE `web_domain` ADD `directive_snippets_id` int(11) unsigned NOT NULL default '0'; |
| | |
| | | `name` varchar(255) DEFAULT NULL, |
| | | `type` varchar(255) DEFAULT NULL, |
| | | `snippet` mediumtext, |
| | | `customer_viewable` ENUM('n','y') NOT NULL DEFAULT 'n', |
| | | `active` enum('n','y') NOT NULL DEFAULT 'y', |
| | | PRIMARY KEY (`directive_snippets_id`) |
| | | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; |
| | |
| | | `rewrite_rules` mediumtext, |
| | | `added_date` date NOT NULL DEFAULT '0000-00-00', |
| | | `added_by` varchar(255) DEFAULT NULL, |
| | | `directive_snippets_id` int(11) unsigned NOT NULL default '0', |
| | | PRIMARY KEY (`domain_id`), |
| | | UNIQUE KEY `serverdomain` ( `server_id` , `ip_address`, `domain` ) |
| | | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; |
New file |
| | |
| | | <?php
|
| | |
|
| | |
|
| | | class plugin_directive_snippets extends plugin_base
|
| | | {
|
| | | var $module;
|
| | | var $form;
|
| | | var $tab;
|
| | | var $record_id;
|
| | | var $formdef;
|
| | | var $options;
|
| | |
|
| | | public function onShow()
|
| | | {
|
| | | global $app;
|
| | |
|
| | | $listTpl = new tpl;
|
| | | $listTpl->newTemplate('templates/web_directive_snippets.htm');
|
| | |
|
| | | //* Loading language file
|
| | | $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_web_directive_snippets.lng";
|
| | |
|
| | | include $lng_file;
|
| | | $listTpl->setVar($wb);
|
| | |
|
| | | $message = '';
|
| | | $error = '';
|
| | |
|
| | | $server_type = $app->getconf->get_server_config($this->form->dataRecord['server_id'], 'web');
|
| | | $server_type = $server_type['server_type'];
|
| | | $records = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND type = ? ORDER BY name ASC", $server_type);
|
| | |
|
| | | for ($i = 0, $c = count($records); $i < $c; $i++)
|
| | | {
|
| | | $records[$i]['is_selected'] = false;
|
| | |
|
| | | if ($this->form->dataRecord['directive_snippets_id'] === $records[$i]['directive_snippets_id'])
|
| | | $records[$i]['is_selected'] = true;
|
| | | }
|
| | |
|
| | | $listTpl->setLoop('records', $records);
|
| | |
|
| | | $list_name = 'directive_snippets_list';
|
| | | $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id;
|
| | | $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"];
|
| | | $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"];
|
| | | $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"];
|
| | | $_SESSION["s"]["form"]["return_to"] = $list_name;
|
| | |
|
| | | return $listTpl->grab();
|
| | | }
|
| | | |
| | | public function onUpdate()
|
| | | {
|
| | | global $app, $conf;
|
| | |
|
| | | if (isset($this->form->dataRecord['directive_snippets_id']) && $this->form->oldDataRecord['directive_snippets_id'] !== $this->form->dataRecord['directive_snippets_id']) {
|
| | | $app->db->query('UPDATE web_domain SET directive_snippets_id = ? WHERE domain_id = ?', $this->form->dataRecord['directive_snippets_id'], $this->form->id);
|
| | | }
|
| | | }
|
| | |
|
| | | public function onInsert()
|
| | | {
|
| | | global $app, $conf;
|
| | |
|
| | | if (isset($this->form->dataRecord['directive_snippets_id'])) {
|
| | | $app->db->query('UPDATE web_domain SET directive_snippets_id = ? WHERE domain_id = ?', $this->form->dataRecord['directive_snippets_id'], $this->form->id);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | ?> |
| | |
| | | 'maxlength' => '255', |
| | | 'searchable' => 2 |
| | | ), |
| | | 'customer_viewable' => array ( |
| | | 'datatype' => 'VARCHAR', |
| | | 'formtype' => 'CHECKBOX', |
| | | 'default' => 'n', |
| | | 'value' => array(0 => 'n', 1 => 'y') |
| | | ), |
| | | 'active' => array ( |
| | | 'datatype' => 'VARCHAR', |
| | | 'formtype' => 'CHECKBOX', |
| | |
| | | $wb['directive_snippets_name_empty'] = 'Bitte geben Sie einen Namen für den Schnipsel an.'; |
| | | $wb['directive_snippets_name_error_unique'] = 'Es existiert schon ein Direktiven-Schnipsel mit diesem Namen.'; |
| | | $wb['variables_txt'] = 'Variablen'; |
| | | $wb['customer_viewable_txt'] = 'Sichtbar für Kunden'; |
| | | ?> |
| | |
| | | $wb["directive_snippets_name_empty"] = 'Please specify a name for the snippet.'; |
| | | $wb["directive_snippets_name_error_unique"] = 'There is already a directive snippet with this name.'; |
| | | $wb['variables_txt'] = 'Variables'; |
| | | $wb['customer_viewable_txt'] = 'Customer viewable'; |
| | | ?> |
| | |
| | | <label for="snippet">{tmpl_var name='snippet_txt'}</label> |
| | | <textarea name="snippet" id="snippet" rows='10' cols='50' style="width:400px;">{tmpl_var name='snippet'}</textarea><span class="nginx"> {tmpl_var name='variables_txt'}: </span><a href="javascript:void(0);" class="addPlaceholder nginx">{DOCROOT}</a><span class="nginx">, </span><a href="javascript:void(0);" class="addPlaceholder nginx">{FASTCGIPASS}</a> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <p class="label">{tmpl_var name='customer_viewable_txt'}</p> |
| | | <div class="multiField"> |
| | | {tmpl_var name='customer_viewable'} |
| | | </div> |
| | | </div> |
| | | <div class="ctrlHolder"> |
| | | <p class="label">{tmpl_var name='active_txt'}</p> |
| | | <div class="multiField"> |
| | |
| | | } else { |
| | | jQuery('.nginx:visible').hide(); |
| | | } |
| | | |
| | | if (jQuery('#type').val() != 'nginx' && jQuery('#type').val() != 'apache') { |
| | | jQuery('#customer_viewable').closest('div.ctrlHolder:visible').hide(); |
| | | }else { |
| | | jQuery('#customer_viewable').closest('div.ctrlHolder:hidden').show(); |
| | | } |
| | | |
| | | jQuery('#type').change(function(){ |
| | | if (jQuery(this).val() != 'nginx' && jQuery(this).val() != 'apache') { |
| | | jQuery('#customer_viewable').closest('div.ctrlHolder:visible').hide(); |
| | | } else { |
| | | jQuery('#customer_viewable').closest('div.ctrlHolder:hidden').show(); |
| | | } |
| | | if(jQuery(this).val() == 'nginx'){ |
| | | jQuery('.nginx:hidden').show(); |
| | | } else { |
| | |
| | | $json .= '"}'; |
| | | } |
| | | |
| | | if ($type == 'getdirectivesnippet') { |
| | | $server_type = 'apache'; |
| | | $web_config = $app->getconf->get_server_config($server_id, 'web'); |
| | | if (!empty($web_config['server_type'])) |
| | | $server_type = $web_config['server_type']; |
| | | |
| | | $snippets = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND type = ? ORDER BY name ASC", $server_type); |
| | | |
| | | $json = json_encode($snippets); |
| | | } |
| | | |
| | | //} |
| | | |
| | | header('Content-type: application/json'); |
| | |
| | | //################################# |
| | | // ENDE Datatable fields |
| | | //################################# |
| | | ) |
| | | ), |
| | | 'plugins' => array ( |
| | | // needs serverId for web.server_type |
| | | 'directive_snippets_id' => array ( |
| | | 'class' => 'plugin_directive_snippets' |
| | | ), |
| | | ) |
| | | ); |
| | | |
| | | // add type-specific field attributes |
New file |
| | |
| | | <?php
|
| | | $wb['directive_snippets_id_txt'] = 'Gewünschte Konfiguration';
|
| | | ?> |
New file |
| | |
| | | <?php
|
| | | $wb['directive_snippets_id_txt'] = 'Desired configuration';
|
| | | ?> |
New file |
| | |
| | | <div class="ctrlHolder">
|
| | | <label for="directive_snippets_id">
|
| | | {tmpl_var name='directive_snippets_id_txt'}
|
| | | </label>
|
| | |
|
| | | <select name="directive_snippets_id" id="directive_snippets_id" class="selectInput formLengthHalf">
|
| | | <option value="0"></option>
|
| | | <tmpl_loop name="records">
|
| | | <option {tmpl_if name='is_selected' op='==' value='true'}selected="selected" {/tmpl_if}value="{tmpl_var name='directive_snippets_id'}">
|
| | | {tmpl_var name='name'}
|
| | | </option>
|
| | | </tmpl_loop>
|
| | | </select>
|
| | | </div> |
| | |
| | | {tmpl_var name='fastcgi_php_version'} |
| | | </select> |
| | | </div> |
| | | {tmpl_var name="directive_snippets_id"} |
| | | <div class="ctrlHolder"> |
| | | <p class="label">{tmpl_var name='active_txt'}</p> |
| | | <div class="multiField"> |
| | |
| | | adjustForm(); |
| | | reloadWebIP(); |
| | | reloadFastcgiPHPVersions(); |
| | | reloadDirectiveSnippets(); |
| | | }); |
| | | } |
| | | adjustForm(true); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | 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>'; |
| | | for (var i = 0, len = data.length; i < len; i++) { |
| | | var isSelected = ''; |
| | | |
| | | if ($('#directive_snippets_id').val() == i + 1) { |
| | | isSelected = 'selected="selected"'; |
| | | } |
| | | |
| | | options += '<option ' + isSelected + ' value="' + data[i]['directive_snippets_id'] + '">' + data[i]['name'] + '</option>'; |
| | | } |
| | | |
| | | $('#directive_snippets_id').html(options).change(); |
| | | }); |
| | | } |
| | | |
| | | function reloadWebIP() { |
| | | loadOptionInto('ip_address','sites/ajax_get_ip.php?ip_type=IPv4&server_id='+serverId+'&client_group_id='+clientGroupId); |
| | |
| | | } |
| | | |
| | | <tmpl_if name="readonly_tab"> |
| | | jQuery('div.panel_web_domain').find('fieldset').find('input,select,button').bind('click mousedown', function(e) { e.preventDefault(); }).focus(function() { $(this).blur(); }); |
| | | jQuery('div.panel_web_domain').find('fieldset').find('input,select,button').not('#directive_snippets_id').bind('click mousedown', function(e) { e.preventDefault(); }).focus(function() { $(this).blur(); }); |
| | | jQuery('#dom-edit-submit').click(function() { |
| | | submitForm('pageForm','sites/web_vhost_domain_edit.php'); |
| | | submitForm('pageForm','sites/web_vhost_domain_edit.php'); |
| | | }); |
| | | <tmpl_else> |
| | | jQuery('#dom-edit-submit').click(function() { |
| | |
| | | if($app->functions->intval($this->dataRecord["server_id"]) > 0) { |
| | | // check if server is in client's servers or add it. |
| | | $chk_sid = explode(',', $client['web_servers']); |
| | | if(in_array($this->dataRecord["server_id"], $client['web_servers']) == false) { |
| | | if(in_array($this->dataRecord["server_id"], explode(',', $client['web_servers'])) == false) { |
| | | if($client['web_servers'] != '') $client['web_servers'] .= ','; |
| | | $client['web_servers'] .= $app->functions->intval($this->dataRecord["server_id"]); |
| | | } |
| | |
| | | $vhost_data['custom_php_ini_dir'] = escapeshellcmd($custom_php_ini_dir); |
| | | |
| | | // Custom Apache directives |
| | | if(intval($data['new']['directive_snippets_id']) > 0){ |
| | | $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'apache' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); |
| | | if(isset($snippet['snippet'])){ |
| | | $vhost_data['apache_directives'] = $snippet['snippet']; |
| | | } |
| | | } |
| | | // Make sure we only have Unix linebreaks |
| | | $vhost_data['apache_directives'] = str_replace("\r\n", "\n", $vhost_data['apache_directives']); |
| | | $vhost_data['apache_directives'] = str_replace("\r", "\n", $vhost_data['apache_directives']); |
| | |
| | | |
| | | // Custom nginx directives |
| | | $final_nginx_directives = array(); |
| | | $nginx_directives = $data['new']['nginx_directives']; |
| | | if(intval($data['new']['directive_snippets_id']) > 0){ |
| | | $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); |
| | | if(isset($snippet['snippet'])){ |
| | | $nginx_directives = $snippet['snippet']; |
| | | } else { |
| | | $nginx_directives = $data['new']['nginx_directives']; |
| | | } |
| | | } else { |
| | | $nginx_directives = $data['new']['nginx_directives']; |
| | | } |
| | | // Make sure we only have Unix linebreaks |
| | | $nginx_directives = str_replace("\r\n", "\n", $nginx_directives); |
| | | $nginx_directives = str_replace("\r", "\n", $nginx_directives); |