diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..496ee2ca6a2f08396a4076fe43dedf3dc0da8b6d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..28cc297e8f57ee1f5944d357cfdde7c741fd961e --- /dev/null +++ b/README.md @@ -0,0 +1,67 @@ +#ISPConfig Wizard module + +This module allows you to create DNS Zone, Site, Database User, Database, FTP User, SSH User, Mail Domain and Mailboxes in one form. You just define domain name and using checkboxes decide which services you want to create. Services are created using user defined templates. + +This module is compatible with ISPConfig version 3.1 + +##Installation + +This module have to be installed on master node in multiserver setup. + +- Download this repo as archive, unpack it to `/usr/local/ispconfig/interface/web/` +- Create DB table provided in db.sql file `mysql -u root -p < db.sql` +- Enable module in user interface System -> CP Users -> Admin user -> Check "wizard" and save. + - If it doesn't work, enable module manually by editing admin user in DB table `sys_user` column `modules` + +##Changelog + +###Version 1.0.1 + +Release date: July 21 2016 + +First publicly released version. + +##Planned features + +- Export results as PDF +- Email results as HTML/PDF + +##Screenshots + +![New service](https://git.ispconfig.org/ispconfig/module-wizard/raw/master/readme_images/new_service.png) + +![Template](https://git.ispconfig.org/ispconfig/module-wizard/raw/master/readme_images/template.png) + +##Contributing + +Contributions are welcome. Our release model uses [Git Flow approach](http://danielkummer.github.io/git-flow-cheatsheet/), so you have to base your branches on `develop` and should have name `feature/name-of-feature` or `hotfix/name-of-hotfix`. + +Please contribute your translations, which are located in `lib/lang/` directory. Thank you. + +##License + +Copyright (c) 2016, Kristián Feldsam, FELDSAM s.r.o. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +- Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/db.sql b/db.sql new file mode 100644 index 0000000000000000000000000000000000000000..9c9fd12eef19c663f501d73f309157d3c77fbfe1 --- /dev/null +++ b/db.sql @@ -0,0 +1,92 @@ +/* +Copyright (c) 2016, Kristián Feldsam, FELDSAM s.r.o. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +USE `dbispconfig`; + +CREATE TABLE `wizard_template` ( + `template_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, + `web_server_id` int(11) unsigned NOT NULL DEFAULT '0', + `mail_server_id` int(11) unsigned NOT NULL DEFAULT '0', + `database_server_id` int(11) unsigned NOT NULL DEFAULT '0', + `dns_server_id` int(11) unsigned NOT NULL DEFAULT '0', + `template_name` varchar(255) NOT NULL DEFAULT '', + `ip_address` varchar(39) DEFAULT NULL, + `ipv6_address` varchar(255) DEFAULT NULL, + `traffic_quota` bigint(20) NOT NULL DEFAULT '-1', + `hd_quota` bigint(20) NOT NULL DEFAULT '-1', + `database_quota` int(11) unsigned DEFAULT NULL, + `mailbox_quota` int(11) unsigned DEFAULT NULL, + `cgi` enum('n','y') NOT NULL DEFAULT 'n', + `ssi` enum('n','y') NOT NULL DEFAULT 'n', + `suexec` enum('n','y') NOT NULL DEFAULT 'y', + `errordocs` tinyint(1) NOT NULL DEFAULT '1', + `subdomain` enum('none','www','*') NOT NULL DEFAULT 'www', + `php` varchar(32) NOT NULL DEFAULT 'fast-cgi', + `fastcgi_php_version` varchar(255) DEFAULT NULL, + `ruby` enum('n','y') NOT NULL DEFAULT 'n', + `python` enum('n','y') NOT NULL DEFAULT 'n', + `perl` enum('n','y') NOT NULL DEFAULT 'n', + `seo_redirect` varchar(255) DEFAULT NULL, + `rewrite_to_https` enum('n','y') NOT NULL DEFAULT 'n', + `allow_override` varchar(255) NOT NULL DEFAULT 'All', + `http_port` int(11) NOT NULL DEFAULT '80', + `https_port` int(11) NOT NULL DEFAULT '443', + `apache_directives` mediumtext, + `nginx_directives` mediumtext, + `php_fpm_use_socket` enum('n','y') NOT NULL DEFAULT 'n', + `pm` enum('static','dynamic','ondemand') NOT NULL DEFAULT 'dynamic', + `pm_max_children` int(11) unsigned NOT NULL DEFAULT '10', + `pm_start_servers` int(11) unsigned NOT NULL DEFAULT '2', + `pm_min_spare_servers` int(11) unsigned NOT NULL DEFAULT '1', + `pm_max_spare_servers` int(11) unsigned NOT NULL DEFAULT '5', + `pm_process_idle_timeout` int(11) unsigned NOT NULL DEFAULT '10', + `pm_max_requests` int(11) unsigned NOT NULL DEFAULT '0', + `custom_php_ini` mediumtext, + `database_charset` varchar(64) DEFAULT NULL, + `database_remote_access` enum('n','y') NOT NULL DEFAULT 'n', + `database_remote_ips` text, + `policy` int(11) unsigned NOT NULL DEFAULT '0', + `dkim` enum('n','y') NOT NULL DEFAULT 'n', + `dkim_selector` varchar(63) NOT NULL DEFAULT 'default', + `quota_files` bigint(20) NOT NULL DEFAULT '-1', + `ul_ratio` int(11) NOT NULL DEFAULT '-1', + `dl_ratio` int(11) NOT NULL DEFAULT '-1', + `ul_bandwidth` int(11) NOT NULL DEFAULT '-1', + `dl_bandwidth` int(11) NOT NULL DEFAULT '-1', + `shell` varchar(255) NOT NULL DEFAULT '/bin/bash', + `shell_chroot` varchar(255) NOT NULL DEFAULT '', + `enablesmtp` enum('n','y') NOT NULL DEFAULT 'y', + `enableimap` enum('n','y') NOT NULL DEFAULT 'y', + `enablepop3` enum('n','y') NOT NULL DEFAULT 'y', + PRIMARY KEY (`template_id`) +) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; diff --git a/form/new_service.tform.php b/form/new_service.tform.php new file mode 100644 index 0000000000000000000000000000000000000000..b47f061db0291607b08376455d75e34c98453434 --- /dev/null +++ b/form/new_service.tform.php @@ -0,0 +1,191 @@ + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Form Definition + + Tabledefinition + + Datatypes: + - INTEGER (Forces the input to Int) + - DOUBLE + - CURRENCY (Formats the values to currency notation) + - VARCHAR (no format check, maxlength: 255) + - TEXT (no format check) + - DATE (Dateformat, automatic conversion to timestamps) + + Formtype: + - TEXT (Textfield) + - TEXTAREA (Textarea) + - PASSWORD (Password textfield, input is not shown when edited) + - SELECT (Select option field) + - RADIO + - CHECKBOX + - CHECKBOXARRAY + - FILE + + VALUE: + - Wert oder Array + + Hint: + The ID field of the database table is not part of the datafield definition. + The ID field must be always auto incement (int or bigint). + + Search: + - searchable = 1 or searchable = 2 include the field in the search + - searchable = 1: this field will be the title of the search result + - searchable = 2: this field will be included in the description of the search result + + +*/ + +$form["title"] = "New service wizard"; +$form["description"] = ""; +$form["name"] = "new_service"; +$form["action"] = "new_service.php"; +$form["db_table"] = "wizard_template"; +$form["db_table_idx"] = "template_id"; +$form["db_history"] = "no"; +$form["tab_default"] = "client"; +$form["auth"] = 'yes'; // yes / no + +$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 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"]['client'] = array( + 'title' => "New service", + 'description' => 'Create domain, mail domain, site, database and ftp/ssh', + 'width' => 100, + 'template' => "templates/new_service.htm", + 'fields' => array ( + 'domain' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( + 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( + 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'domain_error_empty'), + 2 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/', + 'errmsg'=> 'domain_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'client_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT sys_group.groupid, sys_group.client_id, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY client.company_name, client.contact_name, sys_group.name", + 'keyfield'=> 'client_id', + 'valuefield'=> 'contactname' + ), + 'value' => '' + ), + 'template_id' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT template_id, template_name FROM wizard_template WHERE {AUTHSQL} ORDER BY template_name', + 'keyfield'=> 'template_id', + 'valuefield'=> 'template_name' + ), + 'value' => '', + ), + 'db' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'db_type' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => 'mysql', + 'value' => array( + //'mongo' => 'MongoDB', + 'mysql' => 'MySQL' + ) + ), + 'ftp' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'ssh' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'mail' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'mailboxes' => array ( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'width' => '30', + ), + 'dns' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'dns_template_id' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT template_id, name FROM dns_template WHERE visible = 'Y' ORDER BY name ASC", + 'keyfield'=> 'template_id', + 'valuefield'=> 'name' + ), + 'value' => '', + ), + ) +); \ No newline at end of file diff --git a/form/template.tform.php b/form/template.tform.php new file mode 100644 index 0000000000000000000000000000000000000000..f9ef0c1e7bef56c170ef21427bf280ce83427dfd --- /dev/null +++ b/form/template.tform.php @@ -0,0 +1,297 @@ + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + Form Definition + + Tabledefinition + + Datatypes: + - INTEGER (Forces the input to Int) + - DOUBLE + - CURRENCY (Formats the values to currency notation) + - VARCHAR (no format check, maxlength: 255) + - TEXT (no format check) + - DATE (Dateformat, automatic conversion to timestamps) + + Formtype: + - TEXT (Textfield) + - TEXTAREA (Textarea) + - PASSWORD (Password textfield, input is not shown when edited) + - SELECT (Select option field) + - RADIO + - CHECKBOX + - CHECKBOXARRAY + - FILE + + VALUE: + - Wert oder Array + + Hint: + The ID field of the database table is not part of the datafield definition. + The ID field must be always auto incement (int or bigint). + + Search: + - searchable = 1 or searchable = 2 include the field in the search + - searchable = 1: this field will be the title of the search result + - searchable = 2: this field will be included in the description of the search result + + +*/ + +$form["title"] = "Wizard template"; +$form["description"] = ""; +$form["name"] = "template"; +$form["action"] = "template_edit.php"; +$form["db_table"] = "wizard_template"; +$form["db_table_idx"] = "template_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "site"; +$form["list_default"] = "template_list.php"; +$form["auth"] = 'yes'; // yes / no + +$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 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"]['site'] = array( + 'title' => "Web", + 'width' => 100, + 'template' => "templates/template_site.htm", + 'fields' => load_foreing_form('site', '../sites/form/web_vhost_domain.tform.php'), +); + +$form["tabs"]['database'] = array( + 'title' => "Database", + 'width' => 100, + 'template' => "templates/template_database.htm", + 'fields' => load_foreing_form('database', '../sites/form/database.tform.php'), +); + +$form["tabs"]['ftp'] = array( + 'title' => "FTP", + 'width' => 100, + 'template' => "templates/template_ftp.htm", + 'fields' => load_foreing_form('ftp', '../sites/form/ftp_user.tform.php'), +); + +$form["tabs"]['ssh'] = array( + 'title' => "SSH", + 'width' => 100, + 'template' => "templates/template_ssh.htm", + 'fields' => load_foreing_form('ssh', '../sites/form/shell_user.tform.php'), +); + +$form["tabs"]['mail'] = array( + 'title' => "Mail", + 'width' => 100, + 'template' => "templates/template_mail.htm", + 'fields' => load_foreing_form('mail', '../mail/form/mail_domain.tform.php'), +); + +$form["tabs"]['dns'] = array( + 'title' => "DNS", + 'width' => 100, + 'template' => "templates/template_dns.htm", + 'fields' => array( + 'dns_server_id' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id, server_name FROM server WHERE mirror_server_id = 0 AND {AUTHSQL} AND dns_server = 1 ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name', + ), + 'value' => '', + ), + ), +); + +function load_foreing_form($type, $path) +{ + global $app; + + require $path; + + switch($type) + { + case 'site': + $new_form = $form['tabs']['domain']['fields'] + $form['tabs']['redirect']['fields'] + $form['tabs']['advanced']['fields']; + + // unset fields + unset($new_form['domain']); + unset($new_form['type']); + unset($new_form['vhost_type']); + unset($new_form['ssl']); + unset($new_form['ssl_letsencrypt']); + unset($new_form['web_folder']); + unset($new_form['parent_domain_id']); + unset($new_form['active']); + unset($new_form['redirect_type']); + unset($new_form['redirect_path']); + unset($new_form['rewrite_rules']); + unset($new_form['document_root']); + unset($new_form['system_user']); + unset($new_form['system_group']); + unset($new_form['php_open_basedir']); + unset($new_form['proxy_directives']); + unset($new_form['added_date']); + unset($new_form['added_by']); + unset($new_form['enable_pagespeed']); + + // rename server id + $new_form['web_server_id'] = $new_form['server_id']; + unset($new_form['server_id']); + + // add template name field + $new_form['template_name'] = array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'template_name_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '40', + 'maxlength' => '255', + ); + break; + case 'database': + $new_form = $form['tabs']['database']['fields']; + + // unset fields + unset($new_form['parent_domain_id']); + unset($new_form['type']); + unset($new_form['database_name']); + unset($new_form['database_name_prefix']); + unset($new_form['database_user_id']); + unset($new_form['database_ro_user_id']); + unset($new_form['active']); + + // rename fields + $new_form['database_server_id'] = $new_form['server_id']; + unset($new_form['server_id']); + $new_form['database_remote_access'] = $new_form['remote_access']; + unset($new_form['remote_access']); + $new_form['database_remote_ips'] = $new_form['remote_ips']; + unset($new_form['remote_ips']); + + break; + case 'ftp': + $new_form = $form['tabs']['advanced']['fields']; + + // unset fields + unset($new_form['uid']); + unset($new_form['gid']); + unset($new_form['dir']); + unset($new_form['expires']); + + break; + case 'ssh': + $new_form = $form['tabs']['advanced']['fields']; + + // unset fields + unset($new_form['puser']); + unset($new_form['pgroup']); + unset($new_form['dir']); + + // add chroot + $new_form['shell_chroot'] = array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => array('no' => 'None', 'jailkit' => 'Jailkit') + ); + + break; + case 'mail': + $new_form = $form['tabs']['domain']['fields']; + + // unset fields + unset($new_form['domain']); + unset($new_form['active']); + unset($new_form['dkim_private']); + unset($new_form['dkim_public']); + + // rename server id + $new_form['mail_server_id'] = $new_form['server_id']; + unset($new_form['server_id']); + + // add policy id + $new_form['policy'] = array( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT id, policy_name FROM spamfilter_policy WHERE {AUTHSQL} ORDER BY policy_name', + 'keyfield'=> 'id', + 'valuefield'=> 'policy_name' + ), + 'value' => '', + ); + + // add mailbox options + $new_form['mailbox_quota'] = array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 1 => array ( 'type' => 'ISINT', + 'errmsg'=> 'quota_error_isint'), + 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([0-9]{1,})$/', + 'errmsg'=> 'quota_error_value'), + ), + 'default' => '-1', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ); + $new_form['enablesmtp'] = array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(1 => 'y', 0 => 'n') + ); + $new_form['enableimap'] = array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(1 => 'y', 0 => 'n') + ); + $new_form['enablepop3'] = array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(1 => 'y', 0 => 'n') + ); + break; + } + + return $new_form; +} \ No newline at end of file diff --git a/lib/admin.conf.php b/lib/admin.conf.php new file mode 100644 index 0000000000000000000000000000000000000000..d886b2c9e640b082031f3e3aff99fc3cc6d4c18b --- /dev/null +++ b/lib/admin.conf.php @@ -0,0 +1,6 @@ += 0.'; +$wb["pm_ondemand_hint_txt"] = 'Please note that you must have PHP version >= 5.3.9 in order to use the ondemand process manager. If you select ondemand for an older PHP version, PHP will not start anymore!'; +$wb["pm_max_children_txt"] = 'PHP-FPM pm.max_children'; +$wb["pm_start_servers_txt"] = 'PHP-FPM pm.start_servers'; +$wb["pm_min_spare_servers_txt"] = 'PHP-FPM pm.min_spare_servers'; +$wb["pm_max_spare_servers_txt"] = 'PHP-FPM pm.max_spare_servers'; +$wb["error_php_fpm_pm_settings_txt"] = 'Values of PHP-FPM pm settings must be as follows: pm.max_children >= pm.max_spare_servers >= pm.start_servers >= pm.min_spare_servers > 0'; +$wb["pm_max_children_error_regex"] = 'PHP-FPM pm.max_children must be a positive integer value.'; +$wb["pm_start_servers_error_regex"] = 'PHP-FPM pm.start_servers must be a positive integer value.'; +$wb["pm_min_spare_servers_error_regex"] = 'PHP-FPM pm.min_spare_servers must be a positive integer value.'; +$wb["pm_max_spare_servers_error_regex"] = 'PHP-FPM pm.max_spare_servers must be a positive integer value.'; +$wb["apache_directives_txt"] = 'Apache Directives'; +$wb["nginx_directives_txt"] = 'Nginx Directives'; +$wb["proxy_directives_txt"] = 'Proxy Directives'; +$wb["custom_php_ini_txt"] = 'Custom php.ini settings'; +$wb["seo_redirect_txt"] = 'SEO Redirect'; +$wb['rewrite_to_https_txt'] = 'Rewrite HTTP to HTTPS'; +$wb["no_redirect_txt"] = 'No redirect'; +$wb["none_txt"] = 'None'; +$wb["php_fpm_use_socket_txt"] = 'Use Socket For PHP-FPM'; +$wb["traffic_quota_error_regex"] = 'Traffic quota is invalid.'; +$wb['traffic_quota_error_empty'] = 'Traffic quota is empty.'; +$wb['hd_quota_error_regex'] = 'Harddisk quota is invalid.'; +$wb['hd_quota_error_empty'] = 'Harddisk quota is 0 or empty.'; +$wb["btn_save_txt"] = 'Save'; +$wb["btn_cancel_txt"] = 'Cancel'; +$wb["variables_txt"] = 'Variables'; +$wb["disabled_txt"] = 'Disabled'; +$wb["template_name_txt"] = 'Template name'; +$wb["template_name_error_empty"] = 'Template name can not be empty!'; +$wb["policy_txt"] = 'Spamfilter'; +$wb["no_policy"] = '- not enabled -'; +$wb["dkim_txt"] = 'Enable DKIM'; +$wb['dkim_selector_txt'] = 'DKIM-Selector'; +$wb['dkim_selector_error'] = 'Invalid DKIM-Selector. Use only lower-case alphanumeric characters (a-z or 0-9) up to 63 chars'; +$wb["remote_access_txt"] = 'Remote Access'; +$wb["remote_ips_txt"] = 'Remote Access IPs (separate by , and leave blank for any)'; +$wb["database_charset_txt"] = 'Database charset'; +$wb["database_remote_error_ips"] = 'At least one of the entered ip addresses is invalid.'; +$wb['limit_database_quota_txt'] = 'Database quota'; +$wb['limit_database_quota_error_notint'] = 'The database quota limit must be a number.'; +$wb["quota_files_txt"] = 'Filequota'; +$wb["quota_files_unity_txt"] = 'Files'; +$wb["ul_ratio_txt"] = 'Upload ratio'; +$wb["dl_ratio_txt"] = 'Download ratio'; +$wb["ul_bandwidth_txt"] = 'Upload bandwidth'; +$wb["dl_bandwidth_txt"] = 'Download bandwidth'; +$wb['shell_txt'] = "Shell"; +$wb['chroot_txt'] = "Chroot Shell"; +$wb['shell_error_regex'] = 'Invalid shell'; +$wb['shell_error_empty'] = 'Shell is empty!'; +$wb["enablesmtp_txt"] = 'Enable SMTP (sending)'; +$wb["enableimap_txt"] = 'Enable IMAP'; +$wb["enablepop3_txt"] = 'Enable POP3'; +$wb["mailbox_quota_txt"] = 'Mailbox quota (0 for unlimited)'; +$wb["quota_error_isint"] = 'Mailbox size must be a number.'; +$wb["quota_error_value"] = 'Invalid quota value. Allowed values are: 0 for unlimited or numbers > 1'; +$wb['http_port_txt'] = 'HTTP Port'; +$wb['https_port_txt'] = 'HTTPS Port'; \ No newline at end of file diff --git a/lib/lang/en_wizard_template_list.lng b/lib/lang/en_wizard_template_list.lng new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/lib/module.conf.php b/lib/module.conf.php new file mode 100644 index 0000000000000000000000000000000000000000..b206008e2dcc4acda6dcc3f5497372d6c4d5a88c --- /dev/null +++ b/lib/module.conf.php @@ -0,0 +1,45 @@ + 'New service wizard', + 'target' => 'content', + 'link' => 'wizard/new_service.php' + ); + +$items[] = array( 'title' => 'Templates', + 'target' => 'content', + 'link' => 'wizard/template_list.php' + ); + + +// Append the menu $items defined above to a menu section labeled 'Support' +$module['nav'][] = array( 'title' => 'Wizard', + 'open' => 1, + 'items' => $items + ); \ No newline at end of file diff --git a/list/template.list.php b/list/template.list.php new file mode 100644 index 0000000000000000000000000000000000000000..7ba67a08e021747dcbc4e0dc5f939fce4ab0f8de --- /dev/null +++ b/list/template.list.php @@ -0,0 +1,58 @@ + "template_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); \ No newline at end of file diff --git a/new_service.php b/new_service.php new file mode 100644 index 0000000000000000000000000000000000000000..f3c78c9e9e5d683909ca4c1a16989edf2976cddb --- /dev/null +++ b/new_service.php @@ -0,0 +1,588 @@ + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/****************************************** +* Begin Form configuration +******************************************/ + +$tform_def_file = "form/new_service.tform.php"; + +/****************************************** +* End Form configuration +******************************************/ + +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; + +//* Check permissions for module +$app->auth->check_module_permissions('wizard'); + +// Loading classes +$app->uses('tpl,tform,remoting'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + + function onShowEnd() { + global $app, $conf; + + $fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true); + + // select first template as default + if($fields['dns_template_id'] == 0) + { + $first_template = $app->db->queryOneRecord("SELECT template_id FROM dns_template WHERE visible = 'Y' ORDER BY name ASC"); + $fields['dns_template_id'] = $first_template['template_id']; + } + + $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = ?", $fields['dns_template_id']); + $fields = explode(',', $template_record['fields']); + if(is_array($fields)) { + foreach($fields as $field) { + $app->tpl->setVar($field."_VISIBLE", 1); + $field = strtolower($field); + $app->tpl->setVar($field, $_POST['dns_'.$field]); + } + } + + parent::onShowEnd(); + } + + function onSubmit() { + global $app, $conf; + + $fields = $app->tform->encode($this->dataRecord, $app->tform->getCurrentTab(), true); + + // check for domain unique name + if($app->db->queryOneRecord('SELECT domain_id FROM domain WHERE domain = "'.$fields['domain'].'"')) { + $app->tform->errorMessage = $app->tform->wordbook['domain_error_unique']; + } + + if($app->tform->errorMessage) + { + $this->onError(); + return; + } + + if($_POST['create'] != 1) + { + $app->tform->errorMessage = 'DUMMY'; + $app->tpl->setVar($this->dataRecord); + $this->onShow(); + return; + } + + // Domain OK, continue + $remote = new remote_actions; + + // load template + $template = $app->db->queryOneRecord("SELECT * FROM wizard_template WHERE template_id = ? LIMIT 0,1", $fields['template_id']); + + // client prefix and group id + $res = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($fields['client_id'])); + $client_group_id = $res['groupid']; + $client_prefix = 'c'.$fields['client_id']; + + // add domain + $domain_id = $remote->insert_query('../client/form/domain.tform.php', $fields['client_id'], array('domain' => $fields['domain'])); + + // DNS Zone + if($fields['dns']) + { + if(isset($_POST['dns_ns1']) && $_POST['dns_ns1'] != ''){ + $_POST['dns_ns1'] = $app->functions->idn_encode($_POST['dns_ns1']); + $_POST['dns_ns1'] = strtolower($_POST['dns_ns1']); + } + if(isset($_POST['dns_ns2']) && $_POST['dns_ns2'] != ''){ + $_POST['dns_ns2'] = $app->functions->idn_encode($_POST['dns_ns2']); + $_POST['dns_ns2'] = strtolower($_POST['dns_ns2']); + } + if(isset($_POST['dns_email']) && $_POST['dns_email'] != ''){ + $_POST['dns_email'] = $app->functions->idn_encode($_POST['dns_email']); + $_POST['dns_email'] = strtolower($_POST['dns_email']); + } + + $dns_error = ''; + + if(isset($_POST['dns_ip']) && $_POST['dns_ip'] == '') $dns_error .= $app->lng('error_ip_empty').'
'; + + if(isset($_POST['dns_ipv6']) && $_POST['dns_ipv6'] == '') $dns_error .= $app->lng('error_ipv6_empty').'
'; + + if(isset($_POST['dns_ns1']) && $_POST['dns_ns1'] == '') $dns_error .= $app->lng('error_ns1_empty').'
'; + elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/', $_POST['ns1'])) $dns_error .= $app->lng('error_ns1_regex').'
'; + + if(isset($_POST['dns_ns2']) && $_POST['dns_ns2'] == '') $dns_error .= $app->lng('error_ns2_empty').'
'; + elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/', $_POST['ns2'])) $dns_error .= $app->lng('error_ns2_regex').'
'; + + if(isset($_POST['dns_email']) && $_POST['dns_email'] == '') $dns_error .= $app->lng('error_email_empty').'
'; + elseif(isset($_POST['dns_email']) && filter_var($_POST['dns_email'], FILTER_VALIDATE_EMAIL) === false) $dns_error .= $app->lng('error_email_regex').'
'; + + // check for dns errors + if($dns_error) + { + $app->tform->errorMessage = $dns_error; + $this->onError(); + return; + } + + $tform_def_file = "form/dns_soa.tform.php"; + $app->tform->loadFormDef($tform_def_file); + + // replace template placeholders + $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = ?", $fields['dns_template_id']); + $tpl_content = $template_record['template']; + $tpl_content = str_replace('{DOMAIN}', $fields['domain'], $tpl_content); + if($_POST['dns_ip'] != '') $tpl_content = str_replace('{IP}', $_POST['dns_ip'], $tpl_content); + if($_POST['dns_ipv6'] != '') $tpl_content = str_replace('{IPV6}',$_POST['dns_ipv6'],$tpl_content); + if($_POST['dns_ns1'] != '') $tpl_content = str_replace('{NS1}', $_POST['dns_ns1'], $tpl_content); + if($_POST['dns_ns2'] != '') $tpl_content = str_replace('{NS2}', $_POST['dns_ns2'], $tpl_content); + if($_POST['dns_email'] != '') $tpl_content = str_replace('{EMAIL}', $_POST['dns_email'], $tpl_content); + + $enable_dnssec = (($_POST['dns_dnssec'] == 'Y') ? 'Y' : 'N'); + + // Parse the template + $tpl_rows = explode("\n", $tpl_content); + $section = ''; + $vars = array(); + $vars['xfer']=''; + $dns_rr = array(); + foreach($tpl_rows as $row) { + $row = trim($row); + if(substr($row, 0, 1) == '[') { + if($row == '[ZONE]') { + $section = 'zone'; + } elseif($row == '[DNS_RECORDS]') { + $section = 'dns_records'; + } else { + die('Unknown section type'); + } + } else { + if($row != '') { + // Handle zone section + if($section == 'zone') { + $parts = explode('=', $row); + $key = trim($parts[0]); + $val = trim($parts[1]); + if($key != '') $vars[$key] = $val; + } + // Handle DNS Record rows + if($section == 'dns_records') { + $parts = explode('|', $row); + $dns_rr[] = array( + 'name' => $parts[1], + 'type' => $parts[0], + 'data' => $parts[2], + 'aux' => $parts[3], + 'ttl' => $parts[4] + ); + } + } + } + + } // end foreach + + $dns_error = ''; + + if($vars['origin'] == '') $dns_error .= $app->lng('error_origin_empty').'
'; + if($vars['ns'] == '') $dns_error .= $app->lng('error_ns_empty').'
'; + if($vars['mbox'] == '') $dns_error .= $app->lng('error_mbox_empty').'
'; + if($vars['refresh'] == '') $dns_error .= $app->lng('error_refresh_empty').'
'; + if($vars['retry'] == '') $dns_error .= $app->lng('error_retry_empty').'
'; + if($vars['expire'] == '') $dns_error .= $app->lng('error_expire_empty').'
'; + if($vars['minimum'] == '') $dns_error .= $app->lng('error_minimum_empty').'
'; + if($vars['ttl'] == '') $dns_error .= $app->lng('error_ttl_empty').'
'; + + // check for dns errors + if($dns_error) + { + $app->tform->errorMessage = $dns_error; + $this->onError(); + return; + } + + // Insert the soa record + $sys_userid = $_SESSION['s']['user']['userid']; + $origin = $vars['origin']; + $ns = $vars['ns']; + $mbox = str_replace('@', '.', $vars['mbox']); + $refresh = $vars['refresh']; + $retry = $vars['retry']; + $expire = $vars['expire']; + $minimum = $vars['minimum']; + $ttl = $vars['ttl']; + $xfer = $vars['xfer']; + $also_notify = $vars['also_notify']; + $update_acl = $vars['update_acl']; + $serial = $app->validate_dns->increase_serial(0); + + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $client_group_id, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $template['dns_server_id'], + "origin" => $origin, + "ns" => $ns, + "mbox" => $mbox, + "serial" => $serial, + "refresh" => $refresh, + "retry" => $retry, + "expire" => $expire, + "minimum" => $minimum, + "ttl" => $ttl, + "active" => 'Y', + "xfer" => $xfer, + "also_notify" => $also_notify, + "update_acl" => $update_acl, + "dnssec_wanted" => $enable_dnssec + ); + $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); + + // Insert the dns_rr records + if(is_array($dns_rr) && $dns_soa_id > 0) { + foreach($dns_rr as $rr) { + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $client_group_id, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $template['dns_server_id'], + "zone" => $dns_soa_id, + "name" => $rr['name'], + "type" => $rr['type'], + "data" => $rr['data'], + "aux" => $rr['aux'], + "ttl" => $rr['ttl'], + "active" => 'Y' + ); + $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); + } + } + + $tform_def_file = "form/new_service.tform.php"; + $app->tform->loadFormDef($tform_def_file); + } + + if($fields['mail']) + { + // add mail domain + $params = array( + 'server_id' => $template['mail_server_id'], + 'domain' => $fields['domain'], + 'active' => 'y' + ); + $mail_domain_id = $remote->insert_query('../mail/form/mail_domain.tform.php', $fields['client_id'], $params); + + if($template['policy']) + { + $params = array( + 'server_id' => $template['mail_server_id'], + 'policy_id' => $template['policy'], + 'priority' => 5, + 'email' => '@'.$fields['domain'], + 'fullname' => '@'.$fields['domain'], + 'local' => 'Y', + ); + + $remote->insert_query('../mail/form/spamfilter_users.tform.php', $fields['client_id'], $params); + } + + if($fields['mailboxes']) + { + $mailboxes = explode(',', $fields['mailboxes']); + $mailbox_passwords = array(); + + foreach($mailboxes as $alias) + { + $alias = strtolower($app->functions->idn_encode($alias)); + $mailbox = $alias.'@'.$fields['domain']; + + // validate, on error skip + if( ! preg_match('/^[_a-z0-9][\w\.\-_\+@]{1,63}$/', $mailbox)) continue; + + $mailbox_passwords[$mailbox] = substr(sha1(rand()), 0, 10); + + $params = array( + 'server_id' => $template['mail_server_id'], + 'uid' => -1, + 'gid' => -1, + 'email' => $mailbox, + 'login' => $mailbox, + 'password' => $mailbox_passwords[$mailbox], + 'quota' => $template['mailbox_quota']*1024*1024, + 'postfix' => 'y', + 'disableimap' => ($template['enableimap'] == 'y' ? 'n' : 'y'), + 'disablepop3' => ($template['enablepop3'] == 'y' ? 'n' : 'y'), + 'disablesmtp' => ($template['enablesmtp'] == 'y' ? 'n' : 'y'), + 'maildir' => '/var/vmail/'.$fields['domain'].'/'.$alias, + 'homedir' => '/var/vmail', + ); + + $remote->insert_query('../mail/form/mail_user.tform.php', $fields['client_id'], $params); + } + } + } + + // add site + $params = array( + 'type' => 'vhost', + 'domain' => $fields['domain'], + 'server_id' => $template['web_server_id'], + 'ip_address' => $template['ip_address'], + 'ipv6_address' => $template['ipv6_address'], + 'traffic_quota' => $template['traffic_quota'], + 'hd_quota' => $template['hd_quota'], + 'cgi' => $template['cgi'], + 'ssi' => $template['ssi'], + 'suexec' => $template['suexec'], + 'ruby' => $template['ruby'], + 'python' => $template['python'], + 'perl' => $template['perl'], + 'errordocs' => $template['errordocs'], + 'subdomain' => $template['subdomain'], + 'php' => $template['php'], + 'fastcgi_php_version' => $template['fastcgi_php_version'], + 'seo_redirect' => $template['seo_redirect'], + 'rewrite_to_https' => $template['rewrite_to_https'], + 'allow_override' => $template['allow_override'], + 'http_port' => $template['http_port'], + 'https_port' => $template['https_port'], + 'apache_directives' => $template['apache_directives'], + 'nginx_directives' => $template['nginx_directives'], + 'php_fpm_use_socket' => $template['php_fpm_use_socket'], + 'pm' => $template['pm'], + 'pm_max_children' => $template['pm_max_children'], + 'pm_start_servers' => $template['pm_start_servers'], + 'pm_min_spare_servers' => $template['pm_min_spare_servers'], + 'pm_max_spare_servers' => $template['pm_max_spare_servers'], + 'pm_process_idle_timeout' => $template['pm_process_idle_timeout'], + 'pm_max_requests' => $template['pm_max_requests'], + 'custom_php_ini' => $template['custom_php_ini'], + 'active' => 'y', + 'document_root' => '-', + 'system_user' => '-', + 'system_group' => '-', + 'client_group_id' => $client_group_id, + ); + + $site_id = $remote->insert_query('../sites/form/web_vhost_domain.tform.php', $fields['client_id'], $params, 'sites:web_vhost_domain:on_after_insert'); + + // get site data + $app->uses('remoting_lib'); + $app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php'); + $site_data = $app->remoting_lib->getDataRecord($site_id); + + // generate username + $generated_username = $client_prefix.substr(sha1(rand()), 0, 8); + + if($fields['db']) + { + // add database user + $db_user_params = array( + 'server_id' => $template['database_server_id'], + 'database_user' => $generated_username, + 'database_password' => substr(sha1(rand()), 0, 10) + ); + $db_user_id = $remote->insert_query('../sites/form/database_user.tform.php', $fields['client_id'], $db_user_params, 'sites:web_database_user:on_after_insert'); + + // add database + $params = array( + 'server_id' => $template['database_server_id'], + 'parent_domain_id' => $site_id, + 'type' => $fields['db_type'], + 'database_quota' => $template['database_quota'], + 'database_name' => $db_user_params['database_user'], + 'database_user_id' => $db_user_id, + 'database_charset' => $template['database_charset'], + 'remote_access' => $template['database_remote_access'], + 'remote_ips' => $template['database_remote_ips'], + 'active' => 'y' + ); + $remote->sites_database_add($fields['client_id'], $params); + } + + if($fields['ftp']) { + // add ftp user + $ftp_params = array( + 'server_id' => $template['web_server_id'], + 'parent_domain_id' => $site_id, + 'username' => $generated_username, + 'password' => substr(sha1(rand()), 0, 10), + 'quota_size' => $template['hd_quota'], + 'dir' => $site_data['document_root'], + 'uid' => $site_data['system_user'], + 'gid' => $site_data['system_group'], + 'sys_groupid' => $site_data['sys_groupid'], + 'quota_files' => $template['quota_files'], + 'ul_ratio' => $template['ul_ratio'], + 'dl_ratio' => $template['dl_ratio'], + 'ul_bandwidth' => $template['ul_bandwidth'], + 'dl_bandwidth' => $template['dl_bandwidth'], + 'active' => 'y', + ); + $remote->insert_query('../sites/form/ftp_user.tform.php', $fields['client_id'], $ftp_params); + } + + if($fields['ssh']) { + // add ssh user + $ssh_params = array( + 'server_id' => $template['web_server_id'], + 'parent_domain_id' => $site_id, + 'quota_size' => $template['hd_quota'], + 'dir' => $site_data['document_root'], + 'puser' => $site_data['system_user'], + 'pgroup' => $site_data['system_group'], + 'sys_groupid' => $site_data['sys_groupid'], + 'chroot' => $template['shell_chroot'], + 'shell' => $template['shell'], + 'active' => 'y', + 'username' => $generated_username, + ); + + // username, password + if(isset($ftp_params)) { + $ssh_params['password'] = $ftp_params['password']; + } else { + $ssh_params['password'] = substr(sha1(rand()), 0, 10); + } + + $remote->insert_query('../sites/form/shell_user.tform.php', $fields['client_id'], $ssh_params); + } + + // results + echo ' + +
+ + + + + + + '; + if(isset($db_user_params)) { + echo + ' + + + + + + + '; + } + if(isset($ftp_params)) { + echo' + + + + + + + + '; + } + if(isset($ssh_params)) { + echo' + + + + + + + + '; + } + if(isset($mailbox_passwords) and (bool)count($mailbox_passwords)) + { + echo ' + + + + '; + foreach($mailbox_passwords as $mail => $pass) + { + echo' + + + + '; + } + } + echo' + +
'.$fields['domain'].'
DB name/userDB password
'.$db_user_params['database_user'].''.$db_user_params['database_password'].'
FTP userFTP password
'.$ftp_params['username'].''.$ftp_params['password'].'
SSH userSSH password
'.$ssh_params['username'].''.$ssh_params['password'].'
MailboxPassword
'.$mail.''.$pass.'
+
+ '; + } + +} + +class remote_actions extends remoting { + public function insert_query($formdef_file, $client_id, $params, $event_identifier = '') { + return $this->insertQuery($formdef_file, $client_id, $params, $event_identifier); + } + + public function sites_database_add($client_id, $params) + { + global $app; + + $sql = $this->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params); + if($sql !== false) { + $app->uses('sites_database_plugin'); + + $this->id = 0; + $this->dataRecord = $params; + $app->sites_database_plugin->processDatabaseInsert($this); + + $retval = $this->insertQueryExecute($sql, $params); + + // set correct values for backup_interval and backup_copies + if(isset($params['backup_interval']) || isset($params['backup_copies'])){ + $sql_set = array(); + if(isset($params['backup_interval'])) $sql_set[] = "backup_interval = '".$app->db->quote($params['backup_interval'])."'"; + if(isset($params['backup_copies'])) $sql_set[] = "backup_copies = ".$app->functions->intval($params['backup_copies']); + //$app->db->query("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval); + $this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval, $retval, $params); + } + + return $retval; + } + + return false; + } +} + +$page = new page_action; +$page->onLoad(); diff --git a/readme_images/new_service.png b/readme_images/new_service.png new file mode 100644 index 0000000000000000000000000000000000000000..e01ecd4ede6fc99271f3993f0b4e07611ee4d766 Binary files /dev/null and b/readme_images/new_service.png differ diff --git a/readme_images/template.png b/readme_images/template.png new file mode 100644 index 0000000000000000000000000000000000000000..62b1399f59d3921b48d37bde8f07bac7a64d5ce3 Binary files /dev/null and b/readme_images/template.png differ diff --git a/template_edit.php b/template_edit.php new file mode 100644 index 0000000000000000000000000000000000000000..44643f641c9157944a487c62cdd1189eb2932a0d --- /dev/null +++ b/template_edit.php @@ -0,0 +1,108 @@ + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +/****************************************** +* Begin Form configuration +******************************************/ + +$tform_def_file = "form/template.tform.php"; + +/****************************************** +* End Form configuration +******************************************/ + +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; + +//* Check permissions for module +$app->auth->check_module_permissions('wizard'); +$app->auth->check_module_permissions('sites'); + +// Loading classes +$app->uses('tpl,tform,tform_actions,tools_sites'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + + function onShowEnd() + { + global $app, $conf; + + $app->uses('getconf'); + + if($this->dataRecord["web_server_id"]) + { + $web_server_id = $this->dataRecord["web_server_id"]; + } + else + { + $default_web_server = $app->db->queryOneRecord("SELECT server_id FROM server WHERE web_server = ? ORDER BY server_id LIMIT 0,1", 1); + $web_server_id = $default_web_server['server_id']; + } + + $web_config = $app->getconf->get_server_config($web_server_id, 'web'); + + //* Fill the IPv4 select field + $sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv4' AND server_id = ".$web_server_id; + $ips = $app->db->queryAllRecords($sql); + $ip_select = ($web_config['enable_ip_wildcard'] == 'y')?"":""; + //$ip_select = ""; + if(is_array($ips)) { + foreach( $ips as $ip) { + $selected = ($ip["ip_address"] == $this->dataRecord["ip_address"])?'SELECTED':''; + $ip_select .= "\r\n"; + } + } + $app->tpl->setVar("ip_address", $ip_select); + unset($tmp); + unset($ips); + + //* Fill the IPv6 select field + $sql = "SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND server_id = ".$web_server_id; + $ips = $app->db->queryAllRecords($sql); + $ip_select = ""; + //$ip_select = ""; + if(is_array($ips)) { + foreach( $ips as $ip) { + $selected = ($ip["ip_address"] == $this->dataRecord["ipv6_address"])?'SELECTED':''; + $ip_select .= "\r\n"; + } + } + $app->tpl->setVar("ipv6_address", $ip_select); + unset($tmp); + unset($ips); + + parent::onShowEnd(); + } + +} + +$page = new page_action; +$page->onLoad(); diff --git a/template_list.php b/template_list.php new file mode 100644 index 0000000000000000000000000000000000000000..3aa380618ac3b259a193b9d7987157852736860e --- /dev/null +++ b/template_list.php @@ -0,0 +1,49 @@ + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of ISPConfig nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY +OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; + +/****************************************** +* Begin Form configuration +******************************************/ + +$list_def_file = "list/template.list.php"; + +/****************************************** +* End Form configuration +******************************************/ + +//* Check permissions for module +$app->auth->check_module_permissions('wizard'); + +$app->uses('listform_actions'); + +$app->listform_actions->SQLOrderBy = 'ORDER BY wizard_template.template_name'; +$app->listform_actions->onLoad(); diff --git a/templates/new_service.htm b/templates/new_service.htm new file mode 100644 index 0000000000000000000000000000000000000000..28c30c4a56b42df4091c02e8cb84eda06ab1c514 --- /dev/null +++ b/templates/new_service.htm @@ -0,0 +1,195 @@ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ {tmpl_var name='db'} +
+
+ +
+ +
+ +
+
+ +
+ +
+ {tmpl_var name='ftp'} +
+
+ +
+ +
+ {tmpl_var name='ssh'} +
+
+ +
+ +
+ {tmpl_var name='mail'} +
+
+ +
+ +
+ +
+
{tmpl_var name='mailboxes_help_txt'}
+
+ +
+ +
+ {tmpl_var name='dns'} +
+
+ +
+ +
+
+ + +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ + + +
+ +
+ +
+
+ + +
+
+ + \ No newline at end of file diff --git a/templates/template_database.htm b/templates/template_database.htm new file mode 100644 index 0000000000000000000000000000000000000000..c752aa3150afd79fe9dbb8d86c16582578dd78ca --- /dev/null +++ b/templates/template_database.htm @@ -0,0 +1,60 @@ +
+ +
+ +
+
+
+ +
+ +
+
 MB
