From ef55b578effea959ed4fdcdb0fd4bbab38209fef Mon Sep 17 00:00:00 2001 From: ftimme Date: Thu, 6 Sep 2012 15:21:32 +0000 Subject: [PATCH] - New feature: you can now add directive snippets for Apache, nginx, and PHP under System > Directive Snippets. These snippets are then available on the Options tab of a web site where they can be easily added to the respective textarea by simply clicking the name of the directive snippet. --- install/sql/incremental/upd_0040.sql | 20 ++++ install/sql/ispconfig3.sql | 20 ++++ .../web/admin/directive_snippets_del.php | 51 +++++++++ .../web/admin/directive_snippets_edit.php | 53 +++++++++ .../web/admin/directive_snippets_list.php | 52 +++++++++ .../admin/form/directive_snippets.tform.php | 101 ++++++++++++++++++ interface/web/admin/lib/lang/de.lng | 1 + .../admin/lib/lang/de_directive_snippets.lng | 9 ++ .../lib/lang/de_directive_snippets_list.lng | 7 ++ interface/web/admin/lib/lang/en.lng | 1 + .../admin/lib/lang/en_directive_snippets.lng | 9 ++ .../lib/lang/en_directive_snippets_list.lng | 7 ++ interface/web/admin/lib/module.conf.php | 5 + .../admin/list/directive_snippets.list.php | 78 ++++++++++++++ .../templates/directive_snippets_edit.htm | 38 +++++++ .../templates/directive_snippets_list.htm | 57 ++++++++++ interface/web/js/scrigo.js.php | 6 ++ .../web/sites/lib/lang/de_web_domain.lng | 3 + .../web/sites/lib/lang/en_web_domain.lng | 3 + .../sites/templates/web_domain_advanced.htm | 6 +- interface/web/sites/web_domain_edit.php | 35 ++++++ 21 files changed, 559 insertions(+), 3 deletions(-) create mode 100644 interface/web/admin/directive_snippets_del.php create mode 100644 interface/web/admin/directive_snippets_edit.php create mode 100644 interface/web/admin/directive_snippets_list.php create mode 100644 interface/web/admin/form/directive_snippets.tform.php create mode 100644 interface/web/admin/lib/lang/de_directive_snippets.lng create mode 100644 interface/web/admin/lib/lang/de_directive_snippets_list.lng create mode 100644 interface/web/admin/lib/lang/en_directive_snippets.lng create mode 100644 interface/web/admin/lib/lang/en_directive_snippets_list.lng create mode 100644 interface/web/admin/list/directive_snippets.list.php create mode 100644 interface/web/admin/templates/directive_snippets_edit.htm create mode 100644 interface/web/admin/templates/directive_snippets_list.htm diff --git a/install/sql/incremental/upd_0040.sql b/install/sql/incremental/upd_0040.sql index d613681f1..423772e86 100644 --- a/install/sql/incremental/upd_0040.sql +++ b/install/sql/incremental/upd_0040.sql @@ -2,3 +2,23 @@ -- Removal of the domain module UPDATE sys_user SET startmodule = 'dashboard' WHERE startmodule = 'domain'; UPDATE sys_user SET modules = replace(modules, ',domain', '') WHERE modules like '%domain%'; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `directive_snippets` +-- + +CREATE TABLE IF NOT EXISTS `directive_snippets` ( + `directive_snippets_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) unsigned NOT NULL DEFAULT '0', + `sys_groupid` int(11) unsigned NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `type` varchar(255) DEFAULT NULL, + `snippet` mediumtext, + `active` enum('n','y') NOT NULL DEFAULT 'y', + PRIMARY KEY (`directive_snippets_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 205840800..2817f7558 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -347,6 +347,26 @@ CREATE TABLE `cron` ( -- -------------------------------------------------------- +-- +-- Table structure for table `directive_snippets` +-- + +CREATE TABLE IF NOT EXISTS `directive_snippets` ( + `directive_snippets_id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `sys_userid` int(11) unsigned NOT NULL DEFAULT '0', + `sys_groupid` int(11) unsigned NOT NULL DEFAULT '0', + `sys_perm_user` varchar(5) DEFAULT NULL, + `sys_perm_group` varchar(5) DEFAULT NULL, + `sys_perm_other` varchar(5) DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `type` varchar(255) DEFAULT NULL, + `snippet` mediumtext, + `active` enum('n','y') NOT NULL DEFAULT 'y', + PRIMARY KEY (`directive_snippets_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + -- -- Table structure for table `dns_rr` -- diff --git a/interface/web/admin/directive_snippets_del.php b/interface/web/admin/directive_snippets_del.php new file mode 100644 index 000000000..ee1ab8b27 --- /dev/null +++ b/interface/web/admin/directive_snippets_del.php @@ -0,0 +1,51 @@ +auth->check_module_permissions('admin'); + +$app->uses("tform_actions"); +$app->tform_actions->onDelete(); + +?> \ No newline at end of file diff --git a/interface/web/admin/directive_snippets_edit.php b/interface/web/admin/directive_snippets_edit.php new file mode 100644 index 000000000..317dc58bb --- /dev/null +++ b/interface/web/admin/directive_snippets_edit.php @@ -0,0 +1,53 @@ +auth->check_module_permissions('admin'); + +// Loading classes +$app->uses('tpl,tform,tform_actions'); + +// let tform_actions handle the page +$app->tform_actions->onLoad(); + +?> \ No newline at end of file diff --git a/interface/web/admin/directive_snippets_list.php b/interface/web/admin/directive_snippets_list.php new file mode 100644 index 000000000..4f411942c --- /dev/null +++ b/interface/web/admin/directive_snippets_list.php @@ -0,0 +1,52 @@ +auth->check_module_permissions('admin'); + +$app->uses('listform_actions'); + +$app->listform_actions->onLoad(); + + +?> \ No newline at end of file diff --git a/interface/web/admin/form/directive_snippets.tform.php b/interface/web/admin/form/directive_snippets.tform.php new file mode 100644 index 000000000..a8b43b534 --- /dev/null +++ b/interface/web/admin/form/directive_snippets.tform.php @@ -0,0 +1,101 @@ + 0 id must match with id of current user +$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user +$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete +$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete + +$form["tabs"]['directive_snippets'] = array ( + 'title' => "Directive Snippets", + 'width' => 100, + 'template' => "templates/directive_snippets_edit.htm", + 'fields' => array ( + ################################## + # Begin Datatable fields + ################################## + 'name' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'directive_snippets_name_empty'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'directive_snippets_name_error_unique'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'type' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => array('apache' => 'Apache','nginx' => 'nginx','php' => 'PHP'), + ), + 'snippet' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'active' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n',1 => 'y') + ), + ################################## + # ENDE Datatable fields + ################################## + ) +); + + +?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/de.lng b/interface/web/admin/lib/lang/de.lng index a90537e1a..bec98adf5 100644 --- a/interface/web/admin/lib/lang/de.lng +++ b/interface/web/admin/lib/lang/de.lng @@ -28,6 +28,7 @@ $wb['Jailkit'] = 'Jailkit'; $wb['Rescue'] = 'Rescue'; $wb['Server IP addresses'] = 'Server IP-Adressen'; $wb['Additional PHP Versions'] = 'Zusätzliche PHP-Versionen'; +$wb['Directive Snippets'] = 'Direktiven-Schnipsel'; $wb['Firewall'] = 'Firewall'; $wb['Interface'] = 'Interface'; $wb['Interface Config'] = 'Main Config'; diff --git a/interface/web/admin/lib/lang/de_directive_snippets.lng b/interface/web/admin/lib/lang/de_directive_snippets.lng new file mode 100644 index 000000000..b0417fedf --- /dev/null +++ b/interface/web/admin/lib/lang/de_directive_snippets.lng @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/interface/web/admin/lib/lang/de_directive_snippets_list.lng b/interface/web/admin/lib/lang/de_directive_snippets_list.lng new file mode 100644 index 000000000..a928a4d76 --- /dev/null +++ b/interface/web/admin/lib/lang/de_directive_snippets_list.lng @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en.lng b/interface/web/admin/lib/lang/en.lng index 3cbf996e2..d9cbc7f83 100644 --- a/interface/web/admin/lib/lang/en.lng +++ b/interface/web/admin/lib/lang/en.lng @@ -36,6 +36,7 @@ $wb['Server Config'] = 'Server Config'; $wb['Rescue'] = 'Rescue'; $wb['Server IP addresses'] = 'Server IP addresses'; $wb['Additional PHP Versions'] = 'Additional PHP Versions'; +$wb['Directive Snippets'] = 'Directive Snippets'; $wb['Firewall'] = 'Firewall'; $wb['Interface'] = 'Interface'; diff --git a/interface/web/admin/lib/lang/en_directive_snippets.lng b/interface/web/admin/lib/lang/en_directive_snippets.lng new file mode 100644 index 000000000..ee40ab06f --- /dev/null +++ b/interface/web/admin/lib/lang/en_directive_snippets.lng @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_directive_snippets_list.lng b/interface/web/admin/lib/lang/en_directive_snippets_list.lng new file mode 100644 index 000000000..702e7e250 --- /dev/null +++ b/interface/web/admin/lib/lang/en_directive_snippets_list.lng @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php index 91a9401f1..489daacf2 100644 --- a/interface/web/admin/lib/module.conf.php +++ b/interface/web/admin/lib/module.conf.php @@ -47,6 +47,11 @@ $items[] = array( 'title' => 'Additional PHP Versions', 'target' => 'content', 'link' => 'admin/server_php_list.php', 'html_id' => 'server_php_list'); + +$items[] = array( 'title' => 'Directive Snippets', + 'target' => 'content', + 'link' => 'admin/directive_snippets_list.php', + 'html_id' => 'directive_snippets_list'); $items[] = array( 'title' => 'Firewall', 'target' => 'content', diff --git a/interface/web/admin/list/directive_snippets.list.php b/interface/web/admin/list/directive_snippets.list.php new file mode 100644 index 000000000..ec023c1ec --- /dev/null +++ b/interface/web/admin/list/directive_snippets.list.php @@ -0,0 +1,78 @@ + "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
Yes
",'n' => "
No
")); + + +$liste["item"][] = array( 'field' => "name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "type", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP')); + +?> \ No newline at end of file diff --git a/interface/web/admin/templates/directive_snippets_edit.htm b/interface/web/admin/templates/directive_snippets_edit.htm new file mode 100644 index 000000000..0d57c06d5 --- /dev/null +++ b/interface/web/admin/templates/directive_snippets_edit.htm @@ -0,0 +1,38 @@ +

+

+ +
+ +
+
+
+ + +
+
+ + +
+
+ + +
+
+

{tmpl_var name='active_txt'}

+
+ {tmpl_var name='active'} +
+
+
+ + + +
+ + +
+
+ +
\ No newline at end of file diff --git a/interface/web/admin/templates/directive_snippets_list.htm b/interface/web/admin/templates/directive_snippets_list.htm new file mode 100644 index 000000000..e3db36ed7 --- /dev/null +++ b/interface/web/admin/templates/directive_snippets_list.htm @@ -0,0 +1,57 @@ +

+

+ +
+ +
+
{tmpl_var name="toolsarea_head_txt"} +
+ +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{tmpl_var name='search_limit'}
+ +
{tmpl_var name="active"}{tmpl_var name="name"}{tmpl_var name="type"} + {tmpl_var name='delete_txt'} +
+
+
+ +
\ No newline at end of file diff --git a/interface/web/js/scrigo.js.php b/interface/web/js/scrigo.js.php index e550b472f..caa717e6d 100644 --- a/interface/web/js/scrigo.js.php +++ b/interface/web/js/scrigo.js.php @@ -638,6 +638,12 @@ jQuery('.addPlaceholder').live("click", function(){ var template = jQuery(this).siblings(':input'); template.insertAtCaret(placeholderText); }); + +jQuery('.addPlaceholderContent').live("click", function(){ + var placeholderContentText = jQuery(this).find('.addPlaceholderContent').text(); + var template2 = jQuery(this).siblings(':input'); + template2.insertAtCaret(placeholderContentText); +}); jQuery.fn.extend({ insertAtCaret: function(myValue){ diff --git a/interface/web/sites/lib/lang/de_web_domain.lng b/interface/web/sites/lib/lang/de_web_domain.lng index 8e79f9c91..81aea7e6a 100644 --- a/interface/web/sites/lib/lang/de_web_domain.lng +++ b/interface/web/sites/lib/lang/de_web_domain.lng @@ -105,4 +105,7 @@ $wb['generate_password_txt'] = 'Passwort erzeugen'; $wb['repeat_password_txt'] = 'Passwort wiederholen'; $wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.'; $wb['password_match_txt'] = 'Die Passwörter stimmen überein.'; +$wb['available_php_directive_snippets_txt'] = 'Verfügbare PHP-Direktiven-Schnipsel:'; +$wb['available_apache_directive_snippets_txt'] = 'Verfügbare Apache-Direktiven-Schnipsel:'; +$wb['available_nginx_directive_snippets_txt'] = 'Verfügbare nginx-Direktiven-Schnipsel:'; ?> diff --git a/interface/web/sites/lib/lang/en_web_domain.lng b/interface/web/sites/lib/lang/en_web_domain.lng index 87462db56..641f15f7d 100644 --- a/interface/web/sites/lib/lang/en_web_domain.lng +++ b/interface/web/sites/lib/lang/en_web_domain.lng @@ -105,4 +105,7 @@ $wb['generate_password_txt'] = 'Generate Password'; $wb['repeat_password_txt'] = 'Repeat Password'; $wb['password_mismatch_txt'] = 'The passwords do not match.'; $wb['password_match_txt'] = 'The passwords do match.'; +$wb['available_php_directive_snippets_txt'] = 'Available PHP Directive Snippets:'; +$wb['available_apache_directive_snippets_txt'] = 'Available Apache Directive Snippets:'; +$wb['available_nginx_directive_snippets_txt'] = 'Available nginx Directive Snippets:'; ?> \ No newline at end of file diff --git a/interface/web/sites/templates/web_domain_advanced.htm b/interface/web/sites/templates/web_domain_advanced.htm index f61cf500c..fec38c5b3 100644 --- a/interface/web/sites/templates/web_domain_advanced.htm +++ b/interface/web/sites/templates/web_domain_advanced.htm @@ -67,15 +67,15 @@
- +  {tmpl_var name="available_php_directive_snippets_txt"}

 {tmpl_var name="php_directive_snippets_txt"}
- +  {tmpl_var name="available_apache_directive_snippets_txt"}

 {tmpl_var name="apache_directive_snippets_txt"}
- +  {tmpl_var name="available_nginx_directive_snippets_txt"}

 {tmpl_var name="nginx_directive_snippets_txt"}
diff --git a/interface/web/sites/web_domain_edit.php b/interface/web/sites/web_domain_edit.php index 8a684d0d1..6a4735c9f 100644 --- a/interface/web/sites/web_domain_edit.php +++ b/interface/web/sites/web_domain_edit.php @@ -343,6 +343,41 @@ class page_action extends tform_actions { $app->tpl->setVar("client_group_id",$client_select); foreach($read_limits as $limit) $app->tpl->setVar($limit, ($limit == 'force_suexec' ? 'n' : 'y')); + + // Directive Snippets + $php_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'php' AND active = 'y'"); + $php_directive_snippets_txt = ''; + if(is_array($php_directive_snippets) && !empty($php_directive_snippets)){ + foreach($php_directive_snippets as $php_directive_snippet){ + $php_directive_snippets_txt .= '['.$php_directive_snippet['name'].'] '; + } + } + if($php_directive_snippets_txt == '') $php_directive_snippets_txt = '------'; + $app->tpl->setVar("php_directive_snippets_txt",$php_directive_snippets_txt); + + if($server_type == 'apache'){ + $apache_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'apache' AND active = 'y'"); + $apache_directive_snippets_txt = ''; + if(is_array($apache_directive_snippets) && !empty($apache_directive_snippets)){ + foreach($apache_directive_snippets as $apache_directive_snippet){ + $apache_directive_snippets_txt .= '['.$apache_directive_snippet['name'].'] '; + } + } + if($apache_directive_snippets_txt == '') $apache_directive_snippets_txt = '------'; + $app->tpl->setVar("apache_directive_snippets_txt",$apache_directive_snippets_txt); + } + + if($server_type = 'nginx'){ + $nginx_directive_snippets = $app->db->queryAllRecords("SELECT * FROM directive_snippets WHERE type = 'nginx' AND active = 'y'"); + $nginx_directive_snippets_txt = ''; + if(is_array($nginx_directive_snippets) && !empty($nginx_directive_snippets)){ + foreach($nginx_directive_snippets as $nginx_directive_snippet){ + $nginx_directive_snippets_txt .= '['.$nginx_directive_snippet['name'].'] '; + } + } + if($nginx_directive_snippets_txt == '') $nginx_directive_snippets_txt = '------'; + $app->tpl->setVar("nginx_directive_snippets_txt",$nginx_directive_snippets_txt); + } } $ssl_domain_select = ''; -- GitLab