+
+
+ +
+ +
+
+
+ +
+ {tmpl_var name='database_remote_access'} +
+
+
+ +
+ +
+
+ + + +
+
+ + +
+
+ + \ No newline at end of file diff --git a/templates/template_dns.htm b/templates/template_dns.htm new file mode 100644 index 0000000000000000000000000000000000000000..3d105ac0f38c458943c4e416cce7871bbb66e0b6 --- /dev/null +++ b/templates/template_dns.htm @@ -0,0 +1,15 @@ +
+ +
+
+ + + +
+
+ + +
+
\ No newline at end of file diff --git a/templates/template_ftp.htm b/templates/template_ftp.htm new file mode 100644 index 0000000000000000000000000000000000000000..d0aee50e8514b3ba4cec43a4415b9216600ed7ea --- /dev/null +++ b/templates/template_ftp.htm @@ -0,0 +1,42 @@ +
+ +
+ +
+
{tmpl_var name='quota_files_unity_txt'}
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
kb/s
+
+
+ +
+ +
+
kb/s
+
+ + + +
+
+ + +
+
\ No newline at end of file diff --git a/templates/template_mail.htm b/templates/template_mail.htm new file mode 100644 index 0000000000000000000000000000000000000000..ee92d87123df6d29e8bec93ec1bd98a59c313c40 --- /dev/null +++ b/templates/template_mail.htm @@ -0,0 +1,83 @@ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
 MB
+
+
+ +
+ {tmpl_var name='enablesmtp'} +
+
+
+ +
+ {tmpl_var name='enableimap'} +
+
+
+ +
+ {tmpl_var name='enablepop3'} +
+
+ +
+ +
+ {tmpl_var name='dkim'} +
+
+
+ +
+ +
+
+ + + +
+
+ + +
+
+ \ No newline at end of file diff --git a/templates/template_site.htm b/templates/template_site.htm new file mode 100644 index 0000000000000000000000000000000000000000..1e8d7a56c5cf7852b9c697fa29347ff4effec5e2 --- /dev/null +++ b/templates/template_site.htm @@ -0,0 +1,360 @@ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
 MB
+
+
+ +
+ +
+
 MB
+
+
+ +
+ {tmpl_var name='cgi'} +
+
+
+ +
+ {tmpl_var name='ssi'} +
+
+
+ +
+ {tmpl_var name='suexec'} +
+
+
+ +
+ {tmpl_var name='errordocs'} +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ {tmpl_var name='perl'} +
+
+
+ +
+ {tmpl_var name='ruby'} +
+
+
+ +
+ {tmpl_var name='python'} +
+
+
+ +
+ +
+
+
+ +
+ {tmpl_var name="rewrite_to_https"} +
+
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+ {tmpl_var name='php_fpm_use_socket'} +
+
+
+ +
+ +
+
+
+ {tmpl_var name='pm_ondemand_hint_txt'} +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+ {tmpl_var name='variables_txt'}:
+ {DOCROOT} +
+
+
+ +
+ +
+
+ {tmpl_var name='variables_txt'}:
+ {DOCROOT}
+ {FASTCGIPASS} +
+
+ + + +
+
+ + +
+
+ + \ No newline at end of file diff --git a/templates/template_ssh.htm b/templates/template_ssh.htm new file mode 100644 index 0000000000000000000000000000000000000000..590ae65cf89b0a3d869b75b081f63639c799afdd --- /dev/null +++ b/templates/template_ssh.htm @@ -0,0 +1,23 @@ +
+ +
+ +
+
+
+ +
+ +
+
+ + + +
+
+ + +
+
\ No newline at end of file diff --git a/templates/wizard_template_list.htm b/templates/wizard_template_list.htm new file mode 100644 index 0000000000000000000000000000000000000000..cce5ac777b03eb0f73afd21ca3263258d55c7539 --- /dev/null +++ b/templates/wizard_template_list.htm @@ -0,0 +1,52 @@ + +

+ + +

{tmpl_var name="toolsarea_head_txt"}

+ + + + + + +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{tmpl_var name='search_limit'}
+ +
{tmpl_var name="template_name"} + +
{tmpl_var name='globalsearch_noresults_text_txt'}
+
+ + \ No newline at end of file