latham
2011-04-08 532ae591db5b5f020abf60609ded0d2d32b76d86
Remove DOS line returns lathama

210 files modified
41964 ■■■■ changed files
docs/INSTALL_FEDORA_9.txt 430 ●●●● patch | view | raw | blame | history
docs/INSTALL_OPENSUSE_11.txt 402 ●●●● patch | view | raw | blame | history
docs/INSTALL_OPENSUSE_11_1.txt 420 ●●●● patch | view | raw | blame | history
helper_scripts/setup_in_openvz/diff_openssl.cnf 50 ●●●● patch | view | raw | blame | history
helper_scripts/setup_in_openvz/install_server.sh 122 ●●●● patch | view | raw | blame | history
helper_scripts/setup_in_openvz/recreate_ssh_and_hostname.sh 36 ●●●● patch | view | raw | blame | history
install/autoupdate.php 628 ●●●● patch | view | raw | blame | history
install/dist/conf/debian40.conf.php 388 ●●●● patch | view | raw | blame | history
install/dist/conf/debian60.conf.php 388 ●●●● patch | view | raw | blame | history
install/install.php 980 ●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php 3564 ●●●● patch | view | raw | blame | history
install/sql/README.txt 78 ●●●● patch | view | raw | blame | history
install/sql/incremental/upd_0007.sql 36 ●●●● patch | view | raw | blame | history
install/update.php 716 ●●●● patch | view | raw | blame | history
interface/index.htm 16 ●●●● patch | view | raw | blame | history
interface/lib/classes/auth.inc.php 256 ●●●● patch | view | raw | blame | history
interface/lib/classes/form.inc.php 948 ●●●● patch | view | raw | blame | history
interface/lib/classes/functions.inc.php 220 ●●●● patch | view | raw | blame | history
interface/lib/classes/plugin_base.inc.php 126 ●●●● patch | view | raw | blame | history
interface/lib/classes/plugin_dbhistory.inc.php 136 ●●●● patch | view | raw | blame | history
interface/lib/classes/remoting.inc.php 4770 ●●●● patch | view | raw | blame | history
interface/lib/classes/session.inc.php 256 ●●●● patch | view | raw | blame | history
interface/lib/classes/tpl_cache.inc.php 370 ●●●● patch | view | raw | blame | history
interface/lib/classes/tpl_error.inc.php 182 ●●●● patch | view | raw | blame | history
interface/lib/classes/validate_dns.inc.php 572 ●●●● patch | view | raw | blame | history
interface/web/admin/form/firewall.tform.php 222 ●●●● patch | view | raw | blame | history
interface/web/admin/form/remote_user.tform.php 318 ●●●● patch | view | raw | blame | history
interface/web/admin/form/system_config.tform.php 540 ●●●● patch | view | raw | blame | history
interface/web/admin/form/users.tform.php 910 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_config.lng 162 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_users.lng 56 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/firewall_edit.htm 76 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/groups_edit.htm 52 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/language_add.htm 64 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/language_edit.htm 64 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/language_list.htm 94 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/remote_action_ispcupdate.htm 50 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/remote_action_osupdate.htm 50 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_cron_edit.htm 60 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_fastcgi_edit.htm 92 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_getmail_edit.htm 44 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_jailkit_edit.htm 68 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_vlogger_edit.htm 44 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_edit_config.htm 44 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_ip_edit.htm 68 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_package_install.htm 58 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_package_list.htm 92 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_repo_edit.htm 80 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/software_update_list.htm 98 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/users_groups_edit.htm 60 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/users_user_edit.htm 134 ●●●● patch | view | raw | blame | history
interface/web/capp.php 110 ●●●● patch | view | raw | blame | history
interface/web/client/form/client.tform.php 1720 ●●●● patch | view | raw | blame | history
interface/web/client/form/client_template.tform.php 1048 ●●●● patch | view | raw | blame | history
interface/web/client/form/reseller.tform.php 1622 ●●●● patch | view | raw | blame | history
interface/web/client/lib/admin.conf.php 2 ●●● patch | view | raw | blame | history
interface/web/client/templates/client_edit_address.htm 228 ●●●● patch | view | raw | blame | history
interface/web/client/templates/client_edit_limits.htm 404 ●●●● patch | view | raw | blame | history
interface/web/client/templates/client_template_edit_limits.htm 272 ●●●● patch | view | raw | blame | history
interface/web/client/templates/client_template_edit_template.htm 56 ●●●● patch | view | raw | blame | history
interface/web/client/templates/reseller_edit_limits.htm 374 ●●●● patch | view | raw | blame | history
interface/web/dashboard/dashlets/limits.php 354 ●●●● patch | view | raw | blame | history
interface/web/dashboard/dashlets/modules.php 108 ●●●● patch | view | raw | blame | history
interface/web/dashboard/lib/custom_menu.inc.php 152 ●●●● patch | view | raw | blame | history
interface/web/dashboard/templates/custom_menu.htm 14 ●●●● patch | view | raw | blame | history
interface/web/designer/lib/admin.conf.php 6 ●●●● patch | view | raw | blame | history
interface/web/designer/lib/lang/cz_module_edit.lng 20 ●●●● patch | view | raw | blame | history
interface/web/designer/lib/lang/fr_module_edit.lng 4 ●●●● patch | view | raw | blame | history
interface/web/designer/lib/lang/id_module_edit.lng 20 ●●●● patch | view | raw | blame | history
interface/web/designer/lib/lang/nl_module_edit.lng 20 ●●●● patch | view | raw | blame | history
interface/web/designer/lib/lang/pl_module_edit.lng 20 ●●●● patch | view | raw | blame | history
interface/web/designer/templates/form_edit.htm 156 ●●●● patch | view | raw | blame | history
interface/web/designer/templates/form_show.htm 120 ●●●● patch | view | raw | blame | history
interface/web/designer/templates/paging.tpl.htm 16 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_a_list.php 46 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_rr_del.php 132 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_slave_del.php 136 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_soa_del.php 136 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_template_del.php 114 ●●●● patch | view | raw | blame | history
interface/web/dns/dns_template_list.php 46 ●●●● patch | view | raw | blame | history
interface/web/dns/form/dns_template.tform.php 200 ●●●● patch | view | raw | blame | history
interface/web/dns/lib/admin.conf.php 2 ●●● patch | view | raw | blame | history
interface/web/dns/list/dns_template.list.php 158 ●●●● patch | view | raw | blame | history
interface/web/dns/templates/dns_records_edit.htm 24 ●●●● patch | view | raw | blame | history
interface/web/dns/templates/dns_template_edit.htm 76 ●●●● patch | view | raw | blame | history
interface/web/domain/lib/admin.conf.php 56 ●●●● patch | view | raw | blame | history
interface/web/domain/lib/lang/en_domain_list.lng 8 ●●●● patch | view | raw | blame | history
interface/web/help/templates/support_message_edit.htm 66 ●●●● patch | view | raw | blame | history
interface/web/help/templates/support_message_view.htm 48 ●●●● patch | view | raw | blame | history
interface/web/index.php 80 ●●●● patch | view | raw | blame | history
interface/web/js/yui/datatable/assets/datatable.css 152 ●●●● patch | view | raw | blame | history
interface/web/js/yui/logger/assets/logger.css 40 ●●●● patch | view | raw | blame | history
interface/web/login/templates/password_reset.htm 66 ●●●● patch | view | raw | blame | history
interface/web/mail/form/mail_mailinglist.tform.php 242 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/admin.conf.php 2 ●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_alias_list.lng 14 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_blacklist_list.lng 18 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_domain_admin_list.lng 14 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_domain_catchall_list.lng 16 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_forward_list.lng 14 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_mailinglist.lng 28 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_mailinglist_list.lng 8 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_spamfilter_list.lng 14 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_transport_list.lng 16 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_mail_whitelist_list.lng 18 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_spamfilter_policy_list.lng 16 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_spamfilter_users_list.lng 18 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/en_spamfilter_whitelist_list.lng 16 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/fr_mail_user.lng 4 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/lang/id_mail_alias_list.lng 14 ●●●● patch | view | raw | blame | history
interface/web/mail/lib/module.conf.php 398 ●●●● patch | view | raw | blame | history
interface/web/mail/list/mail_mailinglist.list.php 132 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_del.php 194 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_domain_edit.php 738 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_mailinglist_del.php 114 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_mailinglist_edit.php 512 ●●●● patch | view | raw | blame | history
interface/web/mail/mail_mailinglist_list.php 86 ●●●● patch | view | raw | blame | history
interface/web/mail/mailinglist.php 134 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_alias_edit.htm 78 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_blacklist_edit.htm 82 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_content_filter_edit.htm 100 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_domain_admin_list.htm 24 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_domain_catchall_edit.htm 76 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_get_edit.htm 108 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_mailinglist_edit.htm 160 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_mailinglist_list.htm 106 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_relay_recipient_list.htm 18 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_transport_edit.htm 112 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_user_custom_rules_edit.htm 44 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_user_stats_list.htm 104 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/mail_whitelist_edit.htm 82 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_blacklist_edit.htm 98 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_config_getmail_edit.htm 44 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_config_mail_edit.htm 132 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_config_server_edit.htm 76 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_other_edit.htm 160 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_policy_edit.htm 128 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_quarantine_edit.htm 88 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_taglevel_edit.htm 104 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_users_edit.htm 100 ●●●● patch | view | raw | blame | history
interface/web/mail/templates/spamfilter_whitelist_edit.htm 98 ●●●● patch | view | raw | blame | history
interface/web/monitor/lib/admin.conf.php 2 ●●● patch | view | raw | blame | history
interface/web/monitor/templates/datalog_list.htm 98 ●●●● patch | view | raw | blame | history
interface/web/monitor/templates/show_data.htm 24 ●●●● patch | view | raw | blame | history
interface/web/monitor/templates/show_log.htm 50 ●●●● patch | view | raw | blame | history
interface/web/monitor/templates/show_sys_state.htm 50 ●●●● patch | view | raw | blame | history
interface/web/monitor/templates/syslog_list.htm 112 ●●●● patch | view | raw | blame | history
interface/web/nav.php 228 ●●●● patch | view | raw | blame | history
interface/web/sites/cron_del.php 126 ●●●● patch | view | raw | blame | history
interface/web/sites/cron_list.php 44 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/admin.conf.php 2 ●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_database_admin_list.lng 18 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_user_quota_stats_list.lng 14 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_domain.lng 148 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_domain_admin_list.lng 16 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/cron_edit.htm 136 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/database_admin_list.htm 36 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/ftp_user_advanced.htm 100 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/ftp_user_advanced_client.htm 44 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/ftp_user_edit.htm 96 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/shell_user_advanced.htm 68 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/shell_user_edit.htm 132 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/user_quota_stats_list.htm 12 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_aliasdomain_edit.htm 112 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_domain_admin_list.htm 30 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_domain_redirect.htm 56 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/web_subdomain_edit.htm 84 ●●●● patch | view | raw | blame | history
interface/web/sites/templates/webdav_user_edit.htm 116 ●●●● patch | view | raw | blame | history
interface/web/temp/en.lng 302 ●●●● patch | view | raw | blame | history
interface/web/themes/default/css/central.css 64 ●●●● patch | view | raw | blame | history
interface/web/themes/default/css/patches/central.css 74 ●●●● patch | view | raw | blame | history
interface/web/themes/default/css/print/print_100.css 62 ●●●● patch | view | raw | blame | history
interface/web/themes/default/css/screen/basemod_2col_left_seo.css 96 ●●●● patch | view | raw | blame | history
interface/web/themes/default/css/screen/content.css 376 ●●●● patch | view | raw | blame | history
interface/web/themes/default/css/screen/uni-form-generic.css 270 ●●●● patch | view | raw | blame | history
interface/web/themes/default/licences.txt 16 ●●●● patch | view | raw | blame | history
interface/web/themes/default/templates/module.tpl.htm 72 ●●●● patch | view | raw | blame | history
interface/web/themes/default/templates/module_tree.tpl.htm 74 ●●●● patch | view | raw | blame | history
interface/web/themes/default/templates/sidenav.tpl.htm 48 ●●●● patch | view | raw | blame | history
interface/web/themes/default/templates/tabbed_form.tpl.htm 56 ●●●● patch | view | raw | blame | history
interface/web/themes/default/templates/topnav.tpl.htm 18 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/!important.txt 8 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/core/base.css 458 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/core/iehacks.css 620 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/core/print_base.css 240 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/core/slim_base.css 98 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/core/slim_iehacks.css 70 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/core/slim_print_base.css 40 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/debug/debug.css 314 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/navigation/nav_vlist.css 216 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/patches/patch_layout_draft.css 58 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/patches/patch_nav_vlist.css 122 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/print/print_003_draft.css 62 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/print/print_020_draft.css 60 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/print/print_023_draft.css 80 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/print/print_100_draft.css 62 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/print/print_103_draft.css 74 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/print/print_120_draft.css 78 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/print/print_123_draft.css 78 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/screen/basemod_draft.css 138 ●●●● patch | view | raw | blame | history
interface/web/themes/default/yaml/screen/content_default.css 340 ●●●● patch | view | raw | blame | history
interface/web/themes/default_64_navimg/css/additional.css 118 ●●●● patch | view | raw | blame | history
interface/web/themes/default_no_navimg/css/additional.css 118 ●●●● patch | view | raw | blame | history
interface/web/tools/form/user_settings.tform.php 328 ●●●● patch | view | raw | blame | history
interface/web/tools/templates/user_settings.htm 88 ●●●● patch | view | raw | blame | history
server/lib/classes/tpl_cache.inc.php 370 ●●●● patch | view | raw | blame | history
server/lib/classes/tpl_error.inc.php 182 ●●●● patch | view | raw | blame | history
server/mods-available/mail_module.inc.php 322 ●●●● patch | view | raw | blame | history
server/mods-available/remoteaction_core_module.inc.php 406 ●●●● patch | view | raw | blame | history
server/plugins-available/mailman_plugin.inc.php 310 ●●●● patch | view | raw | blame | history
docs/INSTALL_FEDORA_9.txt
@@ -1,215 +1,215 @@
Installation
-----------
It is recommended to use a clean (fresh) Fedora install. Then follow the steps below to setup your server with ISPConfig 3:
Installation of some basic requirements:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum update
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'
You should disable selinux now, as some programs will not start when selinux is enabled:
vi /etc/selinux/config
and set:
SELINUX=disabled
then reboot the server.
1) Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin with the following command line (on one line!):
yum install ntp httpd mysql-server php php-mysql php-mbstring rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel phpMyAdmin pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel getmail
useradd -m -s /bin/bash compileuser
passwd compileuser
visudo
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
compileuser   ALL=(ALL)       ALL
su compileuser
mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros
wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.61.0.tar.bz2
wget http://prdownloads.sourceforge.net/courier/courier-imap-4.4.1.tar.bz2
wget http://prdownloads.sourceforge.net/courier/maildrop-2.0.4.tar.bz2
sudo rpmbuild -ta courier-authlib-0.61.0.tar.bz2
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-authlib-0.61.0-1.fc9.i386.rpm
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-authlib-mysql-0.61.0-1.fc9.i386.rpm
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-authlib-devel-0.61.0-1.fc9.i386.rpm
rpmbuild -ta courier-imap-4.4.1.tar.bz2
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-imap-4.4.1-1.9.i386.rpm
sudo rpmbuild -ta maildrop-2.0.4.tar.bz2
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/maildrop-2.0.4-1.9.i386.rpm
exit
yum install postfix
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
chkconfig --levels 235 httpd on
/etc/init.d/httpd start
chkconfig --levels 235 courier-authlib on
/etc/init.d/courier-authlib start
chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start
chkconfig --levels 235 courier-imap on
/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart
Set the mysql database password:
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h ispconfig.local -u root password yourrootsqlpassword
2) Install Amavisd-new, Spamassassin and Clamav (1 line!):
yum install amavisd-new spamassassin clamav clamav-data clamav-server clamav-update unzip bzip2 unrar
chkconfig --levels 235 amavisd on
chkconfig --levels 235 clamd.amavisd on
/usr/bin/freshclam
/etc/init.d/amavisd start
/etc/init.d/clamd.amavisd start
3) Install apache, PHP5 and phpmyadmin (1 line!):
yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel phpmyadmin
4) Install pure-ftpd and quota
yum install pure-ftpd quota
chkconfig --levels 235 pure-ftpd on
5) Install mydns
rpm -i http://mydns.bboy.net/download/mydns-mysql-1.1.0-1.i386.rpm
chkconfig --levels 235 mydns on
6) Install vlogger and webalizer
yum install webalizer perl-DateTime-Format-HTTP perl-DateTime-Format-Builder
cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*
7) Configure the firewall
Now you should switch off the firewall by running:
system-config-firewall-tui
ISPConfig comes with a iptables bsed firewall script that can be meneged from within the ispconfig interface.
8) Install ISPConfig 3
There are two possile scenarios, but not both:
8.1) Install the latest released version
8.2) Install directly from SVN
8.1) Installation of beta 3 from tar.gz
  cd /tmp
  wget http://www.ispconfig.org/downloads/ISPConfig-3.0.0.9-rc2.tar.gz
  tar xvfz ISPConfig-3.0.0.9-rc2.tar.gz
  cd ispconfig3_install/install/
8.2) Installation from SVN
  yum install subversion
  cd /tmp
  svn export svn://svn.ispconfig.org/ispconfig3/trunk/
  cd trunk/install
8.1+8.2) Now proceed with the ISPConfig installation.
Now start the installation process by executing:
php -q install.php
The installer will configure all services like postfix, sasl, courier, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not necessary. To login to the ISPConfig controlpanel, open the following URL in your browser (replace the IP to match your settings!):
http://192.168.0.100:8080/
the default login is:
user: admin
password: admin
In case you get a permission denied error from apache, please restart the apache webserver process.
Optional:
Install a webbased Email Client
yum install squirrelmail
----------------------------------------------------------------------------------------------------------
Hints:
debian 4.0 under openvz:
VPSID=101
for CAP in CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE
do
  vzctl set $VPSID --capability ${CAP}:on --save
done
----------------------------------------------------------------------------------------------------------
Installing Jailkit:
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
rm -rf jailkit-2.5*
Installation
-----------
It is recommended to use a clean (fresh) Fedora install. Then follow the steps below to setup your server with ISPConfig 3:
Installation of some basic requirements:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum update
yum groupinstall 'Development Tools'
yum groupinstall 'Development Libraries'
You should disable selinux now, as some programs will not start when selinux is enabled:
vi /etc/selinux/config
and set:
SELINUX=disabled
then reboot the server.
1) Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin with the following command line (on one line!):
yum install ntp httpd mysql-server php php-mysql php-mbstring rpm-build gcc mysql-devel openssl-devel cyrus-sasl-devel pkgconfig zlib-devel phpMyAdmin pcre-devel openldap-devel postgresql-devel expect libtool-ltdl-devel openldap-servers libtool gdbm-devel pam-devel gamin-devel getmail
useradd -m -s /bin/bash compileuser
passwd compileuser
visudo
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
compileuser   ALL=(ALL)       ALL
su compileuser
mkdir $HOME/rpm
mkdir $HOME/rpm/SOURCES
mkdir $HOME/rpm/SPECS
mkdir $HOME/rpm/BUILD
mkdir $HOME/rpm/SRPMS
mkdir $HOME/rpm/RPMS
mkdir $HOME/rpm/RPMS/i386
echo "%_topdir $HOME/rpm" >> $HOME/.rpmmacros
wget http://prdownloads.sourceforge.net/courier/courier-authlib-0.61.0.tar.bz2
wget http://prdownloads.sourceforge.net/courier/courier-imap-4.4.1.tar.bz2
wget http://prdownloads.sourceforge.net/courier/maildrop-2.0.4.tar.bz2
sudo rpmbuild -ta courier-authlib-0.61.0.tar.bz2
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-authlib-0.61.0-1.fc9.i386.rpm
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-authlib-mysql-0.61.0-1.fc9.i386.rpm
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-authlib-devel-0.61.0-1.fc9.i386.rpm
rpmbuild -ta courier-imap-4.4.1.tar.bz2
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/courier-imap-4.4.1-1.9.i386.rpm
sudo rpmbuild -ta maildrop-2.0.4.tar.bz2
sudo rpm -ivh /home/compileuser/rpm/RPMS/i386/maildrop-2.0.4-1.9.i386.rpm
exit
yum install postfix
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
chkconfig --levels 235 httpd on
/etc/init.d/httpd start
chkconfig --levels 235 courier-authlib on
/etc/init.d/courier-authlib start
chkconfig --levels 235 sendmail off
chkconfig --levels 235 postfix on
chkconfig --levels 235 saslauthd on
/etc/init.d/sendmail stop
/etc/init.d/postfix start
/etc/init.d/saslauthd start
chkconfig --levels 235 courier-imap on
/etc/init.d/courier-authlib restart
/etc/init.d/courier-imap restart
Set the mysql database password:
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h ispconfig.local -u root password yourrootsqlpassword
2) Install Amavisd-new, Spamassassin and Clamav (1 line!):
yum install amavisd-new spamassassin clamav clamav-data clamav-server clamav-update unzip bzip2 unrar
chkconfig --levels 235 amavisd on
chkconfig --levels 235 clamd.amavisd on
/usr/bin/freshclam
/etc/init.d/amavisd start
/etc/init.d/clamd.amavisd start
3) Install apache, PHP5 and phpmyadmin (1 line!):
yum install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-magpierss php-mapserver php-mbstring php-mcrypt php-mhash php-mssql php-shout php-snmp php-soap php-tidy curl curl-devel perl-libwww-perl ImageMagick libxml2 libxml2-devel phpmyadmin
4) Install pure-ftpd and quota
yum install pure-ftpd quota
chkconfig --levels 235 pure-ftpd on
5) Install mydns
rpm -i http://mydns.bboy.net/download/mydns-mysql-1.1.0-1.i386.rpm
chkconfig --levels 235 mydns on
6) Install vlogger and webalizer
yum install webalizer perl-DateTime-Format-HTTP perl-DateTime-Format-Builder
cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*
7) Configure the firewall
Now you should switch off the firewall by running:
system-config-firewall-tui
ISPConfig comes with a iptables bsed firewall script that can be meneged from within the ispconfig interface.
8) Install ISPConfig 3
There are two possile scenarios, but not both:
8.1) Install the latest released version
8.2) Install directly from SVN
8.1) Installation of beta 3 from tar.gz
  cd /tmp
  wget http://www.ispconfig.org/downloads/ISPConfig-3.0.0.9-rc2.tar.gz
  tar xvfz ISPConfig-3.0.0.9-rc2.tar.gz
  cd ispconfig3_install/install/
8.2) Installation from SVN
  yum install subversion
  cd /tmp
  svn export svn://svn.ispconfig.org/ispconfig3/trunk/
  cd trunk/install
8.1+8.2) Now proceed with the ISPConfig installation.
Now start the installation process by executing:
php -q install.php
The installer will configure all services like postfix, sasl, courier, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not necessary. To login to the ISPConfig controlpanel, open the following URL in your browser (replace the IP to match your settings!):
http://192.168.0.100:8080/
the default login is:
user: admin
password: admin
In case you get a permission denied error from apache, please restart the apache webserver process.
Optional:
Install a webbased Email Client
yum install squirrelmail
----------------------------------------------------------------------------------------------------------
Hints:
debian 4.0 under openvz:
VPSID=101
for CAP in CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE
do
  vzctl set $VPSID --capability ${CAP}:on --save
done
----------------------------------------------------------------------------------------------------------
Installing Jailkit:
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
rm -rf jailkit-2.5*
docs/INSTALL_OPENSUSE_11.txt
@@ -1,201 +1,201 @@
Installation
-----------
It is recommended to use a clean (fresh) OpenSUSE installatiom where you selected to install just the minimal packages. A Gnome or KDE desktop is not needed and will just slow down the server. Then follow the steps below to setup your server with ISPConfig 3:
Install some basic packes and the compilers that we need later
yast2 -i findutils readline libgcc glibc-devel findutils-locate gcc flex lynx compat-readline4 db-devel wget gcc-c++ make vim telnet cron iptables iputils man man-pages
1) Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin with the following command line (on one line!):
yast2 -i postfix postfix-mysql mysql mysql-client phpMyAdmin courier-imap courier-authlib courier-authlib-mysql python cron cyrus-sasl cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapi cyrus-sasl-otp cyrus-sasl-plain cyrus-sasl-saslauthd libmysqlclient-devel
chkconfig --add mysql
/etc/init.d/mysql start
chkconfig --add postfix
/etc/init.d/postfix start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add fam
chkconfig --add courier-authdaemon
chkconfig --add courier-pop
chkconfig --add courier-imap
/etc/init.d/courier-pop start
/etc/init.d/courier-imap start
chkconfig --add courier-pop-ssl
chkconfig --add courier-imap-ssl
/etc/init.d/courier-pop-ssl start
/etc/init.d/courier-imap-ssl start
cd /tmp
wget http://download.opensuse.org/repositories/server:/mail/openSUSE_11.0/i586/getmail-4.7.6-1.4.i586.rpm
rpm -i getmail-4.7.6-1.4.i586.rpm
// Warnings like "warning: getmail-4.7.6-1.4.i586.rpm: Header V3 DSA signature: NOKEY, key ID 367fe7fc" can be ignored.
// Install maildrop
rpm --force -i http://download.opensuse.org/repositories/home%3A/cboltz/openSUSE_10.3/i586/maildrop-2.0.3-16.1.i586.rpm
// Install pam_mysql
yast2 -i pam-devel
cd /tmp
wget http://heanet.dl.sourceforge.net/sourceforge/pam-mysql/pam_mysql-0.7RC1.tar.gz
tar xvfz pam_mysql-0.7RC1.tar.gz
cd pam_mysql-0.7RC1
./configure
make
make install
rm -rf pam_mysql-0.7RC1
rm pam_mysql-0.7RC1.tar.gz
// Set the mysql database password:
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h ispconfig.local -u root password yourrootsqlpassword
2) Install Amavisd-new, Spamassassin and Clamav (1 line!):
yast2 -i amavisd-new clamav clamav-db zoo unzip unrar bzip2 unarj perl-DBD-mysql
chkconfig --add amavis
chkconfig --add clamd
/etc/init.d/amavis start
/etc/init.d/clamd start
3) Install PHP5 modules (1 line!):
yast2 -i php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dbase php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-mysql php5-ncurses php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm ImageMagick curl
Then run the following to enable the Apache modules:
a2enmod suexec
a2enmod rewrite
a2enmod ssl
a2enmod actions
chkconfig --add apache2
/etc/init.d/apache2 start
4) Install pure-ftpd and quota
yast2 -i pure-ftpd quota
// The current pure-ftpd package from SuSE is unstable and segfaults when a file is uploaded,
// we will replace it with a manually compiled package now:
cd /tmp
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz
tar xvfz pure-ftpd-1.0.21.tar.gz
cd pure-ftpd-1.0.21/
./configure --sysconfdir=/etc/pure-ftpd --with-everything --with-mysql
make
make install
mv /usr/sbin/pure-ftpd /usr/sbin/pure-ftpd.suse
ln -s /usr/local/sbin/pure-ftpd /usr/sbin/pure-ftpd
rm -rf pure-ftpd-1.0.21
rm -f pure-ftpd-1.0.21.tar.gz
chkconfig --add pure-ftpd
/etc/init.d/pure-ftpd start
5) Install mydns
cd /tmp
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/server:/dns/SUSE_Factory/i586/mydns-mysql-1.1.0-3.72.i586.rpm
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/server:/dns/SUSE_Factory/i586/mydns-1.1.0-3.72.i586.rpm
rpm -i mydns*.rpm
rm -rf /tmp/mydns*
chkconfig --add mydns
6) Install vlogger and webalizer
cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*
yast2 -i webalizer perl-DateManip
7) Install ISPConfig 3
There are two possile scenarios, but not both:
7.1) Install the latest released version
7.2) Install directly from SVN
7.1) Installation of beta 3 from tar.gz
  cd /tmp
  wget http://www.ispconfig.org/downloads/ISPConfig-3.0.0.9-rc2.tar.gz
  tar xvfz ISPConfig-3.0.0.9-rc2.tar.gz
  cd ispconfig3_install/install/
7.2) Installation from SVN
  yast2 -i subversion
  cd /tmp
  svn export svn://svn.ispconfig.org/ispconfig3/trunk/
  cd trunk/install
7.1+7.2) Now proceed with the ISPConfig installation.
Now start the installation process by executing:
php -q install.php
The installer will configure all services like postfix, sasl, courier, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not necessary. To login to the ISPConfig controlpanel, open the following URL in your browser (replace the IP to match your settings!):
http://192.168.0.100:8080/
the default login is:
user: admin
password: admin
In case you get a permission denied error from apache, please restart the apache webserver process.
Optional:
Install a webbased Email Client
yast2 -i squirrelmail
----------------------------------------------------------------------------------------------------------
Hints:
debian 4.0 under openvz:
VPSID=101
for CAP in CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE
do
  vzctl set $VPSID --capability ${CAP}:on --save
done
----------------------------------------------------------------------------------------------------------
Installing Jailkit:
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
rm -rf jailkit-2.5*
Installation
-----------
It is recommended to use a clean (fresh) OpenSUSE installatiom where you selected to install just the minimal packages. A Gnome or KDE desktop is not needed and will just slow down the server. Then follow the steps below to setup your server with ISPConfig 3:
Install some basic packes and the compilers that we need later
yast2 -i findutils readline libgcc glibc-devel findutils-locate gcc flex lynx compat-readline4 db-devel wget gcc-c++ make vim telnet cron iptables iputils man man-pages
1) Install Postfix, Courier, Saslauthd, MySQL, phpMyAdmin with the following command line (on one line!):
yast2 -i postfix postfix-mysql mysql mysql-client phpMyAdmin courier-imap courier-authlib courier-authlib-mysql python cron cyrus-sasl cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapi cyrus-sasl-otp cyrus-sasl-plain cyrus-sasl-saslauthd libmysqlclient-devel
chkconfig --add mysql
/etc/init.d/mysql start
chkconfig --add postfix
/etc/init.d/postfix start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add fam
chkconfig --add courier-authdaemon
chkconfig --add courier-pop
chkconfig --add courier-imap
/etc/init.d/courier-pop start
/etc/init.d/courier-imap start
chkconfig --add courier-pop-ssl
chkconfig --add courier-imap-ssl
/etc/init.d/courier-pop-ssl start
/etc/init.d/courier-imap-ssl start
cd /tmp
wget http://download.opensuse.org/repositories/server:/mail/openSUSE_11.0/i586/getmail-4.7.6-1.4.i586.rpm
rpm -i getmail-4.7.6-1.4.i586.rpm
// Warnings like "warning: getmail-4.7.6-1.4.i586.rpm: Header V3 DSA signature: NOKEY, key ID 367fe7fc" can be ignored.
// Install maildrop
rpm --force -i http://download.opensuse.org/repositories/home%3A/cboltz/openSUSE_10.3/i586/maildrop-2.0.3-16.1.i586.rpm
// Install pam_mysql
yast2 -i pam-devel
cd /tmp
wget http://heanet.dl.sourceforge.net/sourceforge/pam-mysql/pam_mysql-0.7RC1.tar.gz
tar xvfz pam_mysql-0.7RC1.tar.gz
cd pam_mysql-0.7RC1
./configure
make
make install
rm -rf pam_mysql-0.7RC1
rm pam_mysql-0.7RC1.tar.gz
// Set the mysql database password:
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h ispconfig.local -u root password yourrootsqlpassword
2) Install Amavisd-new, Spamassassin and Clamav (1 line!):
yast2 -i amavisd-new clamav clamav-db zoo unzip unrar bzip2 unarj perl-DBD-mysql
chkconfig --add amavis
chkconfig --add clamd
/etc/init.d/amavis start
/etc/init.d/clamd start
3) Install PHP5 modules (1 line!):
yast2 -i php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dbase php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-mysql php5-ncurses php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm ImageMagick curl
Then run the following to enable the Apache modules:
a2enmod suexec
a2enmod rewrite
a2enmod ssl
a2enmod actions
chkconfig --add apache2
/etc/init.d/apache2 start
4) Install pure-ftpd and quota
yast2 -i pure-ftpd quota
// The current pure-ftpd package from SuSE is unstable and segfaults when a file is uploaded,
// we will replace it with a manually compiled package now:
cd /tmp
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.21.tar.gz
tar xvfz pure-ftpd-1.0.21.tar.gz
cd pure-ftpd-1.0.21/
./configure --sysconfdir=/etc/pure-ftpd --with-everything --with-mysql
make
make install
mv /usr/sbin/pure-ftpd /usr/sbin/pure-ftpd.suse
ln -s /usr/local/sbin/pure-ftpd /usr/sbin/pure-ftpd
rm -rf pure-ftpd-1.0.21
rm -f pure-ftpd-1.0.21.tar.gz
chkconfig --add pure-ftpd
/etc/init.d/pure-ftpd start
5) Install mydns
cd /tmp
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/server:/dns/SUSE_Factory/i586/mydns-mysql-1.1.0-3.72.i586.rpm
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/server:/dns/SUSE_Factory/i586/mydns-1.1.0-3.72.i586.rpm
rpm -i mydns*.rpm
rm -rf /tmp/mydns*
chkconfig --add mydns
6) Install vlogger and webalizer
cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*
yast2 -i webalizer perl-DateManip
7) Install ISPConfig 3
There are two possile scenarios, but not both:
7.1) Install the latest released version
7.2) Install directly from SVN
7.1) Installation of beta 3 from tar.gz
  cd /tmp
  wget http://www.ispconfig.org/downloads/ISPConfig-3.0.0.9-rc2.tar.gz
  tar xvfz ISPConfig-3.0.0.9-rc2.tar.gz
  cd ispconfig3_install/install/
7.2) Installation from SVN
  yast2 -i subversion
  cd /tmp
  svn export svn://svn.ispconfig.org/ispconfig3/trunk/
  cd trunk/install
7.1+7.2) Now proceed with the ISPConfig installation.
Now start the installation process by executing:
php -q install.php
The installer will configure all services like postfix, sasl, courier, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not necessary. To login to the ISPConfig controlpanel, open the following URL in your browser (replace the IP to match your settings!):
http://192.168.0.100:8080/
the default login is:
user: admin
password: admin
In case you get a permission denied error from apache, please restart the apache webserver process.
Optional:
Install a webbased Email Client
yast2 -i squirrelmail
----------------------------------------------------------------------------------------------------------
Hints:
debian 4.0 under openvz:
VPSID=101
for CAP in CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE CHOWN DAC_READ_SEARCH SETGID SETUID NET_BIND_SERVICE NET_ADMIN SYS_CHROOT SYS_NICE
do
  vzctl set $VPSID --capability ${CAP}:on --save
done
----------------------------------------------------------------------------------------------------------
Installing Jailkit:
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
rm -rf jailkit-2.5*
docs/INSTALL_OPENSUSE_11_1.txt
@@ -1,210 +1,210 @@
Installation
-----------
It is recommended to use a clean (fresh) OpenSUSE installatiom where you selected to install just the minimal packages. A Gnome or KDE desktop is not needed and will just slow down the server. Then follow the steps below to setup your server with ISPConfig 3:
The following guide is for the 32Bit version of openSUSE, for 64Bit installations the package names may differ especially the names of downloaded rpm files.
Install some basic packes and the compilers that we need later
yast2 -i findutils readline libgcc glibc-devel findutils-locate gcc flex lynx compat-readline4 db-devel wget gcc-c++ make vim telnet cron iptables iputils man man-pages nano pico
1) Install Postfix, Courier, Saslauthd, MySQL with the following command line (on one line!):
yast2 -i postfix postfix-mysql mysql mysql-client courier-imap courier-authlib courier-authlib-mysql python cron cyrus-sasl cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapi cyrus-sasl-otp cyrus-sasl-plain cyrus-sasl-saslauthd libmysqlclient-devel
chkconfig --add mysql
/etc/init.d/mysql start
chkconfig --add postfix
/etc/init.d/postfix start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add fam
chkconfig --add courier-authdaemon
chkconfig --add courier-pop
chkconfig --add courier-imap
/etc/init.d/courier-pop start
/etc/init.d/courier-imap start
chkconfig --add courier-pop-ssl
chkconfig --add courier-imap-ssl
/etc/init.d/courier-pop-ssl start
/etc/init.d/courier-imap-ssl start
cd /tmp
wget http://download.opensuse.org/repositories/server:/mail/openSUSE_11.0/i586/getmail-4.7.6-1.4.i586.rpm
rpm -i getmail-4.7.6-1.4.i586.rpm
// Install maildrop
wget http://download.opensuse.org/repositories/home:/atzewilms/openSUSE_11.1_Update/i586/maildrop-2.0.4-10.5.i586.rpm
rpm --force -i maildrop-2.0.4-10.5.i586.rpm
// Install pam_mysql
yast2 -i pam-devel
cd /tmp
wget http://heanet.dl.sourceforge.net/sourceforge/pam-mysql/pam_mysql-0.7RC1.tar.gz
tar xvfz pam_mysql-0.7RC1.tar.gz
cd pam_mysql-0.7RC1
./configure
make
make install
rm -rf /tmp/pam_mysql-0.7RC1
rm /tmp/pam_mysql-0.7RC1.tar.gz
// Set the mysql database password:
mysql_secure_installation
2) Install Amavisd-new, Spamassassin and Clamav (1 line!):
yast2 -i amavisd-new clamav clamav-db zoo unzip unrar bzip2 unarj perl-DBD-mysql
chkconfig --add amavis
chkconfig --add clamd
/etc/init.d/amavis start
/etc/init.d/clamd start
2.1) Install apache2
yast2 -i apache2 apache2-mod_fcgid
rpm -i http://download.opensuse.org/repositories/server:/php/server_database_apache_openSUSE_11.0/i586/suphp-0.6.2-10.41.i586.rpm
3) Install PHP5 modules (1 line!):
yast2 -i php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dbase php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-mysql php5-ncurses php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm ImageMagick curl apache2-mod_php5
Then run the following to enable the Apache modules:
a2enmod suexec
a2enmod rewrite
a2enmod ssl
a2enmod actions
a2enmod suphp
a2enmod fcgid
// Fix a suexec permission problem
chown root:www /usr/sbin/suexec2
chmod 4755 /usr/sbin/suexec2
// and start apache
chkconfig --add apache2
/etc/init.d/apache2 start
cd /tmp
yast2 -i pwgen
rpm -i http://download.opensuse.org/repositories/server:/php:/applications/openSUSE_11.1/noarch/phpMyAdmin-3.1.2-1.1.noarch.rpm
ln -s /srv/www/htdocs/phpMyAdmin /usr/local/ispconfig/interface/web/phpmyadmin
// Warnings like "warning: phpMyAdmin-3.1.2-1.1.src.rpm: Header V3 DSA signature: NOKEY, key ID 367fe7fc" can be ignored.
4) Install pure-ftpd and quota
yast2 -i pure-ftpd quota
chkconfig --add pure-ftpd
/etc/init.d/pure-ftpd start
5) Install mydns
cd /tmp
wget http://download.opensuse.org/repositories/home:/bajizs_cnt/openSUSE_11.1/i586/mydns-ng-1.2.8-1.1.i586.rpm
wget http://download.opensuse.org/repositories/home:/bajizs_cnt/openSUSE_11.1/i586/mydns-ng-mysql-1.2.8-1.1.i586.rpm
rpm -i mydns*.rpm
chkconfig --add mydns
6) Install vlogger and webalizer
cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*
yast2 -i webalizer perl-DateManip
6.1 Install fail2ban
rpm -i http://download.opensuse.org/repositories/home:/leonardocf/openSUSE_11.0/i586/fail2ban-0.8.2-5.2.i586.rpm
6.2) Cleanup
rm -f /tmp/*.rpm
6.2 Install jailkit
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
cd ..
rm -rf jailkit-2.5*
7) Install ISPConfig 3
There are two possile scenarios, but not both:
7.1) Install the latest released version
7.2) Install directly from SVN
7.1) Installation of beta 3 from tar.gz
  cd /tmp
  wget http://www.ispconfig.org/downloads/ISPConfig-3.0.0.9-rc2.tar.gz
  tar xvfz ISPConfig-3.0.0.9-rc2.tar.gz
  cd ispconfig3_install/install/
7.2) Installation from SVN
  yast2 -i subversion
  cd /tmp
  svn export svn://svn.ispconfig.org/ispconfig3/trunk/
  cd trunk/install
7.1+7.2) Now proceed with the ISPConfig installation.
Now start the installation process by executing:
php -q install.php
// Cleanup
rm -rf /tmp/trunk
The installer will configure all services like postfix, sasl, courier, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not necessary. To login to the ISPConfig controlpanel, open the following URL in your browser (replace the IP to match your settings!):
http://192.168.0.100:8080/
the default login is:
user: admin
password: admin
In case you get a permission denied error from apache, please restart the apache webserver process.
Optional:
Install a webbased Email Client
yast2 -i squirrelmail
Installation
-----------
It is recommended to use a clean (fresh) OpenSUSE installatiom where you selected to install just the minimal packages. A Gnome or KDE desktop is not needed and will just slow down the server. Then follow the steps below to setup your server with ISPConfig 3:
The following guide is for the 32Bit version of openSUSE, for 64Bit installations the package names may differ especially the names of downloaded rpm files.
Install some basic packes and the compilers that we need later
yast2 -i findutils readline libgcc glibc-devel findutils-locate gcc flex lynx compat-readline4 db-devel wget gcc-c++ make vim telnet cron iptables iputils man man-pages nano pico
1) Install Postfix, Courier, Saslauthd, MySQL with the following command line (on one line!):
yast2 -i postfix postfix-mysql mysql mysql-client courier-imap courier-authlib courier-authlib-mysql python cron cyrus-sasl cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapi cyrus-sasl-otp cyrus-sasl-plain cyrus-sasl-saslauthd libmysqlclient-devel
chkconfig --add mysql
/etc/init.d/mysql start
chkconfig --add postfix
/etc/init.d/postfix start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add saslauthd
/etc/init.d/saslauthd start
chkconfig --add fam
chkconfig --add courier-authdaemon
chkconfig --add courier-pop
chkconfig --add courier-imap
/etc/init.d/courier-pop start
/etc/init.d/courier-imap start
chkconfig --add courier-pop-ssl
chkconfig --add courier-imap-ssl
/etc/init.d/courier-pop-ssl start
/etc/init.d/courier-imap-ssl start
cd /tmp
wget http://download.opensuse.org/repositories/server:/mail/openSUSE_11.0/i586/getmail-4.7.6-1.4.i586.rpm
rpm -i getmail-4.7.6-1.4.i586.rpm
// Install maildrop
wget http://download.opensuse.org/repositories/home:/atzewilms/openSUSE_11.1_Update/i586/maildrop-2.0.4-10.5.i586.rpm
rpm --force -i maildrop-2.0.4-10.5.i586.rpm
// Install pam_mysql
yast2 -i pam-devel
cd /tmp
wget http://heanet.dl.sourceforge.net/sourceforge/pam-mysql/pam_mysql-0.7RC1.tar.gz
tar xvfz pam_mysql-0.7RC1.tar.gz
cd pam_mysql-0.7RC1
./configure
make
make install
rm -rf /tmp/pam_mysql-0.7RC1
rm /tmp/pam_mysql-0.7RC1.tar.gz
// Set the mysql database password:
mysql_secure_installation
2) Install Amavisd-new, Spamassassin and Clamav (1 line!):
yast2 -i amavisd-new clamav clamav-db zoo unzip unrar bzip2 unarj perl-DBD-mysql
chkconfig --add amavis
chkconfig --add clamd
/etc/init.d/amavis start
/etc/init.d/clamd start
2.1) Install apache2
yast2 -i apache2 apache2-mod_fcgid
rpm -i http://download.opensuse.org/repositories/server:/php/server_database_apache_openSUSE_11.0/i586/suphp-0.6.2-10.41.i586.rpm
3) Install PHP5 modules (1 line!):
yast2 -i php5-bcmath php5-bz2 php5-calendar php5-ctype php5-curl php5-dbase php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-mbstring php5-mcrypt php5-mysql php5-ncurses php5-odbc php5-openssl php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear php5-sysvmsg php5-sysvshm ImageMagick curl apache2-mod_php5
Then run the following to enable the Apache modules:
a2enmod suexec
a2enmod rewrite
a2enmod ssl
a2enmod actions
a2enmod suphp
a2enmod fcgid
// Fix a suexec permission problem
chown root:www /usr/sbin/suexec2
chmod 4755 /usr/sbin/suexec2
// and start apache
chkconfig --add apache2
/etc/init.d/apache2 start
cd /tmp
yast2 -i pwgen
rpm -i http://download.opensuse.org/repositories/server:/php:/applications/openSUSE_11.1/noarch/phpMyAdmin-3.1.2-1.1.noarch.rpm
ln -s /srv/www/htdocs/phpMyAdmin /usr/local/ispconfig/interface/web/phpmyadmin
// Warnings like "warning: phpMyAdmin-3.1.2-1.1.src.rpm: Header V3 DSA signature: NOKEY, key ID 367fe7fc" can be ignored.
4) Install pure-ftpd and quota
yast2 -i pure-ftpd quota
chkconfig --add pure-ftpd
/etc/init.d/pure-ftpd start
5) Install mydns
cd /tmp
wget http://download.opensuse.org/repositories/home:/bajizs_cnt/openSUSE_11.1/i586/mydns-ng-1.2.8-1.1.i586.rpm
wget http://download.opensuse.org/repositories/home:/bajizs_cnt/openSUSE_11.1/i586/mydns-ng-mysql-1.2.8-1.1.i586.rpm
rpm -i mydns*.rpm
chkconfig --add mydns
6) Install vlogger and webalizer
cd /tmp
wget http://n0rp.chemlab.org/vlogger/vlogger-1.3.tar.gz
tar xvfz vlogger-1.3.tar.gz
mv vlogger-1.3/vlogger /usr/sbin/
rm -rf vlogger*
yast2 -i webalizer perl-DateManip
6.1 Install fail2ban
rpm -i http://download.opensuse.org/repositories/home:/leonardocf/openSUSE_11.0/i586/fail2ban-0.8.2-5.2.i586.rpm
6.2) Cleanup
rm -f /tmp/*.rpm
6.2 Install jailkit
cd /tmp
wget http://olivier.sessink.nl/jailkit/jailkit-2.5.tar.gz
tar xvfz jailkit-2.5.tar.gz
cd jailkit-2.5
./configure
make
make install
cd ..
rm -rf jailkit-2.5*
7) Install ISPConfig 3
There are two possile scenarios, but not both:
7.1) Install the latest released version
7.2) Install directly from SVN
7.1) Installation of beta 3 from tar.gz
  cd /tmp
  wget http://www.ispconfig.org/downloads/ISPConfig-3.0.0.9-rc2.tar.gz
  tar xvfz ISPConfig-3.0.0.9-rc2.tar.gz
  cd ispconfig3_install/install/
7.2) Installation from SVN
  yast2 -i subversion
  cd /tmp
  svn export svn://svn.ispconfig.org/ispconfig3/trunk/
  cd trunk/install
7.1+7.2) Now proceed with the ISPConfig installation.
Now start the installation process by executing:
php -q install.php
// Cleanup
rm -rf /tmp/trunk
The installer will configure all services like postfix, sasl, courier, etc. for you. A manual setup as required for ISPConfig 2 (perfect setup guides) is not necessary. To login to the ISPConfig controlpanel, open the following URL in your browser (replace the IP to match your settings!):
http://192.168.0.100:8080/
the default login is:
user: admin
password: admin
In case you get a permission denied error from apache, please restart the apache webserver process.
Optional:
Install a webbased Email Client
yast2 -i squirrelmail
helper_scripts/setup_in_openvz/diff_openssl.cnf
@@ -1,25 +1,25 @@
# diff openssl.cnf /usr/lib/ssl/openssl.cnf
68c68
< default_days    = 3653            # how long to certify for
---
> default_days    = 365            # how long to certify for
125c125
< countryName_default        = YOURCOUNTRY
---
> countryName_default        = AU
130c130
< stateOrProvinceName_default    = YOURPROVINCE
---
> stateOrProvinceName_default    = Some-State
135c135
< 0.organizationName_default    = YOURDOMAIN
---
> 0.organizationName_default    = Internet Widgits Pty Ltd
142c142
< organizationalUnitName_default    = ISP
---
> #organizationalUnitName_default    =
145d144
< commonName_default        = YOURHOSTNAME
149d147
< emailAddress_default        = postmaster@YOURDOMAIN
# diff openssl.cnf /usr/lib/ssl/openssl.cnf
68c68
< default_days    = 3653            # how long to certify for
---
> default_days    = 365            # how long to certify for
125c125
< countryName_default        = YOURCOUNTRY
---
> countryName_default        = AU
130c130
< stateOrProvinceName_default    = YOURPROVINCE
---
> stateOrProvinceName_default    = Some-State
135c135
< 0.organizationName_default    = YOURDOMAIN
---
> 0.organizationName_default    = Internet Widgits Pty Ltd
142c142
< organizationalUnitName_default    = ISP
---
> #organizationalUnitName_default    =
145d144
< commonName_default        = YOURHOSTNAME
149d147
< emailAddress_default        = postmaster@YOURDOMAIN
helper_scripts/setup_in_openvz/install_server.sh
@@ -1,61 +1,61 @@
#!/bin/bash
# Script to configuring an ispconfig3 server in a Debian VPS
# by calocen [at] gmail [dot] com
# getting some enviromment values
myhostname=`hostname -f`
mydomain=`hostname -d`
myip=`hostname -i`
[ ! -x /usr/bin/geoiplookup ] && apt-get --assume-yes install geoip-bin
mycountry=`geoiplookup $myip | cut -f4 -d" " | cut -f1 -d","`
myprovince=`geoiplookup $myip | cut -f5 -d" "`
# reconfiguring webalizer, postfix
# could be cool to modify here webalizer values
dpkg-reconfigure -u webalizer
postconf -e "myhostname =  $myhostname"
postconf -e "mydestination =  $myhostname, localhost"
echo $myhostname > /etc/mailname
dpkg-reconfigure -u postfix
# request new password
oldpwd=`grep password /root/.my.cnf | tr "\t" " " | tr -s " " | cut -f3 -d" "`
read -p "mysql password: [$oldpwd] " mysqlpwd
[ -z $mysqlpwd ] && mysqlpwd=$oldpwd
echo $mysqlpwd
#read -p "Are you sure? (y/n) " sure
## who said fear ##
set -x
mysqladmin -u root -p$oldpwd password $mysqlpwd
mysqladmin -u root -p$mysqlpwd -h localhost password $mysqlpwd
cat << EOF > /root/.my.cnf
[client]
password    = $mysqlpwd
EOF
chmod 600 /root/.my.cnf
# changing mydns password
mysql -e "SET PASSWORD FOR 'mydns'@'%' = PASSWORD( '$mysqlpwd' )"
mysql -e "SET PASSWORD FOR 'mydns'@'localhost' = PASSWORD( '$mysqlpwd' )"
cp -ax /etc/mydns.conf /etc/mydns.conf~
sed s/$oldpwd/$mysqlpwd/g < /etc/mydns.conf~ > /etc/mydns.conf
# enabling mydns
mydns --create-tables > /tmp/mydns.sql
mysql -e "CREATE DATABASE IF NOT EXISTS mydns ; USE mydns ; SOURCE /tmp/mydns.sql;"
rm /tmp/mydns.*
invoke-rc.d mydns restart
# preparing server installation
mv /etc/ssl/openssl.cnf /etc/ssl/openssl.cnf~
sed s/"YOURHOSTNAME"/"$myhostname"/g < /usr/local/bin/openssl.cnf |
sed s/"YOURDOMAIN"/"$mydomain"/g | \
sed s/"YOURCOUNTRY"/"$mycountry"/g | \
sed s/"YOURPROVINCE"/"$myprovince"/g > /etc/ssl/openssl.cnf
tar xfz /root/downloads/ISPConfig-3.0.0.7-beta.tar.gz -C /usr/local/src
# here would be some stuff to update from SVN
cd /usr/local/src/ispconfig3_install/install/
php -q install.php
#!/bin/bash
# Script to configuring an ispconfig3 server in a Debian VPS
# by calocen [at] gmail [dot] com
# getting some enviromment values
myhostname=`hostname -f`
mydomain=`hostname -d`
myip=`hostname -i`
[ ! -x /usr/bin/geoiplookup ] && apt-get --assume-yes install geoip-bin
mycountry=`geoiplookup $myip | cut -f4 -d" " | cut -f1 -d","`
myprovince=`geoiplookup $myip | cut -f5 -d" "`
# reconfiguring webalizer, postfix
# could be cool to modify here webalizer values
dpkg-reconfigure -u webalizer
postconf -e "myhostname =  $myhostname"
postconf -e "mydestination =  $myhostname, localhost"
echo $myhostname > /etc/mailname
dpkg-reconfigure -u postfix
# request new password
oldpwd=`grep password /root/.my.cnf | tr "\t" " " | tr -s " " | cut -f3 -d" "`
read -p "mysql password: [$oldpwd] " mysqlpwd
[ -z $mysqlpwd ] && mysqlpwd=$oldpwd
echo $mysqlpwd
#read -p "Are you sure? (y/n) " sure
## who said fear ##
set -x
mysqladmin -u root -p$oldpwd password $mysqlpwd
mysqladmin -u root -p$mysqlpwd -h localhost password $mysqlpwd
cat << EOF > /root/.my.cnf
[client]
password    = $mysqlpwd
EOF
chmod 600 /root/.my.cnf
# changing mydns password
mysql -e "SET PASSWORD FOR 'mydns'@'%' = PASSWORD( '$mysqlpwd' )"
mysql -e "SET PASSWORD FOR 'mydns'@'localhost' = PASSWORD( '$mysqlpwd' )"
cp -ax /etc/mydns.conf /etc/mydns.conf~
sed s/$oldpwd/$mysqlpwd/g < /etc/mydns.conf~ > /etc/mydns.conf
# enabling mydns
mydns --create-tables > /tmp/mydns.sql
mysql -e "CREATE DATABASE IF NOT EXISTS mydns ; USE mydns ; SOURCE /tmp/mydns.sql;"
rm /tmp/mydns.*
invoke-rc.d mydns restart
# preparing server installation
mv /etc/ssl/openssl.cnf /etc/ssl/openssl.cnf~
sed s/"YOURHOSTNAME"/"$myhostname"/g < /usr/local/bin/openssl.cnf |
sed s/"YOURDOMAIN"/"$mydomain"/g | \
sed s/"YOURCOUNTRY"/"$mycountry"/g | \
sed s/"YOURPROVINCE"/"$myprovince"/g > /etc/ssl/openssl.cnf
tar xfz /root/downloads/ISPConfig-3.0.0.7-beta.tar.gz -C /usr/local/src
# here would be some stuff to update from SVN
cd /usr/local/src/ispconfig3_install/install/
php -q install.php
helper_scripts/setup_in_openvz/recreate_ssh_and_hostname.sh
@@ -1,18 +1,18 @@
#!/bin/bash
set -x
echo "" > /etc/resolv.conf
echo "" > /etc/hostname
echo "" > /etc/mailname
rm -f /etc/ssh/ssh_host_*
cat << EOF > /etc/rc2.d/S15ssh_gen_host_keys
#!/bin/bash
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N ''
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N ''
dpkg-reconfigure -u webalizer
postconf -e "myhostname =  $(hostname -f)"
postconf -e "mydestination =  $(hostname -f), localhost"
echo $(hostname -f) > /etc/mailname
dpkg-reconfigure -u postfix
rm -f \$0
EOF
chmod a+x /etc/rc2.d/S15ssh_gen_host_keys
#!/bin/bash
set -x
echo "" > /etc/resolv.conf
echo "" > /etc/hostname
echo "" > /etc/mailname
rm -f /etc/ssh/ssh_host_*
cat << EOF > /etc/rc2.d/S15ssh_gen_host_keys
#!/bin/bash
ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N ''
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N ''
dpkg-reconfigure -u webalizer
postconf -e "myhostname =  $(hostname -f)"
postconf -e "mydestination =  $(hostname -f), localhost"
echo $(hostname -f) > /etc/mailname
dpkg-reconfigure -u postfix
rm -f \$0
EOF
chmod a+x /etc/rc2.d/S15ssh_gen_host_keys
install/autoupdate.php
@@ -1,314 +1,314 @@
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
/*
    ISPConfig 3 updater.
*/
error_reporting(E_ALL|E_STRICT);
/*
 * If the auto-updater flag is not on (the file does not exist) then cancel the auto-update!
*/
if (!file_exists('autoupdate')) {
    //** The banner on the command line
    echo "\n\n".str_repeat('-',80)."\n";
    echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
    echo "\n".str_repeat('-',80)."\n";
    echo "\n\n>>This script is for internal use only! Please use update.php!  \n\n";
    exit;
}
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
$conf['mysql']['master_slave_setup'] = 'n';
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** There is a error if user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    die("internal error - MYSQL-Root passord not known");
}
/*
 *  Prepare the dump of the database
*/
prepareDBDump();
//* initialize the database
$inst->db = new db();
/*
 * The next line is a bit tricky!
 * At the automated update we have no connection to the master-db (we don't need it, because
 * there are only TWO points, where this is needed)
 * 1) update the rights --> the autoupdater sets the rights of all clients when the server is
 *    autoupdated)
 * 2) update the server-settings (is web installed, is mail installed) --> the autoupdates
 *    doesn't change any of this settings, so there ist no need to update this.
 * This means, the autoupdater did not need any connection to the master-db (only to the local bd
 * of the master-server). To avoid any problems, we set the master-db to the local one.
 */
$inst->dbmaster = $inst->db;
/*
 * If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights
*/
if($conf['mysql']['master_slave_setup'] != 'y') {
    $inst->grant_master_database_rights();
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure all Services
 */
if($conf['services']['mail'] == true) {
    //** Configure postfix
    swriteln('Configuring Postfix');
    $inst->configure_postfix('dont-create-certs');
    //** Configure mailman
    swriteln('Configuring Mailman');
    $inst->configure_mailman('update');
    //* Configure Jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //** Configure saslauthd
        swriteln('Configuring SASL');
        $inst->configure_saslauthd();
        //** Configure PAM
        swriteln('Configuring PAM');
        $inst->configure_pam();
        //* Configure courier
        swriteln('Configuring Courier');
        $inst->configure_courier();
    }
    //** Configure Spamasassin
    swriteln('Configuring Spamassassin');
    $inst->configure_spamassassin();
    //** Configure Amavis
    swriteln('Configuring Amavisd');
    $inst->configure_amavis();
    //** Configure Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
}
if($conf['services']['web'] == true) {
    //** Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
}
if($conf['services']['dns'] == true) {
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
}
if($conf['services']['web'] == true) {
    //** Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure vlogger
    swriteln('Configuring vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
}
//* Configure DBServer
swriteln('Configuring Database');
$inst->configure_dbserver();
//if(@is_dir('/etc/Bastille')) {
//* Configure Firewall
swriteln('Configuring Firewall');
$inst->configure_firewall();
//}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$conf['apache']['vhost_port'] = get_ispconfig_port_number();
$inst->install_ispconfig();
//** Configure Crontab
swriteln('Updating Crontab');
$inst->install_crontab();
//** Restart services:
swriteln('Restarting services ...');
if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' reload');
if($conf['services']['mail']) {
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
}
if($conf['services']['web']) {
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
}
if($conf['services']['dns']) {
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}
echo "Update finished.\n";
?>
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
/*
    ISPConfig 3 updater.
*/
error_reporting(E_ALL|E_STRICT);
/*
 * If the auto-updater flag is not on (the file does not exist) then cancel the auto-update!
*/
if (!file_exists('autoupdate')) {
    //** The banner on the command line
    echo "\n\n".str_repeat('-',80)."\n";
    echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
    echo "\n".str_repeat('-',80)."\n";
    echo "\n\n>>This script is for internal use only! Please use update.php!  \n\n";
    exit;
}
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
$conf['mysql']['master_slave_setup'] = 'n';
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** There is a error if user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    die("internal error - MYSQL-Root passord not known");
}
/*
 *  Prepare the dump of the database
*/
prepareDBDump();
//* initialize the database
$inst->db = new db();
/*
 * The next line is a bit tricky!
 * At the automated update we have no connection to the master-db (we don't need it, because
 * there are only TWO points, where this is needed)
 * 1) update the rights --> the autoupdater sets the rights of all clients when the server is
 *    autoupdated)
 * 2) update the server-settings (is web installed, is mail installed) --> the autoupdates
 *    doesn't change any of this settings, so there ist no need to update this.
 * This means, the autoupdater did not need any connection to the master-db (only to the local bd
 * of the master-server). To avoid any problems, we set the master-db to the local one.
 */
$inst->dbmaster = $inst->db;
/*
 * If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights
*/
if($conf['mysql']['master_slave_setup'] != 'y') {
    $inst->grant_master_database_rights();
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure all Services
 */
if($conf['services']['mail'] == true) {
    //** Configure postfix
    swriteln('Configuring Postfix');
    $inst->configure_postfix('dont-create-certs');
    //** Configure mailman
    swriteln('Configuring Mailman');
    $inst->configure_mailman('update');
    //* Configure Jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //** Configure saslauthd
        swriteln('Configuring SASL');
        $inst->configure_saslauthd();
        //** Configure PAM
        swriteln('Configuring PAM');
        $inst->configure_pam();
        //* Configure courier
        swriteln('Configuring Courier');
        $inst->configure_courier();
    }
    //** Configure Spamasassin
    swriteln('Configuring Spamassassin');
    $inst->configure_spamassassin();
    //** Configure Amavis
    swriteln('Configuring Amavisd');
    $inst->configure_amavis();
    //** Configure Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
}
if($conf['services']['web'] == true) {
    //** Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
}
if($conf['services']['dns'] == true) {
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
}
if($conf['services']['web'] == true) {
    //** Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure vlogger
    swriteln('Configuring vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
}
//* Configure DBServer
swriteln('Configuring Database');
$inst->configure_dbserver();
//if(@is_dir('/etc/Bastille')) {
//* Configure Firewall
swriteln('Configuring Firewall');
$inst->configure_firewall();
//}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$conf['apache']['vhost_port'] = get_ispconfig_port_number();
$inst->install_ispconfig();
//** Configure Crontab
swriteln('Updating Crontab');
$inst->install_crontab();
//** Restart services:
swriteln('Restarting services ...');
if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' reload');
if($conf['services']['mail']) {
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
}
if($conf['services']['web']) {
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
}
if($conf['services']['dns']) {
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}
echo "Update finished.\n";
?>
install/dist/conf/debian40.conf.php
@@ -1,195 +1,195 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian40';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Mailman
$conf['mailman']['installed'] = false; // will be detected automatically during installation
$conf['mailman']['config_dir'] = '/etc/mailman';
$conf['mailman']['init_script'] = 'mailman';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
<?php
?>
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian40';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Mailman
$conf['mailman']['installed'] = false; // will be detected automatically during installation
$conf['mailman']['config_dir'] = '/etc/mailman';
$conf['mailman']['init_script'] = 'mailman';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
?>
install/dist/conf/debian60.conf.php
@@ -1,195 +1,195 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian60';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Mailman
$conf['mailman']['installed'] = false; // will be detected automatically during installation
$conf['mailman']['config_dir'] = '/etc/mailman';
$conf['mailman']['init_script'] = 'mailman';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
<?php
?>
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
//***  Debian 4.0 default settings
//* Main
$conf['language'] = 'en';
$conf['distname'] = 'debian60';
$conf['hostname'] = 'server1.domain.tld'; // Full hostname
$conf['ispconfig_install_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_config_dir'] = '/usr/local/ispconfig';
$conf['ispconfig_log_priority'] = 2;  // 0 = Debug, 1 = Warning, 2 = Error
$conf['ispconfig_log_dir'] = '/var/log/ispconfig';
$conf['server_id'] = 1;
$conf['init_scripts'] = '/etc/init.d';
$conf['runlevel'] = '/etc';
$conf['shells'] = '/etc/shells';
$conf['pam'] = '/etc/pam.d';
//* Services provided by this server, this selection will be overridden by the expert mode
$conf['services']['mail'] = true;
$conf['services']['web'] = true;
$conf['services']['dns'] = true;
$conf['services']['file'] = true;
$conf['services']['db'] = true;
$conf['services']['vserver'] = true;
//* MySQL
$conf['mysql']['installed'] = false; // will be detected automatically during installation
$conf['mysql']['init_script'] = 'mysql';
$conf['mysql']['host'] = 'localhost';
$conf['mysql']['ip'] = '127.0.0.1';
$conf['mysql']['port'] = '3306';
$conf['mysql']['database'] = 'dbispconfig';
$conf['mysql']['admin_user'] = 'root';
$conf['mysql']['admin_password'] = '';
$conf['mysql']['charset'] = 'utf8';
$conf['mysql']['ispconfig_user'] = 'ispconfig';
$conf['mysql']['ispconfig_password'] = md5 (uniqid (rand()));
$conf['mysql']['master_slave_setup'] = 'n';
$conf['mysql']['master_host'] = '';
$conf['mysql']['master_database'] = 'dbispconfig';
$conf['mysql']['master_admin_user'] = 'root';
$conf['mysql']['master_admin_password'] = '';
$conf['mysql']['master_ispconfig_user'] = '';
$conf['mysql']['master_ispconfig_password'] = md5 (uniqid (rand()));
//* Apache
$conf['apache']['installed'] = false; // will be detected automatically during installation
$conf['apache']['user'] = 'www-data';
$conf['apache']['group'] = 'www-data';
$conf['apache']['init_script'] = 'apache2';
$conf['apache']['version'] = '2.2';
$conf['apache']['vhost_conf_dir'] = '/etc/apache2/sites-available';
$conf['apache']['vhost_conf_enabled_dir'] = '/etc/apache2/sites-enabled';
$conf['apache']['vhost_port'] = '8080';
$conf['apache']['php_ini_path_apache'] = '/etc/php5/apache2/php.ini';
$conf['apache']['php_ini_path_cgi'] = '/etc/php5/cgi/php.ini';
//* Website base settings
$conf['web']['website_basedir'] = '/var/www';
$conf['web']['website_path'] = '/var/www/clients/client[client_id]/web[website_id]';
$conf['web']['website_symlinks'] = '/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/';
//* Apps base settings
$conf['web']['apps_vhost_ip'] = '_default_';
$conf['web']['apps_vhost_port'] = '8081';
$conf['web']['apps_vhost_servername'] = '';
$conf['web']['apps_vhost_user'] = 'ispapps';
$conf['web']['apps_vhost_group'] = 'ispapps';
//* Fastcgi
$conf['fastcgi']['fastcgi_phpini_path'] = '/etc/php5/cgi/';
$conf['fastcgi']['fastcgi_starter_path'] = '/var/www/php-fcgi-scripts/[system_user]/';
//* Postfix
$conf['postfix']['installed'] = false; // will be detected automatically during installation
$conf['postfix']['config_dir'] = '/etc/postfix';
$conf['postfix']['init_script'] = 'postfix';
$conf['postfix']['user'] = 'postfix';
$conf['postfix']['group'] = 'postfix';
$conf['postfix']['vmail_userid'] = '5000';
$conf['postfix']['vmail_username'] = 'vmail';
$conf['postfix']['vmail_groupid'] = '5000';
$conf['postfix']['vmail_groupname'] = 'vmail';
$conf['postfix']['vmail_mailbox_base'] = '/var/vmail';
//* Mailman
$conf['mailman']['installed'] = false; // will be detected automatically during installation
$conf['mailman']['config_dir'] = '/etc/mailman';
$conf['mailman']['init_script'] = 'mailman';
//* Getmail
$conf['getmail']['installed'] = false; // will be detected automatically during installation
$conf['getmail']['config_dir'] = '/etc/getmail';
$conf['getmail']['program'] = '/usr/bin/getmail';
//* Courier
$conf['courier']['installed'] = false; // will be detected automatically during installation
$conf['courier']['config_dir'] = '/etc/courier';
$conf['courier']['courier-authdaemon'] = 'courier-authdaemon';
$conf['courier']['courier-imap'] = 'courier-imap';
$conf['courier']['courier-imap-ssl'] = 'courier-imap-ssl';
$conf['courier']['courier-pop'] = 'courier-pop';
$conf['courier']['courier-pop-ssl'] = 'courier-pop-ssl';
//* Dovecot
$conf['dovecot']['installed'] = false; // will be detected automatically during installation
$conf['dovecot']['config_dir'] = '/etc/dovecot';
$conf['dovecot']['init_script'] = 'dovecot';
//* SASL
$conf['saslauthd']['installed'] = false; // will be detected automatically during installation
$conf['saslauthd']['config'] = '/etc/default/saslauthd';
$conf['saslauthd']['init_script'] = 'saslauthd';
//* Amavisd
$conf['amavis']['installed'] = false; // will be detected automatically during installation
$conf['amavis']['config_dir'] = '/etc/amavis';
$conf['amavis']['init_script'] = 'amavis';
//* ClamAV
$conf['clamav']['installed'] = false; // will be detected automatically during installation
$conf['clamav']['init_script'] = 'clamav-daemon';
//* Pureftpd
$conf['pureftpd']['installed'] = false; // will be detected automatically during installation
$conf['pureftpd']['config_dir'] = '/etc/pure-ftpd';
$conf['pureftpd']['init_script'] = 'pure-ftpd-mysql';
//* MyDNS
$conf['mydns']['installed'] = false; // will be detected automatically during installation
$conf['mydns']['config_dir'] = '/etc';
$conf['mydns']['init_script'] = 'mydns';
//* PowerDNS
$conf['powerdns']['installed'] = false; // will be detected automatically during installation
$conf['powerdns']['database'] = 'powerdns';
$conf["powerdns"]["config_dir"] = '/etc/powerdns/pdns.d';
$conf['powerdns']['init_script'] = 'pdns';
//* BIND DNS Server
$conf['bind']['installed'] = false; // will be detected automatically during installation
$conf['bind']['bind_user'] = 'root';
$conf['bind']['bind_group'] = 'bind';
$conf['bind']['bind_zonefiles_dir'] = '/etc/bind';
$conf['bind']['named_conf_path'] = '/etc/bind/named.conf';
$conf['bind']['named_conf_local_path'] = '/etc/bind/named.conf.local';
$conf['bind']['init_script'] = 'bind9';
//* Jailkit
$conf['jailkit']['installed'] = false; // will be detected automatically during installation
$conf['jailkit']['config_dir'] = '/etc/jailkit';
$conf['jailkit']['jk_init'] = 'jk_init.ini';
$conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini';
$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico';
$conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php';
//* vlogger
$conf['vlogger']['config_dir'] = '/etc';
//* cron
$conf['cron']['init_script'] = 'cron';
$conf['cron']['crontab_dir'] = '/etc/cron.d';
$conf['cron']['wget'] = '/usr/bin/wget';
?>
install/install.php
@@ -1,490 +1,490 @@
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
/*
    ISPConfig 3 installer.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Initial configuration  \n\n";
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) {
    chdir( realpath(dirname(__FILE__)) );
}
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for existing installation
/*if(is_dir("/usr/local/ispconfig")) {
    die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.');
}*/
//** Get distribution identifier
$dist = get_distname();
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//****************************************************************************************************
//** Installer Interface
//****************************************************************************************************
$inst = new installer();
swriteln($inst->lng('    Following will be a few questions for primary configuration so be careful.'));
swriteln($inst->lng('    Default values are in [brackets] and can be accepted with <ENTER>.'));
swriteln($inst->lng('    Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
//** Check log file is writable (probably not root or sudo)
if(!is_writable(dirname(ISPC_LOG_FILE))){
    die("ERROR: Cannot write to the ".dirname(ISPC_LOG_FILE)." directory. Are you root or sudo ?\n\n");
}
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
if(is_dir('/usr/local/ispconfig')) {
    die('ISPConfig 3 installation found. Please use update.php instead if install.php to update the installation.');
}
//** Detect the installed applications
$inst->find_installed_apps();
//** Select the language
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en');
//** Select installation mode
$install_mode = $inst->simple_query('Installation mode', array('standard','expert'), 'standard');
//** Get the hostname
$tmp_out = array();
exec('hostname -f', $tmp_out);
$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', $tmp_out[0]);
unset($tmp_out);
// Check if the mysql functions are loaded in PHP
if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.');
//** Get MySQL root credentials
$finished = false;
do {
    $tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']);
    $tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']);
    $tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
    $tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database']);
    $tmp_mysql_server_charset = $inst->free_query('MySQL charset', $conf['mysql']['charset']);
    //* Initialize the MySQL server connection
    if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
        $conf['mysql']['host'] = $tmp_mysql_server_host;
        $conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
        $conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password;
        $conf['mysql']['database'] = $tmp_mysql_server_database;
        $conf['mysql']['charset'] = $tmp_mysql_server_charset;
        $finished = true;
    } else {
        swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error());
    }
} while ($finished == false);
unset($finished);
// Resolve the IP address of the MySQL hostname.
$tmp = explode(':',$conf['mysql']['host']);
if(!$conf['mysql']['ip'] = gethostbyname($tmp[0])) die('Unable to resolve hostname'.$tmp[0]);
unset($tmp);
//** Initializing database connection
include_once('lib/mysql.lib.php');
$inst->db = new db();
//** Begin with standard or expert installation
if($install_mode == 'standard') {
    //* Create the MySQL database
    $inst->configure_database();
    //* Insert the Server record into the database
    $inst->add_database_server_record();
    //* Configure Postfix
    $inst->configure_postfix();
    //* Configure Mailman
    $inst->configure_mailman('install');
    //* Configure jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure Dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //* Configure saslauthd
        swriteln('Configuring SASL');
        $inst->configure_saslauthd();
        //* Configure PAM
        swriteln('Configuring PAM');
        $inst->configure_pam();
        //* Configure Courier
        swriteln('Configuring Courier');
        $inst->configure_courier();
    }
    //* Configure Spamasassin
    swriteln('Configuring Spamassassin');
    $inst->configure_spamassassin();
    //* Configure Amavis
    swriteln('Configuring Amavisd');
    $inst->configure_amavis();
    //* Configure Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
    //* Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
    //* Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure Vlogger
    swriteln('Configuring Vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig');
    //** Customize the port ISPConfig runs on
    $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}else{
    //* In expert mode, we select the services in the following steps, only db is always available
    $conf['services']['mail'] = false;
    $conf['services']['web'] = false;
    $conf['services']['dns'] = false;
    $conf['services']['db'] = true;
    //** Get Server ID
    // $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1');
    // Server ID is an autoInc value of the mysql database now
    if(strtolower($inst->simple_query('Shall this server join an existing ISPConfig multiserver setup',array('y','n'),'n')) == 'y') {
        $conf['mysql']['master_slave_setup'] = 'y';
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
    } else {
        // the master DB is the same then the slave DB
        $inst->dbmaster = $inst->db;
    }
    //* Create the mysql database
    $inst->configure_database();
    //* Insert the Server record into the database
    swriteln('Adding ISPConfig server record to database.');
    swriteln('');
    $inst->add_database_server_record();
    if(strtolower($inst->simple_query('Configure Mail', array('y','n') ,'y') ) == 'y') {
        $conf['services']['mail'] = true;
        //* Configure Postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix();
        //* Configure Mailman
        swriteln('Configuring Mailman');
        $inst->configure_mailman();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //* Configure saslauthd
            swriteln('Configuring SASL');
            $inst->configure_saslauthd();
            //* Configure PAM
            swriteln('Configuring PAM');
            $inst->configure_pam();
            //* Configure courier
            swriteln('Configuring Courier');
            $inst->configure_courier();
        }
        //* Configure Spamasassin
        swriteln('Configuring Spamassassin');
        $inst->configure_spamassassin();
        //* Configure Amavis
        swriteln('Configuring Amavisd');
        $inst->configure_amavis();
        //* Configure Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
        if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    }
    //** Configure Jailkit
    if(strtolower($inst->simple_query('Configure Jailkit', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
    }
    //** Configure Pureftpd
    if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    //** Configure DNS
    if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') {
        $conf['services']['dns'] = true;
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
            if($conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
            if($conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
            if($conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        }
    }
    //** Configure Apache
    swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure Apache Server' option.\n");
    if(strtolower($inst->simple_query('Configure Apache Server',array('y','n'),'y')) == 'y') {
        $conf['services']['web'] = true;
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure Vlogger
        swriteln('Configuring Vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //** Configure Firewall
    if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') {
        swriteln('Configuring Firewall');
        $inst->configure_firewall();
    }
    //** Configure ISPConfig :-)
    if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),'y')) == 'y') {
        swriteln('Installing ISPConfig');
        //** We want to check if the server is a module or cgi based php enabled server
        //** TODO: Don't always ask for this somehow ?
        /*
        $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
        if($fast_cgi == 'yes') {
             $alias = $inst->free_query('Script Alias', '/php/');
             $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
             $conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
        } else {
             $conf['apache']['vhost_cgi_alias'] = "";
        }
        */
        //** Customise the port ISPConfig runs on
        $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
        if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface',array('y','n'),'y')) == 'y') {
            $inst->make_ispconfig_ssl_cert();
        }
        $inst->install_ispconfig_interface = true;
    } else {
        $inst->install_ispconfig_interface = false;
    }
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    if($conf['apache']['init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
} //* << $install_mode / 'Standard' or Genius
echo "Installation completed.\n";
?>
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
/*
    ISPConfig 3 installer.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Initial configuration  \n\n";
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) {
    chdir( realpath(dirname(__FILE__)) );
}
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for existing installation
/*if(is_dir("/usr/local/ispconfig")) {
    die('We will stop here. There is already a ISPConfig installation, use the update script to update this installation.');
}*/
//** Get distribution identifier
$dist = get_distname();
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//****************************************************************************************************
//** Installer Interface
//****************************************************************************************************
$inst = new installer();
swriteln($inst->lng('    Following will be a few questions for primary configuration so be careful.'));
swriteln($inst->lng('    Default values are in [brackets] and can be accepted with <ENTER>.'));
swriteln($inst->lng('    Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
//** Check log file is writable (probably not root or sudo)
if(!is_writable(dirname(ISPC_LOG_FILE))){
    die("ERROR: Cannot write to the ".dirname(ISPC_LOG_FILE)." directory. Are you root or sudo ?\n\n");
}
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
if(is_dir('/usr/local/ispconfig')) {
    die('ISPConfig 3 installation found. Please use update.php instead if install.php to update the installation.');
}
//** Detect the installed applications
$inst->find_installed_apps();
//** Select the language
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en');
//** Select installation mode
$install_mode = $inst->simple_query('Installation mode', array('standard','expert'), 'standard');
//** Get the hostname
$tmp_out = array();
exec('hostname -f', $tmp_out);
$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', $tmp_out[0]);
unset($tmp_out);
// Check if the mysql functions are loaded in PHP
if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.');
//** Get MySQL root credentials
$finished = false;
do {
    $tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']);
    $tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']);
    $tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
    $tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database']);
    $tmp_mysql_server_charset = $inst->free_query('MySQL charset', $conf['mysql']['charset']);
    //* Initialize the MySQL server connection
    if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
        $conf['mysql']['host'] = $tmp_mysql_server_host;
        $conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user;
        $conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password;
        $conf['mysql']['database'] = $tmp_mysql_server_database;
        $conf['mysql']['charset'] = $tmp_mysql_server_charset;
        $finished = true;
    } else {
        swriteln($inst->lng('Unable to connect to the specified MySQL server').' '.mysql_error());
    }
} while ($finished == false);
unset($finished);
// Resolve the IP address of the MySQL hostname.
$tmp = explode(':',$conf['mysql']['host']);
if(!$conf['mysql']['ip'] = gethostbyname($tmp[0])) die('Unable to resolve hostname'.$tmp[0]);
unset($tmp);
//** Initializing database connection
include_once('lib/mysql.lib.php');
$inst->db = new db();
//** Begin with standard or expert installation
if($install_mode == 'standard') {
    //* Create the MySQL database
    $inst->configure_database();
    //* Insert the Server record into the database
    $inst->add_database_server_record();
    //* Configure Postfix
    $inst->configure_postfix();
    //* Configure Mailman
    $inst->configure_mailman('install');
    //* Configure jailkit
    swriteln('Configuring Jailkit');
    $inst->configure_jailkit();
    if($conf['dovecot']['installed'] == true) {
        //* Configure Dovecot
        swriteln('Configuring Dovecot');
        $inst->configure_dovecot();
    } else {
        //* Configure saslauthd
        swriteln('Configuring SASL');
        $inst->configure_saslauthd();
        //* Configure PAM
        swriteln('Configuring PAM');
        $inst->configure_pam();
        //* Configure Courier
        swriteln('Configuring Courier');
        $inst->configure_courier();
    }
    //* Configure Spamasassin
    swriteln('Configuring Spamassassin');
    $inst->configure_spamassassin();
    //* Configure Amavis
    swriteln('Configuring Amavisd');
    $inst->configure_amavis();
    //* Configure Getmail
    swriteln('Configuring Getmail');
    $inst->configure_getmail();
    //* Configure Pureftpd
    swriteln('Configuring Pureftpd');
    $inst->configure_pureftpd();
    //* Configure DNS
    if($conf['powerdns']['installed'] == true) {
        swriteln('Configuring PowerDNS');
        $inst->configure_powerdns();
    } elseif($conf['bind']['installed'] == true) {
        swriteln('Configuring BIND');
        $inst->configure_bind();
    } else {
        swriteln('Configuring MyDNS');
        $inst->configure_mydns();
    }
    //* Configure Apache
    swriteln('Configuring Apache');
    $inst->configure_apache();
    //** Configure Vlogger
    swriteln('Configuring Vlogger');
    $inst->configure_vlogger();
    //** Configure apps vhost
    swriteln('Configuring Apps vhost');
    $inst->configure_apps_vhost();
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig');
    //** Customize the port ISPConfig runs on
    $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
    if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
    if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
    if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
    if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
    if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
    if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
    if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
    if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
    if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
    if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
    if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
    if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
    if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
}else{
    //* In expert mode, we select the services in the following steps, only db is always available
    $conf['services']['mail'] = false;
    $conf['services']['web'] = false;
    $conf['services']['dns'] = false;
    $conf['services']['db'] = true;
    //** Get Server ID
    // $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1');
    // Server ID is an autoInc value of the mysql database now
    if(strtolower($inst->simple_query('Shall this server join an existing ISPConfig multiserver setup',array('y','n'),'n')) == 'y') {
        $conf['mysql']['master_slave_setup'] = 'y';
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
    } else {
        // the master DB is the same then the slave DB
        $inst->dbmaster = $inst->db;
    }
    //* Create the mysql database
    $inst->configure_database();
    //* Insert the Server record into the database
    swriteln('Adding ISPConfig server record to database.');
    swriteln('');
    $inst->add_database_server_record();
    if(strtolower($inst->simple_query('Configure Mail', array('y','n') ,'y') ) == 'y') {
        $conf['services']['mail'] = true;
        //* Configure Postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix();
        //* Configure Mailman
        swriteln('Configuring Mailman');
        $inst->configure_mailman();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //* Configure saslauthd
            swriteln('Configuring SASL');
            $inst->configure_saslauthd();
            //* Configure PAM
            swriteln('Configuring PAM');
            $inst->configure_pam();
            //* Configure courier
            swriteln('Configuring Courier');
            $inst->configure_courier();
        }
        //* Configure Spamasassin
        swriteln('Configuring Spamassassin');
        $inst->configure_spamassassin();
        //* Configure Amavis
        swriteln('Configuring Amavisd');
        $inst->configure_amavis();
        //* Configure Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
        if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    }
    //** Configure Jailkit
    if(strtolower($inst->simple_query('Configure Jailkit', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
    }
    //** Configure Pureftpd
    if(strtolower($inst->simple_query('Configure FTP Server', array('y','n'),'y') ) == 'y') {
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'])) system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    //** Configure DNS
    if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') {
        $conf['services']['dns'] = true;
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
            if($conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
            if($conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
            if($conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        }
    }
    //** Configure Apache
    swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure Apache Server' option.\n");
    if(strtolower($inst->simple_query('Configure Apache Server',array('y','n'),'y')) == 'y') {
        $conf['services']['web'] = true;
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure Vlogger
        swriteln('Configuring Vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //** Configure Firewall
    if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') {
        swriteln('Configuring Firewall');
        $inst->configure_firewall();
    }
    //** Configure ISPConfig :-)
    if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),'y')) == 'y') {
        swriteln('Installing ISPConfig');
        //** We want to check if the server is a module or cgi based php enabled server
        //** TODO: Don't always ask for this somehow ?
        /*
        $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
        if($fast_cgi == 'yes') {
             $alias = $inst->free_query('Script Alias', '/php/');
             $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
             $conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
        } else {
             $conf['apache']['vhost_cgi_alias'] = "";
        }
        */
        //** Customise the port ISPConfig runs on
        $conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', '8080');
        if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface',array('y','n'),'y')) == 'y') {
            $inst->make_ispconfig_ssl_cert();
        }
        $inst->install_ispconfig_interface = true;
    } else {
        $inst->install_ispconfig_interface = false;
    }
    $inst->install_ispconfig();
    //* Configure DBServer
    swriteln('Configuring DBServer');
    $inst->configure_dbserver();
    //* Configure ISPConfig
    swriteln('Installing ISPConfig crontab');
    $inst->install_crontab();
    if($conf['apache']['init_script'] != '' && @is_file($conf['init_scripts'].'/'.$conf['apache']['init_script'])) system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
} //* << $install_mode / 'Standard' or Genius
echo "Installation completed.\n";
?>
install/lib/installer_base.lib.php
@@ -1,1788 +1,1788 @@
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
class installer_base {
    var $wb = array();
    var $language = 'en';
    var $db;
    public $conf;
    public $install_ispconfig_interface = true;
    public $is_update = false; // true if it is an update, falsi if it is a new install
    public function __construct() {
        global $conf; //TODO: maybe $conf  should be passed to constructor
        //$this->conf = $conf;
    }
    //: TODO  Implement the translation function and language files for the installer.
    public function lng($text) {
        return $text;
    }
    public function error($msg) {
        die('ERROR: '.$msg."\n");
    }
    public function warning($msg) {
        echo('WARNING: '.$msg."\n");
    }
    public function simple_query($query, $answers, $default) {
        $finished = false;
        do {
            $answers_str = implode(',', $answers);
            swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
            $input = sread();
            //* Stop the installation
            if($input == 'quit') {
                swriteln($this->lng("Installation terminated by user.\n"));
                die();
            }
            //* Select the default
            if($input == '') {
                $answer = $default;
                $finished = true;
            }
            //* Set answer id valid
            if(in_array($input, $answers)) {
                $answer = $input;
                $finished = true;
            }
        } while ($finished == false);
        swriteln();
        return $answer;
    }
    public function free_query($query,$default) {
        swrite($this->lng($query).' ['.$default.']: ');
        $input = sread();
        //* Stop the installation
        if($input == 'quit') {
            swriteln($this->lng("Installation terminated by user.\n"));
            die();
        }
        $answer =  ($input == '') ? $default : $input;
        swriteln();
        return $answer;
    }
    /*
    // TODO: this function is not used atmo I think - pedro
    function request_language(){
        swriteln(lng('Enter your language'));
        swriteln(lng('de, en'));
    }
    */
    //** Detect installed applications
    public function find_installed_apps() {
        global $conf;
        if(is_installed('mysql') || is_installed('mysqld')) $conf['mysql']['installed'] = true;
        if(is_installed('postfix')) $conf['postfix']['installed'] = true;
        if(is_installed('mailman')) $conf['mailman']['installed'] = true;
        if(is_installed('apache') || is_installed('apache2') || is_installed('httpd')) $conf['apache']['installed'] = true;
        if(is_installed('getmail')) $conf['getmail']['installed'] = true;
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
class installer_base {
    var $wb = array();
    var $language = 'en';
    var $db;
    public $conf;
    public $install_ispconfig_interface = true;
    public $is_update = false; // true if it is an update, falsi if it is a new install
    public function __construct() {
        global $conf; //TODO: maybe $conf  should be passed to constructor
        //$this->conf = $conf;
    }
    //: TODO  Implement the translation function and language files for the installer.
    public function lng($text) {
        return $text;
    }
    public function error($msg) {
        die('ERROR: '.$msg."\n");
    }
    public function warning($msg) {
        echo('WARNING: '.$msg."\n");
    }
    public function simple_query($query, $answers, $default) {
        $finished = false;
        do {
            $answers_str = implode(',', $answers);
            swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
            $input = sread();
            //* Stop the installation
            if($input == 'quit') {
                swriteln($this->lng("Installation terminated by user.\n"));
                die();
            }
            //* Select the default
            if($input == '') {
                $answer = $default;
                $finished = true;
            }
            //* Set answer id valid
            if(in_array($input, $answers)) {
                $answer = $input;
                $finished = true;
            }
        } while ($finished == false);
        swriteln();
        return $answer;
    }
    public function free_query($query,$default) {
        swrite($this->lng($query).' ['.$default.']: ');
        $input = sread();
        //* Stop the installation
        if($input == 'quit') {
            swriteln($this->lng("Installation terminated by user.\n"));
            die();
        }
        $answer =  ($input == '') ? $default : $input;
        swriteln();
        return $answer;
    }
    /*
    // TODO: this function is not used atmo I think - pedro
    function request_language(){
        swriteln(lng('Enter your language'));
        swriteln(lng('de, en'));
    }
    */
    //** Detect installed applications
    public function find_installed_apps() {
        global $conf;
        if(is_installed('mysql') || is_installed('mysqld')) $conf['mysql']['installed'] = true;
        if(is_installed('postfix')) $conf['postfix']['installed'] = true;
        if(is_installed('mailman')) $conf['mailman']['installed'] = true;
        if(is_installed('apache') || is_installed('apache2') || is_installed('httpd')) $conf['apache']['installed'] = true;
        if(is_installed('getmail')) $conf['getmail']['installed'] = true;
        if(is_installed('courierlogger')) $conf['courier']['installed'] = true;
        if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
        if(is_installed('saslsauthd')) $conf['saslauthd']['installed'] = true;
        if(is_installed('amavisd-new')) $conf['amavis']['installed'] = true;
        if(is_installed('clamdscan')) $conf['clamav']['installed'] = true;
        if(is_installed('pure-ftpd') || is_installed('pure-ftpd-wrapper')) $conf['pureftpd']['installed'] = true;
        if(is_installed('mydns') || is_installed('mydns-ng')) $conf['mydns']['installed'] = true;
        if(is_installed('jk_chrootsh')) $conf['jailkit']['installed'] = true;
        if(is_installed('pdns_server') || is_installed('pdns_control')) $conf['powerdns']['installed'] = true;
        if(is_installed('named') || is_installed('bind') || is_installed('bind9')) $conf['bind']['installed'] = true;
    }
    /** Create the database for ISPConfig */
    public function configure_database() {
        global $conf;
        //** Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['mysql']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['mysql']['database'].'.');
        }
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        //* Load the database dump into the database, if database contains no tables
        $db_tables = $this->db->getTables();
        if(count($db_tables) > 0) {
            $this->error('Stopped: Database already contains some tables.');
        } else {
            if($conf['mysql']['admin_password'] == '') {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
            } else {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
            }
            $db_tables = $this->db->getTables();
            if(count($db_tables) == 0) {
                $this->error('Unable to load SQL-Dump into database table.');
            }
            //* Load system.ini into the sys_ini table
            $system_ini = $this->db->quote(rf('tpl/system.ini.master'));
            $this->db->query("UPDATE sys_ini SET config = '$system_ini' WHERE sysini_id = 1");
        }
    }
    //** Create the server record in the database
    public function add_database_server_record() {
        global $conf;
        if($conf['mysql']['host'] == 'localhost') {
            $from_host = 'localhost';
        } else {
            $from_host = $conf['hostname'];
        }
        // Delete ISPConfig user in the local database, in case that it exists
        $this->db->query("DELETE FROM mysql.user WHERE User = '".$conf['mysql']['ispconfig_user']."' AND Host = '".$from_host."';");
        $this->db->query("DELETE FROM mysql.db WHERE Db = '".$conf['mysql']['database']."' AND Host = '".$from_host."';");
        $this->db->query('FLUSH PRIVILEGES;');
        //* Create the ISPConfig database user in the local database
        $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$conf['mysql']['database'].".* "
                ."TO '".$conf['mysql']['ispconfig_user']."'@'".$from_host."' "
                ."IDENTIFIED BY '".$conf['mysql']['ispconfig_password']."';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create database user: '.$conf['mysql']['ispconfig_user'].' Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        $tpl_ini_array = ini_to_array(rf('tpl/server.ini.master'));
        //* Update further distribution specific parameters for server config here
        //* HINT: Every line added here has to be added in update.lib.php too!!
        $tpl_ini_array['web']['vhost_conf_dir'] = $conf['apache']['vhost_conf_dir'];
        $tpl_ini_array['web']['vhost_conf_enabled_dir'] = $conf['apache']['vhost_conf_enabled_dir'];
        $tpl_ini_array['jailkit']['jailkit_chroot_app_programs'] = $conf['jailkit']['jailkit_chroot_app_programs'];
        $tpl_ini_array['fastcgi']['fastcgi_phpini_path'] = $conf['fastcgi']['fastcgi_phpini_path'];
        $tpl_ini_array['fastcgi']['fastcgi_starter_path'] = $conf['fastcgi']['fastcgi_starter_path'];
        $tpl_ini_array['server']['hostname'] = $conf['hostname'];
        $tpl_ini_array['server']['ip_address'] = @gethostbyname($conf['hostname']);
        $tpl_ini_array['web']['website_basedir'] = $conf['web']['website_basedir'];
        $tpl_ini_array['web']['website_path'] = $conf['web']['website_path'];
        $tpl_ini_array['web']['website_symlinks'] = $conf['web']['website_symlinks'];
        $tpl_ini_array['cron']['crontab_dir'] = $conf['cron']['crontab_dir'];
        $tpl_ini_array['web']['security_level'] = 20;
        $tpl_ini_array['web']['user'] = $conf['apache']['user'];
        $tpl_ini_array['web']['group'] = $conf['apache']['group'];
        $tpl_ini_array['web']['php_ini_path_apache'] = $conf['apache']['php_ini_path_apache'];
        $tpl_ini_array['web']['php_ini_path_cgi'] = $conf['apache']['php_ini_path_cgi'];
        $tpl_ini_array['mail']['pop3_imap_daemon'] = ($conf['dovecot']['installed'] == true)?'dovecot':'courier';
        $tpl_ini_array['mail']['mail_filter_syntax'] = ($conf['dovecot']['installed'] == true)?'sieve':'maildrop';
        $tpl_ini_array['dns']['bind_user'] = $conf['bind']['bind_user'];
        $tpl_ini_array['dns']['bind_group'] = $conf['bind']['bind_group'];
        $tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir'];
        $tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
        $tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
        if (array_key_exists('awstats', $conf)) {
            foreach ($conf['awstats'] as $aw_sett => $aw_value) {
                $tpl_ini_array['web']['awstats_'.$aw_sett] = $aw_value;
            }
        }
        $server_ini_content = array_to_ini($tpl_ini_array);
        $server_ini_content = mysql_real_escape_string($server_ini_content);
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        //** Get the database version number based on the patchfiles
        $found = true;
        $current_db_version = 1;
        while($found == true) {
            $next_db_version = intval($current_db_version + 1);
            $patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
            if(is_file($patch_filename)) {
                $current_db_version = $next_db_version;
            } else {
                $found = false;
            }
        }
        $current_db_version = intval($current_db_version);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            //* Insert the server record in master DB
            $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->dbmaster->query($sql);
            $conf['server_id'] = $this->dbmaster->insertID();
            $conf['server_id'] = $conf['server_id'];
            //* Insert the same record in the local DB
            $sql = "INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES ('".$conf['server_id']."',1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            //* username for the ispconfig user
            $conf['mysql']['master_ispconfig_user'] = 'ispcsrv'.$conf['server_id'];
            $this->grant_master_database_rights();
        } else {
            //* Insert the server, if its not a mster / slave setup
            $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            $conf['server_id'] = $this->db->insertID();
            $conf['server_id'] = $conf['server_id'];
        }
    }
    public function grant_master_database_rights() {
        global $conf;
        /*
         * The following code is a little bit tricky:
         * * If we HAVE a master-slave - Setup then the client has to grant the rights for himself
         *   at the master.
         * * If we DO NOT have a master-slave - Setup then we have two possibilities
         *   1) it is a single server
         *   2) it is the MASTER of n clients
        */
        $hosts = array();
        if($conf['mysql']['master_slave_setup'] == 'y') {
            /*
             * it is a master-slave - Setup so the slave has to grant its rights in the master
             * database
             */
            //* insert the ispconfig user in the remote server
            $from_host = $conf['hostname'];
            $from_ip = gethostbyname($conf['hostname']);
            $hosts[$from_host]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_host]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_host]['pwd'] = $conf['mysql']['master_ispconfig_password'];
            $hosts[$from_ip]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_ip]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_ip]['pwd'] = $conf['mysql']['master_ispconfig_password'];
        } else{
            /*
             * it is NOT a master-slave - Setup so we have to find out all clients and their
             * host
             */
            $query = "SELECT Host, User FROM mysql.user WHERE User like 'ispcsrv%' ORDER BY User, Host";
            $data = $this->dbmaster->queryAllRecords($query);
            if($data === false) {
                $this->error('Unable to get the user rights: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            foreach ($data as $item){
                $hosts[$item['Host']]['user'] = $item['User'];
                $hosts[$item['Host']]['db'] = $conf['mysql']['master_database'];
                $hosts[$item['Host']]['pwd'] = ''; // the user already exists, so we need no pwd!
            }
        }
        if(count($hosts) > 0) {
        foreach($hosts as $host => $value) {
            /*
             * If a pwd exists, this means, we have to add the new user (and his pwd).
             * if not, the user already exists and we do not need the pwd
             */
            if ($value['pwd'] != ''){
                $query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'";
                $this->dbmaster->query($query); // ignore the error
            }
            /*
             *  Try to delete all rights of the user in case that it exists.
             *  In Case that it will not exist, do nothing (ignore the error!)
             */
            $query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' ";
            $this->dbmaster->query($query); // ignore the error
            //* Create the ISPConfig database user in the remote database
            $query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT ON ".$value['db'].".`sys_log` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`software_update_inst` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`updated`) ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT ON ".$value['db'].".`sys_group` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`action_state`, `response`) ON ".$value['db'].".`sys_remoteaction` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT , DELETE ON ".$value['db'].".`monitor_data` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`mail_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`web_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
        }
        /*
         * It is all done. Relod the rights...
         */
        $this->dbmaster->query('FLUSH PRIVILEGES;');
        }
    }
    //** writes postfix configuration files
    public function process_postfix_config($configfile) {
        global $conf;
        $config_dir = $conf['postfix']['config_dir'].'/';
        $full_file_name = $config_dir.$configfile;
        //* Backup exiting file
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($full_file_name, $content);
    }
    public function configure_jailkit() {
        global $conf;
        $cf = $conf['jailkit'];
        $config_dir = $cf['config_dir'];
        $jk_init = $cf['jk_init'];
        $jk_chrootsh = $cf['jk_chrootsh'];
        if (is_dir($config_dir)) {
            if(is_file($config_dir.'/'.$jk_init)) copy($config_dir.'/'.$jk_init, $config_dir.'/'.$jk_init.'~');
            if(is_file($config_dir.'/'.$jk_chrootsh.'.master')) copy($config_dir.'/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh.'~');
            copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init);
            copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh);
        }
    }
    public function configure_mailman($status = 'insert') {
        global $conf;
        $config_dir = $conf['mailman']['config_dir'].'/';
        $full_file_name = $config_dir.'mm_cfg.py';
        //* Backup exiting file
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.'mm_cfg.py~');
        }
        // load files
        $content = rf('tpl/mm_cfg.py.master');
        $old_file = rf($full_file_name);
        $old_options = array();
        $lines = explode("\n", $old_file);
        foreach ($lines as $line)
        {
            if (strlen($line) && substr($line, 0, 1) != '#')
            {
                list($key, $value) = explode("=", $line);
                if (!empty($value))
                {
                    $key = rtrim($key);
                    $old_options[$key] = trim($value);
                }
            }
        }
        $virtual_domains = '';
        if($status == 'update')
        {
            // create virtual_domains list
            $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain");
            foreach($domainAll as $domain)
            {
                if ($domainAll[0]['domain'] == $domain['domain'])
                    $virtual_domains .= "'".$domain['domain']."'";
                else
                    $virtual_domains .= ", '".$domain['domain']."'";
            }
        }
        else
            $virtual_domains = "' '";
        $content = str_replace('{hostname}', $conf['hostname'], $content);
        $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content);
        $content = str_replace('{virtual_domains}', $virtual_domains, $content);
        wf($full_file_name, $content);
    }
    public function configure_postfix($options = '') {
        global $conf;
        $cf = $conf['postfix'];
        $config_dir = $cf['config_dir'];
        if(!is_dir($config_dir)) {
            $this->error("The postfix configuration directory '$config_dir' does not exist.");
        }
        //* mysql-virtual_domains.cf
        $this->process_postfix_config('mysql-virtual_domains.cf');
        //* mysql-virtual_forwardings.cf
        $this->process_postfix_config('mysql-virtual_forwardings.cf');
        //* mysql-virtual_mailboxes.cf
        $this->process_postfix_config('mysql-virtual_mailboxes.cf');
        //* mysql-virtual_email2email.cf
        $this->process_postfix_config('mysql-virtual_email2email.cf');
        //* mysql-virtual_transports.cf
        $this->process_postfix_config('mysql-virtual_transports.cf');
        //* mysql-virtual_recipient.cf
        $this->process_postfix_config('mysql-virtual_recipient.cf');
        //* mysql-virtual_sender.cf
        $this->process_postfix_config('mysql-virtual_sender.cf');
        //* mysql-virtual_client.cf
        $this->process_postfix_config('mysql-virtual_client.cf');
        //* mysql-virtual_relaydomains.cf
        $this->process_postfix_config('mysql-virtual_relaydomains.cf');
        //* mysql-virtual_relayrecipientmaps.cf
        $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
        //* Changing mode and group of the new created config files.
        caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
        caselog('chgrp '.$cf['group'].' '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                __FILE__, __LINE__, 'chgrp on mysql-virtual_*.cf*', 'chgrp on mysql-virtual_*.cf* failed');
        //* Creating virtual mail user and group
        $command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
        if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
        if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $postconf_commands = array (
                'myhostname = '.$conf['hostname'],
                'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
                'mynetworks = 127.0.0.0/8 [::1]/128',
                'alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
                'alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
                'virtual_alias_domains =',
                'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, proxy:mysql:'.$config_dir.'/mysql-virtual_email2email.cf, hash:/var/lib/mailman/data/virtual-mailman',
                'virtual_mailbox_domains = proxy:mysql:'.$config_dir.'/mysql-virtual_domains.cf',
                'virtual_mailbox_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailboxes.cf',
                'virtual_mailbox_base = '.$cf['vmail_mailbox_base'],
                'virtual_uid_maps = static:'.$cf['vmail_userid'],
                'virtual_gid_maps = static:'.$cf['vmail_groupid'],
                'smtpd_sasl_auth_enable = yes',
                'broken_sasl_auth_clients = yes',
                'smtpd_sasl_authenticated_header = yes',
                'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination',
                'smtpd_use_tls = yes',
                'smtpd_tls_security_level = may',
                'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert',
                'smtpd_tls_key_file = '.$config_dir.'/smtpd.key',
                'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf',
                'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf',
                'relay_recipient_maps = mysql:'.$config_dir.'/mysql-virtual_relayrecipientmaps.cf',
                'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps',
                'smtpd_sender_restrictions = check_sender_access mysql:'.$config_dir.'/mysql-virtual_sender.cf',
                'smtpd_client_restrictions = check_client_access mysql:'.$config_dir.'/mysql-virtual_client.cf',
                'maildrop_destination_concurrency_limit = 1',
                'maildrop_destination_recipient_limit   = 1',
                'virtual_transport = maildrop',
                'header_checks = regexp:'.$config_dir.'/header_checks',
                'mime_header_checks = regexp:'.$config_dir.'/mime_header_checks',
                'nested_header_checks = regexp:'.$config_dir.'/nested_header_checks',
                'body_checks = regexp:'.$config_dir.'/body_checks',
                'owner_request_special = no'
        );
        //* Create the header and body check files
        touch($config_dir.'/header_checks');
        touch($config_dir.'/mime_header_checks');
        touch($config_dir.'/nested_header_checks');
        touch($config_dir.'/body_checks');
        //* Create the mailman files
        exec('mkdir -p /var/lib/mailman/data');
        touch('/var/lib/mailman/data/aliases');
        exec('postmap /var/lib/mailman/data/aliases');
        touch('/var/lib/mailman/data/virtual-mailman');
        exec('postmap /var/lib/mailman/data/virtual-mailman');
        //* Make a backup copy of the main.cf file
        copy($config_dir.'/main.cf', $config_dir.'/main.cf~');
        //* Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        }
        if(!stristr($options,'dont-create-certs')) {
            //* Create the SSL certificate
            $command = 'cd '.$config_dir.'; '
        if(is_installed('dovecot')) $conf['dovecot']['installed'] = true;
        if(is_installed('saslsauthd')) $conf['saslauthd']['installed'] = true;
        if(is_installed('amavisd-new')) $conf['amavis']['installed'] = true;
        if(is_installed('clamdscan')) $conf['clamav']['installed'] = true;
        if(is_installed('pure-ftpd') || is_installed('pure-ftpd-wrapper')) $conf['pureftpd']['installed'] = true;
        if(is_installed('mydns') || is_installed('mydns-ng')) $conf['mydns']['installed'] = true;
        if(is_installed('jk_chrootsh')) $conf['jailkit']['installed'] = true;
        if(is_installed('pdns_server') || is_installed('pdns_control')) $conf['powerdns']['installed'] = true;
        if(is_installed('named') || is_installed('bind') || is_installed('bind9')) $conf['bind']['installed'] = true;
    }
    /** Create the database for ISPConfig */
    public function configure_database() {
        global $conf;
        //** Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['mysql']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['mysql']['database'].'.');
        }
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        //* Load the database dump into the database, if database contains no tables
        $db_tables = $this->db->getTables();
        if(count($db_tables) > 0) {
            $this->error('Stopped: Database already contains some tables.');
        } else {
            if($conf['mysql']['admin_password'] == '') {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
            } else {
                caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
            }
            $db_tables = $this->db->getTables();
            if(count($db_tables) == 0) {
                $this->error('Unable to load SQL-Dump into database table.');
            }
            //* Load system.ini into the sys_ini table
            $system_ini = $this->db->quote(rf('tpl/system.ini.master'));
            $this->db->query("UPDATE sys_ini SET config = '$system_ini' WHERE sysini_id = 1");
        }
    }
    //** Create the server record in the database
    public function add_database_server_record() {
        global $conf;
        if($conf['mysql']['host'] == 'localhost') {
            $from_host = 'localhost';
        } else {
            $from_host = $conf['hostname'];
        }
        // Delete ISPConfig user in the local database, in case that it exists
        $this->db->query("DELETE FROM mysql.user WHERE User = '".$conf['mysql']['ispconfig_user']."' AND Host = '".$from_host."';");
        $this->db->query("DELETE FROM mysql.db WHERE Db = '".$conf['mysql']['database']."' AND Host = '".$from_host."';");
        $this->db->query('FLUSH PRIVILEGES;');
        //* Create the ISPConfig database user in the local database
        $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$conf['mysql']['database'].".* "
                ."TO '".$conf['mysql']['ispconfig_user']."'@'".$from_host."' "
                ."IDENTIFIED BY '".$conf['mysql']['ispconfig_password']."';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create database user: '.$conf['mysql']['ispconfig_user'].' Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* Set the database name in the DB library
        $this->db->dbName = $conf['mysql']['database'];
        $tpl_ini_array = ini_to_array(rf('tpl/server.ini.master'));
        //* Update further distribution specific parameters for server config here
        //* HINT: Every line added here has to be added in update.lib.php too!!
        $tpl_ini_array['web']['vhost_conf_dir'] = $conf['apache']['vhost_conf_dir'];
        $tpl_ini_array['web']['vhost_conf_enabled_dir'] = $conf['apache']['vhost_conf_enabled_dir'];
        $tpl_ini_array['jailkit']['jailkit_chroot_app_programs'] = $conf['jailkit']['jailkit_chroot_app_programs'];
        $tpl_ini_array['fastcgi']['fastcgi_phpini_path'] = $conf['fastcgi']['fastcgi_phpini_path'];
        $tpl_ini_array['fastcgi']['fastcgi_starter_path'] = $conf['fastcgi']['fastcgi_starter_path'];
        $tpl_ini_array['server']['hostname'] = $conf['hostname'];
        $tpl_ini_array['server']['ip_address'] = @gethostbyname($conf['hostname']);
        $tpl_ini_array['web']['website_basedir'] = $conf['web']['website_basedir'];
        $tpl_ini_array['web']['website_path'] = $conf['web']['website_path'];
        $tpl_ini_array['web']['website_symlinks'] = $conf['web']['website_symlinks'];
        $tpl_ini_array['cron']['crontab_dir'] = $conf['cron']['crontab_dir'];
        $tpl_ini_array['web']['security_level'] = 20;
        $tpl_ini_array['web']['user'] = $conf['apache']['user'];
        $tpl_ini_array['web']['group'] = $conf['apache']['group'];
        $tpl_ini_array['web']['php_ini_path_apache'] = $conf['apache']['php_ini_path_apache'];
        $tpl_ini_array['web']['php_ini_path_cgi'] = $conf['apache']['php_ini_path_cgi'];
        $tpl_ini_array['mail']['pop3_imap_daemon'] = ($conf['dovecot']['installed'] == true)?'dovecot':'courier';
        $tpl_ini_array['mail']['mail_filter_syntax'] = ($conf['dovecot']['installed'] == true)?'sieve':'maildrop';
        $tpl_ini_array['dns']['bind_user'] = $conf['bind']['bind_user'];
        $tpl_ini_array['dns']['bind_group'] = $conf['bind']['bind_group'];
        $tpl_ini_array['dns']['bind_zonefiles_dir'] = $conf['bind']['bind_zonefiles_dir'];
        $tpl_ini_array['dns']['named_conf_path'] = $conf['bind']['named_conf_path'];
        $tpl_ini_array['dns']['named_conf_local_path'] = $conf['bind']['named_conf_local_path'];
        if (array_key_exists('awstats', $conf)) {
            foreach ($conf['awstats'] as $aw_sett => $aw_value) {
                $tpl_ini_array['web']['awstats_'.$aw_sett] = $aw_value;
            }
        }
        $server_ini_content = array_to_ini($tpl_ini_array);
        $server_ini_content = mysql_real_escape_string($server_ini_content);
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        //** Get the database version number based on the patchfiles
        $found = true;
        $current_db_version = 1;
        while($found == true) {
            $next_db_version = intval($current_db_version + 1);
            $patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql';
            if(is_file($patch_filename)) {
                $current_db_version = $next_db_version;
            } else {
                $found = false;
            }
        }
        $current_db_version = intval($current_db_version);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            //* Insert the server record in master DB
            $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->dbmaster->query($sql);
            $conf['server_id'] = $this->dbmaster->insertID();
            $conf['server_id'] = $conf['server_id'];
            //* Insert the same record in the local DB
            $sql = "INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES ('".$conf['server_id']."',1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            //* username for the ispconfig user
            $conf['mysql']['master_ispconfig_user'] = 'ispcsrv'.$conf['server_id'];
            $this->grant_master_database_rights();
        } else {
            //* Insert the server, if its not a mster / slave setup
            $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version);";
            $this->db->query($sql);
            $conf['server_id'] = $this->db->insertID();
            $conf['server_id'] = $conf['server_id'];
        }
    }
    public function grant_master_database_rights() {
        global $conf;
        /*
         * The following code is a little bit tricky:
         * * If we HAVE a master-slave - Setup then the client has to grant the rights for himself
         *   at the master.
         * * If we DO NOT have a master-slave - Setup then we have two possibilities
         *   1) it is a single server
         *   2) it is the MASTER of n clients
        */
        $hosts = array();
        if($conf['mysql']['master_slave_setup'] == 'y') {
            /*
             * it is a master-slave - Setup so the slave has to grant its rights in the master
             * database
             */
            //* insert the ispconfig user in the remote server
            $from_host = $conf['hostname'];
            $from_ip = gethostbyname($conf['hostname']);
            $hosts[$from_host]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_host]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_host]['pwd'] = $conf['mysql']['master_ispconfig_password'];
            $hosts[$from_ip]['user'] = $conf['mysql']['master_ispconfig_user'];
            $hosts[$from_ip]['db'] = $conf['mysql']['master_database'];
            $hosts[$from_ip]['pwd'] = $conf['mysql']['master_ispconfig_password'];
        } else{
            /*
             * it is NOT a master-slave - Setup so we have to find out all clients and their
             * host
             */
            $query = "SELECT Host, User FROM mysql.user WHERE User like 'ispcsrv%' ORDER BY User, Host";
            $data = $this->dbmaster->queryAllRecords($query);
            if($data === false) {
                $this->error('Unable to get the user rights: '.$value['db'].' Error: '.$this->dbmaster->errorMessage);
            }
            foreach ($data as $item){
                $hosts[$item['Host']]['user'] = $item['User'];
                $hosts[$item['Host']]['db'] = $conf['mysql']['master_database'];
                $hosts[$item['Host']]['pwd'] = ''; // the user already exists, so we need no pwd!
            }
        }
        if(count($hosts) > 0) {
        foreach($hosts as $host => $value) {
            /*
             * If a pwd exists, this means, we have to add the new user (and his pwd).
             * if not, the user already exists and we do not need the pwd
             */
            if ($value['pwd'] != ''){
                $query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'";
                $this->dbmaster->query($query); // ignore the error
            }
            /*
             *  Try to delete all rights of the user in case that it exists.
             *  In Case that it will not exist, do nothing (ignore the error!)
             */
            $query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' ";
            $this->dbmaster->query($query); // ignore the error
            //* Create the ISPConfig database user in the remote database
            $query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT ON ".$value['db'].".`sys_log` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`software_update_inst` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE(`updated`) ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT ON ".$value['db'].".`sys_group` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, UPDATE (`action_state`, `response`) ON ".$value['db'].".`sys_remoteaction` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT , DELETE ON ".$value['db'].".`monitor_data` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`mail_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, UPDATE ON ".$value['db'].".`web_traffic` TO '".$value['user']."'@'".$host."' ";
            if(!$this->dbmaster->query($query)) {
                $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
        }
        /*
         * It is all done. Relod the rights...
         */
        $this->dbmaster->query('FLUSH PRIVILEGES;');
        }
    }
    //** writes postfix configuration files
    public function process_postfix_config($configfile) {
        global $conf;
        $config_dir = $conf['postfix']['config_dir'].'/';
        $full_file_name = $config_dir.$configfile;
        //* Backup exiting file
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($full_file_name, $content);
    }
    public function configure_jailkit() {
        global $conf;
        $cf = $conf['jailkit'];
        $config_dir = $cf['config_dir'];
        $jk_init = $cf['jk_init'];
        $jk_chrootsh = $cf['jk_chrootsh'];
        if (is_dir($config_dir)) {
            if(is_file($config_dir.'/'.$jk_init)) copy($config_dir.'/'.$jk_init, $config_dir.'/'.$jk_init.'~');
            if(is_file($config_dir.'/'.$jk_chrootsh.'.master')) copy($config_dir.'/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh.'~');
            copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init);
            copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh);
        }
    }
    public function configure_mailman($status = 'insert') {
        global $conf;
        $config_dir = $conf['mailman']['config_dir'].'/';
        $full_file_name = $config_dir.'mm_cfg.py';
        //* Backup exiting file
        if(is_file($full_file_name)) {
            copy($full_file_name, $config_dir.'mm_cfg.py~');
        }
        // load files
        $content = rf('tpl/mm_cfg.py.master');
        $old_file = rf($full_file_name);
        $old_options = array();
        $lines = explode("\n", $old_file);
        foreach ($lines as $line)
        {
            if (strlen($line) && substr($line, 0, 1) != '#')
            {
                list($key, $value) = explode("=", $line);
                if (!empty($value))
                {
                    $key = rtrim($key);
                    $old_options[$key] = trim($value);
                }
            }
        }
        $virtual_domains = '';
        if($status == 'update')
        {
            // create virtual_domains list
            $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain");
            foreach($domainAll as $domain)
            {
                if ($domainAll[0]['domain'] == $domain['domain'])
                    $virtual_domains .= "'".$domain['domain']."'";
                else
                    $virtual_domains .= ", '".$domain['domain']."'";
            }
        }
        else
            $virtual_domains = "' '";
        $content = str_replace('{hostname}', $conf['hostname'], $content);
        $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content);
        $content = str_replace('{virtual_domains}', $virtual_domains, $content);
        wf($full_file_name, $content);
    }
    public function configure_postfix($options = '') {
        global $conf;
        $cf = $conf['postfix'];
        $config_dir = $cf['config_dir'];
        if(!is_dir($config_dir)) {
            $this->error("The postfix configuration directory '$config_dir' does not exist.");
        }
        //* mysql-virtual_domains.cf
        $this->process_postfix_config('mysql-virtual_domains.cf');
        //* mysql-virtual_forwardings.cf
        $this->process_postfix_config('mysql-virtual_forwardings.cf');
        //* mysql-virtual_mailboxes.cf
        $this->process_postfix_config('mysql-virtual_mailboxes.cf');
        //* mysql-virtual_email2email.cf
        $this->process_postfix_config('mysql-virtual_email2email.cf');
        //* mysql-virtual_transports.cf
        $this->process_postfix_config('mysql-virtual_transports.cf');
        //* mysql-virtual_recipient.cf
        $this->process_postfix_config('mysql-virtual_recipient.cf');
        //* mysql-virtual_sender.cf
        $this->process_postfix_config('mysql-virtual_sender.cf');
        //* mysql-virtual_client.cf
        $this->process_postfix_config('mysql-virtual_client.cf');
        //* mysql-virtual_relaydomains.cf
        $this->process_postfix_config('mysql-virtual_relaydomains.cf');
        //* mysql-virtual_relayrecipientmaps.cf
        $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
        //* Changing mode and group of the new created config files.
        caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
        caselog('chgrp '.$cf['group'].' '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
                __FILE__, __LINE__, 'chgrp on mysql-virtual_*.cf*', 'chgrp on mysql-virtual_*.cf* failed');
        //* Creating virtual mail user and group
        $command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
        if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
        if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $postconf_commands = array (
                'myhostname = '.$conf['hostname'],
                'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
                'mynetworks = 127.0.0.0/8 [::1]/128',
                'alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
                'alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
                'virtual_alias_domains =',
                'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, proxy:mysql:'.$config_dir.'/mysql-virtual_email2email.cf, hash:/var/lib/mailman/data/virtual-mailman',
                'virtual_mailbox_domains = proxy:mysql:'.$config_dir.'/mysql-virtual_domains.cf',
                'virtual_mailbox_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailboxes.cf',
                'virtual_mailbox_base = '.$cf['vmail_mailbox_base'],
                'virtual_uid_maps = static:'.$cf['vmail_userid'],
                'virtual_gid_maps = static:'.$cf['vmail_groupid'],
                'smtpd_sasl_auth_enable = yes',
                'broken_sasl_auth_clients = yes',
                'smtpd_sasl_authenticated_header = yes',
                'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination',
                'smtpd_use_tls = yes',
                'smtpd_tls_security_level = may',
                'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert',
                'smtpd_tls_key_file = '.$config_dir.'/smtpd.key',
                'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf',
                'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf',
                'relay_recipient_maps = mysql:'.$config_dir.'/mysql-virtual_relayrecipientmaps.cf',
                'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps',
                'smtpd_sender_restrictions = check_sender_access mysql:'.$config_dir.'/mysql-virtual_sender.cf',
                'smtpd_client_restrictions = check_client_access mysql:'.$config_dir.'/mysql-virtual_client.cf',
                'maildrop_destination_concurrency_limit = 1',
                'maildrop_destination_recipient_limit   = 1',
                'virtual_transport = maildrop',
                'header_checks = regexp:'.$config_dir.'/header_checks',
                'mime_header_checks = regexp:'.$config_dir.'/mime_header_checks',
                'nested_header_checks = regexp:'.$config_dir.'/nested_header_checks',
                'body_checks = regexp:'.$config_dir.'/body_checks',
                'owner_request_special = no'
        );
        //* Create the header and body check files
        touch($config_dir.'/header_checks');
        touch($config_dir.'/mime_header_checks');
        touch($config_dir.'/nested_header_checks');
        touch($config_dir.'/body_checks');
        //* Create the mailman files
        exec('mkdir -p /var/lib/mailman/data');
        touch('/var/lib/mailman/data/aliases');
        exec('postmap /var/lib/mailman/data/aliases');
        touch('/var/lib/mailman/data/virtual-mailman');
        exec('postmap /var/lib/mailman/data/virtual-mailman');
        //* Make a backup copy of the main.cf file
        copy($config_dir.'/main.cf', $config_dir.'/main.cf~');
        //* Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        }
        if(!stristr($options,'dont-create-certs')) {
            //* Create the SSL certificate
            $command = 'cd '.$config_dir.'; '
                    .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509';
            exec($command);
            $command = 'chmod o= '.$config_dir.'/smtpd.key';
            caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        }
        //** We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop.
        $command = 'chmod 755  /var/run/courier/authdaemon/';
        if(is_file('/var/run/courier/authdaemon/')) caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        //* Changing maildrop lines in posfix master.cf
        if(is_file($config_dir.'/master.cf')) {
            copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
        }
        if(is_file($config_dir.'/master.cf~')) {
            chmod($config_dir.'/master.cf~', 0400);
        }
        $configfile = $config_dir.'/master.cf';
        $content = rf($configfile);
        $content = str_replace('flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}',
                'flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d '.$cf['vmail_username'].' ${extension} ${recipient} ${user} ${nexthop} ${sender}',
                $content);
        wf($configfile, $content);
        //* Writing the Maildrop mailfilter file
        $configfile = 'mailfilter';
        if(is_file($cf['vmail_mailbox_base'].'/.'.$configfile)) {
            copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content);
        wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content);
        //* Create the directory for the custom mailfilters
        if(!is_dir($cf['vmail_mailbox_base'].'/mailfilters')) {
            $command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters';
            caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        //* Chmod and chown the .mailfilter file
        $command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'chmod -R 600 '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_saslauthd() {
        global $conf;
        $configfile = 'sasl_smtpd.conf';
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf')) copy($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$conf['postfix']['config_dir'].'/sasl/smtpd.conf~');
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf~')) chmod($conf['postfix']['config_dir'].'/sasl/smtpd.conf~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$content);
        // TODO: Chmod and chown on the config file
        // Recursively create the spool directory
        if(!@is_dir('/var/spool/postfix/var/run/saslauthd')) mkdir('/var/spool/postfix/var/run/saslauthd', 0755, true);
        // Edit the file /etc/default/saslauthd
        $configfile = $conf['saslauthd']['config'];
        if(is_file($configfile)) copy($configfile,$configfile.'~');
        if(is_file($configfile.'~')) chmod($configfile.'~', 0400);
        $content = rf($configfile);
        $content = str_replace('START=no','START=yes',$content);
        // Debian
        $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
        // Ubuntu
        $content = str_replace('OPTIONS="-c -m /var/run/saslauthd"','OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"',$content);
        wf($configfile,$content);
        // Edit the file /etc/init.d/saslauthd
        $configfile = $conf['init_scripts'].'/'.$conf['saslauthd']['init_script'];
        $content = rf($configfile);
        $content = str_replace('PIDFILE=$RUN_DIR/saslauthd.pid','PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"',$content);
        wf($configfile,$content);
        // add the postfix user to the sasl group (at least necessary for Ubuntu 8.04 and most likely Debian Lenny as well.
        exec('adduser postfix sasl');
    }
    public function configure_pam() {
        global $conf;
        $pam = $conf['pam'];
        //* configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'pamd_smtp';
        if(is_file($pam.'/smtp'))    copy($pam.'/smtp', $pam.'/smtp~');
        if(is_file($pam.'/smtp~'))   chmod($pam.'/smtp~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        wf($pam.'/smtp', $content);
        // On some OSes smtp is world readable which allows for reading database information.  Removing world readable rights should have no effect.
        if(is_file($pam.'/smtp'))    exec("chmod o= $pam/smtp");
        chmod($pam.'/smtp', 0660);
        chown($pam.'/smtp', 'daemon');
        chgrp($pam.'/smtp', 'daemon');
    }
    public function configure_courier() {
        global $conf;
        $config_dir = $conf['courier']['config_dir'];
        //* authmysqlrc
        $configfile = 'authmysqlrc';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0660);
        chown($config_dir.'/'.$configfile, 'daemon');
        chgrp($config_dir.'/'.$configfile, 'daemon');
        //* authdaemonrc
        $configfile = $config_dir.'/authdaemonrc';
        if(is_file($configfile)) {
            copy($configfile, $configfile.'~');
        }
        if(is_file($configfile.'~')) {
            chmod($configfile.'~', 0400);
        }
        $content = rf($configfile);
        $content = str_replace('authmodulelist="authpam"', 'authmodulelist="authmysql"', $content);
        wf($configfile, $content);
    }
    public function configure_dovecot() {
        global $conf;
        $config_dir = $conf['dovecot']['config_dir'];
        //* Configure master.cf and add a line for deliver
        if(is_file($conf['postfix']['config_dir'].'/master.cf')) {
            copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~2');
        }
        if(is_file($conf['postfix']['config_dir'].'/master.cf~')) {
            chmod($conf['postfix']['config_dir'].'/master.cf~2', 0400);
        }
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'dovecot/deliver')) {
            $deliver_content = 'dovecot   unix  -       n       n       -       -       pipe'."\n".'  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
            af($conf['postfix']['config_dir'].'/master.cf',$deliver_content);
        }
        unset($content);
        unset($deliver_content);
        //* Reconfigure postfix to use dovecot authentication
        // Adding the amavisd commands to the postfix configuration
        $postconf_commands = array (
                'dovecot_destination_recipient_limit = 1',
                'virtual_transport = dovecot',
                'smtpd_sasl_type = dovecot',
                'smtpd_sasl_path = private/auth'
        );
        // Make a backup copy of the main.cf file
        copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~3');
        // Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        //* copy dovecot.conf
        $configfile = 'dovecot.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
        //* dovecot-sql.conf
        $configfile = 'dovecot-sql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/debian_dovecot-sql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
    }
    public function configure_amavis() {
        global $conf;
        // amavisd user config file
        $configfile = 'amavisd_user_config';
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) copy($conf['amavis']['config_dir'].'/conf.d/50-user',$conf['amavis']['config_dir'].'/50-user~');
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user~')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_port}',$conf['mysql']['port'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['amavis']['config_dir'].'/conf.d/50-user',$content);
        // TODO: chmod and chown on the config file
        // Adding the amavisd commands to the postfix configuration
        $postconf_commands = array (
                'content_filter = amavis:[127.0.0.1]:10024',
                'receive_override_options = no_address_mappings'
        );
        // Make a backup copy of the main.cf file
        copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~2');
        // Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        // Append the configuration for amavisd to the master.cf file
        if(is_file($conf['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf',$conf['postfix']['config_dir'].'/master.cf~');
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'127.0.0.1:10025')) {
            unset($content);
            $content = rf('tpl/master_cf_amavis.master');
            af($conf['postfix']['config_dir'].'/master.cf',$content);
        }
        unset($content);
        // Add the clamav user to the amavis group
        exec('adduser clamav amavis');
    }
    public function configure_spamassassin() {
        global $conf;
        //* Enable spamasasssin on debian and ubuntu
        $configfile = '/etc/default/spamassassin';
        if(is_file($configfile)) {
            copy($configfile, $configfile.'~');
        }
        $content = rf($configfile);
        $content = str_replace('ENABLED=0', 'ENABLED=1', $content);
        wf($configfile, $content);
    }
    public function configure_getmail() {
        global $conf;
        $config_dir = $conf['getmail']['config_dir'];
        if(!@is_dir($config_dir)) mkdir(escapeshellcmd($config_dir), 0700, true);
        $command = 'useradd -d '.$config_dir.' getmail';
        if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chown -R getmail $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chmod -R 700 $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_pureftpd() {
        global $conf;
        $config_dir = $conf['pureftpd']['config_dir'];
        //* configure pure-ftpd for MySQL authentication against the ispconfig database
        $configfile = 'db/mysql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        if(is_file($config_dir.'/'.$configfile.'~')) {
            chmod($config_dir.'/'.$configfile.'~', 0400);
        }
        $content = rf('tpl/pureftpd_mysql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
        // **enable chrooting
        //exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/BrokenClientsCompatibility');
        exec('echo "yes" > '.$config_dir.'/conf/DisplayDotFiles');
        if(is_file('/etc/default/pure-ftpd-common')) {
            replaceLine('/etc/default/pure-ftpd-common','STANDALONE_OR_INETD=inetd','STANDALONE_OR_INETD=standalone',1,0);
            replaceLine('/etc/default/pure-ftpd-common','VIRTUALCHROOT=false','VIRTUALCHROOT=true',1,0);
        }
        if(is_file('/etc/inetd.conf')) {
            replaceLine('/etc/inetd.conf','/usr/sbin/pure-ftpd-wrapper','#ftp     stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/pure-ftpd-wrapper',0,0);
            if(is_file($conf['init_scripts'].'/'.'openbsd-inetd')) exec($conf['init_scripts'].'/'.'openbsd-inetd restart');
        }
        if(!is_file('/etc/pure-ftpd/conf/DontResolve')) exec('echo "yes" > /etc/pure-ftpd/conf/DontResolve');
    }
    public function configure_mydns() {
        global $conf;
        // configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'mydns.conf';
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile)) copy($conf['mydns']['config_dir'].'/'.$configfile,$conf['mydns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile.'~')) chmod($conf['mydns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        $content = str_replace('{server_id}',$conf['server_id'],$content);
        wf($conf['mydns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['mydns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['mydns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['mydns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_powerdns() {
        global $conf;
        //* Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['powerdns']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['powerdns']['database'].'.');
        }
        //* Create the ISPConfig database user in the local database
        $query = "GRANT ALL ON `".$conf['powerdns']['database']."` . * TO '".$conf['mysql']['ispconfig_user']."'@'localhost';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* load the powerdns databse dump
        if($conf['mysql']['admin_password'] == '') {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        } else {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        }
        //* Create the powerdns config file
        $configfile = 'pdns.local';
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile)) copy($conf['powerdns']['config_dir'].'/'.$configfile,$conf['powerdns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile.'~')) chmod($conf['powerdns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{powerdns_database}',$conf['powerdns']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($conf['powerdns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['powerdns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_bind() {
        global $conf;
        //* Check if the zonefile directory has a slash at the end
        $content=$conf['bind']['bind_zonefiles_dir'];
        if(substr($content,-1,1) != '/') {
            $content .= '/';
        }
        //* Create the slave subdirectory
        $content .= 'slave';
        if(!@is_dir($content)) mkdir($content, 0770, true);
        //* Chown the slave subdirectory to $conf['bind']['bind_user']
        chown($content, $conf['bind']['bind_user']);
        chgrp($content, $conf['bind']['bind_group']);
    }
    public function configure_apache() {
        global $conf;
        //* Create the logging directory for the vhost logfiles
        if(!@is_dir($conf['ispconfig_log_dir'].'/httpd')) mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true);
        if(is_file('/etc/suphp/suphp.conf')) {
            replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp="php:/usr/bin/php-cgi"',0);
            //replaceLine('/etc/suphp/suphp.conf','docroot=','docroot=/var/clients',0);
            replaceLine('/etc/suphp/suphp.conf','umask=0077','umask=0022',0);
        }
        if(is_file('/etc/apache2/sites-enabled/000-default')) {
            replaceLine('/etc/apache2/sites-available/000-default','NameVirtualHost *','NameVirtualHost *:80',1,0);
            replaceLine('/etc/apache2/sites-available/000-default','<VirtualHost *>','<VirtualHost *:80>',1,0);
        }
        if(is_file('/etc/apache2/ports.conf')) {
            // add a line "Listen 443" to ports conf if line does not exist
            replaceLine('/etc/apache2/ports.conf','Listen 443','Listen 443',1);
        }
        //* Copy the ISPConfig configuration include
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
        $content = rf('tpl/apache_ispconfig.conf.master');
        $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(is_array($records) && count($records) > 0) {
            foreach($records as $rec) {
                $content .= 'NameVirtualHost '.$rec['ip_address'].":80\n";
                $content .= 'NameVirtualHost '.$rec['ip_address'].":443\n";
            }
        }
        $content .= "\n";
        wf($vhost_conf_dir.'/ispconfig.conf',$content);
        if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.conf')) {
            symlink($vhost_conf_dir.'/ispconfig.conf',$vhost_conf_enabled_dir.'/000-ispconfig.conf');
        }
        //* make sure that webalizer finds its config file when it is directly in /etc
        if(@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) {
            mkdir('/etc/webalizer');
            symlink('/etc/webalizer.conf','/etc/webalizer/webalizer.conf');
        }
        if(is_file('/etc/webalizer/webalizer.conf')) {
            // Change webalizer mode to incremental
            replaceLine('/etc/webalizer/webalizer.conf','#IncrementalName','IncrementalName webalizer.current',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#Incremental','Incremental     yes',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#HistoryName','HistoryName     webalizer.hist',0,0);
        }
        // Check the awsatst script
        if(!is_dir('/usr/share/awstats/tools')) exec('mkdir -p /usr/share/awstats/tools');
        if(!file_exists('/usr/share/awstats/tools/awstats_buildstaticpages.pl') && file_exists('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl')) symlink('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl','/usr/share/awstats/tools/awstats_buildstaticpages.pl');
            exec($command);
            $command = 'chmod o= '.$config_dir.'/smtpd.key';
            caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        }
        //** We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop.
        $command = 'chmod 755  /var/run/courier/authdaemon/';
        if(is_file('/var/run/courier/authdaemon/')) caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
        //* Changing maildrop lines in posfix master.cf
        if(is_file($config_dir.'/master.cf')) {
            copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
        }
        if(is_file($config_dir.'/master.cf~')) {
            chmod($config_dir.'/master.cf~', 0400);
        }
        $configfile = $config_dir.'/master.cf';
        $content = rf($configfile);
        $content = str_replace('flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}',
                'flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d '.$cf['vmail_username'].' ${extension} ${recipient} ${user} ${nexthop} ${sender}',
                $content);
        wf($configfile, $content);
        //* Writing the Maildrop mailfilter file
        $configfile = 'mailfilter';
        if(is_file($cf['vmail_mailbox_base'].'/.'.$configfile)) {
            copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content);
        wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content);
        //* Create the directory for the custom mailfilters
        if(!is_dir($cf['vmail_mailbox_base'].'/mailfilters')) {
            $command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters';
            caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        //* Chmod and chown the .mailfilter file
        $command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'chmod -R 600 '.$cf['vmail_mailbox_base'].'/.mailfilter';
        caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_saslauthd() {
        global $conf;
        $configfile = 'sasl_smtpd.conf';
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf')) copy($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$conf['postfix']['config_dir'].'/sasl/smtpd.conf~');
        if(is_file($conf['postfix']['config_dir'].'/sasl/smtpd.conf~')) chmod($conf['postfix']['config_dir'].'/sasl/smtpd.conf~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['postfix']['config_dir'].'/sasl/smtpd.conf',$content);
        // TODO: Chmod and chown on the config file
        // Recursively create the spool directory
        if(!@is_dir('/var/spool/postfix/var/run/saslauthd')) mkdir('/var/spool/postfix/var/run/saslauthd', 0755, true);
        // Edit the file /etc/default/saslauthd
        $configfile = $conf['saslauthd']['config'];
        if(is_file($configfile)) copy($configfile,$configfile.'~');
        if(is_file($configfile.'~')) chmod($configfile.'~', 0400);
        $content = rf($configfile);
        $content = str_replace('START=no','START=yes',$content);
        // Debian
        $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
        // Ubuntu
        $content = str_replace('OPTIONS="-c -m /var/run/saslauthd"','OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"',$content);
        wf($configfile,$content);
        // Edit the file /etc/init.d/saslauthd
        $configfile = $conf['init_scripts'].'/'.$conf['saslauthd']['init_script'];
        $content = rf($configfile);
        $content = str_replace('PIDFILE=$RUN_DIR/saslauthd.pid','PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"',$content);
        wf($configfile,$content);
        // add the postfix user to the sasl group (at least necessary for Ubuntu 8.04 and most likely Debian Lenny as well.
        exec('adduser postfix sasl');
    }
    public function configure_pam() {
        global $conf;
        $pam = $conf['pam'];
        //* configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'pamd_smtp';
        if(is_file($pam.'/smtp'))    copy($pam.'/smtp', $pam.'/smtp~');
        if(is_file($pam.'/smtp~'))   chmod($pam.'/smtp~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        wf($pam.'/smtp', $content);
        // On some OSes smtp is world readable which allows for reading database information.  Removing world readable rights should have no effect.
        if(is_file($pam.'/smtp'))    exec("chmod o= $pam/smtp");
        chmod($pam.'/smtp', 0660);
        chown($pam.'/smtp', 'daemon');
        chgrp($pam.'/smtp', 'daemon');
    }
    public function configure_courier() {
        global $conf;
        $config_dir = $conf['courier']['config_dir'];
        //* authmysqlrc
        $configfile = 'authmysqlrc';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0660);
        chown($config_dir.'/'.$configfile, 'daemon');
        chgrp($config_dir.'/'.$configfile, 'daemon');
        //* authdaemonrc
        $configfile = $config_dir.'/authdaemonrc';
        if(is_file($configfile)) {
            copy($configfile, $configfile.'~');
        }
        if(is_file($configfile.'~')) {
            chmod($configfile.'~', 0400);
        }
        $content = rf($configfile);
        $content = str_replace('authmodulelist="authpam"', 'authmodulelist="authmysql"', $content);
        wf($configfile, $content);
    }
    public function configure_dovecot() {
        global $conf;
        $config_dir = $conf['dovecot']['config_dir'];
        //* Configure master.cf and add a line for deliver
        if(is_file($conf['postfix']['config_dir'].'/master.cf')) {
            copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~2');
        }
        if(is_file($conf['postfix']['config_dir'].'/master.cf~')) {
            chmod($conf['postfix']['config_dir'].'/master.cf~2', 0400);
        }
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'dovecot/deliver')) {
            $deliver_content = 'dovecot   unix  -       n       n       -       -       pipe'."\n".'  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
            af($conf['postfix']['config_dir'].'/master.cf',$deliver_content);
        }
        unset($content);
        unset($deliver_content);
        //* Reconfigure postfix to use dovecot authentication
        // Adding the amavisd commands to the postfix configuration
        $postconf_commands = array (
                'dovecot_destination_recipient_limit = 1',
                'virtual_transport = dovecot',
                'smtpd_sasl_type = dovecot',
                'smtpd_sasl_path = private/auth'
        );
        // Make a backup copy of the main.cf file
        copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~3');
        // Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        //* copy dovecot.conf
        $configfile = 'dovecot.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
        //* dovecot-sql.conf
        $configfile = 'dovecot-sql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        chmod($config_dir.'/'.$configfile.'~', 0400);
        $content = rf('tpl/debian_dovecot-sql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
    }
    public function configure_amavis() {
        global $conf;
        // amavisd user config file
        $configfile = 'amavisd_user_config';
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) copy($conf['amavis']['config_dir'].'/conf.d/50-user',$conf['amavis']['config_dir'].'/50-user~');
        if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user~')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_port}',$conf['mysql']['port'],$content);
        $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
        wf($conf['amavis']['config_dir'].'/conf.d/50-user',$content);
        // TODO: chmod and chown on the config file
        // Adding the amavisd commands to the postfix configuration
        $postconf_commands = array (
                'content_filter = amavis:[127.0.0.1]:10024',
                'receive_override_options = no_address_mappings'
        );
        // Make a backup copy of the main.cf file
        copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~2');
        // Executing the postconf commands
        foreach($postconf_commands as $cmd) {
            $command = "postconf -e '$cmd'";
            caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        // Append the configuration for amavisd to the master.cf file
        if(is_file($conf['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf',$conf['postfix']['config_dir'].'/master.cf~');
        $content = rf($conf['postfix']['config_dir'].'/master.cf');
        // Only add the content if we had not addded it before
        if(!stristr($content,'127.0.0.1:10025')) {
            unset($content);
            $content = rf('tpl/master_cf_amavis.master');
            af($conf['postfix']['config_dir'].'/master.cf',$content);
        }
        unset($content);
        // Add the clamav user to the amavis group
        exec('adduser clamav amavis');
    }
    public function configure_spamassassin() {
        global $conf;
        //* Enable spamasasssin on debian and ubuntu
        $configfile = '/etc/default/spamassassin';
        if(is_file($configfile)) {
            copy($configfile, $configfile.'~');
        }
        $content = rf($configfile);
        $content = str_replace('ENABLED=0', 'ENABLED=1', $content);
        wf($configfile, $content);
    }
    public function configure_getmail() {
        global $conf;
        $config_dir = $conf['getmail']['config_dir'];
        if(!@is_dir($config_dir)) mkdir(escapeshellcmd($config_dir), 0700, true);
        $command = 'useradd -d '.$config_dir.' getmail';
        if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chown -R getmail $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = "chmod -R 700 $config_dir";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_pureftpd() {
        global $conf;
        $config_dir = $conf['pureftpd']['config_dir'];
        //* configure pure-ftpd for MySQL authentication against the ispconfig database
        $configfile = 'db/mysql.conf';
        if(is_file($config_dir.'/'.$configfile)) {
            copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
        }
        if(is_file($config_dir.'/'.$configfile.'~')) {
            chmod($config_dir.'/'.$configfile.'~', 0400);
        }
        $content = rf('tpl/pureftpd_mysql.conf.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        wf($config_dir.'/'.$configfile, $content);
        chmod($config_dir.'/'.$configfile, 0600);
        chown($config_dir.'/'.$configfile, 'root');
        chgrp($config_dir.'/'.$configfile, 'root');
        // **enable chrooting
        //exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/ChrootEveryone');
        exec('echo "yes" > '.$config_dir.'/conf/BrokenClientsCompatibility');
        exec('echo "yes" > '.$config_dir.'/conf/DisplayDotFiles');
        if(is_file('/etc/default/pure-ftpd-common')) {
            replaceLine('/etc/default/pure-ftpd-common','STANDALONE_OR_INETD=inetd','STANDALONE_OR_INETD=standalone',1,0);
            replaceLine('/etc/default/pure-ftpd-common','VIRTUALCHROOT=false','VIRTUALCHROOT=true',1,0);
        }
        if(is_file('/etc/inetd.conf')) {
            replaceLine('/etc/inetd.conf','/usr/sbin/pure-ftpd-wrapper','#ftp     stream  tcp     nowait  root    /usr/sbin/tcpd /usr/sbin/pure-ftpd-wrapper',0,0);
            if(is_file($conf['init_scripts'].'/'.'openbsd-inetd')) exec($conf['init_scripts'].'/'.'openbsd-inetd restart');
        }
        if(!is_file('/etc/pure-ftpd/conf/DontResolve')) exec('echo "yes" > /etc/pure-ftpd/conf/DontResolve');
    }
    public function configure_mydns() {
        global $conf;
        // configure pam for SMTP authentication agains the ispconfig database
        $configfile = 'mydns.conf';
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile)) copy($conf['mydns']['config_dir'].'/'.$configfile,$conf['mydns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['mydns']['config_dir'].'/'.$configfile.'~')) chmod($conf['mydns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        $content = str_replace('{server_id}',$conf['server_id'],$content);
        wf($conf['mydns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['mydns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['mydns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['mydns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_powerdns() {
        global $conf;
        //* Create the database
        if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['powerdns']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) {
            $this->error('Unable to create MySQL database: '.$conf['powerdns']['database'].'.');
        }
        //* Create the ISPConfig database user in the local database
        $query = "GRANT ALL ON `".$conf['powerdns']['database']."` . * TO '".$conf['mysql']['ispconfig_user']."'@'localhost';";
        if(!$this->db->query($query)) {
            $this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage);
        }
        //* Reload database privelages
        $this->db->query('FLUSH PRIVILEGES;');
        //* load the powerdns databse dump
        if($conf['mysql']['admin_password'] == '') {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        } else {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['powerdns']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/powerdns.sql' &> /dev/null",
                    __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in powerdns.sql');
        }
        //* Create the powerdns config file
        $configfile = 'pdns.local';
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile)) copy($conf['powerdns']['config_dir'].'/'.$configfile,$conf['powerdns']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['powerdns']['config_dir'].'/'.$configfile.'~')) chmod($conf['powerdns']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{powerdns_database}',$conf['powerdns']['database'],$content);
        $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
        wf($conf['powerdns']['config_dir'].'/'.$configfile,$content);
        chmod($conf['powerdns']['config_dir'].'/'.$configfile, 0600);
        chown($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['powerdns']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_bind() {
        global $conf;
        //* Check if the zonefile directory has a slash at the end
        $content=$conf['bind']['bind_zonefiles_dir'];
        if(substr($content,-1,1) != '/') {
            $content .= '/';
        }
        //* Create the slave subdirectory
        $content .= 'slave';
        if(!@is_dir($content)) mkdir($content, 0770, true);
        //* Chown the slave subdirectory to $conf['bind']['bind_user']
        chown($content, $conf['bind']['bind_user']);
        chgrp($content, $conf['bind']['bind_group']);
    }
    public function configure_apache() {
        global $conf;
        //* Create the logging directory for the vhost logfiles
        if(!@is_dir($conf['ispconfig_log_dir'].'/httpd')) mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true);
        if(is_file('/etc/suphp/suphp.conf')) {
            replaceLine('/etc/suphp/suphp.conf','php=php:/usr/bin','x-httpd-suphp="php:/usr/bin/php-cgi"',0);
            //replaceLine('/etc/suphp/suphp.conf','docroot=','docroot=/var/clients',0);
            replaceLine('/etc/suphp/suphp.conf','umask=0077','umask=0022',0);
        }
        if(is_file('/etc/apache2/sites-enabled/000-default')) {
            replaceLine('/etc/apache2/sites-available/000-default','NameVirtualHost *','NameVirtualHost *:80',1,0);
            replaceLine('/etc/apache2/sites-available/000-default','<VirtualHost *>','<VirtualHost *:80>',1,0);
        }
        if(is_file('/etc/apache2/ports.conf')) {
            // add a line "Listen 443" to ports conf if line does not exist
            replaceLine('/etc/apache2/ports.conf','Listen 443','Listen 443',1);
        }
        //* Copy the ISPConfig configuration include
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
        $content = rf('tpl/apache_ispconfig.conf.master');
        $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
        if(is_array($records) && count($records) > 0) {
            foreach($records as $rec) {
                $content .= 'NameVirtualHost '.$rec['ip_address'].":80\n";
                $content .= 'NameVirtualHost '.$rec['ip_address'].":443\n";
            }
        }
        $content .= "\n";
        wf($vhost_conf_dir.'/ispconfig.conf',$content);
        if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.conf')) {
            symlink($vhost_conf_dir.'/ispconfig.conf',$vhost_conf_enabled_dir.'/000-ispconfig.conf');
        }
        //* make sure that webalizer finds its config file when it is directly in /etc
        if(@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) {
            mkdir('/etc/webalizer');
            symlink('/etc/webalizer.conf','/etc/webalizer/webalizer.conf');
        }
        if(is_file('/etc/webalizer/webalizer.conf')) {
            // Change webalizer mode to incremental
            replaceLine('/etc/webalizer/webalizer.conf','#IncrementalName','IncrementalName webalizer.current',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#Incremental','Incremental     yes',0,0);
            replaceLine('/etc/webalizer/webalizer.conf','#HistoryName','HistoryName     webalizer.hist',0,0);
        }
        // Check the awsatst script
        if(!is_dir('/usr/share/awstats/tools')) exec('mkdir -p /usr/share/awstats/tools');
        if(!file_exists('/usr/share/awstats/tools/awstats_buildstaticpages.pl') && file_exists('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl')) symlink('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl','/usr/share/awstats/tools/awstats_buildstaticpages.pl');
        if(file_exists('/etc/awstats/awstats.conf.local')) replaceLine('/etc/awstats/awstats.conf.local','LogFormat=4','LogFormat=1',0,1);
        
        //* add a sshusers group
        $command = 'groupadd sshusers';
        if(!is_group('sshusers')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_firewall() {
        global $conf;
        $dist_init_scripts = $conf['init_scripts'];
        if(is_dir('/etc/Bastille.backup')) caselog('rm -rf /etc/Bastille.backup', __FILE__, __LINE__);
        if(is_dir('/etc/Bastille')) caselog('mv -f /etc/Bastille /etc/Bastille.backup', __FILE__, __LINE__);
        @mkdir('/etc/Bastille', 0700);
        if(is_dir('/etc/Bastille.backup/firewall.d')) caselog('cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/', __FILE__, __LINE__);
        caselog('cp -f tpl/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        caselog('chmod 644 /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        $content = rf('/etc/Bastille/bastille-firewall.cfg');
        $content = str_replace('{DNS_SERVERS}', '', $content);
        $tcp_public_services = '';
        $udp_public_services = '';
        $row = $this->db->queryOneRecord('SELECT * FROM '.$conf["mysql"]["database"].'.firewall WHERE server_id = '.intval($conf['server_id']));
        if(trim($row['tcp_port']) != '' || trim($row['udp_port']) != '') {
            $tcp_public_services = trim(str_replace(',',' ',$row['tcp_port']));
            $udp_public_services = trim(str_replace(',',' ',$row['udp_port']));
        } else {
            $tcp_public_services = '21 22 25 53 80 110 143 443 3306 8080 10000';
            $udp_public_services = '53';
        }
        if(!stristr($tcp_public_services, $conf['apache']['vhost_port'])) {
            $tcp_public_services .= ' '.intval($conf['apache']['vhost_port']);
            if($row['tcp_port'] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ',".intval($conf['apache']['vhost_port'])."' WHERE server_id = ".intval($conf['server_id']));
        }
        $content = str_replace('{TCP_PUBLIC_SERVICES}', $tcp_public_services, $content);
        $content = str_replace('{UDP_PUBLIC_SERVICES}', $udp_public_services, $content);
        wf('/etc/Bastille/bastille-firewall.cfg', $content);
        if(is_file($dist_init_scripts.'/bastille-firewall')) caselog('mv -f '.$dist_init_scripts.'/bastille-firewall '.$dist_init_scripts.'/bastille-firewall.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-firewall '.$dist_init_scripts, __FILE__, __LINE__);
        caselog('chmod 700 '.$dist_init_scripts.'/bastille-firewall', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-ipchains')) caselog('mv -f /sbin/bastille-ipchains /sbin/bastille-ipchains.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-ipchains /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-ipchains', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-netfilter')) caselog('mv -f /sbin/bastille-netfilter /sbin/bastille-netfilter.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-netfilter /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-netfilter', __FILE__, __LINE__);
        if(!@is_dir('/var/lock/subsys')) caselog('mkdir /var/lock/subsys', __FILE__, __LINE__);
        exec('which ipchains &> /dev/null', $ipchains_location, $ret_val);
        if(!is_file('/sbin/ipchains') && !is_link('/sbin/ipchains') && $ret_val == 0) phpcaselog(@symlink(shell_exec('which ipchains'), '/sbin/ipchains'), 'create symlink', __FILE__, __LINE__);
        unset($ipchains_location);
        exec('which iptables &> /dev/null', $iptables_location, $ret_val);
        if(!is_file('/sbin/iptables') && !is_link('/sbin/iptables') && $ret_val == 0) phpcaselog(@symlink(trim(shell_exec('which iptables')), '/sbin/iptables'), 'create symlink', __FILE__, __LINE__);
        unset($iptables_location);
    }
    public function configure_vlogger() {
        global $conf;
        //** Configure vlogger to use traffic logging to mysql (master) db
        $configfile = 'vlogger-dbi.conf';
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile)) copy($conf['vlogger']['config_dir'].'/'.$configfile,$conf['vlogger']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile.'~')) chmod($conf['vlogger']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['master_ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['master_ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['master_database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['master_host'],$content);
        } else {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['host'],$content);
        }
        wf($conf['vlogger']['config_dir'].'/'.$configfile,$content);
        chmod($conf['vlogger']['config_dir'].'/'.$configfile, 0600);
        chown($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_apps_vhost() {
        global $conf;
        //* Create the ispconfig apps vhost user and group
        $apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
        $apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
        $install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
        $command = 'groupadd '.$apps_vhost_user;
        if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$apps_vhost_group.' -d '.$install_dir.' '.$apps_vhost_group;
        if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        if(!@is_dir($install_dir)) mkdir($install_dir, 0755, true);
        chown($install_dir, $apps_vhost_user);
        chgrp($install_dir, $apps_vhost_group);
        //* Copy the apps vhost file
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        $apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '')?'':'ServerName '.$conf['web']['apps_vhost_servername'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_apps.vhost.master');
        $content = str_replace('{apps_vhost_ip}', $conf['web']['apps_vhost_ip'], $content);
        $content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
        $content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
        $content = str_replace('{website_basedir}', $conf['web']['website_basedir'], $content);
        $content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        wf($vhost_conf_dir.'/apps.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
        //* and create the symlink
        if($this->install_ispconfig_interface == true) {
            if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
                symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
            }
        }
        if(!is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter')) {
            mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
            copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
        }
    }
    public function make_ispconfig_ssl_cert() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        $ssl_crt_file = $install_dir.'/interface/ssl/ispserver.crt';
        $ssl_csr_file = $install_dir.'/interface/ssl/ispserver.csr';
        $ssl_key_file = $install_dir.'/interface/ssl/ispserver.key';
        if(!@is_dir($install_dir.'/interface/ssl')) mkdir($install_dir.'/interface/ssl', 0755, true);
        $ssl_pw = substr(md5(mt_rand()),0,6);
        exec("openssl genrsa -des3 -passout pass:$ssl_pw -out $ssl_key_file 4096");
        exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -out $ssl_csr_file");
        exec("openssl req -x509 -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -in $ssl_csr_file -out $ssl_crt_file -days 3650");
        exec("openssl rsa -passin pass:$ssl_pw -in $ssl_key_file -out $ssl_key_file.insecure");
        rename($ssl_key_file,$ssl_key_file.'.secure');
        rename($ssl_key_file.'.insecure',$ssl_key_file);
    }
    public function install_ispconfig() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Create the ISPConfig installation directory
        if(!@is_dir($install_dir)) {
            $command = "mkdir $install_dir";
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        //* Create a ISPConfig user and group
        $command = 'groupadd ispconfig';
        if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g ispconfig -d '.$install_dir.' ispconfig';
        if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* copy the ISPConfig interface part
        $command = 'cp -rf ../interface '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* copy the ISPConfig server part
        $command = 'cp -rf ../server '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Create a symlink, so ISPConfig is accessible via web
        // Replaced by a separate vhost definition for port 8080
        // $command = "ln -s $install_dir/interface/web/ /var/www/ispconfig";
        // caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Create the config file for ISPConfig interface
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/interface/lib/'.$configfile)) {
            copy($install_dir.'/interface/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        $content = str_replace('{language}', $conf['language'], $content);
        wf($install_dir.'/interface/lib/'.$configfile, $content);
        //* Create the config file for ISPConfig server
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/server/lib/'.$configfile)) {
            copy($install_dir.'/server/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        //* add a sshusers group
        $command = 'groupadd sshusers';
        if(!is_group('sshusers')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
    }
    public function configure_firewall() {
        global $conf;
        $dist_init_scripts = $conf['init_scripts'];
        if(is_dir('/etc/Bastille.backup')) caselog('rm -rf /etc/Bastille.backup', __FILE__, __LINE__);
        if(is_dir('/etc/Bastille')) caselog('mv -f /etc/Bastille /etc/Bastille.backup', __FILE__, __LINE__);
        @mkdir('/etc/Bastille', 0700);
        if(is_dir('/etc/Bastille.backup/firewall.d')) caselog('cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/', __FILE__, __LINE__);
        caselog('cp -f tpl/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        caselog('chmod 644 /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__);
        $content = rf('/etc/Bastille/bastille-firewall.cfg');
        $content = str_replace('{DNS_SERVERS}', '', $content);
        $tcp_public_services = '';
        $udp_public_services = '';
        $row = $this->db->queryOneRecord('SELECT * FROM '.$conf["mysql"]["database"].'.firewall WHERE server_id = '.intval($conf['server_id']));
        if(trim($row['tcp_port']) != '' || trim($row['udp_port']) != '') {
            $tcp_public_services = trim(str_replace(',',' ',$row['tcp_port']));
            $udp_public_services = trim(str_replace(',',' ',$row['udp_port']));
        } else {
            $tcp_public_services = '21 22 25 53 80 110 143 443 3306 8080 10000';
            $udp_public_services = '53';
        }
        if(!stristr($tcp_public_services, $conf['apache']['vhost_port'])) {
            $tcp_public_services .= ' '.intval($conf['apache']['vhost_port']);
            if($row['tcp_port'] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ',".intval($conf['apache']['vhost_port'])."' WHERE server_id = ".intval($conf['server_id']));
        }
        $content = str_replace('{TCP_PUBLIC_SERVICES}', $tcp_public_services, $content);
        $content = str_replace('{UDP_PUBLIC_SERVICES}', $udp_public_services, $content);
        wf('/etc/Bastille/bastille-firewall.cfg', $content);
        if(is_file($dist_init_scripts.'/bastille-firewall')) caselog('mv -f '.$dist_init_scripts.'/bastille-firewall '.$dist_init_scripts.'/bastille-firewall.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-firewall '.$dist_init_scripts, __FILE__, __LINE__);
        caselog('chmod 700 '.$dist_init_scripts.'/bastille-firewall', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-ipchains')) caselog('mv -f /sbin/bastille-ipchains /sbin/bastille-ipchains.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-ipchains /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-ipchains', __FILE__, __LINE__);
        if(is_file('/sbin/bastille-netfilter')) caselog('mv -f /sbin/bastille-netfilter /sbin/bastille-netfilter.backup', __FILE__, __LINE__);
        caselog('cp -f apps/bastille-netfilter /sbin', __FILE__, __LINE__);
        caselog('chmod 700 /sbin/bastille-netfilter', __FILE__, __LINE__);
        if(!@is_dir('/var/lock/subsys')) caselog('mkdir /var/lock/subsys', __FILE__, __LINE__);
        exec('which ipchains &> /dev/null', $ipchains_location, $ret_val);
        if(!is_file('/sbin/ipchains') && !is_link('/sbin/ipchains') && $ret_val == 0) phpcaselog(@symlink(shell_exec('which ipchains'), '/sbin/ipchains'), 'create symlink', __FILE__, __LINE__);
        unset($ipchains_location);
        exec('which iptables &> /dev/null', $iptables_location, $ret_val);
        if(!is_file('/sbin/iptables') && !is_link('/sbin/iptables') && $ret_val == 0) phpcaselog(@symlink(trim(shell_exec('which iptables')), '/sbin/iptables'), 'create symlink', __FILE__, __LINE__);
        unset($iptables_location);
    }
    public function configure_vlogger() {
        global $conf;
        //** Configure vlogger to use traffic logging to mysql (master) db
        $configfile = 'vlogger-dbi.conf';
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile)) copy($conf['vlogger']['config_dir'].'/'.$configfile,$conf['vlogger']['config_dir'].'/'.$configfile.'~');
        if(is_file($conf['vlogger']['config_dir'].'/'.$configfile.'~')) chmod($conf['vlogger']['config_dir'].'/'.$configfile.'~', 0400);
        $content = rf('tpl/'.$configfile.'.master');
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['master_ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['master_ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['master_database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['master_host'],$content);
        } else {
            $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
            $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
            $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
            $content = str_replace('{mysql_server_ip}',$conf['mysql']['host'],$content);
        }
        wf($conf['vlogger']['config_dir'].'/'.$configfile,$content);
        chmod($conf['vlogger']['config_dir'].'/'.$configfile, 0600);
        chown($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
        chgrp($conf['vlogger']['config_dir'].'/'.$configfile, 'root');
    }
    public function configure_apps_vhost() {
        global $conf;
        //* Create the ispconfig apps vhost user and group
        $apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']);
        $apps_vhost_group = escapeshellcmd($conf['web']['apps_vhost_group']);
        $install_dir = escapeshellcmd($conf['web']['website_basedir'].'/apps');
        $command = 'groupadd '.$apps_vhost_user;
        if(!is_group($apps_vhost_group)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g '.$apps_vhost_group.' -d '.$install_dir.' '.$apps_vhost_group;
        if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'adduser '.$conf['apache']['user'].' '.$apps_vhost_group;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        if(!@is_dir($install_dir)) mkdir($install_dir, 0755, true);
        chown($install_dir, $apps_vhost_user);
        chgrp($install_dir, $apps_vhost_group);
        //* Copy the apps vhost file
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        $apps_vhost_servername = ($conf['web']['apps_vhost_servername'] == '')?'':'ServerName '.$conf['web']['apps_vhost_servername'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_apps.vhost.master');
        $content = str_replace('{apps_vhost_ip}', $conf['web']['apps_vhost_ip'], $content);
        $content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
        $content = str_replace('{apps_vhost_dir}', $conf['web']['website_basedir'].'/apps', $content);
        $content = str_replace('{website_basedir}', $conf['web']['website_basedir'], $content);
        $content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['web']['apps_vhost_ip'] == 80 or $conf['web']['apps_vhost_ip'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        wf($vhost_conf_dir.'/apps.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
        //* and create the symlink
        if($this->install_ispconfig_interface == true) {
            if(@is_link($vhost_conf_enabled_dir.'/apps.vhost')) unlink($vhost_conf_enabled_dir.'/apps.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-apps.vhost')) {
                symlink($vhost_conf_dir.'/apps.vhost',$vhost_conf_enabled_dir.'/000-apps.vhost');
            }
        }
        if(!is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter')) {
            mkdir($conf['web']['website_basedir'].'/php-fcgi-scripts/apps', 0755, true);
            copy('tpl/apache_apps_fcgi_starter.master',$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chmod +x '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter');
            exec('chown -R ispapps:ispapps '.$conf['web']['website_basedir'].'/php-fcgi-scripts/apps');
        }
    }
    public function make_ispconfig_ssl_cert() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        $ssl_crt_file = $install_dir.'/interface/ssl/ispserver.crt';
        $ssl_csr_file = $install_dir.'/interface/ssl/ispserver.csr';
        $ssl_key_file = $install_dir.'/interface/ssl/ispserver.key';
        if(!@is_dir($install_dir.'/interface/ssl')) mkdir($install_dir.'/interface/ssl', 0755, true);
        $ssl_pw = substr(md5(mt_rand()),0,6);
        exec("openssl genrsa -des3 -passout pass:$ssl_pw -out $ssl_key_file 4096");
        exec("openssl req -new -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -out $ssl_csr_file");
        exec("openssl req -x509 -passin pass:$ssl_pw -passout pass:$ssl_pw -key $ssl_key_file -in $ssl_csr_file -out $ssl_crt_file -days 3650");
        exec("openssl rsa -passin pass:$ssl_pw -in $ssl_key_file -out $ssl_key_file.insecure");
        rename($ssl_key_file,$ssl_key_file.'.secure');
        rename($ssl_key_file.'.insecure',$ssl_key_file);
    }
    public function install_ispconfig() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Create the ISPConfig installation directory
        if(!@is_dir($install_dir)) {
            $command = "mkdir $install_dir";
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        //* Create a ISPConfig user and group
        $command = 'groupadd ispconfig';
        if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        $command = 'useradd -g ispconfig -d '.$install_dir.' ispconfig';
        if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* copy the ISPConfig interface part
        $command = 'cp -rf ../interface '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* copy the ISPConfig server part
        $command = 'cp -rf ../server '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Create a symlink, so ISPConfig is accessible via web
        // Replaced by a separate vhost definition for port 8080
        // $command = "ln -s $install_dir/interface/web/ /var/www/ispconfig";
        // caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Create the config file for ISPConfig interface
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/interface/lib/'.$configfile)) {
            copy($install_dir.'/interface/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        $content = str_replace('{language}', $conf['language'], $content);
        wf($install_dir.'/server/lib/'.$configfile, $content);
        //* Create the config file for remote-actions (but only, if it does not exist, because
        //  the value is a autoinc-value and so changed by the remoteaction_core_module
        if (!file_exists($install_dir.'/server/lib/remote_action.inc.php')) {
            $content = '<?php' . "\n" . '$maxid_remote_action = 0;' . "\n" . '?>';
            wf($install_dir.'/server/lib/remote_action.inc.php', $content);
        }
        //* Enable the server modules and plugins.
        // TODO: Implement a selector which modules and plugins shall be enabled.
        $dir = $install_dir.'/server/mods-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/mods-available/'.$file);
                        $module_name = substr($file,0,-8);
                        $tmp = new $module_name;
                        if($tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) {
                                @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
                                // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-enabled/'.$file);
                            }
                            if (strpos($file, '_core_module') !== false) {
                                if(!@is_link($install_dir.'/server/mods-core/'.$file)) {
                                    @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
                                    // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        $dir = $install_dir.'/server/plugins-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/plugins-available/'.$file);
                        $plugin_name = substr($file,0,-8);
                        $tmp = new $plugin_name;
                        if(method_exists($tmp,'onInstall') && $tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) {
                                @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
                                //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-enabled/'.$file);
                            }
                            if (strpos($file, '_core_plugin') !== false) {
                                if(!@is_link($install_dir.'/server/plugins-core/'.$file)) {
                                    @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
                                    //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        // Update the server config
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled' WHERE server_id = ".intval($conf['server_id']);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $this->dbmaster->query($sql);
            $this->db->query($sql);
        } else {
            $this->db->query($sql);
        }
        //* Chmod the files
        $command = 'chmod -R 750 '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* chown the files to the ispconfig user and group
        $command = 'chown -R ispconfig:ispconfig '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Make the global language file directory group writable
        exec("chmod -R 770 $install_dir/interface/lib/lang");
        //* Make the temp directory for language file exports writable
        if(is_dir($install_dir.'/interface/web/temp')) exec("chmod -R 770 $install_dir/interface/web/temp");
        //* Make all interface language file directories group writable
        $handle = @opendir($install_dir.'/interface/web');
        while ($file = @readdir ($handle)) {
            if ($file != '.' && $file != '..') {
                if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) {
                    $handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang');
                    chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang',0770);
                    while ($lang_file = @readdir ($handle2)) {
                        if ($lang_file != '.' && $lang_file != '..') {
                            chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file,0770);
                        }
                    }
                }
            }
        }
        //* make sure that the server config file (not the interface one) is only readable by the root user
        chmod($install_dir.'/server/lib/'.$configfile, 0600);
        chown($install_dir.'/server/lib/'.$configfile, 'root');
        chgrp($install_dir.'/server/lib/'.$configfile, 'root');
        chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
        chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
        chgrp($install_dir.'/server/lib/remote_action.inc.php', 'root');
        if(@is_file($install_dir.'/server/lib/mysql_clientdb.conf')) {
            chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
            chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
            chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        }
        // TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
        // and must be fixed as this will allow the apache user to read the ispconfig files.
        // Later this must run as own apache server or via suexec!
        $command = 'adduser www-data ispconfig';
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Make the shell scripts executable
        $command = "chmod +x $install_dir/server/scripts/*.sh";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Copy the ISPConfig vhost for the controlpanel
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_ispconfig.vhost.master');
        $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
            $content = str_replace('{ssl_comment}', '', $content);
        } else {
            $content = str_replace('{ssl_comment}', '#', $content);
        }
        wf($vhost_conf_dir.'/ispconfig.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
        //* and create the symlink
        if($this->install_ispconfig_interface == true && $this->is_update == false) {
            if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) {
                symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');
            }
        }
        if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
            mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
            copy('tpl/apache_ispconfig_fcgi_starter.master','/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            symlink($install_dir.'/interface/web','/var/www/ispconfig');
            exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
        }
        //* Install the update script
        if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
        chown($install_dir.'/server/scripts/update_from_svn.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_svn.sh', 0700);
        chown($install_dir.'/server/scripts/update_from_tgz.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_tgz.sh', 0700);
        chown($install_dir.'/server/scripts/ispconfig_update.sh', 'root');
        chmod($install_dir.'/server/scripts/ispconfig_update.sh', 0700);
        if(!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update_from_svn.sh');
        if(!is_link('/usr/local/bin/ispconfig_update.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update.sh');
        //* Make the logs readable for the ispconfig user
        if(@is_file('/var/log/mail.log')) exec('chmod +r /var/log/mail.log');
        if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn');
        if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err');
        if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages');
        if(@is_file('/var/log/clamav/clamav.log')) exec('chmod +r /var/log/clamav/clamav.log');
        if(@is_file('/var/log/clamav/freshclam.log')) exec('chmod +r /var/log/clamav/freshclam.log');
        //* Create the ispconfig log file and directory
        if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) {
            if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir'], 0755);
            touch($conf['ispconfig_log_dir'].'/ispconfig.log');
        }
        rename($install_dir.'/server/scripts/run-getmail.sh','/usr/local/bin/run-getmail.sh');
        if(is_user('getmail')) chown('/usr/local/bin/run-getmail.sh', 'getmail');
        chmod('/usr/local/bin/run-getmail.sh', 0744);
        //* Add Log-Rotation
        if (is_dir('/etc/logrotate.d')) {
            @unlink('/etc/logrotate.d/logispc3'); // ignore, if the file is not there
            /* We rotate these logs in cron_daily.php
            $fh = fopen('/etc/logrotate.d/logispc3', 'w');
            fwrite($fh,
                    "$conf['ispconfig_log_dir']/ispconfig.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "} \n" .
                    "$conf['ispconfig_log_dir']/cron.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "}");
            fclose($fh);
            */
        }
    }
    public function configure_dbserver() {
        global $conf;
        //* If this server shall act as database server for client DB's, we configure this here
        $install_dir = $conf['ispconfig_install_dir'];
        // Create a file with the database login details which
        // are used to create the client databases.
        if(!is_dir($install_dir.'/server/lib')) {
            $command = "mkdir $install_dir/server/lib";
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        $content = rf('tpl/mysql_clientdb.conf.master');
        $content = str_replace('{username}',$conf['mysql']['admin_user'],$content);
        $content = str_replace('{password}',$conf['mysql']['admin_password'], $content);
        wf($install_dir.'/server/lib/mysql_clientdb.conf',$content);
        chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
        chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
    }
    public function install_crontab() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Root Crontab
        exec('crontab -u root -l > crontab.txt');
        $existing_root_cron_jobs = file('crontab.txt');
        // remove existing ispconfig cronjobs, in case the syntax has changed
        foreach($existing_root_cron_jobs as $key => $val) {
            if(stristr($val,$install_dir)) unset($existing_root_cron_jobs[$key]);
        }
        $root_cron_jobs = array(
                "* * * * * ".$install_dir."/server/server.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log",
                "30 00 * * * ".$install_dir."/server/cron_daily.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log"
        );
        foreach($root_cron_jobs as $cron_job) {
            if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
                $existing_root_cron_jobs[] = $cron_job."\n";
            }
        }
        file_put_contents('crontab.txt', $existing_root_cron_jobs);
        exec('crontab -u root crontab.txt &> /dev/null');
        unlink('crontab.txt');
        //* Getmail crontab
        if(is_user('getmail')) {
            $cf = $conf['getmail'];
            exec('crontab -u getmail -l > crontab.txt');
            $existing_cron_jobs = file('crontab.txt');
            $cron_jobs = array(
                    '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> '.$conf['ispconfig_log_dir'].'/cron.log'
            );
            // remove existing ispconfig cronjobs, in case the syntax has changed
            foreach($existing_cron_jobs as $key => $val) {
                if(stristr($val,'getmail')) unset($existing_cron_jobs[$key]);
            }
            foreach($cron_jobs as $cron_job) {
                if(!in_array($cron_job."\n", $existing_cron_jobs)) {
                    $existing_cron_jobs[] = $cron_job."\n";
                }
            }
            file_put_contents('crontab.txt', $existing_cron_jobs);
            exec('crontab -u getmail crontab.txt &> /dev/null');
            unlink('crontab.txt');
        }
        touch($conf['ispconfig_log_dir'].'/cron.log');
        chmod($conf['ispconfig_log_dir'].'/cron.log', 0666);
    }
    /**
     * Helper function - get the path to a template file based on
     * the local part of the filename. Checks first for the existence
     * of a distribution specific file and if not found looks in the
     * base template folder. Optionally the behaviour can be changed
     * by setting the 2nd parameter which will fetch the contents
     * of the template file and return it instead of the path. The 3rd
     * parameter further extends this behaviour by filtering the contents
     * by inserting the ispconfig database credentials using the {} placeholders.
     *
     * @param string $tLocal local part of filename
     * @param bool $tRf
     * @param bool $tDBCred
     * @return string Relative path to the chosen template file
     */
    protected function get_template_file($tLocal, $tRf=false, $tDBCred=false) {
        global $conf, $dist;
        $final_path = '';
        $dist_template = 'dist/tpl/'.strtolower($dist['name'])."/$tLocal.master";
        if (file_exists($dist_template)) {
            $final_path = $dist_template;
        } else {
            $final_path = "tpl/$tLocal.master";
        }
        if (!$tRf) {
            return $final_path;
        } else {
            return (!$tDBCred) ? rf($final_path) : $this->insert_db_credentials(rf($final_path));
        }
    }
    /**
     * Helper function - writes the contents to a config file
     * and performs a backup if the file exist. Additionally
     * if the file exists the new file will be given the
     * same rights and ownership as the original. Optionally the
     * rights and/or ownership can be overriden by appending umask,
     * user and group to the parameters. Providing only uid and gid
     * values will result in only a chown.
     *
     * @param $tConf
     * @param $tContents
     * @return bool
     */
    protected function write_config_file($tConf, $tContents) {
        // Backup config file before writing new contents and stat file
        if ( is_file($tConf) ) {
            $stat = exec('stat -c \'%a %U %G\' '.escapeshellarg($tConf), $output, $res);
            if ($res == 0) { // stat successfull
                list($access, $user, $group) = split(" ", $stat);
            }
            if ( copy($tConf, $tConf.'~') ) {
                chmod($tConf.'~', 0400);
            }
        }
        wf($tConf, $tContents); // write file
        if (func_num_args() >= 4) // override rights and/or ownership
        {
            $args = func_get_args();
            $output = array_slice($args, 2);
            switch (sizeof($output)) {
                case 3:
                    $umask = array_shift($output);
                    if (is_numeric($umask) && preg_match('/^0?[0-7]{3}$/', $umask)) {
                        $access = $umask;
                    }
                case 2:
                    if (is_user($output[0]) && is_group($output[1])) {
                        list($user,$group) = $output;
                    }
                    break;
            }
        }
        if (!empty($user) && !empty($group)) {
            chown($tConf, $user);
            chgrp($tConf, $group);
        }
        if (!empty($access)) {
            exec("chmod $access $tConf");
        }
    }
    /**
     * Helper function - filter the contents of a config
     * file by inserting the common ispconfig database
     * credentials.
     *
     * @param $tContents
     * @return string
     */
    protected function insert_db_credentials($tContents) {
        global $conf;
        $tContents = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $tContents);
        $tContents = str_replace('{mysql_server_ispconfig_password}', $conf["mysql"]["ispconfig_password"], $tContents);
        $tContents = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $tContents);
        $tContents = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $tContents);
        $tContents = str_replace('{mysql_server_host}',$conf['mysql']['host'], $tContents);
        $tContents = str_replace('{mysql_server_port}',$conf["mysql"]["port"], $tContents);
        return $tContents;
    }
}
?>
        wf($install_dir.'/interface/lib/'.$configfile, $content);
        //* Create the config file for ISPConfig server
        $configfile = 'config.inc.php';
        if(is_file($install_dir.'/server/lib/'.$configfile)) {
            copy($install_dir.'/server/lib/'.$configfile, $install_dir.'/interface/lib/'.$configfile.'~');
        }
        $content = rf('tpl/'.$configfile.'.master');
        $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
        $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
        $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
        $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
        $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
        $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
        $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
        $content = str_replace('{server_id}', $conf['server_id'], $content);
        $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
        $content = str_replace('{language}', $conf['language'], $content);
        wf($install_dir.'/server/lib/'.$configfile, $content);
        //* Create the config file for remote-actions (but only, if it does not exist, because
        //  the value is a autoinc-value and so changed by the remoteaction_core_module
        if (!file_exists($install_dir.'/server/lib/remote_action.inc.php')) {
            $content = '<?php' . "\n" . '$maxid_remote_action = 0;' . "\n" . '?>';
            wf($install_dir.'/server/lib/remote_action.inc.php', $content);
        }
        //* Enable the server modules and plugins.
        // TODO: Implement a selector which modules and plugins shall be enabled.
        $dir = $install_dir.'/server/mods-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/mods-available/'.$file);
                        $module_name = substr($file,0,-8);
                        $tmp = new $module_name;
                        if($tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) {
                                @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
                                // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-enabled/'.$file);
                            }
                            if (strpos($file, '_core_module') !== false) {
                                if(!@is_link($install_dir.'/server/mods-core/'.$file)) {
                                    @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
                                    // @symlink($install_dir.'/server/mods-available/'.$file, '../mods-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        $dir = $install_dir.'/server/plugins-available/';
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
                        include_once($install_dir.'/server/plugins-available/'.$file);
                        $plugin_name = substr($file,0,-8);
                        $tmp = new $plugin_name;
                        if(method_exists($tmp,'onInstall') && $tmp->onInstall()) {
                            if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) {
                                @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
                                //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-enabled/'.$file);
                            }
                            if (strpos($file, '_core_plugin') !== false) {
                                if(!@is_link($install_dir.'/server/plugins-core/'.$file)) {
                                    @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
                                    //@symlink($install_dir.'/server/plugins-available/'.$file, '../plugins-core/'.$file);
                                }
                            }
                        }
                        unset($tmp);
                    }
                }
                closedir($dh);
            }
        }
        // Update the server config
        $mail_server_enabled = ($conf['services']['mail'])?1:0;
        $web_server_enabled = ($conf['services']['web'])?1:0;
        $dns_server_enabled = ($conf['services']['dns'])?1:0;
        $file_server_enabled = ($conf['services']['file'])?1:0;
        $db_server_enabled = ($conf['services']['db'])?1:0;
        $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
        $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled' WHERE server_id = ".intval($conf['server_id']);
        if($conf['mysql']['master_slave_setup'] == 'y') {
            $this->dbmaster->query($sql);
            $this->db->query($sql);
        } else {
            $this->db->query($sql);
        }
        //* Chmod the files
        $command = 'chmod -R 750 '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* chown the files to the ispconfig user and group
        $command = 'chown -R ispconfig:ispconfig '.$install_dir;
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Make the global language file directory group writable
        exec("chmod -R 770 $install_dir/interface/lib/lang");
        //* Make the temp directory for language file exports writable
        if(is_dir($install_dir.'/interface/web/temp')) exec("chmod -R 770 $install_dir/interface/web/temp");
        //* Make all interface language file directories group writable
        $handle = @opendir($install_dir.'/interface/web');
        while ($file = @readdir ($handle)) {
            if ($file != '.' && $file != '..') {
                if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) {
                    $handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang');
                    chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang',0770);
                    while ($lang_file = @readdir ($handle2)) {
                        if ($lang_file != '.' && $lang_file != '..') {
                            chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file,0770);
                        }
                    }
                }
            }
        }
        //* make sure that the server config file (not the interface one) is only readable by the root user
        chmod($install_dir.'/server/lib/'.$configfile, 0600);
        chown($install_dir.'/server/lib/'.$configfile, 'root');
        chgrp($install_dir.'/server/lib/'.$configfile, 'root');
        chmod($install_dir.'/server/lib/remote_action.inc.php', 0600);
        chown($install_dir.'/server/lib/remote_action.inc.php', 'root');
        chgrp($install_dir.'/server/lib/remote_action.inc.php', 'root');
        if(@is_file($install_dir.'/server/lib/mysql_clientdb.conf')) {
            chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
            chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
            chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        }
        // TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
        // and must be fixed as this will allow the apache user to read the ispconfig files.
        // Later this must run as own apache server or via suexec!
        $command = 'adduser www-data ispconfig';
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Make the shell scripts executable
        $command = "chmod +x $install_dir/server/scripts/*.sh";
        caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        //* Copy the ISPConfig vhost for the controlpanel
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf('tpl/apache_ispconfig.vhost.master');
        $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
        // comment out the listen directive if port is 80 or 443
        if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
            $content = str_replace('{vhost_port_listen}', '#', $content);
        } else {
            $content = str_replace('{vhost_port_listen}', '', $content);
        }
        if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
            $content = str_replace('{ssl_comment}', '', $content);
        } else {
            $content = str_replace('{ssl_comment}', '#', $content);
        }
        wf($vhost_conf_dir.'/ispconfig.vhost', $content);
        //copy('tpl/apache_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost');
        //* and create the symlink
        if($this->install_ispconfig_interface == true && $this->is_update == false) {
            if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost');
            if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) {
                symlink($vhost_conf_dir.'/ispconfig.vhost',$vhost_conf_enabled_dir.'/000-ispconfig.vhost');
            }
        }
        if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
            mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true);
            copy('tpl/apache_ispconfig_fcgi_starter.master','/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
            symlink($install_dir.'/interface/web','/var/www/ispconfig');
            exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig');
        }
        //* Install the update script
        if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
        chown($install_dir.'/server/scripts/update_from_svn.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_svn.sh', 0700);
        chown($install_dir.'/server/scripts/update_from_tgz.sh', 'root');
        chmod($install_dir.'/server/scripts/update_from_tgz.sh', 0700);
        chown($install_dir.'/server/scripts/ispconfig_update.sh', 'root');
        chmod($install_dir.'/server/scripts/ispconfig_update.sh', 0700);
        if(!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update_from_svn.sh');
        if(!is_link('/usr/local/bin/ispconfig_update.sh')) symlink($install_dir.'/server/scripts/ispconfig_update.sh','/usr/local/bin/ispconfig_update.sh');
        //* Make the logs readable for the ispconfig user
        if(@is_file('/var/log/mail.log')) exec('chmod +r /var/log/mail.log');
        if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn');
        if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err');
        if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages');
        if(@is_file('/var/log/clamav/clamav.log')) exec('chmod +r /var/log/clamav/clamav.log');
        if(@is_file('/var/log/clamav/freshclam.log')) exec('chmod +r /var/log/clamav/freshclam.log');
        //* Create the ispconfig log file and directory
        if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) {
            if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir'], 0755);
            touch($conf['ispconfig_log_dir'].'/ispconfig.log');
        }
        rename($install_dir.'/server/scripts/run-getmail.sh','/usr/local/bin/run-getmail.sh');
        if(is_user('getmail')) chown('/usr/local/bin/run-getmail.sh', 'getmail');
        chmod('/usr/local/bin/run-getmail.sh', 0744);
        //* Add Log-Rotation
        if (is_dir('/etc/logrotate.d')) {
            @unlink('/etc/logrotate.d/logispc3'); // ignore, if the file is not there
            /* We rotate these logs in cron_daily.php
            $fh = fopen('/etc/logrotate.d/logispc3', 'w');
            fwrite($fh,
                    "$conf['ispconfig_log_dir']/ispconfig.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "} \n" .
                    "$conf['ispconfig_log_dir']/cron.log { \n" .
                    "    weekly \n" .
                    "    missingok \n" .
                    "    rotate 4 \n" .
                    "    compress \n" .
                    "    delaycompress \n" .
                    "}");
            fclose($fh);
            */
        }
    }
    public function configure_dbserver() {
        global $conf;
        //* If this server shall act as database server for client DB's, we configure this here
        $install_dir = $conf['ispconfig_install_dir'];
        // Create a file with the database login details which
        // are used to create the client databases.
        if(!is_dir($install_dir.'/server/lib')) {
            $command = "mkdir $install_dir/server/lib";
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
        }
        $content = rf('tpl/mysql_clientdb.conf.master');
        $content = str_replace('{username}',$conf['mysql']['admin_user'],$content);
        $content = str_replace('{password}',$conf['mysql']['admin_password'], $content);
        wf($install_dir.'/server/lib/mysql_clientdb.conf',$content);
        chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
        chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
        chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
    }
    public function install_crontab() {
        global $conf;
        $install_dir = $conf['ispconfig_install_dir'];
        //* Root Crontab
        exec('crontab -u root -l > crontab.txt');
        $existing_root_cron_jobs = file('crontab.txt');
        // remove existing ispconfig cronjobs, in case the syntax has changed
        foreach($existing_root_cron_jobs as $key => $val) {
            if(stristr($val,$install_dir)) unset($existing_root_cron_jobs[$key]);
        }
        $root_cron_jobs = array(
                "* * * * * ".$install_dir."/server/server.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log",
                "30 00 * * * ".$install_dir."/server/cron_daily.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log"
        );
        foreach($root_cron_jobs as $cron_job) {
            if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
                $existing_root_cron_jobs[] = $cron_job."\n";
            }
        }
        file_put_contents('crontab.txt', $existing_root_cron_jobs);
        exec('crontab -u root crontab.txt &> /dev/null');
        unlink('crontab.txt');
        //* Getmail crontab
        if(is_user('getmail')) {
            $cf = $conf['getmail'];
            exec('crontab -u getmail -l > crontab.txt');
            $existing_cron_jobs = file('crontab.txt');
            $cron_jobs = array(
                    '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> '.$conf['ispconfig_log_dir'].'/cron.log'
            );
            // remove existing ispconfig cronjobs, in case the syntax has changed
            foreach($existing_cron_jobs as $key => $val) {
                if(stristr($val,'getmail')) unset($existing_cron_jobs[$key]);
            }
            foreach($cron_jobs as $cron_job) {
                if(!in_array($cron_job."\n", $existing_cron_jobs)) {
                    $existing_cron_jobs[] = $cron_job."\n";
                }
            }
            file_put_contents('crontab.txt', $existing_cron_jobs);
            exec('crontab -u getmail crontab.txt &> /dev/null');
            unlink('crontab.txt');
        }
        touch($conf['ispconfig_log_dir'].'/cron.log');
        chmod($conf['ispconfig_log_dir'].'/cron.log', 0666);
    }
    /**
     * Helper function - get the path to a template file based on
     * the local part of the filename. Checks first for the existence
     * of a distribution specific file and if not found looks in the
     * base template folder. Optionally the behaviour can be changed
     * by setting the 2nd parameter which will fetch the contents
     * of the template file and return it instead of the path. The 3rd
     * parameter further extends this behaviour by filtering the contents
     * by inserting the ispconfig database credentials using the {} placeholders.
     *
     * @param string $tLocal local part of filename
     * @param bool $tRf
     * @param bool $tDBCred
     * @return string Relative path to the chosen template file
     */
    protected function get_template_file($tLocal, $tRf=false, $tDBCred=false) {
        global $conf, $dist;
        $final_path = '';
        $dist_template = 'dist/tpl/'.strtolower($dist['name'])."/$tLocal.master";
        if (file_exists($dist_template)) {
            $final_path = $dist_template;
        } else {
            $final_path = "tpl/$tLocal.master";
        }
        if (!$tRf) {
            return $final_path;
        } else {
            return (!$tDBCred) ? rf($final_path) : $this->insert_db_credentials(rf($final_path));
        }
    }
    /**
     * Helper function - writes the contents to a config file
     * and performs a backup if the file exist. Additionally
     * if the file exists the new file will be given the
     * same rights and ownership as the original. Optionally the
     * rights and/or ownership can be overriden by appending umask,
     * user and group to the parameters. Providing only uid and gid
     * values will result in only a chown.
     *
     * @param $tConf
     * @param $tContents
     * @return bool
     */
    protected function write_config_file($tConf, $tContents) {
        // Backup config file before writing new contents and stat file
        if ( is_file($tConf) ) {
            $stat = exec('stat -c \'%a %U %G\' '.escapeshellarg($tConf), $output, $res);
            if ($res == 0) { // stat successfull
                list($access, $user, $group) = split(" ", $stat);
            }
            if ( copy($tConf, $tConf.'~') ) {
                chmod($tConf.'~', 0400);
            }
        }
        wf($tConf, $tContents); // write file
        if (func_num_args() >= 4) // override rights and/or ownership
        {
            $args = func_get_args();
            $output = array_slice($args, 2);
            switch (sizeof($output)) {
                case 3:
                    $umask = array_shift($output);
                    if (is_numeric($umask) && preg_match('/^0?[0-7]{3}$/', $umask)) {
                        $access = $umask;
                    }
                case 2:
                    if (is_user($output[0]) && is_group($output[1])) {
                        list($user,$group) = $output;
                    }
                    break;
            }
        }
        if (!empty($user) && !empty($group)) {
            chown($tConf, $user);
            chgrp($tConf, $group);
        }
        if (!empty($access)) {
            exec("chmod $access $tConf");
        }
    }
    /**
     * Helper function - filter the contents of a config
     * file by inserting the common ispconfig database
     * credentials.
     *
     * @param $tContents
     * @return string
     */
    protected function insert_db_credentials($tContents) {
        global $conf;
        $tContents = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $tContents);
        $tContents = str_replace('{mysql_server_ispconfig_password}', $conf["mysql"]["ispconfig_password"], $tContents);
        $tContents = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $tContents);
        $tContents = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $tContents);
        $tContents = str_replace('{mysql_server_host}',$conf['mysql']['host'], $tContents);
        $tContents = str_replace('{mysql_server_port}',$conf["mysql"]["port"], $tContents);
        return $tContents;
    }
}
?>
install/sql/README.txt
@@ -1,39 +1,39 @@
---------------------------------------------------------------------------------
- Developer README
---------------------------------------------------------------------------------
When you add or modify a database field or table in the ISPConfig database,
then follow these steps:
1) Add the field or table in the ispconfig3.sql file. This file contains the
   complete database dump which is used when ISPConfig gets installed.
2) Create a new file in the "incremental" subfolder wich contains the alter
   table, or if it is a complete new table then the add table, statement(s) in
   MySQL syntax which is/are required to modify the current ispconfig database
   during update. The naming scheme of the sql patch update files is
   upd_0001.sql, upd_0002.sql, upd_0003.sql etc. Ensure that the number that
   you choose for the new file is a +1 increment of the number of the last
   existing file and that the number is formatted with 4 digits.
   A patch file may contain one or more alter table statements. Every patch file
   gets executed once in the database, so do not modify older (already released)
   patch files, they will not get executed again if the update was already run
   once on a system.
   After a patch has been executed, the dbversion field in the server table gets
   increeased to the version number of the last installed patch.
   If you like to run a patch file again for testing purposes on your dev machine,
   then set the number in "dbversion" field of the server table to be lower then
   the number of your patch.
Note: Incremental patches are supported for installed ISPConfig versions > 3.0.3.
      If the installed version is < 3.0.3, then the full update method is used.
      In other words, ISPConfig 3.0.3 is the patch release (dbversion) 0 as the
      incremental update feature has been introduced in 3.0.3.
---------------------------------------------------------------------------------
- Developer README
---------------------------------------------------------------------------------
When you add or modify a database field or table in the ISPConfig database,
then follow these steps:
1) Add the field or table in the ispconfig3.sql file. This file contains the
   complete database dump which is used when ISPConfig gets installed.
2) Create a new file in the "incremental" subfolder wich contains the alter
   table, or if it is a complete new table then the add table, statement(s) in
   MySQL syntax which is/are required to modify the current ispconfig database
   during update. The naming scheme of the sql patch update files is
   upd_0001.sql, upd_0002.sql, upd_0003.sql etc. Ensure that the number that
   you choose for the new file is a +1 increment of the number of the last
   existing file and that the number is formatted with 4 digits.
   A patch file may contain one or more alter table statements. Every patch file
   gets executed once in the database, so do not modify older (already released)
   patch files, they will not get executed again if the update was already run
   once on a system.
   After a patch has been executed, the dbversion field in the server table gets
   increeased to the version number of the last installed patch.
   If you like to run a patch file again for testing purposes on your dev machine,
   then set the number in "dbversion" field of the server table to be lower then
   the number of your patch.
Note: Incremental patches are supported for installed ISPConfig versions > 3.0.3.
      If the installed version is < 3.0.3, then the full update method is used.
      In other words, ISPConfig 3.0.3 is the patch release (dbversion) 0 as the
      incremental update feature has been introduced in 3.0.3.
install/sql/incremental/upd_0007.sql
@@ -1,19 +1,19 @@
ALTER TABLE client ADD COLUMN limit_mailmailinglist int(11) NOT NULL default '-1';
ALTER TABLE client_template ADD COLUMN limit_mailmailinglist int(11) NOT NULL default '-1';
CREATE TABLE IF NOT EXISTS `mail_mailinglist` (
  `mailinglist_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) NOT NULL,
  `sys_perm_group` varchar(5) character set ucs2 NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL,
  `listname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY  (`mailinglist_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
ALTER TABLE client ADD COLUMN limit_mailmailinglist int(11) NOT NULL default '-1';
ALTER TABLE client_template ADD COLUMN limit_mailmailinglist int(11) NOT NULL default '-1';
CREATE TABLE IF NOT EXISTS `mail_mailinglist` (
  `mailinglist_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) NOT NULL,
  `sys_perm_group` varchar(5) character set ucs2 NOT NULL,
  `sys_perm_other` varchar(5) NOT NULL,
  `server_id` int(11) unsigned NOT NULL default '0',
  `domain` varchar(255) NOT NULL,
  `listname` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `password` varchar(255) NOT NULL,
  PRIMARY KEY  (`mailinglist_id`)
) ENGINE=MyISAM AUTO_INCREMENT=1;
DROP TABLE `mail_mailman_domain`;
install/update.php
@@ -1,358 +1,358 @@
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
/*
    ISPConfig 3 updater.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Update  \n\n";
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for ISPConfig 2.x versions
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
echo "This application will update ISPConfig 3 on your server.\n";
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** Ask user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    $conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
}
/*
 *  Prepare the dump of the database
 */
prepareDBDump();
//* initialize the database
$inst->db = new db();
//* initialize the master DB, if we have a multiserver setup
if($conf['mysql']['master_slave_setup'] == 'y') {
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
} else {
    $inst->dbmaster = $inst->db;
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure the permisson if needed
 * (if this is done at client side, only this client is updated.
 * If this is done at server side, all clients are updated.
 */
//if($conf_old['dbmaster_user'] != '' or $conf_old['dbmaster_host'] != '') {
    //** Update master database rights
    $reconfigure_master_database_rights_answer = $inst->simple_query('Reconfigure Permissions in master database?', array('yes','no'),'no');
    if($reconfigure_master_database_rights_answer == 'yes') {
        $inst->grant_master_database_rights();
    }
//}
//** Shall the services be reconfigured during update
$reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', array('yes','no'),'yes');
if($reconfigure_services_answer == 'yes') {
    if($conf['services']['mail']) {
        //** Configure postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix('dont-create-certs');
        //** Configure mailman
        swriteln('Configuring Mailman');
        $inst->configure_mailman('update');
        //* Configure Jailkit
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //** Configure saslauthd
            swriteln('Configuring SASL');
            $inst->configure_saslauthd();
            //** Configure PAM
            swriteln('Configuring PAM');
            $inst->configure_pam();
            //* Configure courier
            swriteln('Configuring Courier');
            $inst->configure_courier();
        }
        //** Configure Spamasassin
        swriteln('Configuring Spamassassin');
        $inst->configure_spamassassin();
        //** Configure Amavis
        swriteln('Configuring Amavisd');
        $inst->configure_amavis();
        //** Configure Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
    }
    if($conf['services']['web']) {
        //** Configure Pureftpd
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
    }
    if($conf['services']['dns']) {
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
        }
    }
    if($conf['services']['web']) {
        //** Configure Apache
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure vlogger
        swriteln('Configuring vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //* Configure DBServer
    swriteln('Configuring Database');
    $inst->configure_dbserver();
    //if(@is_dir('/etc/Bastille')) {
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //}
}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$ispconfig_port_number = get_ispconfig_port_number();
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number);
// $ispconfig_ssl_default = (is_ispconfig_ssl_enabled() == true)?'y':'n';
if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate',array('yes','no'),'no')) == 'yes') {
    $inst->make_ispconfig_ssl_cert();
}
$inst->install_ispconfig();
//** Configure Crontab
$update_crontab_answer = $inst->simple_query('Reconfigure Crontab?', array('yes','no'),'yes');
if($update_crontab_answer == 'yes') {
    swriteln('Updating Crontab');
    $inst->install_crontab();
}
//** Restart services:
if($reconfigure_services_answer == 'yes') {
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['services']['mail']) {
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
        if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    }
    if($conf['services']['web']) {
        if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    if($conf['services']['dns']) {
        if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
    }
}
echo "Update finished.\n";
?>
<?php
/*
Copyright (c) 2007-2010, Till Brehm, projektfarm Gmbh
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.
*/
/*
    ISPConfig 3 updater.
*/
error_reporting(E_ALL|E_STRICT);
//** The banner on the command line
echo "\n\n".str_repeat('-',80)."\n";
echo " _____ ___________   _____              __ _         ____
|_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
  | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
  | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
 _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
 \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
                                              __/ |
                                             |___/ ";
echo "\n".str_repeat('-',80)."\n";
echo "\n\n>> Update  \n\n";
//** Include the library with the basic installer functions
require_once('lib/install.lib.php');
//** Include the library with the basic updater functions
require_once('lib/update.lib.php');
//** Include the base class of the installer class
require_once('lib/installer_base.lib.php');
//** Ensure that current working directory is install directory
$cur_dir = getcwd();
if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
//** Install logfile
define('ISPC_LOG_FILE', '/var/log/ispconfig_install.log');
define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../'));
//** Check for ISPConfig 2.x versions
if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) {
    die('This software cannot be installed on a server wich runs ISPConfig 2.x.');
}
//** Get distribution identifier
$dist = get_distname();
include_once("/usr/local/ispconfig/server/lib/config.inc.php");
$conf_old = $conf;
unset($conf);
if($dist['id'] == '') die('Linux distribution or version not recognized.');
//** Include the distribution-specific installer class library and configuration
if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php');
include_once('dist/lib/'.$dist['id'].'.lib.php');
include_once('dist/conf/'.$dist['id'].'.conf.php');
//** Get hostname
exec('hostname -f', $tmp_out);
$conf['hostname'] = $tmp_out[0];
unset($tmp_out);
//** Set the mysql login information
$conf["mysql"]["host"] = $conf_old["db_host"];
$conf["mysql"]["database"] = $conf_old["db_database"];
$conf['mysql']['charset'] = 'utf8';
$conf["mysql"]["ispconfig_user"] = $conf_old["db_user"];
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
$conf['language'] = $conf_old['language'];
if($conf['language'] == '{language}') $conf['language'] = 'en';
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];
if(isset($conf_old["dbmaster_database"])) $conf["mysql"]["master_database"] = $conf_old["dbmaster_database"];
if(isset($conf_old["dbmaster_user"])) $conf["mysql"]["master_ispconfig_user"] = $conf_old["dbmaster_user"];
if(isset($conf_old["dbmaster_password"])) $conf["mysql"]["master_ispconfig_password"] = $conf_old["dbmaster_password"];
//* Check if this is a master / slave setup
if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
    $conf['mysql']['master_slave_setup'] = 'y';
}
// Resolve the IP address of the mysql hostname.
if(!$conf['mysql']['ip'] = gethostbyname($conf['mysql']['host'])) die('Unable to resolve hostname'.$conf['mysql']['host']);
$conf['server_id'] = intval($conf_old["server_id"]);
$conf['ispconfig_log_priority'] = $conf_old["log_priority"];
$inst = new installer();
$inst->is_update = true;
//** Detect the installed applications
$inst->find_installed_apps();
echo "This application will update ISPConfig 3 on your server.\n";
//** Initialize the MySQL server connection
include_once('lib/mysql.lib.php');
//** Database update is a bit brute force and should be rebuild later ;)
/*
 * Try to read the DB-admin settings
 */
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf");
$conf["mysql"]["admin_user"] = $clientdb_user;
$conf["mysql"]["admin_password"] = $clientdb_password;
$clientdb_host            = '';
$clientdb_user            = '';
$clientdb_password        = '';
//** Ask user for mysql admin_password if empty
if( empty($conf["mysql"]["admin_password"]) ) {
    $conf["mysql"]["admin_password"] = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
}
/*
 *  Prepare the dump of the database
 */
prepareDBDump();
//* initialize the database
$inst->db = new db();
//* initialize the master DB, if we have a multiserver setup
if($conf['mysql']['master_slave_setup'] == 'y') {
        //** Get MySQL root credentials
        $finished = false;
        do {
            $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host']);
            $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user']);
            $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password']);
            $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database']);
            //* Initialize the MySQL server connection
            if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
                $conf['mysql']['master_host'] = $tmp_mysql_server_host;
                $conf['mysql']['master_admin_user'] = $tmp_mysql_server_admin_user;
                $conf['mysql']['master_admin_password'] = $tmp_mysql_server_admin_password;
                $conf['mysql']['master_database'] = $tmp_mysql_server_database;
                $finished = true;
            } else {
                swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error());
            }
        } while ($finished == false);
        unset($finished);
        // initialize the connection to the master database
        $inst->dbmaster = new db();
        if($inst->dbmaster->linkId) $inst->dbmaster->closeConn();
        $inst->dbmaster->dbHost = $conf['mysql']["master_host"];
        $inst->dbmaster->dbName = $conf['mysql']["master_database"];
        $inst->dbmaster->dbUser = $conf['mysql']["master_admin_user"];
        $inst->dbmaster->dbPass = $conf['mysql']["master_admin_password"];
} else {
    $inst->dbmaster = $inst->db;
}
/*
 *  dump the new Database and reconfigure the server.ini
 */
updateDbAndIni();
/*
 * Reconfigure the permisson if needed
 * (if this is done at client side, only this client is updated.
 * If this is done at server side, all clients are updated.
 */
//if($conf_old['dbmaster_user'] != '' or $conf_old['dbmaster_host'] != '') {
    //** Update master database rights
    $reconfigure_master_database_rights_answer = $inst->simple_query('Reconfigure Permissions in master database?', array('yes','no'),'no');
    if($reconfigure_master_database_rights_answer == 'yes') {
        $inst->grant_master_database_rights();
    }
//}
//** Shall the services be reconfigured during update
$reconfigure_services_answer = $inst->simple_query('Reconfigure Services?', array('yes','no'),'yes');
if($reconfigure_services_answer == 'yes') {
    if($conf['services']['mail']) {
        //** Configure postfix
        swriteln('Configuring Postfix');
        $inst->configure_postfix('dont-create-certs');
        //** Configure mailman
        swriteln('Configuring Mailman');
        $inst->configure_mailman('update');
        //* Configure Jailkit
        swriteln('Configuring Jailkit');
        $inst->configure_jailkit();
        if($conf['dovecot']['installed'] == true) {
            //* Configure dovecot
            swriteln('Configuring Dovecot');
            $inst->configure_dovecot();
        } else {
            //** Configure saslauthd
            swriteln('Configuring SASL');
            $inst->configure_saslauthd();
            //** Configure PAM
            swriteln('Configuring PAM');
            $inst->configure_pam();
            //* Configure courier
            swriteln('Configuring Courier');
            $inst->configure_courier();
        }
        //** Configure Spamasassin
        swriteln('Configuring Spamassassin');
        $inst->configure_spamassassin();
        //** Configure Amavis
        swriteln('Configuring Amavisd');
        $inst->configure_amavis();
        //** Configure Getmail
        swriteln('Configuring Getmail');
        $inst->configure_getmail();
    }
    if($conf['services']['web']) {
        //** Configure Pureftpd
        swriteln('Configuring Pureftpd');
        $inst->configure_pureftpd();
    }
    if($conf['services']['dns']) {
        //* Configure DNS
        if($conf['powerdns']['installed'] == true) {
            swriteln('Configuring PowerDNS');
            $inst->configure_powerdns();
        } elseif($conf['bind']['installed'] == true) {
            swriteln('Configuring BIND');
            $inst->configure_bind();
        } else {
            swriteln('Configuring MyDNS');
            $inst->configure_mydns();
        }
    }
    if($conf['services']['web']) {
        //** Configure Apache
        swriteln('Configuring Apache');
        $inst->configure_apache();
        //** Configure vlogger
        swriteln('Configuring vlogger');
        $inst->configure_vlogger();
        //** Configure apps vhost
        swriteln('Configuring Apps vhost');
        $inst->configure_apps_vhost();
    }
    //* Configure DBServer
    swriteln('Configuring Database');
    $inst->configure_dbserver();
    //if(@is_dir('/etc/Bastille')) {
    //* Configure Firewall
    swriteln('Configuring Firewall');
    $inst->configure_firewall();
    //}
}
//** Configure ISPConfig
swriteln('Updating ISPConfig');
//** Customise the port ISPConfig runs on
$ispconfig_port_number = get_ispconfig_port_number();
$conf['apache']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number);
// $ispconfig_ssl_default = (is_ispconfig_ssl_enabled() == true)?'y':'n';
if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate',array('yes','no'),'no')) == 'yes') {
    $inst->make_ispconfig_ssl_cert();
}
$inst->install_ispconfig();
//** Configure Crontab
$update_crontab_answer = $inst->simple_query('Reconfigure Crontab?', array('yes','no'),'yes');
if($update_crontab_answer == 'yes') {
    swriteln('Updating Crontab');
    $inst->install_crontab();
}
//** Restart services:
if($reconfigure_services_answer == 'yes') {
    swriteln('Restarting services ...');
    if($conf['mysql']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mysql']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mysql']['init_script'].' restart');
    if($conf['services']['mail']) {
        if($conf['postfix']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['postfix']['init_script']))                system($conf['init_scripts'].'/'.$conf['postfix']['init_script'].' restart');
        if($conf['saslauthd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['saslauthd']['init_script']))            system($conf['init_scripts'].'/'.$conf['saslauthd']['init_script'].' restart');
        if($conf['amavis']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['amavis']['init_script']))                    system($conf['init_scripts'].'/'.$conf['amavis']['init_script'].' restart');
        if($conf['clamav']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['clamav']['init_script']))                    system($conf['init_scripts'].'/'.$conf['clamav']['init_script'].' restart');
        if($conf['courier']['courier-authdaemon'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'])) system($conf['init_scripts'].'/'.$conf['courier']['courier-authdaemon'].' restart');
        if($conf['courier']['courier-imap'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap']))             system($conf['init_scripts'].'/'.$conf['courier']['courier-imap'].' restart');
        if($conf['courier']['courier-imap-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl']))     system($conf['init_scripts'].'/'.$conf['courier']['courier-imap-ssl'].' restart');
        if($conf['courier']['courier-pop'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop']))                 system($conf['init_scripts'].'/'.$conf['courier']['courier-pop'].' restart');
        if($conf['courier']['courier-pop-ssl'] != '' && is_executable($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl']))         system($conf['init_scripts'].'/'.$conf['courier']['courier-pop-ssl'].' restart');
        if($conf['dovecot']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['dovecot']['init_script']))         system($conf['init_scripts'].'/'.$conf['dovecot']['init_script'].' restart');
        if($conf['mailman']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mailman']['init_script']))         system($conf['init_scripts'].'/'.$conf['mailman']['init_script'].' restart');
    }
    if($conf['services']['web']) {
        if($conf['apache']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['apache']['init_script']))                 system($conf['init_scripts'].'/'.$conf['apache']['init_script'].' restart');
        if($conf['pureftpd']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['pureftpd']['init_script']))                system($conf['init_scripts'].'/'.$conf['pureftpd']['init_script'].' restart');
    }
    if($conf['services']['dns']) {
        if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['mydns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['mydns']['init_script'].' restart &> /dev/null');
        if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['powerdns']['init_script']))                    system($conf['init_scripts'].'/'.$conf['powerdns']['init_script'].' restart &> /dev/null');
        if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['bind']['init_script']))                    system($conf['init_scripts'].'/'.$conf['bind']['init_script'].' restart &> /dev/null');
    }
}
echo "Update finished.\n";
?>
interface/index.htm
@@ -1,8 +1,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="refresh" content="0;URL=web/index.php">
</head>
<body>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="refresh" content="0;URL=web/index.php">
</head>
<body>
</body>
</html>
interface/lib/classes/auth.inc.php
@@ -1,129 +1,129 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
class auth {
    var $client_limits = null;
    public function get_user_id()
    {
        return $_SESSION['s']['user']['userid'];
    }
    public function is_admin() {
        if($_SESSION['s']['user']['typ'] == 'admin') {
            return true;
        } else {
            return false;
        }
    }
    public function has_clients($userid) {
        global $app, $conf;
        $userid = intval($userid);
        $client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
        if($client['limit_client'] > 0) {
            return true;
        } else {
            return false;
        }
    }
    //** This function adds a given group id to a given user.
    public function add_group_to_user($userid,$groupid) {
        global $app;
        $userid = intval($userid);
        $groupid = intval($groupid);
        if($userid > 0 && $groupid > 0) {
            $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
            $groups = explode(',',$user['groups']);
            if(!in_array($groupid,$groups)) $groups[] = $groupid;
            $groups_string = implode(',',$groups);
            $sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
            $app->db->query($sql);
            return true;
        } else {
            return false;
        }
    }
    //** This function returns given client limit as integer, -1 means no limit
    public function get_client_limit($userid, $limitname)
    {
        global $app;
        // simple query cache
        if($this->client_limits===null)
            $this->client_limits = $app->db->queryOneRecord("SELECT client.* FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
        // isn't client -> no limit
        if(!$this->client_limits)
            return -1;
        if(isset($this->client_limits['limit_'.$limitname])) {
            return $this->client_limits['limit_'.$limitname];
        }
    }
    //** This function removes a given group id from a given user.
    public function remove_group_from_user($userid,$groupid) {
        global $app;
        $userid = intval($userid);
        $groupid = intval($groupid);
        if($userid > 0 && $groupid > 0) {
            $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
            $groups = explode(',',$user['groups']);
            $key = array_search($groupid,$groups);
            unset($groups[$key]);
            $groups_string = implode(',',$groups);
            $sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
            $app->db->query($sql);
            return true;
        } else {
            return false;
        }
    }
    public function check_module_permissions($module) {
        // Check if the current user has the permissions to access this module
        if(!stristr($_SESSION["s"]["user"]["modules"],$module)) {
            // echo "LOGIN_REDIRECT:/index.php";
            header("Location: /index.php");
            exit;
        }
    }
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
class auth {
    var $client_limits = null;
    public function get_user_id()
    {
        return $_SESSION['s']['user']['userid'];
    }
    public function is_admin() {
        if($_SESSION['s']['user']['typ'] == 'admin') {
            return true;
        } else {
            return false;
        }
    }
    public function has_clients($userid) {
        global $app, $conf;
        $userid = intval($userid);
        $client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
        if($client['limit_client'] > 0) {
            return true;
        } else {
            return false;
        }
    }
    //** This function adds a given group id to a given user.
    public function add_group_to_user($userid,$groupid) {
        global $app;
        $userid = intval($userid);
        $groupid = intval($groupid);
        if($userid > 0 && $groupid > 0) {
            $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
            $groups = explode(',',$user['groups']);
            if(!in_array($groupid,$groups)) $groups[] = $groupid;
            $groups_string = implode(',',$groups);
            $sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
            $app->db->query($sql);
            return true;
        } else {
            return false;
        }
    }
    //** This function returns given client limit as integer, -1 means no limit
    public function get_client_limit($userid, $limitname)
    {
        global $app;
        // simple query cache
        if($this->client_limits===null)
            $this->client_limits = $app->db->queryOneRecord("SELECT client.* FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id");
        // isn't client -> no limit
        if(!$this->client_limits)
            return -1;
        if(isset($this->client_limits['limit_'.$limitname])) {
            return $this->client_limits['limit_'.$limitname];
        }
    }
    //** This function removes a given group id from a given user.
    public function remove_group_from_user($userid,$groupid) {
        global $app;
        $userid = intval($userid);
        $groupid = intval($groupid);
        if($userid > 0 && $groupid > 0) {
            $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid");
            $groups = explode(',',$user['groups']);
            $key = array_search($groupid,$groups);
            unset($groups[$key]);
            $groups_string = implode(',',$groups);
            $sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid";
            $app->db->query($sql);
            return true;
        } else {
            return false;
        }
    }
    public function check_module_permissions($module) {
        // Check if the current user has the permissions to access this module
        if(!stristr($_SESSION["s"]["user"]["modules"],$module)) {
            // echo "LOGIN_REDIRECT:/index.php";
            header("Location: /index.php");
            exit;
        }
    }
}
?>
interface/lib/classes/form.inc.php
@@ -1,475 +1,475 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
/**
* Formularbehandlung
*
* Funktionen zur Umwandlung von Formulardaten
* sowie zum vorbereiten von HTML und SQL
* Ausgaben
*
*    Tabellendefinition
*
*    Datentypen:
*    - INTEGER (Wandelt Ausdrücke in Int um)
*    - DOUBLE
*    - CURRENCY (Formatiert Zahlen nach Währungsnotation)
*    - VARCHAR (kein weiterer Format Check)
*    - DATE (Datumsformat, Timestamp Umwandlung)
*
*    Formtype:
*    - TEXT (normales Textfeld)
*    - PASSWORD (Feldinhalt wird nicht angezeigt)
*    - SELECT (Gibt Werte als option Feld aus)
*    - MULTIPLE (Select-Feld mit nehreren Werten)
*
*    VALUE:
*    - Wert oder Array
*
*    SEPARATOR
*    - Trennzeichen für multiple Felder
*
*    Hinweis:
*    Das ID-Feld ist nicht bei den Table Values einzufügen.
*
* @package form
* @author Till Brehm
* @version 1.1
*/
class form {
    /**
    * Definition der Tabelle (array)
    * @var tableDef
    */
    var $tableDef;
    /**
    * Private
    * @var action
    */
    var $action;
    /**
    * Tabellenname (String)
    * @var table_name
    */
    var $table_name;
    /**
    * Debug Variable
    * @var debug
    */
    var $debug = 0;
    /**
    * name des primary Field der Tabelle (string)
    * @var table_index
    */
    var $table_index;
    /**
    * enthält die Fehlermeldung bei Ãœberprüfung
    * der Variablen mit Regex
    * @var errorMessage
    */
    var $errorMessage;
    var $dateformat = "d.m.Y";
    var $formDef;
    /**
    * Laden der Tabellendefinition
    *
    * @param file: Pfad zur Tabellendefinition
    * @return true
    */
    function loadTableDef($file) {
        global $app,$conf;
        include_once($file);
        $this->tableDef = $table;
        $this->table_name = $table_name;
        $this->table_index = $table_index;
        return true;
    }
    function loadFormDef($file) {
        global $app,$conf;
        include_once($file);
        $this->formDef = $form;
        return true;
    }
    /**
    * Konvertiert die Daten des Ã¼bergebenen assoziativen
    * Arrays in "menschenlesbare" Form.
    * Datentyp Konvertierung, z.B. für Ausgabe in Listen.
    *
    * @param record
    * @return record
    */
    function decode($record) {
        if(is_array($record)) {
            foreach($record as $key => $val) {
                switch ($this->tableDef[$key]['datatype']) {
                case 'VARCHAR':
                    $new_record[$key] = stripslashes($val);
                break;
                case 'DATE':
                    if($val > 0) {
                        $new_record[$key] = date($this->dateformat,$val);
                    }
                break;
                case 'INTEGER':
                    $new_record[$key] = intval($val);
                break;
                case 'DOUBLE':
                    $new_record[$key] = $val;
                break;
                case 'CURRENCY':
                    $new_record[$key] = number_format($val, 2, ',', '');
                break;
                default:
                    $new_record[$key] = stripslashes($val);
                }
            }
        }
    return $new_record;
    }
    /**
    * Record für Ausgabe in Formularen vorbereiten.
    *
    * @param record = Datensatz als Array
    * @param action = NEW oder EDIT
    * @return record
    */
    function getHTML($record,$action = 'NEW') {
        global $app;
        if(!is_array($this->tableDef)) $app->error("Keine Tabellendefinition vorhanden.");
        $new_record = array();
        if($action == 'EDIT') {
            $record = $this->decode($record);
            if(is_array($record)) {
                foreach($record as $key => $val) {
                    switch ($this->tableDef[$key]['formtype']) {
                    case 'SELECT':
                        if(is_array($this->tableDef[$key]['value'])) {
                            $out = '';
                            foreach($this->tableDef[$key]['value'] as $k => $v) {
                                $selected = ($k == $val)?' SELECTED':'';
                                $out .= "<option value='$k'$selected>$v</option>\r\n";
                            }
                        }
                        $new_record[$key] = $out;
                    break;
                    case 'MULTIPLE':
                        if(is_array($this->tableDef[$key]['value'])) {
                            // aufsplitten ergebnisse
                            $vals = explode($this->tableDef[$key]['separator'],$val);
                            // HTML schreiben
                            $out = '';
                            foreach($this->tableDef[$key]['value'] as $k => $v) {
                                $selected = '';
                                foreach($vals as $tvl) {
                                    if(trim($tvl) == trim($k)) $selected = ' SELECTED';
                                }
                                $out .= "<option value='$k'$selected>$v</option>\r\n";
                            }
                        }
                        $new_record[$key] = $out;
                    break;
                    case 'PASSWORD':
                        $new_record[$key] = '';
                    break;
                    default:
                        $new_record[$key] = htmlspecialchars($val);
                    }
                }
            }
        } else {
            foreach($this->tableDef as $key => $val) {
                switch ($this->tableDef[$key]['formtype']) {
                case 'SELECT':
                    if(is_array($this->tableDef[$key]['value'])) {
                        $out = '';
                        foreach($this->tableDef[$key]['value'] as $k => $v) {
                            $selected = ($k == $val)?' SELECTED':'';
                            $out .= "<option value='$k'$selected>$v</option>\r\n";
                        }
                    }
                    $new_record[$key] = $out;
                break;
                case 'MULTIPLE':
                        if(is_array($this->tableDef[$key]['value'])) {
                            // aufsplitten ergebnisse
                            $vals = explode($this->tableDef[$key]['separator'],$val);
                            // HTML schreiben
                            $out = '';
                            foreach($this->tableDef[$key]['value'] as $k => $v) {
                                $out .= "<option value='$k'>$v</option>\r\n";
                            }
                        }
                        $new_record[$key] = $out;
                    break;
                case 'PASSWORD':
                    $new_record[$key] = '';
                break;
                default:
                    $new_record[$key] = htmlspecialchars($this->tableDef[$key]['value']);
                }
            }
        }
        if($this->debug == 1) $this->dbg($new_record);
        return $new_record;
    }
    /**
    * Record in "maschinen lesbares" Format Ã¼berführen
    * und Werte gegen reguläre Ausdrücke prüfen.
    *
    * @param record = Datensatz als Array
    * @return record
    */
    function encode($record) {
        $this->errorMessage = '';
        if(is_array($record)) {
            foreach($record as $key => $val) {
                switch ($this->tableDef[$key]['datatype']) {
                case 'VARCHAR':
                    if(!is_array($val)) {
                        $new_record[$key] = mysql_real_escape_string($val);
                    } else {
                        $new_record[$key] = implode($this->tableDef[$key]['separator'],$val);
                    }
                break;
                case 'DATE':
                    if($val > 0) {
                        list($tag,$monat,$jahr) = explode('.',$val);
                        $new_record[$key] = mktime(0,0,0,$monat,$tag,$jahr);
                    }
                break;
                case 'INTEGER':
                    $new_record[$key] = intval($val);
                break;
                case 'DOUBLE':
                    $new_record[$key] = mysql_real_escape_string($val);
                break;
                case 'CURRENCY':
                    $new_record[$key] = str_replace(",",".",$val);
                break;
                }
                if($this->tableDef[$key]['regex'] != '') {
                    // Enable that "." matches also newlines
                    $this->tableDef[$key]['regex'] .= 's';
                    if(!preg_match($this->tableDef[$key]['regex'], $val)) {
                        $this->errorMessage .= $this->tableDef[$key]['errmsg']."<br>\r\n";
                    }
                }
            }
        }
        return $new_record;
    }
    /**
    * SQL Statement für Record erzeugen.
    *
    * @param record = Datensatz als Array
    * @param action = INSERT oder UPDATE
    * @param primary_id
    * @return record
    */
    function getSQL($record, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '') {
        global $app;
        $record = $this->encode($record);
        $sql_insert_key = '';
        $sql_insert_val = '';
        $sql_update = '';
        if(!is_array($this->tableDef)) $app->error("Keine Tabellendefinition vorhanden.");
        // gehe durch alle Felder des Records
        if(is_array($record)) {
        foreach($record as $key => $val) {
            // Wenn es kein leeres Passwortfeld ist
            if (!($this->tableDef[$key]['formtype'] == 'PASSWORD' and $val == '')) {
                // gehe durch alle Felder der TableDef
                foreach($this->tableDef as $tk => $tv) {
                    // Wenn Feld in TableDef enthalten ist
                    if($tk == $key) {
                        // Erzeuge Insert oder Update Quelltext
                        if($action == "INSERT") {
                            if($this->tableDef[$key]['formtype'] == 'PASSWORD') {
                                $sql_insert_key .= "`$key`, ";
                                $sql_insert_val .= "md5('$val'), ";
                            //} elseif($this->tableDef[$key]['formtype'] == 'MULTIPLE') {
                            //    $val = implode($this->tableDef[$key]['separator'],$val);
                            //    $sql_insert_key .= "`$key`, ";
                            //    $sql_insert_val .= "'$val', ";
                            } else {
                                $sql_insert_key .= "`$key`, ";
                                $sql_insert_val .= "'$val', ";
                            }
                        } else {
                            if($this->tableDef[$key]['formtype'] == 'PASSWORD') {
                                $sql_update .= "`$key` = md5('$val'), ";
                            //} elseif($this->tableDef[$key]['formtype'] == 'MULTIPLE') {
                            //    $val = implode($this->tableDef[$key]['separator'],$val);
                            //    $sql_update .= "`$key` = '$val', ";
                            } else {
                                $sql_update .= "`$key` = '$val', ";
                            }
                        }
                    }
                }
            }
        }
        }
        // Füge Backticks nur bei unvollständigen Tabellennamen ein
        if(stristr($this->table_name,'.')) {
            $escape = '';
        } else {
            $escape = '`';
        }
        if($action == "INSERT") {
            $sql_insert_key = substr($sql_insert_key,0,-2);
            $sql_insert_val = substr($sql_insert_val,0,-2);
            $sql = "INSERT INTO ".$escape.$this->table_name.$escape." ($sql_insert_key) VALUES ($sql_insert_val)";
        } else {
            if($primary_id != 0) {
                $sql_update = substr($sql_update,0,-2);
                $sql = "UPDATE ".$escape.$this->table_name.$escape." SET ".$sql_update." WHERE ".$this->table_index ." = ".$primary_id;
                if($sql_ext_where != '') $sql .= " and ".$sql_ext_where;
            } else {
                $app->error("Primary ID fehlt!");
            }
        }
        return $sql;
    }
    /**
    * Debugging arrays.
    *
    * @param array_data
    */
    function dbg($array_data) {
        echo "<pre>";
        print_r($array_data);
        echo "</pre>";
    }
    function showForm() {
        global $app,$conf;
        if(!is_array($this->formDef)) die("Form Definition wurde nicht geladen.");
        if($this->errorMessage == '') {
            // wenn kein Fehler vorliegt
            if($_REQUEST["next_tab"] != '') {
                // wenn nächster Tab bekannt
                $active_tab = $_REQUEST["next_tab"];
            } else {
                // ansonsten ersten tab nehmen
                $active_tab = $this->formDef["tabs"][0]["name"];
            }
        } else {
            // bei Fehlern den gleichen Tab nochmal anzeigen
            $active_tab = $_SESSION["s"]["form"]["tab"];
        }
        // definiere Tabs
        foreach( $this->formDef["tabs"] as $tab) {
            if($tab["name"] == $active_tab) {
                $app->tpl->setInclude('content_tpl',$tab["template"]);
                $tab["active"] = 1;
                $_SESSION["s"]["form"]["tab"] = $tab["name"];
            } else {
                $tab["active"] = 0;
            }
            $frmTab[] = $tab;
        }
        // setze Loop
        $app->tpl->setLoop("formTab", $frmTab);
        // Formular action setzen
        $app->tpl->setVar('form_action',$this->formDef["action"]);
    }
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
/**
* Formularbehandlung
*
* Funktionen zur Umwandlung von Formulardaten
* sowie zum vorbereiten von HTML und SQL
* Ausgaben
*
*    Tabellendefinition
*
*    Datentypen:
*    - INTEGER (Wandelt Ausdrücke in Int um)
*    - DOUBLE
*    - CURRENCY (Formatiert Zahlen nach Währungsnotation)
*    - VARCHAR (kein weiterer Format Check)
*    - DATE (Datumsformat, Timestamp Umwandlung)
*
*    Formtype:
*    - TEXT (normales Textfeld)
*    - PASSWORD (Feldinhalt wird nicht angezeigt)
*    - SELECT (Gibt Werte als option Feld aus)
*    - MULTIPLE (Select-Feld mit nehreren Werten)
*
*    VALUE:
*    - Wert oder Array
*
*    SEPARATOR
*    - Trennzeichen für multiple Felder
*
*    Hinweis:
*    Das ID-Feld ist nicht bei den Table Values einzufügen.
*
* @package form
* @author Till Brehm
* @version 1.1
*/
class form {
    /**
    * Definition der Tabelle (array)
    * @var tableDef
    */
    var $tableDef;
    /**
    * Private
    * @var action
    */
    var $action;
    /**
    * Tabellenname (String)
    * @var table_name
    */
    var $table_name;
    /**
    * Debug Variable
    * @var debug
    */
    var $debug = 0;
    /**
    * name des primary Field der Tabelle (string)
    * @var table_index
    */
    var $table_index;
    /**
    * enthält die Fehlermeldung bei Ãœberprüfung
    * der Variablen mit Regex
    * @var errorMessage
    */
    var $errorMessage;
    var $dateformat = "d.m.Y";
    var $formDef;
    /**
    * Laden der Tabellendefinition
    *
    * @param file: Pfad zur Tabellendefinition
    * @return true
    */
    function loadTableDef($file) {
        global $app,$conf;
        include_once($file);
        $this->tableDef = $table;
        $this->table_name = $table_name;
        $this->table_index = $table_index;
        return true;
    }
    function loadFormDef($file) {
        global $app,$conf;
        include_once($file);
        $this->formDef = $form;
        return true;
    }
    /**
    * Konvertiert die Daten des Ã¼bergebenen assoziativen
    * Arrays in "menschenlesbare" Form.
    * Datentyp Konvertierung, z.B. für Ausgabe in Listen.
    *
    * @param record
    * @return record
    */
    function decode($record) {
        if(is_array($record)) {
            foreach($record as $key => $val) {
                switch ($this->tableDef[$key]['datatype']) {
                case 'VARCHAR':
                    $new_record[$key] = stripslashes($val);
                break;
                case 'DATE':
                    if($val > 0) {
                        $new_record[$key] = date($this->dateformat,$val);
                    }
                break;
                case 'INTEGER':
                    $new_record[$key] = intval($val);
                break;
                case 'DOUBLE':
                    $new_record[$key] = $val;
                break;
                case 'CURRENCY':
                    $new_record[$key] = number_format($val, 2, ',', '');
                break;
                default:
                    $new_record[$key] = stripslashes($val);
                }
            }
        }
    return $new_record;
    }
    /**
    * Record für Ausgabe in Formularen vorbereiten.
    *
    * @param record = Datensatz als Array
    * @param action = NEW oder EDIT
    * @return record
    */
    function getHTML($record,$action = 'NEW') {
        global $app;
        if(!is_array($this->tableDef)) $app->error("Keine Tabellendefinition vorhanden.");
        $new_record = array();
        if($action == 'EDIT') {
            $record = $this->decode($record);
            if(is_array($record)) {
                foreach($record as $key => $val) {
                    switch ($this->tableDef[$key]['formtype']) {
                    case 'SELECT':
                        if(is_array($this->tableDef[$key]['value'])) {
                            $out = '';
                            foreach($this->tableDef[$key]['value'] as $k => $v) {
                                $selected = ($k == $val)?' SELECTED':'';
                                $out .= "<option value='$k'$selected>$v</option>\r\n";
                            }
                        }
                        $new_record[$key] = $out;
                    break;
                    case 'MULTIPLE':
                        if(is_array($this->tableDef[$key]['value'])) {
                            // aufsplitten ergebnisse
                            $vals = explode($this->tableDef[$key]['separator'],$val);
                            // HTML schreiben
                            $out = '';
                            foreach($this->tableDef[$key]['value'] as $k => $v) {
                                $selected = '';
                                foreach($vals as $tvl) {
                                    if(trim($tvl) == trim($k)) $selected = ' SELECTED';
                                }
                                $out .= "<option value='$k'$selected>$v</option>\r\n";
                            }
                        }
                        $new_record[$key] = $out;
                    break;
                    case 'PASSWORD':
                        $new_record[$key] = '';
                    break;
                    default:
                        $new_record[$key] = htmlspecialchars($val);
                    }
                }
            }
        } else {
            foreach($this->tableDef as $key => $val) {
                switch ($this->tableDef[$key]['formtype']) {
                case 'SELECT':
                    if(is_array($this->tableDef[$key]['value'])) {
                        $out = '';
                        foreach($this->tableDef[$key]['value'] as $k => $v) {
                            $selected = ($k == $val)?' SELECTED':'';
                            $out .= "<option value='$k'$selected>$v</option>\r\n";
                        }
                    }
                    $new_record[$key] = $out;
                break;
                case 'MULTIPLE':
                        if(is_array($this->tableDef[$key]['value'])) {
                            // aufsplitten ergebnisse
                            $vals = explode($this->tableDef[$key]['separator'],$val);
                            // HTML schreiben
                            $out = '';
                            foreach($this->tableDef[$key]['value'] as $k => $v) {
                                $out .= "<option value='$k'>$v</option>\r\n";
                            }
                        }
                        $new_record[$key] = $out;
                    break;
                case 'PASSWORD':
                    $new_record[$key] = '';
                break;
                default:
                    $new_record[$key] = htmlspecialchars($this->tableDef[$key]['value']);
                }
            }
        }
        if($this->debug == 1) $this->dbg($new_record);
        return $new_record;
    }
    /**
    * Record in "maschinen lesbares" Format Ã¼berführen
    * und Werte gegen reguläre Ausdrücke prüfen.
    *
    * @param record = Datensatz als Array
    * @return record
    */
    function encode($record) {
        $this->errorMessage = '';
        if(is_array($record)) {
            foreach($record as $key => $val) {
                switch ($this->tableDef[$key]['datatype']) {
                case 'VARCHAR':
                    if(!is_array($val)) {
                        $new_record[$key] = mysql_real_escape_string($val);
                    } else {
                        $new_record[$key] = implode($this->tableDef[$key]['separator'],$val);
                    }
                break;
                case 'DATE':
                    if($val > 0) {
                        list($tag,$monat,$jahr) = explode('.',$val);
                        $new_record[$key] = mktime(0,0,0,$monat,$tag,$jahr);
                    }
                break;
                case 'INTEGER':
                    $new_record[$key] = intval($val);
                break;
                case 'DOUBLE':
                    $new_record[$key] = mysql_real_escape_string($val);
                break;
                case 'CURRENCY':
                    $new_record[$key] = str_replace(",",".",$val);
                break;
                }
                if($this->tableDef[$key]['regex'] != '') {
                    // Enable that "." matches also newlines
                    $this->tableDef[$key]['regex'] .= 's';
                    if(!preg_match($this->tableDef[$key]['regex'], $val)) {
                        $this->errorMessage .= $this->tableDef[$key]['errmsg']."<br>\r\n";
                    }
                }
            }
        }
        return $new_record;
    }
    /**
    * SQL Statement für Record erzeugen.
    *
    * @param record = Datensatz als Array
    * @param action = INSERT oder UPDATE
    * @param primary_id
    * @return record
    */
    function getSQL($record, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '') {
        global $app;
        $record = $this->encode($record);
        $sql_insert_key = '';
        $sql_insert_val = '';
        $sql_update = '';
        if(!is_array($this->tableDef)) $app->error("Keine Tabellendefinition vorhanden.");
        // gehe durch alle Felder des Records
        if(is_array($record)) {
        foreach($record as $key => $val) {
            // Wenn es kein leeres Passwortfeld ist
            if (!($this->tableDef[$key]['formtype'] == 'PASSWORD' and $val == '')) {
                // gehe durch alle Felder der TableDef
                foreach($this->tableDef as $tk => $tv) {
                    // Wenn Feld in TableDef enthalten ist
                    if($tk == $key) {
                        // Erzeuge Insert oder Update Quelltext
                        if($action == "INSERT") {
                            if($this->tableDef[$key]['formtype'] == 'PASSWORD') {
                                $sql_insert_key .= "`$key`, ";
                                $sql_insert_val .= "md5('$val'), ";
                            //} elseif($this->tableDef[$key]['formtype'] == 'MULTIPLE') {
                            //    $val = implode($this->tableDef[$key]['separator'],$val);
                            //    $sql_insert_key .= "`$key`, ";
                            //    $sql_insert_val .= "'$val', ";
                            } else {
                                $sql_insert_key .= "`$key`, ";
                                $sql_insert_val .= "'$val', ";
                            }
                        } else {
                            if($this->tableDef[$key]['formtype'] == 'PASSWORD') {
                                $sql_update .= "`$key` = md5('$val'), ";
                            //} elseif($this->tableDef[$key]['formtype'] == 'MULTIPLE') {
                            //    $val = implode($this->tableDef[$key]['separator'],$val);
                            //    $sql_update .= "`$key` = '$val', ";
                            } else {
                                $sql_update .= "`$key` = '$val', ";
                            }
                        }
                    }
                }
            }
        }
        }
        // Füge Backticks nur bei unvollständigen Tabellennamen ein
        if(stristr($this->table_name,'.')) {
            $escape = '';
        } else {
            $escape = '`';
        }
        if($action == "INSERT") {
            $sql_insert_key = substr($sql_insert_key,0,-2);
            $sql_insert_val = substr($sql_insert_val,0,-2);
            $sql = "INSERT INTO ".$escape.$this->table_name.$escape." ($sql_insert_key) VALUES ($sql_insert_val)";
        } else {
            if($primary_id != 0) {
                $sql_update = substr($sql_update,0,-2);
                $sql = "UPDATE ".$escape.$this->table_name.$escape." SET ".$sql_update." WHERE ".$this->table_index ." = ".$primary_id;
                if($sql_ext_where != '') $sql .= " and ".$sql_ext_where;
            } else {
                $app->error("Primary ID fehlt!");
            }
        }
        return $sql;
    }
    /**
    * Debugging arrays.
    *
    * @param array_data
    */
    function dbg($array_data) {
        echo "<pre>";
        print_r($array_data);
        echo "</pre>";
    }
    function showForm() {
        global $app,$conf;
        if(!is_array($this->formDef)) die("Form Definition wurde nicht geladen.");
        if($this->errorMessage == '') {
            // wenn kein Fehler vorliegt
            if($_REQUEST["next_tab"] != '') {
                // wenn nächster Tab bekannt
                $active_tab = $_REQUEST["next_tab"];
            } else {
                // ansonsten ersten tab nehmen
                $active_tab = $this->formDef["tabs"][0]["name"];
            }
        } else {
            // bei Fehlern den gleichen Tab nochmal anzeigen
            $active_tab = $_SESSION["s"]["form"]["tab"];
        }
        // definiere Tabs
        foreach( $this->formDef["tabs"] as $tab) {
            if($tab["name"] == $active_tab) {
                $app->tpl->setInclude('content_tpl',$tab["template"]);
                $tab["active"] = 1;
                $_SESSION["s"]["form"]["tab"] = $tab["name"];
            } else {
                $tab["active"] = 0;
            }
            $frmTab[] = $tab;
        }
        // setze Loop
        $app->tpl->setLoop("formTab", $frmTab);
        // Formular action setzen
        $app->tpl->setVar('form_action',$this->formDef["action"]);
    }
}
?>
interface/lib/classes/functions.inc.php
@@ -1,111 +1,111 @@
<?php
/*
Copyright (c) 2010, Till Brehm, projektfarm Gmbh
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.
*/
//* The purpose of this library is to provide some general functions.
//* This class is loaded automatically by the ispconfig framework.
class functions {
    public function mail($to, $subject, $text, $from, $filepath = '', $filetype = 'application/pdf', $filename = '') {
        global $app,$conf;
        if($conf['demo_mode'] == true) $app->error("Mail sending disabled in demo mode.");
        if($filepath != '') {
            if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath);
            $content = file_get_contents($filepath);
            $content = chunk_split(base64_encode($content));
            $uid = strtoupper(md5(uniqid(time())));
            if($filename == '') {
                $path_parts = pathinfo($filepath);
                $filename = $path_parts["basename"];
                unset($path_parts);
            }
            $header = "From: $from\nReply-To: $from\n";
            $header .= "MIME-Version: 1.0\n";
            $header .= "Content-Type: multipart/mixed; boundary=$uid\n";
            $header .= "--$uid\n";
            $header .= "Content-Type: text/plain\n";
            $header .= "Content-Transfer-Encoding: 8bit\n\n";
            $header .= "$text\n";
            $header .= "--$uid\n";
            $header .= "Content-Type: $filetype; name=\"$filename\"\n";
            $header .= "Content-Transfer-Encoding: base64\n";
            $header .= "Content-Disposition: attachment; filename=\"$filename\"\n\n";
            $header .= "$content\n";
            $header .= "--$uid--";
            mail($to, $subject, "", $header);
        } else {
            $header = "From: $from\nReply-To: $from\n";
            mail($to, $subject, $text, $header);
        }
        return true;
    }
    public function array_merge($array1,$array2) {
        $out = $array1;
        foreach($array2 as $key => $val) {
            $out[$key] = $val;
        }
        return $out;
    }
    public function currency_format($number) {
        global $app;
        $number_format_decimals = (int)$app->lng('number_format_decimals');
        $number_format_dec_point = $app->lng('number_format_dec_point');
        $number_format_thousands_sep = $app->lng('number_format_thousands_sep');
        if($number_format_thousands_sep == 'number_format_thousands_sep') $number_format_thousands_sep = '';
        return number_format((double)$number, $number_format_decimals, $number_format_dec_point, $number_format_thousands_sep);
    }
    public function get_ispconfig_url() {
        $url = (stristr($_SERVER['SERVER_PROTOCOL'],'HTTPS'))?'https':'http';
        $url .= '://'.$_SERVER['SERVER_NAME'];
        if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
            $url .= ':'.$_SERVER['SERVER_PORT'];
        }
        return $url;
    }
}
<?php
/*
Copyright (c) 2010, Till Brehm, projektfarm Gmbh
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.
*/
//* The purpose of this library is to provide some general functions.
//* This class is loaded automatically by the ispconfig framework.
class functions {
    public function mail($to, $subject, $text, $from, $filepath = '', $filetype = 'application/pdf', $filename = '') {
        global $app,$conf;
        if($conf['demo_mode'] == true) $app->error("Mail sending disabled in demo mode.");
        if($filepath != '') {
            if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath);
            $content = file_get_contents($filepath);
            $content = chunk_split(base64_encode($content));
            $uid = strtoupper(md5(uniqid(time())));
            if($filename == '') {
                $path_parts = pathinfo($filepath);
                $filename = $path_parts["basename"];
                unset($path_parts);
            }
            $header = "From: $from\nReply-To: $from\n";
            $header .= "MIME-Version: 1.0\n";
            $header .= "Content-Type: multipart/mixed; boundary=$uid\n";
            $header .= "--$uid\n";
            $header .= "Content-Type: text/plain\n";
            $header .= "Content-Transfer-Encoding: 8bit\n\n";
            $header .= "$text\n";
            $header .= "--$uid\n";
            $header .= "Content-Type: $filetype; name=\"$filename\"\n";
            $header .= "Content-Transfer-Encoding: base64\n";
            $header .= "Content-Disposition: attachment; filename=\"$filename\"\n\n";
            $header .= "$content\n";
            $header .= "--$uid--";
            mail($to, $subject, "", $header);
        } else {
            $header = "From: $from\nReply-To: $from\n";
            mail($to, $subject, $text, $header);
        }
        return true;
    }
    public function array_merge($array1,$array2) {
        $out = $array1;
        foreach($array2 as $key => $val) {
            $out[$key] = $val;
        }
        return $out;
    }
    public function currency_format($number) {
        global $app;
        $number_format_decimals = (int)$app->lng('number_format_decimals');
        $number_format_dec_point = $app->lng('number_format_dec_point');
        $number_format_thousands_sep = $app->lng('number_format_thousands_sep');
        if($number_format_thousands_sep == 'number_format_thousands_sep') $number_format_thousands_sep = '';
        return number_format((double)$number, $number_format_decimals, $number_format_dec_point, $number_format_thousands_sep);
    }
    public function get_ispconfig_url() {
        $url = (stristr($_SERVER['SERVER_PROTOCOL'],'HTTPS'))?'https':'http';
        $url .= '://'.$_SERVER['SERVER_NAME'];
        if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
            $url .= ':'.$_SERVER['SERVER_PORT'];
        }
        return $url;
    }
}
?>
interface/lib/classes/plugin_base.inc.php
@@ -1,64 +1,64 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
class plugin_base {
    var $plugin_name;
    var $options;
    var $form;
    function onLoad() {
    }
    function onShow() {
    }
    function onInsert() {
    }
    function onUpdate() {
    }
    function onDelete() {
    }
    function setOptions($plugin_name, $options) {
        $this->options = $options;
        $this->plugin_name = $plugin_name;
    }
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
class plugin_base {
    var $plugin_name;
    var $options;
    var $form;
    function onLoad() {
    }
    function onShow() {
    }
    function onInsert() {
    }
    function onUpdate() {
    }
    function onDelete() {
    }
    function setOptions($plugin_name, $options) {
        $this->options = $options;
        $this->plugin_name = $plugin_name;
    }
}
?>
interface/lib/classes/plugin_dbhistory.inc.php
@@ -1,69 +1,69 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
class plugin_dbhistory extends plugin_base {
        var $module;
        var $form;
        var $tab;
        var $record_id;
        var $formdef;
        var $options;
        function onShow() {
            global $app, $conf;
            $content = '';
            $db_table = $app->tform->formDef["db_table"];
            $db_table_idx = $app->tform->formDef["db_table_idx"];
            $primary_id = $this->form->id;
            if($_SESSION["s"]["user"]["typ"] == 'admin') {
                $sql = "SELECT action, tstamp, user, data FROM sys_datalog WHERE dbtable = '".$db_table."' AND dbidx = '".$db_table_idx.":".$primary_id."'";
            } else {
                $sql = "SELECT action, tstamp, user, data FROM sys_datalog WHERE user = '".$_SESSION["s"]["user"]["username"]."' dbtable = '".$db_table."' AND dbidx = '".$db_table_idx.":".$primary_id."'";
            }
            $records = $app->db->queryAllRecords($sql);
            if(is_array($records)) {
                $content .= '<table>';
                foreach($records as $rec) {
                    $content .= "<tr><td>".date("d.m.Y",$rec["tstamp"])."</td><td>".$rec["user"]."</td></tr>";
                }
                $content .= '</table>';
            }
            return $content;
        }
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
class plugin_dbhistory extends plugin_base {
        var $module;
        var $form;
        var $tab;
        var $record_id;
        var $formdef;
        var $options;
        function onShow() {
            global $app, $conf;
            $content = '';
            $db_table = $app->tform->formDef["db_table"];
            $db_table_idx = $app->tform->formDef["db_table_idx"];
            $primary_id = $this->form->id;
            if($_SESSION["s"]["user"]["typ"] == 'admin') {
                $sql = "SELECT action, tstamp, user, data FROM sys_datalog WHERE dbtable = '".$db_table."' AND dbidx = '".$db_table_idx.":".$primary_id."'";
            } else {
                $sql = "SELECT action, tstamp, user, data FROM sys_datalog WHERE user = '".$_SESSION["s"]["user"]["username"]."' dbtable = '".$db_table."' AND dbidx = '".$db_table_idx.":".$primary_id."'";
            }
            $records = $app->db->queryAllRecords($sql);
            if(is_array($records)) {
                $content .= '<table>';
                foreach($records as $rec) {
                    $content .= "<tr><td>".date("d.m.Y",$rec["tstamp"])."</td><td>".$rec["user"]."</td></tr>";
                }
                $content .= '</table>';
            }
            return $content;
        }
}
?>
interface/lib/classes/remoting.inc.php
Diff too large
interface/lib/classes/session.inc.php
@@ -1,129 +1,129 @@
<?php
/*
Copyright (c) 2010, Till Brehm, projektfarm Gmbh
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.
*/
class session {
    private $session_array = array();
    private $db;
    function __construct() {
        $this->db = new db;
    }
    function open ($save_path, $session_name) {
        return true;
    }
    function close () {
        if (!empty($this->session_array)) {
            $result = $this->gc(ini_get('session.gc_maxlifetime'));
            return $result;
        }
        return false;
    }
    function read ($session_id) {
        $rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = '".$this->db->quote($session_id)."'");
        if (is_array($rec)) {
            $this->session_array = $rec;
            return $this->session_array['session_data'];
        } else {
            return '';
        }
    }
    function write ($session_id, $session_data) {
        if (!empty($this->session_array) && $this->session_array['session_id'] != $session_id) {
            $this->session_array = array();
        }
        // Dont write session_data to DB if session data has not been changed after reading it.
        if(isset($this->session_array['session_data']) && $this->session_array['session_data'] != '' && $this->session_array['session_data'] == $session_data) {
            $session_id   = $this->db->quote($session_id);
            $last_updated = date('Y-m-d H:i:s');
            $this->db->query("UPDATE sys_session SET last_updated = '$last_updated' WHERE session_id = '$session_id'");
            return true;
        }
        if ($this->session_array['session_id'] == '') {
            $session_id   = $this->db->quote($session_id);
            $date_created = date('Y-m-d H:i:s');
            $last_updated = date('Y-m-d H:i:s');
            $session_data = $this->db->quote($session_data);
            $sql = "INSERT INTO sys_session (session_id,date_created,last_updated,session_data) VALUES ('$session_id','$date_created','$last_updated','$session_data')";
            $this->db->query($sql);
        } else {
            $session_id   = $this->db->quote($session_id);
            $last_updated = date('Y-m-d H:i:s');
            $session_data = $this->db->quote($session_data);
            $sql = "UPDATE sys_session SET last_updated = '$last_updated', session_data = '$session_data' WHERE session_id = '$session_id'";
            $this->db->query($sql);
        }
        return true;
    }
    function destroy ($session_id) {
        $session_id   = $this->db->quote($session_id);
        $sql = "DELETE FROM sys_session WHERE session_id = '$session_id'";
        $this->db->query($sql);
        return true;
    }
    function gc ($max_lifetime) {
        $real_now = date('Y-m-d H:i:s');
        $dt1 = strtotime("$real_now -$max_lifetime seconds");
        $dt2 = date('Y-m-d H:i:s', $dt1);
        $sql = "DELETE FROM sys_session WHERE last_updated < '$dt2'";
        $this->db->query($sql);
        return true;
    }
    function __destruct () {
        @session_write_close();
    }
}
<?php
/*
Copyright (c) 2010, Till Brehm, projektfarm Gmbh
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.
*/
class session {
    private $session_array = array();
    private $db;
    function __construct() {
        $this->db = new db;
    }
    function open ($save_path, $session_name) {
        return true;
    }
    function close () {
        if (!empty($this->session_array)) {
            $result = $this->gc(ini_get('session.gc_maxlifetime'));
            return $result;
        }
        return false;
    }
    function read ($session_id) {
        $rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = '".$this->db->quote($session_id)."'");
        if (is_array($rec)) {
            $this->session_array = $rec;
            return $this->session_array['session_data'];
        } else {
            return '';
        }
    }
    function write ($session_id, $session_data) {
        if (!empty($this->session_array) && $this->session_array['session_id'] != $session_id) {
            $this->session_array = array();
        }
        // Dont write session_data to DB if session data has not been changed after reading it.
        if(isset($this->session_array['session_data']) && $this->session_array['session_data'] != '' && $this->session_array['session_data'] == $session_data) {
            $session_id   = $this->db->quote($session_id);
            $last_updated = date('Y-m-d H:i:s');
            $this->db->query("UPDATE sys_session SET last_updated = '$last_updated' WHERE session_id = '$session_id'");
            return true;
        }
        if ($this->session_array['session_id'] == '') {
            $session_id   = $this->db->quote($session_id);
            $date_created = date('Y-m-d H:i:s');
            $last_updated = date('Y-m-d H:i:s');
            $session_data = $this->db->quote($session_data);
            $sql = "INSERT INTO sys_session (session_id,date_created,last_updated,session_data) VALUES ('$session_id','$date_created','$last_updated','$session_data')";
            $this->db->query($sql);
        } else {
            $session_id   = $this->db->quote($session_id);
            $last_updated = date('Y-m-d H:i:s');
            $session_data = $this->db->quote($session_data);
            $sql = "UPDATE sys_session SET last_updated = '$last_updated', session_data = '$session_data' WHERE session_id = '$session_id'";
            $this->db->query($sql);
        }
        return true;
    }
    function destroy ($session_id) {
        $session_id   = $this->db->quote($session_id);
        $sql = "DELETE FROM sys_session WHERE session_id = '$session_id'";
        $this->db->query($sql);
        return true;
    }
    function gc ($max_lifetime) {
        $real_now = date('Y-m-d H:i:s');
        $dt1 = strtotime("$real_now -$max_lifetime seconds");
        $dt2 = date('Y-m-d H:i:s', $dt1);
        $sql = "DELETE FROM sys_session WHERE last_updated < '$dt2'";
        $this->db->query($sql);
        return true;
    }
    function __destruct () {
        @session_write_close();
    }
}
?>
interface/lib/classes/tpl_cache.inc.php
@@ -1,186 +1,186 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4.0                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002 Active Fish Group                                 |
// +----------------------------------------------------------------------+
// | Authors: Kelvin Jones <kelvin@kelvinjones.co.uk>                     |
// +----------------------------------------------------------------------+
//
// $Id: cache.php,v 1.1 2003/07/08 12:32:06 platinum Exp $
/**
 * Class uses all of vlibTemplate's functionality but caches the template files.
 * It creates an identical tree structure to your filesystem but with cached files.
 *
 * @author Kelvin Jones <kelvin@kelvinjones.co.uk>
 * @since 22/02/2002
 * @package vLIB
 * @access public
 */
class tplc extends tpl {
/*-----------------------------------------------------------------------------\
|     DO NOT TOUCH ANYTHING IN THIS CLASS, IT MAY NOT WORK OTHERWISE           |
\-----------------------------------------------------------------------------*/
    var $_cache = 1;     // tells vlibTemplate that we're caching
    var $_cachefile;     // full path to current cache file (even if it doesn't yet exist)
    var $_cacheexists;   // has this file been cached before
    var $_cachefilelocked; // is this file currently locked whilst writing
    var $_cachefiledir;  // dir of current cache file
    var $_clearcache = 0;
    /**
     * FUNCTION: clearCache
     * will unset a file, and set $this->_cacheexists to 0.
     *
     * @access public
     * @return boolean
     */
    function clearCache() {
        $this->_clearcache = 1;
        return true;
    }
    /**
     * FUNCTION: recache
     * alias for clearCache().
     *
     * @access public
     * @return boolean
     */
    function recache() {
        return $this->clearCache();
    }
    /**
     * FUNCTION: setCacheLifeTime
     * sets the lifetime of the cached file
     *
     * @param int $int number of seconds to set lifetime to
     * @access public
     * @return boolean
     */
    function setCacheLifeTime($int = null) {
        if ($int == null || !is_int($int)) return false;
        if ($int == 0) $int = 60;
        if ($int == -1) $int = 157680000; // set to 5 yrs time
        $this->OPTIONS['CACHE_LIFETIME'] = $int;
        return true;
    }
    /**
     * FUNCTION: setCacheExtension
     * sets the extention of the cache file
     *
     * @param str $str name of new cache extention
     * @access public
     * @return boolean
     */
    function setCacheExtension($str = null) {
        if ($str == null || !preg_match('/^[a-z0-9]+$/', strtolower($str))) return false;
        $this->OPTIONS['CACHE_EXTENSION'] = strtolower($str);
        return true;
    }
/*----------------------------------------\
          Private Functions
-----------------------------------------*/
    /**
     * FUNCTION: _checkCache
     * checks if there's a cache, if there is then it will read the cache file as the template.
     */
    function _checkCache ($tmplfile) {
        $this->_cachefile = $this->_getFilename($tmplfile);
        if ($this->_clearcache) {
            if (file_exists($this->_cachefile)) unlink($this->_cachefile);
            return false;
        }
        if (file_exists($this->_cachefile)) {
            $this->_cacheexists = 1;
            // if it's expired
            if ((filemtime($this->_cachefile) + $this->OPTIONS['CACHE_LIFETIME']) < date ('U')
                  || filectime($this->_cachefile) < filemtime($tmplfile)) {
                $this->_cacheexists = 0;
                return false; // so that we know to recache
            }
            else {
                return true;
            }
        } else {
            $this->_cacheexists = 0;
            return false;
        }
    }
    /**
     * FUNCTION: _getFilename
     * gets the full pathname for the cached file
     *
     */
    function _getFilename($tmplfile) {
        return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION'];
    }
    /**
     * FUNCTION: _createCache
     * creates the cached file
     *
     */
    function _createCache($data) {
        $cache_file = $this->_cachefile;
        if(!$this->_prepareDirs($cache_file)) return false; // prepare all of the directories
        $f = fopen ($cache_file, "w");
        flock($f, 2); // set an EXclusive lock
        if (!$f) vlibTemplateError::raiseError('VT_ERROR_NO_CACHE_WRITE',KILL,$cache_file);
        fputs ($f, $data); // write the parsed string from vlibTemplate
        flock($f, 3); // UNlock file
        fclose ($f);
        touch ($cache_file);
        return true;
    }
    /**
     * FUNCTION: _prepareDirs
     * prepares the directory structure
     *
     */
    function _prepareDirs($file) {
        if (empty($file)) die('no filename'); //do error in future
        $filepath = dirname($file);
        if (is_dir($filepath)) return true;
        $dirs = preg_split('/[\\/]/', $filepath);
        $currpath;
        foreach ($dirs as $dir) {
            $currpath .= $dir .'/';
            $type = @filetype($currpath);
            ($type=='link') and $type = 'dir';
            if ($type != 'dir' && $type != false && !empty($type)) {
                vlibTemplateError::raiseError('VT_ERROR_WRONG_CACHE_TYPE',KILL,'directory: '.$currpath.', type: '.$type);
            }
            if ($type == 'dir') {
                continue;
            }
            else {
                $s = @mkdir($currpath, 0775);
                if (!$s) vlibTemplateError::raiseError('VT_ERROR_CACHE_MKDIR_FAILURE',KILL,'directory: '.$currpath);
            }
        }
        return true;
    }
} // -- end vlibTemplateCache class
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4.0                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002 Active Fish Group                                 |
// +----------------------------------------------------------------------+
// | Authors: Kelvin Jones <kelvin@kelvinjones.co.uk>                     |
// +----------------------------------------------------------------------+
//
// $Id: cache.php,v 1.1 2003/07/08 12:32:06 platinum Exp $
/**
 * Class uses all of vlibTemplate's functionality but caches the template files.
 * It creates an identical tree structure to your filesystem but with cached files.
 *
 * @author Kelvin Jones <kelvin@kelvinjones.co.uk>
 * @since 22/02/2002
 * @package vLIB
 * @access public
 */
class tplc extends tpl {
/*-----------------------------------------------------------------------------\
|     DO NOT TOUCH ANYTHING IN THIS CLASS, IT MAY NOT WORK OTHERWISE           |
\-----------------------------------------------------------------------------*/
    var $_cache = 1;     // tells vlibTemplate that we're caching
    var $_cachefile;     // full path to current cache file (even if it doesn't yet exist)
    var $_cacheexists;   // has this file been cached before
    var $_cachefilelocked; // is this file currently locked whilst writing
    var $_cachefiledir;  // dir of current cache file
    var $_clearcache = 0;
    /**
     * FUNCTION: clearCache
     * will unset a file, and set $this->_cacheexists to 0.
     *
     * @access public
     * @return boolean
     */
    function clearCache() {
        $this->_clearcache = 1;
        return true;
    }
    /**
     * FUNCTION: recache
     * alias for clearCache().
     *
     * @access public
     * @return boolean
     */
    function recache() {
        return $this->clearCache();
    }
    /**
     * FUNCTION: setCacheLifeTime
     * sets the lifetime of the cached file
     *
     * @param int $int number of seconds to set lifetime to
     * @access public
     * @return boolean
     */
    function setCacheLifeTime($int = null) {
        if ($int == null || !is_int($int)) return false;
        if ($int == 0) $int = 60;
        if ($int == -1) $int = 157680000; // set to 5 yrs time
        $this->OPTIONS['CACHE_LIFETIME'] = $int;
        return true;
    }
    /**
     * FUNCTION: setCacheExtension
     * sets the extention of the cache file
     *
     * @param str $str name of new cache extention
     * @access public
     * @return boolean
     */
    function setCacheExtension($str = null) {
        if ($str == null || !preg_match('/^[a-z0-9]+$/', strtolower($str))) return false;
        $this->OPTIONS['CACHE_EXTENSION'] = strtolower($str);
        return true;
    }
/*----------------------------------------\
          Private Functions
-----------------------------------------*/
    /**
     * FUNCTION: _checkCache
     * checks if there's a cache, if there is then it will read the cache file as the template.
     */
    function _checkCache ($tmplfile) {
        $this->_cachefile = $this->_getFilename($tmplfile);
        if ($this->_clearcache) {
            if (file_exists($this->_cachefile)) unlink($this->_cachefile);
            return false;
        }
        if (file_exists($this->_cachefile)) {
            $this->_cacheexists = 1;
            // if it's expired
            if ((filemtime($this->_cachefile) + $this->OPTIONS['CACHE_LIFETIME']) < date ('U')
                  || filectime($this->_cachefile) < filemtime($tmplfile)) {
                $this->_cacheexists = 0;
                return false; // so that we know to recache
            }
            else {
                return true;
            }
        } else {
            $this->_cacheexists = 0;
            return false;
        }
    }
    /**
     * FUNCTION: _getFilename
     * gets the full pathname for the cached file
     *
     */
    function _getFilename($tmplfile) {
        return $this->OPTIONS['CACHE_DIRECTORY'].'/'.md5('vlibCachestaR'.realpath($tmplfile)).'.'.$this->OPTIONS['CACHE_EXTENSION'];
    }
    /**
     * FUNCTION: _createCache
     * creates the cached file
     *
     */
    function _createCache($data) {
        $cache_file = $this->_cachefile;
        if(!$this->_prepareDirs($cache_file)) return false; // prepare all of the directories
        $f = fopen ($cache_file, "w");
        flock($f, 2); // set an EXclusive lock
        if (!$f) vlibTemplateError::raiseError('VT_ERROR_NO_CACHE_WRITE',KILL,$cache_file);
        fputs ($f, $data); // write the parsed string from vlibTemplate
        flock($f, 3); // UNlock file
        fclose ($f);
        touch ($cache_file);
        return true;
    }
    /**
     * FUNCTION: _prepareDirs
     * prepares the directory structure
     *
     */
    function _prepareDirs($file) {
        if (empty($file)) die('no filename'); //do error in future
        $filepath = dirname($file);
        if (is_dir($filepath)) return true;
        $dirs = preg_split('/[\\/]/', $filepath);
        $currpath;
        foreach ($dirs as $dir) {
            $currpath .= $dir .'/';
            $type = @filetype($currpath);
            ($type=='link') and $type = 'dir';
            if ($type != 'dir' && $type != false && !empty($type)) {
                vlibTemplateError::raiseError('VT_ERROR_WRONG_CACHE_TYPE',KILL,'directory: '.$currpath.', type: '.$type);
            }
            if ($type == 'dir') {
                continue;
            }
            else {
                $s = @mkdir($currpath, 0775);
                if (!$s) vlibTemplateError::raiseError('VT_ERROR_CACHE_MKDIR_FAILURE',KILL,'directory: '.$currpath);
            }
        }
        return true;
    }
} // -- end vlibTemplateCache class
?>
interface/lib/classes/tpl_error.inc.php
@@ -1,92 +1,92 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4.0                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002 Active Fish Group                                 |
// +----------------------------------------------------------------------+
// | Authors: Kelvin Jones <kelvin@kelvinjones.co.uk>                     |
// +----------------------------------------------------------------------+
//
// $Id: error.php,v 1.1 2003/07/08 12:32:06 platinum Exp $
define('FATAL',   E_USER_ERROR);
define('WARNING', E_USER_WARNING);
define('NOTICE',  E_USER_NOTICE);
define('KILL',    -1); // used for killing inside parsing.
/**
 * Class is used by vlibTemplate.
 * It handles all of the error reporting for vlibTemplate.
 *
 * @author Kelvin Jones <kelvin@kelvinjones.co.uk>
 * @since 06/03/2002
 * @package vLIB
 * @access private
 */
class vlibTemplateError {
/*-----------------------------------------------------------------------------\
|     DO NOT TOUCH ANYTHING IN THIS CLASS IT MAY NOT WORK OTHERWISE            |
\-----------------------------------------------------------------------------*/
    function raiseError ($code, $level = null, $extra=null) {
        if (!($level & error_reporting())&& $level != KILL) return; // binary AND checks for reporting level
        $error_codes = array(
                        'VT_ERROR_NOFILE'               => 'vlibTemplate Error: Template ('.$extra.') file not found.',
                        'VT_ERROR_PARSE'                => 'vlibTemplate Error: Parse error!<br />To debug this file, use vlibTemplateDebug instead of vlibTemplate in the class instantiation(i.e. new vlibTemplateDebug).',
                        'VT_NOTICE_INVALID_TAG'         => 'vlibTemplate Notice: Invalid tag ('.$extra.').',
                        'VT_ERROR_INVALID_TAG'          => 'vlibTemplate Error: Invalid tag ('.$extra.'). To disable this you must turn of the STRICT option.',
                        'VT_NOTICE_INVALID_ATT'         => 'vlibTemplate Notice: Invalid attribute ('.$extra.').',
                        'VT_WARNING_INVALID_ARR'        => 'vlibTemplate Warning: Invalid loop structure passed to vlibTemplate::setLoop() (loop name: '.$extra.').',
                        'VT_ERROR_INVALID_ERROR_CODE'   => 'vlibTemplate Error: Invalid error raised.',
                        'VT_ERROR_WRONG_NO_PARAMS'      => 'vlibTemplate Warning: Wrond parameter count passed to '.$extra.'.',
                        'VT_ERROR_UNKNOWN_VAR'          => 'vlibTemplate Error: template var not found.',
                        'VT_ERROR_NO_CACHE_WRITE'       => 'vlibTemplate Error: unable to write to cache file ('.$extra.').',
                        'VT_ERROR_WRONG_CACHE_TYPE'     => 'vlibTemplate Error: non-directory file found in cache root with same name as directory ('.$extra.').',
                        'VT_ERROR_CACHE_MKDIR_FAILURE'  => 'vlibTemplate Error: failed to create directory in cache root ('.$extra.').',
                        'VT_WARNING_NOT_CACHE_OBJ'      => 'vlibTemplate Warning: called a vlibTemplateCache function ('.$extra.') without instantiating the vlibTemplateCache class.',
                        'VT_WARNING_LOOP_NOT_SET'       => 'vlibTemplate Warning: called vlibTemplate::addRow() or vlibTemplate::addLoop() with an invalid loop name.',
                        'VT_WARNING_INVALID_RESOURCE'   => 'vlibTemplate Warning: Invalid resource type passed to vlibTemplate::setDbLoop() for Db "'.$extra.'".',
                        'VT_WARNING_INVALID_LOOP_DB'    => 'vlibTemplate Warning: Invalid Db type passed to vlibTemplate::setDbLoop(), "'.$extra.'" not currently available.',
                        'VT_WARNING_INVALID_IF_OP'      => 'vlibTemplate Warning: The Operator "'.$extra.'" is not supported by vlibTemplate.'
                            );
        $error_levels = array(
                        'VT_ERROR_NOFILE'               => FATAL,
                        'VT_ERROR_PARSE'                => FATAL,
                        'VT_NOTICE_INVALID_TAG'         => NOTICE,
                        'VT_ERROR_INVALID_TAG'          => FATAL,
                        'VT_NOTICE_INVALID_ATT'         => NOTICE,
                        'VT_WARNING_INVALID_ARR'        => WARNING,
                        'VT_ERROR_INVALID_ERROR_CODE'   => FATAL,
                        'VT_ERROR_WRONG_NO_PARAMS'      => WARNING,
                        'VT_ERROR_UNKNOWN_VAR'          => WARNING,
                        'VT_ERROR_NO_CACHE_WRITE'       => KILL,
                        'VT_ERROR_WRONG_CACHE_TYPE'     => KILL,
                        'VT_ERROR_CACHE_MKDIR_FAILURE'  => KILL,
                        'VT_WARNING_NOT_CACHE_OBJ'      => WARNING,
                        'VT_WARNING_LOOP_NOT_SET'       => WARNING,
                        'VT_WARNING_INVALID_RESOURCE'   => WARNING,
                        'VT_WARNING_INVALID_LOOP_DB'    => WARNING,
                        'VT_WARNING_INVALID_IF_OP'      => WARNING
                            );
        ($level === null) and $level = $error_levels[$code];
        if ($level == KILL) {
            die ($error_codes[$code]);
        }
        if ($msg = $error_codes[$code]) {
            trigger_error($msg, $level);
        } else {
            $level = $error_levels['VT_ERROR_INVALID_ERROR_CODE'];
            $msg = $error_codes['VT_ERROR_INVALID_ERROR_CODE'];
            trigger_error($msg, $level);
        }
        return;
    }
}
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 4.0                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2002 Active Fish Group                                 |
// +----------------------------------------------------------------------+
// | Authors: Kelvin Jones <kelvin@kelvinjones.co.uk>                     |
// +----------------------------------------------------------------------+
//
// $Id: error.php,v 1.1 2003/07/08 12:32:06 platinum Exp $
define('FATAL',   E_USER_ERROR);
define('WARNING', E_USER_WARNING);
define('NOTICE',  E_USER_NOTICE);
define('KILL',    -1); // used for killing inside parsing.
/**
 * Class is used by vlibTemplate.
 * It handles all of the error reporting for vlibTemplate.
 *
 * @author Kelvin Jones <kelvin@kelvinjones.co.uk>
 * @since 06/03/2002
 * @package vLIB
 * @access private
 */
class vlibTemplateError {
/*-----------------------------------------------------------------------------\
|     DO NOT TOUCH ANYTHING IN THIS CLASS IT MAY NOT WORK OTHERWISE            |
\-----------------------------------------------------------------------------*/
    function raiseError ($code, $level = null, $extra=null) {
        if (!($level & error_reporting())&& $level != KILL) return; // binary AND checks for reporting level
        $error_codes = array(
                        'VT_ERROR_NOFILE'               => 'vlibTemplate Error: Template ('.$extra.') file not found.',
                        'VT_ERROR_PARSE'                => 'vlibTemplate Error: Parse error!<br />To debug this file, use vlibTemplateDebug instead of vlibTemplate in the class instantiation(i.e. new vlibTemplateDebug).',
                        'VT_NOTICE_INVALID_TAG'         => 'vlibTemplate Notice: Invalid tag ('.$extra.').',
                        'VT_ERROR_INVALID_TAG'          => 'vlibTemplate Error: Invalid tag ('.$extra.'). To disable this you must turn of the STRICT option.',
                        'VT_NOTICE_INVALID_ATT'         => 'vlibTemplate Notice: Invalid attribute ('.$extra.').',
                        'VT_WARNING_INVALID_ARR'        => 'vlibTemplate Warning: Invalid loop structure passed to vlibTemplate::setLoop() (loop name: '.$extra.').',
                        'VT_ERROR_INVALID_ERROR_CODE'   => 'vlibTemplate Error: Invalid error raised.',
                        'VT_ERROR_WRONG_NO_PARAMS'      => 'vlibTemplate Warning: Wrond parameter count passed to '.$extra.'.',
                        'VT_ERROR_UNKNOWN_VAR'          => 'vlibTemplate Error: template var not found.',
                        'VT_ERROR_NO_CACHE_WRITE'       => 'vlibTemplate Error: unable to write to cache file ('.$extra.').',
                        'VT_ERROR_WRONG_CACHE_TYPE'     => 'vlibTemplate Error: non-directory file found in cache root with same name as directory ('.$extra.').',
                        'VT_ERROR_CACHE_MKDIR_FAILURE'  => 'vlibTemplate Error: failed to create directory in cache root ('.$extra.').',
                        'VT_WARNING_NOT_CACHE_OBJ'      => 'vlibTemplate Warning: called a vlibTemplateCache function ('.$extra.') without instantiating the vlibTemplateCache class.',
                        'VT_WARNING_LOOP_NOT_SET'       => 'vlibTemplate Warning: called vlibTemplate::addRow() or vlibTemplate::addLoop() with an invalid loop name.',
                        'VT_WARNING_INVALID_RESOURCE'   => 'vlibTemplate Warning: Invalid resource type passed to vlibTemplate::setDbLoop() for Db "'.$extra.'".',
                        'VT_WARNING_INVALID_LOOP_DB'    => 'vlibTemplate Warning: Invalid Db type passed to vlibTemplate::setDbLoop(), "'.$extra.'" not currently available.',
                        'VT_WARNING_INVALID_IF_OP'      => 'vlibTemplate Warning: The Operator "'.$extra.'" is not supported by vlibTemplate.'
                            );
        $error_levels = array(
                        'VT_ERROR_NOFILE'               => FATAL,
                        'VT_ERROR_PARSE'                => FATAL,
                        'VT_NOTICE_INVALID_TAG'         => NOTICE,
                        'VT_ERROR_INVALID_TAG'          => FATAL,
                        'VT_NOTICE_INVALID_ATT'         => NOTICE,
                        'VT_WARNING_INVALID_ARR'        => WARNING,
                        'VT_ERROR_INVALID_ERROR_CODE'   => FATAL,
                        'VT_ERROR_WRONG_NO_PARAMS'      => WARNING,
                        'VT_ERROR_UNKNOWN_VAR'          => WARNING,
                        'VT_ERROR_NO_CACHE_WRITE'       => KILL,
                        'VT_ERROR_WRONG_CACHE_TYPE'     => KILL,
                        'VT_ERROR_CACHE_MKDIR_FAILURE'  => KILL,
                        'VT_WARNING_NOT_CACHE_OBJ'      => WARNING,
                        'VT_WARNING_LOOP_NOT_SET'       => WARNING,
                        'VT_WARNING_INVALID_RESOURCE'   => WARNING,
                        'VT_WARNING_INVALID_LOOP_DB'    => WARNING,
                        'VT_WARNING_INVALID_IF_OP'      => WARNING
                            );
        ($level === null) and $level = $error_levels[$code];
        if ($level == KILL) {
            die ($error_codes[$code]);
        }
        if ($msg = $error_codes[$code]) {
            trigger_error($msg, $level);
        } else {
            $level = $error_levels['VT_ERROR_INVALID_ERROR_CODE'];
            $msg = $error_codes['VT_ERROR_INVALID_ERROR_CODE'];
            trigger_error($msg, $level);
        }
        return;
    }
}
?>
interface/lib/classes/validate_dns.inc.php
@@ -1,287 +1,287 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
/*
    DNS validation
*/
class validate_dns {
function validate_field($field, $area, $zoneid, $wildcard_allowed = 1){
  //$desc: Name, Data, RP mbox, RP txtref, SRV target, Zone origin, Name server, Admin email
  global $app, $conf;
  switch ($area) {
  case "Name":
    $desc = $app->tform->wordbook['name_txt'];
    break;
  case "Data":
    $desc = $app->tform->wordbook['data_txt'];
    break;
  case "RP mbox":
    $desc = $app->tform->wordbook['rp_mbox_txt'];
    break;
  case "RP txtref":
    $desc = $app->tform->wordbook['rp_txtref_txt'];
    break;
  case "SRV target":
    $desc = $app->tform->wordbook['srv_target_txt'];
    break;
  case "Zone origin":
    $desc = $app->tform->wordbook['zone_origin_txt'];
    break;
  case "Name server":
    $desc = $app->tform->wordbook['ns_txt'];
    break;
  case "Admin email":
    $desc = $app->tform->wordbook['mbox_txt'];
    break;
  }
  $error = '';
  $valid_characters = "*ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_";
  if(strlen($field) > 255) $error .= $desc." ".$app->tform->wordbook['error_255_characters']."<br>\r\n";
  $parts = explode(".", $field);
  $i = 0;
  $empty = 0;
  foreach ($parts as $part){
    $i++;
    if(trim($part) == '') $empty += 1;
    if(strlen($part) > 63) $error .= $desc." ".$app->tform->wordbook['error_63_characters']."<br>\r\n";
    if(strspn($part, $valid_characters) != strlen($part)) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
    if(substr($part, 0, 1) == '-') $error .= $desc." ".$app->tform->wordbook['error_hyphen_begin']."<br>\r\n";
    if(substr($part, -1) == '-') $error .= $desc." ".$app->tform->wordbook['error_hyphen_end']."<br>\r\n";
    if(strstr($part, "*")){
      if($wildcard_allowed){
        if($i != 1) $error .= $desc." ".$app->tform->wordbook['error_wildcard_non_initial_part']."<br>\r\n";
        if($part != "*") $error .= $desc." ".$app->tform->wordbook['error_wildcard_mix']."<br>\r\n";
      } else {
        $error .= $desc." ".$app->tform->wordbook['error_no_wildcard_allowed']."<br>\r\n";
      }
    }
  }
  if(substr($field, -1) == '.'){
    if($i > 2 && $empty > 1) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
  } else {
    if($empty > 0 && $field != '') $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
  }
  if(substr($field, -1) == '.' && $area == 'Name'){
    $soa = $app->db->queryOneRecord("SELECT * FROM soa WHERE id = ".$zoneid);
    if(substr($field, (strlen($field) - strlen($soa['origin']))) != $soa['origin']) $error .= $desc." ".$app->tform->wordbook['error_out_of_zone']."<br>\r\n";
  }
  return $error;
}
function validate_rp_data(&$data, $zoneid){
  global $app, $conf;
  $error = '';
  $fields = explode(" ", trim($data));
  if(count($fields) != 2) return $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_invalid_rp']."<br>\r\n";
  $mbox = $fields[0];
  $txtref = $fields[1];
  $error .= $this->validate_field($mbox, 'RP mbox', $zoneid, 0);
  $error .= $this->validate_field($txtref, 'RP txtref', $zoneid, 0);
  $data = $mbox." ".$txtref;
  return $error;
}
function validate_srv_data(&$data, $zoneid){
  global $app, $conf;
  $error = '';
  $fields = explode(" ", trim($data));
  if(count($fields) != 3) return $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_invalid_srv']."<br>\r\n";
  $weight = $fields[0];
  $port = $fields[1];
  $target = $fields[2];
  if($weight < 0 || $weight > 65535) $error .= $app->tform->wordbook['weight_txt']." (\"<i>" . htmlentities($weight,ENT_QUOTES,$conf["html_content_encoding"])."</i>\") ".$app->tform->wordbook['error_srv_out_of_range']."<br>\r\n";
  if($port < 0 || $port > 65535) $error .= $app->tform->wordbook['port_txt']." (\"<i>".htmlentities($port,ENT_QUOTES,$conf["html_content_encoding"])."</i>\") ".$app->tform->wordbook['error_srv_out_of_range']."<br>\r\n";
  $error .= $this->validate_field($target, "SRV target", $zoneid, 0);
  $data = (int)$weight." ".(int)$port." ".$target;
  return $error;
}
function is_integer($value, $fieldname, $zero_allowed = 0){
  global $app, $conf;
  $error = '';
  if(intval($value) != $value || !is_numeric($value)) $error .= $fieldname." ".$app->tform->wordbook['error_must_be_integer']."<br>\r\n";
  if($value > 2147483647) $error .= $fieldname." ".$app->tform->wordbook['error_must_not_be_greater_than_2147483647']."<br>\r\n";
  if(!$zero_allowed){
    if($value <= 0) $error .= $fieldname." ".$app->tform->wordbook['error_must_be_positive']."<br>\r\n";
  } else {
    if($value < 0) $error .= $fieldname." ".$app->tform->wordbook['error_must_not_be_negative']."<br>\r\n";
  }
  return $error;
}
function validate_rr(&$rr){
  global $app, $conf;
  $error = '';
  $tmp_rr = $rr;
  foreach($tmp_rr as $key => $val){
    $rr[$key] = trim($val);
  }
  unset($tmp_rr);
  $error .= $this->validate_field($rr['name'], 'Name', $rr['zone'], 1);
  switch ($rr['type']) {
  case "A":
    $ip_parts = explode(".", $rr['data']);
    if(count($ip_parts) != 4){
      $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_a']."<br>\r\n";
    } else {
      for($n = 0; $n < 4; $n++){
        $q = $ip_parts[$n];
        if(!is_numeric($q) || (int)$q < 0 || (int)$q > 255 || trim($q) !== $q) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_a']."<br>\r\n";
      }
    }
    $rr['data'] = (int)$ip_parts[0].".".(int)$ip_parts[1].".".(int)$ip_parts[2].".".(int)$ip_parts[3];
    break;
  case "AAAA":
    $valid_chars = "ABCDEFabcdef1234567890:";
    if(strspn($rr['data'], $valid_chars) != strlen($rr['data'])) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_aaaa']."<br>\r\n";
    break;
  case "ALIAS":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    break;
  case "CNAME":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    break;
  case "HINFO":
    if(!strchr($rr['data'], ' ')) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_hinfo']."<br>\r\n";
    break;
  case "MX":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    $error .= $this->is_integer($rr['aux'], $app->tform->wordbook['aux_txt'], 1);
    break;
  case "NS":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    break;
  case "PTR":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    if(substr($rr['data'], -1) != '.') $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_ptr']."<br>\r\n";
    break;
  case "RP":
    $error .= $this->validate_rp_data($rr['data'], $rr['zone']);
    break;
  case "SRV":
    $error .= $this->validate_srv_data($rr['data'], $rr['zone']);
    $error .= $this->is_integer($rr['aux'], $app->tform->wordbook['aux_txt'], 1);
    break;
  case "TXT":
    break;
  }
  $error .= $this->is_integer($rr['ttl'], $app->tform->wordbook['ttl_txt']);
  return $error;
}
function validate_soa(&$soa){
  global $app, $conf;
  $error = '';
  $tmp_soa = $soa;
  foreach($tmp_soa as $key => $val){
    if($key != 'active') $soa[$key] = trim($val);
  }
  unset($tmp_soa);
  if($soa['origin'] == '') $error .= $app->tform->wordbook['origin_txt']." ".$app->tform->wordbook['error_empty']."<br>\r\n";
  if(substr($soa['origin'], -1) != '.') $error .= $app->tform->wordbook['origin_txt']." ".$app->tform->wordbook['error_dot']."<br>\r\n";
  $error .= $this->validate_field($soa['origin'], "Zone origin", $soa['id'], 0);
  $error .= $this->is_integer($soa['ttl'], $app->tform->wordbook['ttl_txt']);
  if($soa['ns'] == '') $error .= $app->tform->wordbook['ns_txt']." ".$app->tform->wordbook['error_empty']."<br>\r\n";
  $error .= $this->validate_field($soa['ns'], "Name server", $soa['id'], 0);
  if($soa['mbox'] == '') $error .= $app->tform->wordbook['mbox_txt']." ".$app->tform->wordbook['error_empty']."<br>\r\n";
  $error .= $this->validate_field($soa['mbox'], "Admin email", $soa['id'], 0);
  $error .= $this->is_integer($soa['refresh'], $app->tform->wordbook['refresh_txt']);
  $error .= $this->is_integer($soa['retry'], $app->tform->wordbook['retry_txt']);
  $error .= $this->is_integer($soa['expire'], $app->tform->wordbook['expire_txt']);
  $error .= $this->is_integer($soa['minimum'], $app->tform->wordbook['minimum_txt']);
  return $error;
}
function increase_serial($serial){
  global $app, $conf;
  // increase serial
  $serial_date = substr($serial, 0, 8);
  $count = intval(substr($serial, 8, 2));
  $current_date = date("Ymd");
  if($serial_date >= $current_date){
    $count += 1;
    if ($count > 99) {
        $serial_date += 1;
        $count = 0;
    }
    $count = str_pad($count, 2, "0", STR_PAD_LEFT);
    $new_serial = $serial_date.$count;
  } else {
    $new_serial = $current_date.'01';
  }
  return $new_serial;
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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.
*/
/*
    DNS validation
*/
class validate_dns {
function validate_field($field, $area, $zoneid, $wildcard_allowed = 1){
  //$desc: Name, Data, RP mbox, RP txtref, SRV target, Zone origin, Name server, Admin email
  global $app, $conf;
  switch ($area) {
  case "Name":
    $desc = $app->tform->wordbook['name_txt'];
    break;
  case "Data":
    $desc = $app->tform->wordbook['data_txt'];
    break;
  case "RP mbox":
    $desc = $app->tform->wordbook['rp_mbox_txt'];
    break;
  case "RP txtref":
    $desc = $app->tform->wordbook['rp_txtref_txt'];
    break;
  case "SRV target":
    $desc = $app->tform->wordbook['srv_target_txt'];
    break;
  case "Zone origin":
    $desc = $app->tform->wordbook['zone_origin_txt'];
    break;
  case "Name server":
    $desc = $app->tform->wordbook['ns_txt'];
    break;
  case "Admin email":
    $desc = $app->tform->wordbook['mbox_txt'];
    break;
  }
  $error = '';
  $valid_characters = "*ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_";
  if(strlen($field) > 255) $error .= $desc." ".$app->tform->wordbook['error_255_characters']."<br>\r\n";
  $parts = explode(".", $field);
  $i = 0;
  $empty = 0;
  foreach ($parts as $part){
    $i++;
    if(trim($part) == '') $empty += 1;
    if(strlen($part) > 63) $error .= $desc." ".$app->tform->wordbook['error_63_characters']."<br>\r\n";
    if(strspn($part, $valid_characters) != strlen($part)) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
    if(substr($part, 0, 1) == '-') $error .= $desc." ".$app->tform->wordbook['error_hyphen_begin']."<br>\r\n";
    if(substr($part, -1) == '-') $error .= $desc." ".$app->tform->wordbook['error_hyphen_end']."<br>\r\n";
    if(strstr($part, "*")){
      if($wildcard_allowed){
        if($i != 1) $error .= $desc." ".$app->tform->wordbook['error_wildcard_non_initial_part']."<br>\r\n";
        if($part != "*") $error .= $desc." ".$app->tform->wordbook['error_wildcard_mix']."<br>\r\n";
      } else {
        $error .= $desc." ".$app->tform->wordbook['error_no_wildcard_allowed']."<br>\r\n";
      }
    }
  }
  if(substr($field, -1) == '.'){
    if($i > 2 && $empty > 1) $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
  } else {
    if($empty > 0 && $field != '') $error .= $desc." ".$app->tform->wordbook['error_invalid_characters']."<br>\r\n";
  }
  if(substr($field, -1) == '.' && $area == 'Name'){
    $soa = $app->db->queryOneRecord("SELECT * FROM soa WHERE id = ".$zoneid);
    if(substr($field, (strlen($field) - strlen($soa['origin']))) != $soa['origin']) $error .= $desc." ".$app->tform->wordbook['error_out_of_zone']."<br>\r\n";
  }
  return $error;
}
function validate_rp_data(&$data, $zoneid){
  global $app, $conf;
  $error = '';
  $fields = explode(" ", trim($data));
  if(count($fields) != 2) return $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_invalid_rp']."<br>\r\n";
  $mbox = $fields[0];
  $txtref = $fields[1];
  $error .= $this->validate_field($mbox, 'RP mbox', $zoneid, 0);
  $error .= $this->validate_field($txtref, 'RP txtref', $zoneid, 0);
  $data = $mbox." ".$txtref;
  return $error;
}
function validate_srv_data(&$data, $zoneid){
  global $app, $conf;
  $error = '';
  $fields = explode(" ", trim($data));
  if(count($fields) != 3) return $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_invalid_srv']."<br>\r\n";
  $weight = $fields[0];
  $port = $fields[1];
  $target = $fields[2];
  if($weight < 0 || $weight > 65535) $error .= $app->tform->wordbook['weight_txt']." (\"<i>" . htmlentities($weight,ENT_QUOTES,$conf["html_content_encoding"])."</i>\") ".$app->tform->wordbook['error_srv_out_of_range']."<br>\r\n";
  if($port < 0 || $port > 65535) $error .= $app->tform->wordbook['port_txt']." (\"<i>".htmlentities($port,ENT_QUOTES,$conf["html_content_encoding"])."</i>\") ".$app->tform->wordbook['error_srv_out_of_range']."<br>\r\n";
  $error .= $this->validate_field($target, "SRV target", $zoneid, 0);
  $data = (int)$weight." ".(int)$port." ".$target;
  return $error;
}
function is_integer($value, $fieldname, $zero_allowed = 0){
  global $app, $conf;
  $error = '';
  if(intval($value) != $value || !is_numeric($value)) $error .= $fieldname." ".$app->tform->wordbook['error_must_be_integer']."<br>\r\n";
  if($value > 2147483647) $error .= $fieldname." ".$app->tform->wordbook['error_must_not_be_greater_than_2147483647']."<br>\r\n";
  if(!$zero_allowed){
    if($value <= 0) $error .= $fieldname." ".$app->tform->wordbook['error_must_be_positive']."<br>\r\n";
  } else {
    if($value < 0) $error .= $fieldname." ".$app->tform->wordbook['error_must_not_be_negative']."<br>\r\n";
  }
  return $error;
}
function validate_rr(&$rr){
  global $app, $conf;
  $error = '';
  $tmp_rr = $rr;
  foreach($tmp_rr as $key => $val){
    $rr[$key] = trim($val);
  }
  unset($tmp_rr);
  $error .= $this->validate_field($rr['name'], 'Name', $rr['zone'], 1);
  switch ($rr['type']) {
  case "A":
    $ip_parts = explode(".", $rr['data']);
    if(count($ip_parts) != 4){
      $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_a']."<br>\r\n";
    } else {
      for($n = 0; $n < 4; $n++){
        $q = $ip_parts[$n];
        if(!is_numeric($q) || (int)$q < 0 || (int)$q > 255 || trim($q) !== $q) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_a']."<br>\r\n";
      }
    }
    $rr['data'] = (int)$ip_parts[0].".".(int)$ip_parts[1].".".(int)$ip_parts[2].".".(int)$ip_parts[3];
    break;
  case "AAAA":
    $valid_chars = "ABCDEFabcdef1234567890:";
    if(strspn($rr['data'], $valid_chars) != strlen($rr['data'])) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_aaaa']."<br>\r\n";
    break;
  case "ALIAS":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    break;
  case "CNAME":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    break;
  case "HINFO":
    if(!strchr($rr['data'], ' ')) $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_hinfo']."<br>\r\n";
    break;
  case "MX":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    $error .= $this->is_integer($rr['aux'], $app->tform->wordbook['aux_txt'], 1);
    break;
  case "NS":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    break;
  case "PTR":
    $error .= $this->validate_field($rr['data'], 'Data', $rr['zone'], 0);
    if(substr($rr['data'], -1) != '.') $error .= $app->tform->wordbook['data_txt']." ".$app->tform->wordbook['error_ptr']."<br>\r\n";
    break;
  case "RP":
    $error .= $this->validate_rp_data($rr['data'], $rr['zone']);
    break;
  case "SRV":
    $error .= $this->validate_srv_data($rr['data'], $rr['zone']);
    $error .= $this->is_integer($rr['aux'], $app->tform->wordbook['aux_txt'], 1);
    break;
  case "TXT":
    break;
  }
  $error .= $this->is_integer($rr['ttl'], $app->tform->wordbook['ttl_txt']);
  return $error;
}
function validate_soa(&$soa){
  global $app, $conf;
  $error = '';
  $tmp_soa = $soa;
  foreach($tmp_soa as $key => $val){
    if($key != 'active') $soa[$key] = trim($val);
  }
  unset($tmp_soa);
  if($soa['origin'] == '') $error .= $app->tform->wordbook['origin_txt']." ".$app->tform->wordbook['error_empty']."<br>\r\n";
  if(substr($soa['origin'], -1) != '.') $error .= $app->tform->wordbook['origin_txt']." ".$app->tform->wordbook['error_dot']."<br>\r\n";
  $error .= $this->validate_field($soa['origin'], "Zone origin", $soa['id'], 0);
  $error .= $this->is_integer($soa['ttl'], $app->tform->wordbook['ttl_txt']);
  if($soa['ns'] == '') $error .= $app->tform->wordbook['ns_txt']." ".$app->tform->wordbook['error_empty']."<br>\r\n";
  $error .= $this->validate_field($soa['ns'], "Name server", $soa['id'], 0);
  if($soa['mbox'] == '') $error .= $app->tform->wordbook['mbox_txt']." ".$app->tform->wordbook['error_empty']."<br>\r\n";
  $error .= $this->validate_field($soa['mbox'], "Admin email", $soa['id'], 0);
  $error .= $this->is_integer($soa['refresh'], $app->tform->wordbook['refresh_txt']);
  $error .= $this->is_integer($soa['retry'], $app->tform->wordbook['retry_txt']);
  $error .= $this->is_integer($soa['expire'], $app->tform->wordbook['expire_txt']);
  $error .= $this->is_integer($soa['minimum'], $app->tform->wordbook['minimum_txt']);
  return $error;
}
function increase_serial($serial){
  global $app, $conf;
  // increase serial
  $serial_date = substr($serial, 0, 8);
  $count = intval(substr($serial, 8, 2));
  $current_date = date("Ymd");
  if($serial_date >= $current_date){
    $count += 1;
    if ($count > 99) {
        $serial_date += 1;
        $count = 0;
    }
    $count = str_pad($count, 2, "0", STR_PAD_LEFT);
    $new_serial = $serial_date.$count;
  } else {
    $new_serial = $current_date.'01';
  }
  return $new_serial;
}
}
interface/web/admin/form/firewall.tform.php
@@ -1,112 +1,112 @@
<?php
/*
    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).
*/
$form["title"]             = "Firewall";
$form["description"]     = "";
$form["name"]             = "firewall";
$form["action"]            = "firewall_edit.php";
$form["db_table"]        = "firewall";
$form["db_table_idx"]    = "firewall_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "firewall";
$form["list_default"]    = "firewall_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"]['firewall'] = array (
    'title'     => "Firewall",
    'width'     => 100,
    'template'     => "templates/firewall_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'server_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'validators'    => array (     0 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'firewall_error_unique'),
                                    ),
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'tcp_port' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\s0-9\,\:]{0,255}$/',
                                                        'errmsg'=> 'tcp_ports_error_regex'),
                                    ),
            'default'    => '20,21,22,25,53,80,110,143,443,3306,8080,8081,10000',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'udp_port' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\s0-9\,\:]{0,255}$/',
                                                        'errmsg'=> 'tcp_ports_error_regex'),
                                    ),
            'default'    => '53,3306',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'active' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'y',
            'value'        => array(0 => 'n',1 => 'y')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
<?php
/*
    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).
*/
$form["title"]             = "Firewall";
$form["description"]     = "";
$form["name"]             = "firewall";
$form["action"]            = "firewall_edit.php";
$form["db_table"]        = "firewall";
$form["db_table_idx"]    = "firewall_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "firewall";
$form["list_default"]    = "firewall_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"]['firewall'] = array (
    'title'     => "Firewall",
    'width'     => 100,
    'template'     => "templates/firewall_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'server_id' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'validators'    => array (     0 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'firewall_error_unique'),
                                    ),
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'tcp_port' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\s0-9\,\:]{0,255}$/',
                                                        'errmsg'=> 'tcp_ports_error_regex'),
                                    ),
            'default'    => '20,21,22,25,53,80,110,143,443,3306,8080,8081,10000',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'udp_port' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\s0-9\,\:]{0,255}$/',
                                                        'errmsg'=> 'tcp_ports_error_regex'),
                                    ),
            'default'    => '53,3306',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'active' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'y',
            'value'        => array(0 => 'n',1 => 'y')
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/admin/form/remote_user.tform.php
@@ -1,162 +1,162 @@
<?php
/*
    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).
*/
$function_list = array();
$function_list['mail_domain_get,mail_domain_add,mail_domain_update,mail_domain_delete,mail_domain_set_status,mail_domain_get_by_domain'] = 'Mail domain functions';
$function_list['mail_mailinglist_get,mail_mailinglist_add,mail_mailinglist_update,mail_mailinglist_delete'] = 'Mail mailinglist functions';
$function_list['mail_user_get,mail_user_add,mail_user_update,mail_user_delete'] = 'Mail user functions';
$function_list['mail_alias_get,mail_alias_add,mail_alias_update,mail_alias_delete'] = 'Mail alias functions';
$function_list['mail_forward_get,mail_forward_add,mail_forward_update,mail_forward_delete'] = 'Mail forward functions';
$function_list['mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions';
$function_list['mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions';
$function_list['mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions';
$function_list['mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions';
$function_list['mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user functions';
$function_list['mail_policy_get,mail_policy_add,mail_policy_update,mail_policy_delete'] = 'Mail spamfilter policy functions';
$function_list['mail_fetchmail_get,mail_fetchmail_add,mail_fetchmail_update,mail_fetchmail_delete'] = 'Mail fetchmail functions';
$function_list['mail_spamfilter_whitelist_get,mail_spamfilter_whitelist_add,mail_spamfilter_whitelist_update,mail_spamfilter_whitelist_delete'] = 'Mail spamfilter whitelist functions';
$function_list['mail_spamfilter_blacklist_get,mail_spamfilter_blacklist_add,mail_spamfilter_blacklist_update,mail_spamfilter_blacklist_delete'] = 'Mail spamfilter blacklist functions';
$function_list['mail_user_filter_get,mail_user_filter_add,mail_user_filter_update,mail_user_filter_delete'] = 'Mail user filter functions';
$function_list['mail_filter_get,mail_filter_add,mail_filter_update,mail_filter_delete'] = 'Mail filter functions';
<?php
/*
    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).
*/
$function_list = array();
$function_list['mail_domain_get,mail_domain_add,mail_domain_update,mail_domain_delete,mail_domain_set_status,mail_domain_get_by_domain'] = 'Mail domain functions';
$function_list['mail_mailinglist_get,mail_mailinglist_add,mail_mailinglist_update,mail_mailinglist_delete'] = 'Mail mailinglist functions';
$function_list['mail_user_get,mail_user_add,mail_user_update,mail_user_delete'] = 'Mail user functions';
$function_list['mail_alias_get,mail_alias_add,mail_alias_update,mail_alias_delete'] = 'Mail alias functions';
$function_list['mail_forward_get,mail_forward_add,mail_forward_update,mail_forward_delete'] = 'Mail forward functions';
$function_list['mail_catchall_get,mail_catchall_add,mail_catchall_update,mail_catchall_delete'] = 'Mail catchall functions';
$function_list['mail_transport_get,mail_transport_add,mail_transport_update,mail_transport_delete'] = 'Mail transport functions';
$function_list['mail_whitelist_get,mail_whitelist_add,mail_whitelist_update,mail_whitelist_delete'] = 'Mail whitelist functions';
$function_list['mail_blacklist_get,mail_blacklist_add,mail_blacklist_update,mail_blacklist_delete'] = 'Mail blacklist functions';
$function_list['mail_spamfilter_user_get,mail_spamfilter_user_add,mail_spamfilter_user_update,mail_spamfilter_user_delete'] = 'Mail spamfilter user functions';
$function_list['mail_policy_get,mail_policy_add,mail_policy_update,mail_policy_delete'] = 'Mail spamfilter policy functions';
$function_list['mail_fetchmail_get,mail_fetchmail_add,mail_fetchmail_update,mail_fetchmail_delete'] = 'Mail fetchmail functions';
$function_list['mail_spamfilter_whitelist_get,mail_spamfilter_whitelist_add,mail_spamfilter_whitelist_update,mail_spamfilter_whitelist_delete'] = 'Mail spamfilter whitelist functions';
$function_list['mail_spamfilter_blacklist_get,mail_spamfilter_blacklist_add,mail_spamfilter_blacklist_update,mail_spamfilter_blacklist_delete'] = 'Mail spamfilter blacklist functions';
$function_list['mail_user_filter_get,mail_user_filter_add,mail_user_filter_update,mail_user_filter_delete'] = 'Mail user filter functions';
$function_list['mail_filter_get,mail_filter_add,mail_filter_update,mail_filter_delete'] = 'Mail filter functions';
$function_list['client_get,client_add,client_update,client_delete,client_get_sites_by_user,client_get_by_username,client_change_password,client_get_id,client_delete_everything'] = 'Client functions';
$function_list['server_get,get_function_list,client_templates_get_all,server_get_serverid_by_ip'] = 'Server functions';
$function_list['sites_cron_get,sites_cron_add,sites_cron_update,sites_cron_delete'] = 'Sites cron functions';
$function_list['sites_database_get,sites_database_add,sites_database_update,sites_database_delete, sites_database_get_all_by_user'] = 'Sites database functions';
$function_list['sites_ftp_user_get,sites_ftp_user_add,sites_ftp_user_update,sites_ftp_user_delete'] = 'Sites FTP-User functions';
$function_list['sites_shell_user_get,sites_shell_user_add,sites_shell_user_update,sites_shell_user_delete'] = 'Sites Shell-User functions';
$function_list['sites_web_domain_get,sites_web_domain_add,sites_web_domain_update,sites_web_domain_delete,sites_web_domain_set_status'] = 'Sites Domain functions';
$function_list['sites_web_aliasdomain_get,sites_web_aliasdomain_add,sites_web_aliasdomain_update,sites_web_aliasdomain_delete'] = 'Sites Aliasdomain functions';
$function_list['sites_web_subdomain_get,sites_web_subdomain_add,sites_web_subdomain_update,sites_web_subdomain_delete'] = 'Sites Subdomain functions';
$function_list['dns_zone_get,dns_zone_add,dns_zone_update,dns_zone_delete,dns_zone_set_status'] = 'DNS zone functions';
$function_list['dns_a_get,dns_a_add,dns_a_update,dns_a_delete'] = 'DNS a functions';
$function_list['dns_aaaa_get,dns_aaaa_add,dns_aaaa_update,dns_aaaa_delete'] = 'DNS aaaa functions';
$function_list['dns_alias_get,dns_alias_add,dns_alias_update,dns_alias_delete'] = 'DNS alias functions';
$function_list['dns_cname_get,dns_cname_add,dns_cname_update,dns_cname_delete'] = 'DNS cname functions';
$function_list['dns_hinfo_get,dns_hinfo_add,dns_hinfo_update,dns_hinfo_delete'] = 'DNS hinfo functions';
$function_list['dns_mx_get,dns_mx_add,dns_mx_update,dns_mx_delete'] = 'DNS mx functions';
$function_list['dns_ns_get,dns_ns_add,dns_ns_update,dns_ns_delete'] = 'DNS ns functions';
$function_list['dns_ptr_get,dns_ptr_add,dns_ptr_update,dns_ptr_delete'] = 'DNS ptr functions';
$function_list['dns_rp_get,dns_rp_add,dns_rp_update,dns_rp_delete'] = 'DNS rp functions';
$function_list['dns_srv_get,dns_srv_add,dns_srv_update,dns_srv_delete'] = 'DNS srv functions';
$function_list['dns_txt_get,dns_txt_add,dns_txt_update,dns_txt_delete'] = 'DNS txt functions';
$function_list['sites_cron_get,sites_cron_add,sites_cron_update,sites_cron_delete'] = 'Sites cron functions';
$function_list['sites_database_get,sites_database_add,sites_database_update,sites_database_delete, sites_database_get_all_by_user'] = 'Sites database functions';
$function_list['sites_ftp_user_get,sites_ftp_user_add,sites_ftp_user_update,sites_ftp_user_delete'] = 'Sites FTP-User functions';
$function_list['sites_shell_user_get,sites_shell_user_add,sites_shell_user_update,sites_shell_user_delete'] = 'Sites Shell-User functions';
$function_list['sites_web_domain_get,sites_web_domain_add,sites_web_domain_update,sites_web_domain_delete,sites_web_domain_set_status'] = 'Sites Domain functions';
$function_list['sites_web_aliasdomain_get,sites_web_aliasdomain_add,sites_web_aliasdomain_update,sites_web_aliasdomain_delete'] = 'Sites Aliasdomain functions';
$function_list['sites_web_subdomain_get,sites_web_subdomain_add,sites_web_subdomain_update,sites_web_subdomain_delete'] = 'Sites Subdomain functions';
$function_list['dns_zone_get,dns_zone_add,dns_zone_update,dns_zone_delete,dns_zone_set_status'] = 'DNS zone functions';
$function_list['dns_a_get,dns_a_add,dns_a_update,dns_a_delete'] = 'DNS a functions';
$function_list['dns_aaaa_get,dns_aaaa_add,dns_aaaa_update,dns_aaaa_delete'] = 'DNS aaaa functions';
$function_list['dns_alias_get,dns_alias_add,dns_alias_update,dns_alias_delete'] = 'DNS alias functions';
$function_list['dns_cname_get,dns_cname_add,dns_cname_update,dns_cname_delete'] = 'DNS cname functions';
$function_list['dns_hinfo_get,dns_hinfo_add,dns_hinfo_update,dns_hinfo_delete'] = 'DNS hinfo functions';
$function_list['dns_mx_get,dns_mx_add,dns_mx_update,dns_mx_delete'] = 'DNS mx functions';
$function_list['dns_ns_get,dns_ns_add,dns_ns_update,dns_ns_delete'] = 'DNS ns functions';
$function_list['dns_ptr_get,dns_ptr_add,dns_ptr_update,dns_ptr_delete'] = 'DNS ptr functions';
$function_list['dns_rp_get,dns_rp_add,dns_rp_update,dns_rp_delete'] = 'DNS rp functions';
$function_list['dns_srv_get,dns_srv_add,dns_srv_update,dns_srv_delete'] = 'DNS srv functions';
$function_list['dns_txt_get,dns_txt_add,dns_txt_update,dns_txt_delete'] = 'DNS txt functions';
$function_list['domains_domain_get,domains_domain_add,domains_domain_delete,domains_get_all_by_user'] = 'Domaintool functions';
$form["title"]             = "Remote user";
$form["description"]     = "";
$form["name"]             = "remote_user";
$form["action"]            = "remote_user_edit.php";
$form["db_table"]        = "remote_user";
$form["db_table_idx"]    = "remote_userid";
$form["db_history"]        = "yes";
$form["tab_default"]    = "remote_user";
$form["list_default"]    = "remote_user_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"]['remote_user'] = array (
    'title'     => "Remote User",
    'width'     => 100,
    'template'     => "templates/remote_user_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'remote_userid' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username',
                                        'keyfield'=> 'remote_userid',
                                        'valuefield'=> 'remote_username'
                                     ),
            'value'        => ''
        ),
        'remote_username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_error_unique'),
                                        1 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
2 => array (    'type' => 'NOTEMPTY',
        'errmsg'=> 'username_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption' => 'MD5',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_functions' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $function_list,
            'separator'    => ';',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '5',
            'cols'        => '30'
        )
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
$form["title"]             = "Remote user";
$form["description"]     = "";
$form["name"]             = "remote_user";
$form["action"]            = "remote_user_edit.php";
$form["db_table"]        = "remote_user";
$form["db_table_idx"]    = "remote_userid";
$form["db_history"]        = "yes";
$form["tab_default"]    = "remote_user";
$form["list_default"]    = "remote_user_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"]['remote_user'] = array (
    'title'     => "Remote User",
    'width'     => 100,
    'template'     => "templates/remote_user_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'remote_userid' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username',
                                        'keyfield'=> 'remote_userid',
                                        'valuefield'=> 'remote_username'
                                     ),
            'value'        => ''
        ),
        'remote_username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_error_unique'),
                                        1 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
2 => array (    'type' => 'NOTEMPTY',
        'errmsg'=> 'username_error_empty'),
                                    ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption' => 'MD5',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'remote_functions' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $function_list,
            'separator'    => ';',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '5',
            'cols'        => '30'
        )
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/admin/form/system_config.tform.php
@@ -1,270 +1,270 @@
<?php
/*
    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).
*/
$form["title"]             = "System Config";
$form["description"]     = "";
$form["name"]             = "system_config";
$form["action"]            = "system_config_edit.php";
$form["db_table"]        = "sys_ini";
$form["db_table_idx"]    = "sysini_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "sites";
$form["list_default"]    = "server_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"]['sites'] = array (
    'title'     => "Sites",
    'width'     => 70,
    'template'     => "templates/system_config_sites_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dbname_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbname_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dbuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ftpuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'ftpuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'shelluser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'shelluser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webdavuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'webdavuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dblist_phpmyadmin_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'phpmyadmin_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'phpmyadmin_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webftp_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webftp_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['mail'] = array (
    'title'     => "Mail",
    'width'     => 70,
    'template'     => "templates/system_config_mail_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'mailboxlist_webmail_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'webmail_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webmail_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'mailmailinglist_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'mailmailinglist_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'mailinglist_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_mail' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['domains'] = array (
    'title'     => "Domains",
    'width'     => 70,
    'template'     => "templates/system_config_domains_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'use_domain_module' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'new_domain_html' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['misc'] = array (
    'title'     => "Misc",
    'width'     => 70,
    'template'     => "templates/system_config_misc_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dashboard_atom_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://www.ispconfig.org/atom',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
<?php
/*
    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).
*/
$form["title"]             = "System Config";
$form["description"]     = "";
$form["name"]             = "system_config";
$form["action"]            = "system_config_edit.php";
$form["db_table"]        = "sys_ini";
$form["db_table_idx"]    = "sysini_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "sites";
$form["list_default"]    = "server_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"]['sites'] = array (
    'title'     => "Sites",
    'width'     => 70,
    'template'     => "templates/system_config_sites_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dbname_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbname_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dbuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'dbuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'ftpuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'ftpuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'shelluser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'shelluser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webdavuser_prefix' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[a-zA-Z0-0\-\_\[\]]{0,50}$/',
                                                        'errmsg'=> 'webdavuser_prefix_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'dblist_phpmyadmin_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'phpmyadmin_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'phpmyadmin_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'webftp_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webftp_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['mail'] = array (
    'title'     => "Mail",
    'width'     => 70,
    'template'     => "templates/system_config_mail_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'mailboxlist_webmail_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'webmail_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'webmail_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'mailmailinglist_link' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'mailmailinglist_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}$/',
                                                        'errmsg'=> 'mailinglist_url_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_mail' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
        'admin_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['domains'] = array (
    'title'     => "Domains",
    'width'     => 70,
    'template'     => "templates/system_config_domains_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'use_domain_module' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOX',
            'default'    => 'n',
            'value'        => array(0 => 'n',1 => 'y')
        ),
        'new_domain_html' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
$form["tabs"]['misc'] = array (
    'title'     => "Misc",
    'width'     => 70,
    'template'     => "templates/system_config_misc_edit.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'dashboard_atom_url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://www.ispconfig.org/atom',
            'value'        => ''
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
?>
interface/web/admin/form/users.tform.php
@@ -1,456 +1,456 @@
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
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
    Tabellendefinition
    Datentypen:
    - INTEGER (Wandelt Ausdr�cke in Int um)
    - DOUBLE
    - CURRENCY (Formatiert Zahlen nach W�hrungsnotation)
    - VARCHAR (kein weiterer Format Check)
    - TEXT (kein weiterer Format Check)
    - DATE (Datumsformat, Timestamp Umwandlung)
    Formtype:
    - TEXT (normales Textfeld)
    - TEXTAREA (normales Textfeld)
    - PASSWORD (Feldinhalt wird nicht angezeigt)
    - SELECT (Gibt Werte als option Feld aus)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hinweis:
    Das ID-Feld ist nicht bei den Table Values einzuf�gen.
*/
$form['title']             = 'Users';
$form['description']     = 'Form to edit systemusers.';
$form['name']             = 'users';
$form['action']            = 'users_edit.php';
$form['db_table']        = 'sys_user';
$form['db_table_idx']    = 'userid';
$form["db_history"]        = "no";
$form['tab_default']    = 'users';
$form['list_default']    = 'users_list.php';
$form['auth']            = 'yes';
//* 0 = id of the user, > 0 id must match with id of current user
$form['auth_preset']['userid']  = 0;
//* 0 = default groupid of the user, > 0 id must match with groupid of current user
$form['auth_preset']['groupid'] = 0;
//** Permissions are: r = read, i = insert, u = update, d = delete
$form['auth_preset']['perm_user']  = 'riud';
$form['auth_preset']['perm_group'] = 'riud';
$form['auth_preset']['perm_other'] = '';
//* Pick out modules
$modules_list = array();
$handle = @opendir(ISPC_WEB_PATH);
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_dir(ISPC_WEB_PATH."/$file")) {
            if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login' && $file != 'designer') {
                $modules_list[$file] = $file;
            }
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Pick out groups
$groups_list = array();
$tmp_records = $app->db->queryAllRecords('SELECT groupid, name FROM sys_group ORDER BY name');
if(is_array($tmp_records)) {
    foreach($tmp_records as $tmp_rec) {
        $groups_list[$tmp_rec['groupid']] = $tmp_rec['name'];
    }
}
$form['tabs']['users'] = array (
    'title'     => 'Users',
    'width'     => 80,
    'template'     => 'templates/users_user_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_empty'),
                                        1 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_err'),
                                    ),
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '30',
            'rows'        => '',
            'cols'        => ''
        ),
        'passwort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '100',
            'rows'        => '',
            'cols'        => ''
        ),
        'modules' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'admin,forms',
            'value'        => $modules_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'startmodule' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $modules_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'app_theme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'typ' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'user',
            'value'        => array ('user' => 'user', 'admin' => 'admin'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'active' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'CHECKBOX',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => array(0 => 0,1 => 1),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '2',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
/*
$form['tabs']['address'] = array (
    'title'     => 'Address',
    'width'     => 80,
    'template'     => 'templates/users_address_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vorname' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'unternehmen' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'strasse' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'ort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'plz' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'land' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'telefon' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
*/
$form['tabs']['groups'] = array (
    'title'     => 'Groups',
    'width'     => 80,
    'template'     => 'templates/users_groups_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'default_group' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'groups' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
<?php
/*
Copyright (c) 2005, Till Brehm, projektfarm Gmbh
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
    Tabellendefinition
    Datentypen:
    - INTEGER (Wandelt Ausdr�cke in Int um)
    - DOUBLE
    - CURRENCY (Formatiert Zahlen nach W�hrungsnotation)
    - VARCHAR (kein weiterer Format Check)
    - TEXT (kein weiterer Format Check)
    - DATE (Datumsformat, Timestamp Umwandlung)
    Formtype:
    - TEXT (normales Textfeld)
    - TEXTAREA (normales Textfeld)
    - PASSWORD (Feldinhalt wird nicht angezeigt)
    - SELECT (Gibt Werte als option Feld aus)
    - RADIO
    - CHECKBOX
    - CHECKBOXARRAY
    - FILE
    VALUE:
    - Wert oder Array
    Hinweis:
    Das ID-Feld ist nicht bei den Table Values einzuf�gen.
*/
$form['title']             = 'Users';
$form['description']     = 'Form to edit systemusers.';
$form['name']             = 'users';
$form['action']            = 'users_edit.php';
$form['db_table']        = 'sys_user';
$form['db_table_idx']    = 'userid';
$form["db_history"]        = "no";
$form['tab_default']    = 'users';
$form['list_default']    = 'users_list.php';
$form['auth']            = 'yes';
//* 0 = id of the user, > 0 id must match with id of current user
$form['auth_preset']['userid']  = 0;
//* 0 = default groupid of the user, > 0 id must match with groupid of current user
$form['auth_preset']['groupid'] = 0;
//** Permissions are: r = read, i = insert, u = update, d = delete
$form['auth_preset']['perm_user']  = 'riud';
$form['auth_preset']['perm_group'] = 'riud';
$form['auth_preset']['perm_other'] = '';
//* Pick out modules
$modules_list = array();
$handle = @opendir(ISPC_WEB_PATH);
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_dir(ISPC_WEB_PATH."/$file")) {
            if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login' && $file != 'designer') {
                $modules_list[$file] = $file;
            }
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Pick out groups
$groups_list = array();
$tmp_records = $app->db->queryAllRecords('SELECT groupid, name FROM sys_group ORDER BY name');
if(is_array($tmp_records)) {
    foreach($tmp_records as $tmp_rec) {
        $groups_list[$tmp_rec['groupid']] = $tmp_rec['name'];
    }
}
$form['tabs']['users'] = array (
    'title'     => 'Users',
    'width'     => 80,
    'template'     => 'templates/users_user_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_empty'),
                                        1 => array (    'type'    => 'UNIQUE',
                                                        'errmsg'=> 'username_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_err'),
                                    ),
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '30',
            'rows'        => '',
            'cols'        => ''
        ),
        'passwort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '15',
            'maxlength'    => '100',
            'rows'        => '',
            'cols'        => ''
        ),
        'modules' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'admin,forms',
            'value'        => $modules_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'startmodule' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $modules_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'app_theme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'typ' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'RADIO',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => 'user',
            'value'        => array ('user' => 'user', 'admin' => 'admin'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'active' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'CHECKBOX',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => array(0 => 0,1 => 1),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '2',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
/*
$form['tabs']['address'] = array (
    'title'     => 'Address',
    'width'     => 80,
    'template'     => 'templates/users_address_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vorname' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'unternehmen' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'strasse' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'ort' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'plz' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'land' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'url' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'telefon' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
*/
$form['tabs']['groups'] = array (
    'title'     => 'Groups',
    'width'     => 80,
    'template'     => 'templates/users_groups_edit.htm',
    'fields'     => array (
    ##################################
    # Beginn Datenbankfelder
    ##################################
        'default_group' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'groups' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'regex'        => '',
            'errmsg'    => '',
            'default'    => '',
            'value'        => $groups_list,
            'separator'    => ',',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        )
    ##################################
    # ENDE Datenbankfelder
    ##################################
    )
);
?>
interface/web/admin/lib/lang/en_server_config.lng
@@ -1,84 +1,84 @@
<?php
$wb["try_rescue_txt"] = 'Activate rescue of all services installed at this server';
$wb["do_not_try_rescue_apache_txt"] = 'If rescue ist activated, do NOT try to rescue Apache';
$wb["do_not_try_rescue_mysql_txt"] = 'If rescue ist activated, do NOT try to rescue mysql';
$wb["do_not_try_rescue_mail_txt"] = 'If rescue ist activated, do NOT try to rescue mail';
$wb["jailkit_chroot_home_txt"] = 'Jailkit chroot home';
$wb["jailkit_chroot_app_sections_txt"] = 'Jailkit chroot app sections';
$wb["jailkit_chroot_app_programs_txt"] = 'Jailkit chrooted applications';
$wb["jailkit_chroot_cron_programs_txt"] = 'Jailkit cron chrooted applications';
$wb["website_path_txt"] = 'Website path';
$wb["website_symlinks_txt"] = 'Website symlinks';
$wb["website_basedir_txt"] = 'Website basedir';
$wb["vhost_conf_dir_txt"] = 'Vhost config dir';
$wb["vhost_conf_enabled_dir_txt"] = 'Vhost config enabled dir';
$wb["getmail_config_dir_txt"] = 'Getmail config dir';
$wb["fastcgi_starter_path_txt"] = 'FastCGI starter path';
$wb["fastcgi_starter_script_txt"] = 'FastCGI starter script';
$wb["fastcgi_alias_txt"] = 'FastCGI Alias';
$wb["fastcgi_phpini_path_txt"] = 'FastCGI php.ini Path';
$wb["fastcgi_children_txt"] = 'FastCGI Children';
$wb["fastcgi_max_requests_txt"] = 'FastCGI max. Requests';
$wb["fastcgi_bin_txt"] = 'FastCGI Bin';
$wb["module_txt"] = 'Module';
$wb["maildir_path_txt"] = 'Maildir Path';
$wb["homedir_path_txt"] = 'Homedir Path';
$wb["mailuser_uid_txt"] = 'Mailuser UID';
$wb["mailuser_gid_txt"] = 'Mailuser GID';
$wb["mailuser_name_txt"] = 'Mailuser Name';
$wb["mailuser_group_txt"] = 'Mailuser Group';
$wb["relayhost_txt"] = 'Relayhost';
$wb["relayhost_user_txt"] = 'Relayhost User';
$wb["relayhost_password_txt"] = 'Relayhost Password';
$wb["mailbox_size_limit_txt"] = 'Mailbox Size Limit';
$wb["message_size_limit_txt"] = 'Message Size Limit';
$wb["ip_address_txt"] = 'IP Address';
$wb["netmask_txt"] = 'Netmask';
$wb["gateway_txt"] = 'Gateway';
$wb["hostname_txt"] = 'Hostname';
$wb["nameservers_txt"] = 'Nameservers';
$wb["auto_network_configuration_txt"] = 'Network Configuration';
$wb["ip_address_error_wrong"] = 'Invalid IP address format.';
$wb["netmask_error_wrong"] = 'Invalid Netmask format.';
$wb["gateway_error_wrong"] = 'Invalid Gateway format.';
$wb["hostname_error_empty"] = 'Hostname is empty.';
$wb["nameservers_error_empty"] = 'Nameserver is empty.';
$wb["config_dir_txt"] = 'Config directory';
$wb["init_script_txt"] = 'Cron init script name';
$wb["crontab_dir_txt"] = 'Path for individual crontabs';
$wb["wget_txt"] = 'Path to wget program';
$wb["web_user_txt"] = 'Apache user';
$wb["web_group_txt"] = 'Apache group';
$wb["security_level_txt"] = 'Security level';
$wb["loglevel_txt"] = 'Loglevel';
$wb["apps_vhost_port_txt"] = 'Apps-vhost port';
$wb["apps_vhost_ip_txt"] = 'Apps-vhost IP';
$wb["apps_vhost_servername_txt"] = 'Apps-vhost Domain';
$wb["bind_user_txt"] = 'BIND User';
$wb["bind_group_txt"] = 'BIND Group';
$wb["bind_zonefiles_dir_txt"] = 'BIND zonefiles directory';
$wb["named_conf_path_txt"] = 'BIND named.conf path';
$wb["bind_user_error_empty"] = 'BIND user is empty.';
$wb["bind_group_error_empty"] = 'BIND group is empty.';
$wb["bind_zonefiles_dir_error_empty"] = 'BIND zonefiles directory is empty.';
$wb["named_conf_path_error_empty"] = 'BIND named.conf path is empty.';
$wb["named_conf_local_path_error_empty"] = 'BIND named.conf.local path is empty.';
$wb["mail_filter_syntax_txt"] = 'Mailfilter Syntax';
$wb["pop3_imap_daemon_txt"] = 'POP3/IMAP Daemon';
$wb["php_open_basedir_txt"] = 'PHP open_basedir';
$wb["php_open_basedir_error_empty"] = 'PHP open_basedir is empty.';
$wb["htaccess_allow_override_txt"] = '.htaccess AllowOverride';
$wb["htaccess_allow_override_error_empty"] = '.htaccess AllowOverride is empty.';
$wb["awstats_conf_dir_txt"] = 'awstats conf folder';
$wb["awstats_data_dir_txt"] = 'awstats data folder';
$wb["awstats_pl_txt"] = 'awstats.pl script';
$wb["awstats_buildstaticpages_pl_txt"] = 'awstats_buildstaticpages.pl script';
$wb["backup_dir_txt"] = 'Backup directory';
$wb["named_conf_local_path_txt"] = 'BIND named.conf.local path';
$wb["php_ini_path_cgi_txt"] = 'CGI php.ini path';
$wb["php_ini_path_apache_txt"] = 'Apache php.ini path';
$wb["check_apache_config_txt"] = 'Test apache configuration on restart';
$wb["network_config_warning_txt"] = 'The network configuration option is only available for Debian and Ubuntu Servers. Do not enable this option if your network interface is not eth0.';
<?php
$wb["try_rescue_txt"] = 'Activate rescue of all services installed at this server';
$wb["do_not_try_rescue_apache_txt"] = 'If rescue ist activated, do NOT try to rescue Apache';
$wb["do_not_try_rescue_mysql_txt"] = 'If rescue ist activated, do NOT try to rescue mysql';
$wb["do_not_try_rescue_mail_txt"] = 'If rescue ist activated, do NOT try to rescue mail';
$wb["jailkit_chroot_home_txt"] = 'Jailkit chroot home';
$wb["jailkit_chroot_app_sections_txt"] = 'Jailkit chroot app sections';
$wb["jailkit_chroot_app_programs_txt"] = 'Jailkit chrooted applications';
$wb["jailkit_chroot_cron_programs_txt"] = 'Jailkit cron chrooted applications';
$wb["website_path_txt"] = 'Website path';
$wb["website_symlinks_txt"] = 'Website symlinks';
$wb["website_basedir_txt"] = 'Website basedir';
$wb["vhost_conf_dir_txt"] = 'Vhost config dir';
$wb["vhost_conf_enabled_dir_txt"] = 'Vhost config enabled dir';
$wb["getmail_config_dir_txt"] = 'Getmail config dir';
$wb["fastcgi_starter_path_txt"] = 'FastCGI starter path';
$wb["fastcgi_starter_script_txt"] = 'FastCGI starter script';
$wb["fastcgi_alias_txt"] = 'FastCGI Alias';
$wb["fastcgi_phpini_path_txt"] = 'FastCGI php.ini Path';
$wb["fastcgi_children_txt"] = 'FastCGI Children';
$wb["fastcgi_max_requests_txt"] = 'FastCGI max. Requests';
$wb["fastcgi_bin_txt"] = 'FastCGI Bin';
$wb["module_txt"] = 'Module';
$wb["maildir_path_txt"] = 'Maildir Path';
$wb["homedir_path_txt"] = 'Homedir Path';
$wb["mailuser_uid_txt"] = 'Mailuser UID';
$wb["mailuser_gid_txt"] = 'Mailuser GID';
$wb["mailuser_name_txt"] = 'Mailuser Name';
$wb["mailuser_group_txt"] = 'Mailuser Group';
$wb["relayhost_txt"] = 'Relayhost';
$wb["relayhost_user_txt"] = 'Relayhost User';
$wb["relayhost_password_txt"] = 'Relayhost Password';
$wb["mailbox_size_limit_txt"] = 'Mailbox Size Limit';
$wb["message_size_limit_txt"] = 'Message Size Limit';
$wb["ip_address_txt"] = 'IP Address';
$wb["netmask_txt"] = 'Netmask';
$wb["gateway_txt"] = 'Gateway';
$wb["hostname_txt"] = 'Hostname';
$wb["nameservers_txt"] = 'Nameservers';
$wb["auto_network_configuration_txt"] = 'Network Configuration';
$wb["ip_address_error_wrong"] = 'Invalid IP address format.';
$wb["netmask_error_wrong"] = 'Invalid Netmask format.';
$wb["gateway_error_wrong"] = 'Invalid Gateway format.';
$wb["hostname_error_empty"] = 'Hostname is empty.';
$wb["nameservers_error_empty"] = 'Nameserver is empty.';
$wb["config_dir_txt"] = 'Config directory';
$wb["init_script_txt"] = 'Cron init script name';
$wb["crontab_dir_txt"] = 'Path for individual crontabs';
$wb["wget_txt"] = 'Path to wget program';
$wb["web_user_txt"] = 'Apache user';
$wb["web_group_txt"] = 'Apache group';
$wb["security_level_txt"] = 'Security level';
$wb["loglevel_txt"] = 'Loglevel';
$wb["apps_vhost_port_txt"] = 'Apps-vhost port';
$wb["apps_vhost_ip_txt"] = 'Apps-vhost IP';
$wb["apps_vhost_servername_txt"] = 'Apps-vhost Domain';
$wb["bind_user_txt"] = 'BIND User';
$wb["bind_group_txt"] = 'BIND Group';
$wb["bind_zonefiles_dir_txt"] = 'BIND zonefiles directory';
$wb["named_conf_path_txt"] = 'BIND named.conf path';
$wb["bind_user_error_empty"] = 'BIND user is empty.';
$wb["bind_group_error_empty"] = 'BIND group is empty.';
$wb["bind_zonefiles_dir_error_empty"] = 'BIND zonefiles directory is empty.';
$wb["named_conf_path_error_empty"] = 'BIND named.conf path is empty.';
$wb["named_conf_local_path_error_empty"] = 'BIND named.conf.local path is empty.';
$wb["mail_filter_syntax_txt"] = 'Mailfilter Syntax';
$wb["pop3_imap_daemon_txt"] = 'POP3/IMAP Daemon';
$wb["php_open_basedir_txt"] = 'PHP open_basedir';
$wb["php_open_basedir_error_empty"] = 'PHP open_basedir is empty.';
$wb["htaccess_allow_override_txt"] = '.htaccess AllowOverride';
$wb["htaccess_allow_override_error_empty"] = '.htaccess AllowOverride is empty.';
$wb["awstats_conf_dir_txt"] = 'awstats conf folder';
$wb["awstats_data_dir_txt"] = 'awstats data folder';
$wb["awstats_pl_txt"] = 'awstats.pl script';
$wb["awstats_buildstaticpages_pl_txt"] = 'awstats_buildstaticpages.pl script';
$wb["backup_dir_txt"] = 'Backup directory';
$wb["named_conf_local_path_txt"] = 'BIND named.conf.local path';
$wb["php_ini_path_cgi_txt"] = 'CGI php.ini path';
$wb["php_ini_path_apache_txt"] = 'Apache php.ini path';
$wb["check_apache_config_txt"] = 'Test apache configuration on restart';
$wb["network_config_warning_txt"] = 'The network configuration option is only available for Debian and Ubuntu Servers. Do not enable this option if your network interface is not eth0.';
$wb["CA_path_txt"] = 'CA Path';
$wb["CA_pass_txt"] = 'CA passphrase';
?>
interface/web/admin/lib/lang/en_users.lng
@@ -1,28 +1,28 @@
<?php
$wb["username_txt"] = 'Username';
$wb["username_err"] = 'The username is too long or contains invalid characters.';
$wb["username_empty"] = 'The username is empty.';
$wb["username_unique"] = 'There is already a user with this username.';
$wb["passwort_txt"] = 'Password';
$wb["password_strength_txt"] = 'Password strength';
$wb["modules_txt"] = 'Module';
$wb["startmodule_txt"] = 'Startmodule';
$wb["app_theme_txt"] = 'Design';
$wb["typ_txt"] = 'Type';
$wb["active_txt"] = 'Active';
$wb["language_txt"] = 'Language';
$wb["name_txt"] = 'Name';
$wb["vorname_txt"] = 'Forename';
$wb["unternehmen_txt"] = 'Company';
$wb["strasse_txt"] = 'Street';
$wb["ort_txt"] = 'City';
$wb["plz_txt"] = 'ZIP';
$wb["land_txt"] = 'Country';
$wb["email_txt"] = 'Email';
$wb["url_txt"] = 'Url';
$wb["telefon_txt"] = 'Telephone';
$wb["fax_txt"] = 'Fax';
$wb["groups_txt"] = 'Groups';
$wb["default_group_txt"] = 'Default Group';
$wb["startmodule_err"] = 'Start module is not within modules.';
?>
<?php
$wb["username_txt"] = 'Username';
$wb["username_err"] = 'The username is too long or contains invalid characters.';
$wb["username_empty"] = 'The username is empty.';
$wb["username_unique"] = 'There is already a user with this username.';
$wb["passwort_txt"] = 'Password';
$wb["password_strength_txt"] = 'Password strength';
$wb["modules_txt"] = 'Module';
$wb["startmodule_txt"] = 'Startmodule';
$wb["app_theme_txt"] = 'Design';
$wb["typ_txt"] = 'Type';
$wb["active_txt"] = 'Active';
$wb["language_txt"] = 'Language';
$wb["name_txt"] = 'Name';
$wb["vorname_txt"] = 'Forename';
$wb["unternehmen_txt"] = 'Company';
$wb["strasse_txt"] = 'Street';
$wb["ort_txt"] = 'City';
$wb["plz_txt"] = 'ZIP';
$wb["land_txt"] = 'Country';
$wb["email_txt"] = 'Email';
$wb["url_txt"] = 'Url';
$wb["telefon_txt"] = 'Telephone';
$wb["fax_txt"] = 'Fax';
$wb["groups_txt"] = 'Groups';
$wb["default_group_txt"] = 'Default Group';
$wb["startmodule_err"] = 'Start module is not within modules.';
?>
interface/web/admin/templates/firewall_edit.htm
@@ -1,38 +1,38 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_firewall">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput">
                    {tmpl_var name='server_id'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="tcp_port">{tmpl_var name='tcp_port_txt'}</label>
        <input name="tcp_port" id="tcp_port" value="{tmpl_var name='tcp_port'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="udp_port">{tmpl_var name='udp_port_txt'}</label>
        <input name="udp_port" id="udp_port" value="{tmpl_var name='udp_port'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='active'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/firewall_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/firewall_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_firewall">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput">
                    {tmpl_var name='server_id'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="tcp_port">{tmpl_var name='tcp_port_txt'}</label>
        <input name="tcp_port" id="tcp_port" value="{tmpl_var name='tcp_port'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="udp_port">{tmpl_var name='udp_port_txt'}</label>
        <input name="udp_port" id="udp_port" value="{tmpl_var name='udp_port'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='active'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/firewall_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/firewall_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/groups_edit.htm
@@ -1,26 +1,26 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_groups">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="name">{tmpl_var name='name_txt'}</label>
        <input name="name" id="name" value="{tmpl_var name='name'}" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
            </div>
      <div class="ctrlHolder">
          <label for="description">{tmpl_var name='description_txt'}</label>
        <textarea name="description" id="description" rows='5' cols='30'>{tmpl_var name='description'}</textarea>
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/groups_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/groups_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_groups">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="name">{tmpl_var name='name_txt'}</label>
        <input name="name" id="name" value="{tmpl_var name='name'}" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
            </div>
      <div class="ctrlHolder">
          <label for="description">{tmpl_var name='description_txt'}</label>
        <textarea name="description" id="description" rows='5' cols='30'>{tmpl_var name='description'}</textarea>
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/groups_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/groups_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/language_add.htm
@@ -1,32 +1,32 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_add">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Language Add</legend>
      <div class="ctrlHolder">
          <label for="lng_select">{tmpl_var name='language_select_txt'}</label>
        <select name="lng_select" id="language" class="selectInput withicons">
                    {tmpl_var name='language_option'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="lng_new">{tmpl_var name='language_new_txt'}</label>
        <input name="lng_new" id="lng_new" value="" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
        <p class="formHint">{tmpl_var name='language_new_hint_txt'}</p>
            </div>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/language_add.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/language_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
    </fieldset>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_add">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Language Add</legend>
      <div class="ctrlHolder">
          <label for="lng_select">{tmpl_var name='language_select_txt'}</label>
        <select name="lng_select" id="language" class="selectInput withicons">
                    {tmpl_var name='language_option'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="lng_new">{tmpl_var name='language_new_txt'}</label>
        <input name="lng_new" id="lng_new" value="" size="30" maxlength="255" type="text" class="textInput formLengthHalf" />
        <p class="formHint">{tmpl_var name='language_new_hint_txt'}</p>
            </div>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/language_add.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/language_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
    </fieldset>
  </div>
</div>
interface/web/admin/templates/language_edit.htm
@@ -1,32 +1,32 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_edit">
  <div class="pnl_formsarea">
    <fieldset id="wf_area_language_edit"><legend>Language File Edit: {tmpl_var name="file_path"}</legend>
      <span class="wf_oneField">
        <tmpl_loop name="records">
        <span class="wf_oneField">
          <label for="records[{tmpl_var name="key"}]" class="wf_preField">{tmpl_var name="key"}</label>
          <input type="text" id="records[{tmpl_var name="key"}]" name="records[{tmpl_var name="key"}]" value="{tmpl_var name='val'}" size="50" maxlength="255">
        </span>
        </tmpl_loop>
      </span>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <input type="hidden" name="lang" value="{tmpl_var name='lang'}">
    <input type="hidden" name="lang_file" value="{tmpl_var name='lang_file'}">
    <input type="hidden" name="module" value="{tmpl_var name='module'}">
    <div class="wf_actions buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/language_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/language_list.php?lng_select={tmpl_var name='lang'}');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_edit">
  <div class="pnl_formsarea">
    <fieldset id="wf_area_language_edit"><legend>Language File Edit: {tmpl_var name="file_path"}</legend>
      <span class="wf_oneField">
        <tmpl_loop name="records">
        <span class="wf_oneField">
          <label for="records[{tmpl_var name="key"}]" class="wf_preField">{tmpl_var name="key"}</label>
          <input type="text" id="records[{tmpl_var name="key"}]" name="records[{tmpl_var name="key"}]" value="{tmpl_var name='val'}" size="50" maxlength="255">
        </span>
        </tmpl_loop>
      </span>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <input type="hidden" name="lang" value="{tmpl_var name='lang'}">
    <input type="hidden" name="lang_file" value="{tmpl_var name='lang_file'}">
    <input type="hidden" name="module" value="{tmpl_var name='module'}">
    <div class="wf_actions buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/language_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/language_list.php?lng_select={tmpl_var name='lang'}');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/language_list.htm
@@ -1,47 +1,47 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_groups">
  <div class="pnl_toolsarea">
    <fieldset class="inlineLabels"><legend>Tools</legend>
      <div class="buttons">
          <div class="ctrlHolder">
              <label for="lng_select">{tmpl_var name='language_select_txt'}</label>
            <select name="lng_select" id="language" class="selectInput withicons" onChange="submitForm('pageForm','admin/language_list.php');">
                        {tmpl_var name='language_option'}
                    </select>
          </div>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_module" scope="col"><tmpl_var name="module_txt"></th>
            <th class="tbl_col_lang_file" scope="col"><tmpl_var name="lang_file_txt"></th>
            <th scope="col"><tmpl_var name="lang_file_date_txt"></th>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_module"><a href="#" onClick="loadContent('admin/language_edit.php?lang_file={tmpl_var name="lang_file"}&module={tmpl_var name="module"}&lang={tmpl_var name="lang"}');">{tmpl_var name="module"}</a></td>
            <td class="tbl_col_lang_file"><a href="#" onClick="loadContent('admin/language_edit.php?lang_file={tmpl_var name="lang_file"}&module={tmpl_var name="module"}&lang={tmpl_var name="lang"}');">{tmpl_var name="lang_file"}</a></td>
            <td><a href="#" onClick="loadContent('admin/language_edit.php?lang_file={tmpl_var name="lang_file"}&module={tmpl_var name="module"}&lang={tmpl_var name="lang"}');">{tmpl_var name="lang_file_date"}</a></td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="3"><tmpl_var name="paging"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_language_groups">
  <div class="pnl_toolsarea">
    <fieldset class="inlineLabels"><legend>Tools</legend>
      <div class="buttons">
          <div class="ctrlHolder">
              <label for="lng_select">{tmpl_var name='language_select_txt'}</label>
            <select name="lng_select" id="language" class="selectInput withicons" onChange="submitForm('pageForm','admin/language_list.php');">
                        {tmpl_var name='language_option'}
                    </select>
          </div>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_module" scope="col"><tmpl_var name="module_txt"></th>
            <th class="tbl_col_lang_file" scope="col"><tmpl_var name="lang_file_txt"></th>
            <th scope="col"><tmpl_var name="lang_file_date_txt"></th>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_module"><a href="#" onClick="loadContent('admin/language_edit.php?lang_file={tmpl_var name="lang_file"}&module={tmpl_var name="module"}&lang={tmpl_var name="lang"}');">{tmpl_var name="module"}</a></td>
            <td class="tbl_col_lang_file"><a href="#" onClick="loadContent('admin/language_edit.php?lang_file={tmpl_var name="lang_file"}&module={tmpl_var name="module"}&lang={tmpl_var name="lang"}');">{tmpl_var name="lang_file"}</a></td>
            <td><a href="#" onClick="loadContent('admin/language_edit.php?lang_file={tmpl_var name="lang_file"}&module={tmpl_var name="module"}&lang={tmpl_var name="lang"}');">{tmpl_var name="lang_file_date"}</a></td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="3"><tmpl_var name="paging"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
interface/web/admin/templates/remote_action_ispcupdate.htm
@@ -1,25 +1,25 @@
<h2><tmpl_var name="do_ispcupdate_caption"></h2>
<p><tmpl_var name="do_ispcupdate_desc"></p>
<div class="panel panel_language_add">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>{tmpl_var name='do_ispcupdate_caption'}</legend>
      <div class="ctrlHolder">
          <label for="server_select">{tmpl_var name='select_server_txt'}</label>
        <select name="server_select" id="server" class="selectInput" onchange="document.getElementById('OKMsg').style.visibility = 'hidden'; ">
                    {tmpl_var name='server_option'}
                </select>
      </div>
    </fieldset>
    <tmpl_if name="msg">
    <div id="OKMsg"><p><tmpl_var name="msg"></p></div>
  </tmpl_if>
      <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_do_txt'}" onClick="submitForm('pageForm','admin/remote_action_ispcupdate.php');"><span>{tmpl_var name='btn_do_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="do_ispcupdate_caption"></h2>
<p><tmpl_var name="do_ispcupdate_desc"></p>
<div class="panel panel_language_add">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>{tmpl_var name='do_ispcupdate_caption'}</legend>
      <div class="ctrlHolder">
          <label for="server_select">{tmpl_var name='select_server_txt'}</label>
        <select name="server_select" id="server" class="selectInput" onchange="document.getElementById('OKMsg').style.visibility = 'hidden'; ">
                    {tmpl_var name='server_option'}
                </select>
      </div>
    </fieldset>
    <tmpl_if name="msg">
    <div id="OKMsg"><p><tmpl_var name="msg"></p></div>
  </tmpl_if>
      <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_do_txt'}" onClick="submitForm('pageForm','admin/remote_action_ispcupdate.php');"><span>{tmpl_var name='btn_do_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/remote_action_osupdate.htm
@@ -1,25 +1,25 @@
<h2><tmpl_var name="do_osupdate_caption"></h2>
<p><tmpl_var name="do_osupdate_desc"></p>
<div class="panel panel_language_add">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>{tmpl_var name='do_osupdate_caption'}</legend>
      <div class="ctrlHolder">
          <label for="server_select">{tmpl_var name='select_server_txt'}</label>
        <select name="server_select" id="server" class="selectInput" onchange="document.getElementById('OKMsg').style.visibility = 'hidden'; ">
                    {tmpl_var name='server_option'}
                </select>
      </div>
    </fieldset>
    <tmpl_if name="msg">
    <div id="OKMsg"><p><tmpl_var name="msg"></p></div>
  </tmpl_if>
      <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_do_txt'}" onClick="submitForm('pageForm','admin/remote_action_osupdate.php');"><span>{tmpl_var name='btn_do_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="do_osupdate_caption"></h2>
<p><tmpl_var name="do_osupdate_desc"></p>
<div class="panel panel_language_add">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>{tmpl_var name='do_osupdate_caption'}</legend>
      <div class="ctrlHolder">
          <label for="server_select">{tmpl_var name='select_server_txt'}</label>
        <select name="server_select" id="server" class="selectInput" onchange="document.getElementById('OKMsg').style.visibility = 'hidden'; ">
                    {tmpl_var name='server_option'}
                </select>
      </div>
    </fieldset>
    <tmpl_if name="msg">
    <div id="OKMsg"><p><tmpl_var name="msg"></p></div>
  </tmpl_if>
      <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_do_txt'}" onClick="submitForm('pageForm','admin/remote_action_osupdate.php');"><span>{tmpl_var name='btn_do_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/server_config_cron_edit.htm
@@ -1,30 +1,30 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
        <label for="init_script">{tmpl_var name='init_script_txt'}</label>
        <input name="init_script" id="init_script" value="{tmpl_var name='init_script'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
        <label for="crontab_dir">{tmpl_var name='crontab_dir_txt'}</label>
        <input name="crontab_dir" id="crontab_dir" value="{tmpl_var name='crontab_dir'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
        <label for="wget">{tmpl_var name='wget_txt'}</label>
        <input name="wget" id="wget" value="{tmpl_var name='wget'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
        <label for="init_script">{tmpl_var name='init_script_txt'}</label>
        <input name="init_script" id="init_script" value="{tmpl_var name='init_script'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
        <label for="crontab_dir">{tmpl_var name='crontab_dir_txt'}</label>
        <input name="crontab_dir" id="crontab_dir" value="{tmpl_var name='crontab_dir'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
        <label for="wget">{tmpl_var name='wget_txt'}</label>
        <input name="wget" id="wget" value="{tmpl_var name='wget'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/server_config_fastcgi_edit.htm
@@ -1,46 +1,46 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="fastcgi_starter_path">{tmpl_var name='fastcgi_starter_path_txt'}</label>
        <input name="fastcgi_starter_path" id="fastcgi_starter_path" value="{tmpl_var name='fastcgi_starter_path'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_starter_script">{tmpl_var name='fastcgi_starter_script_txt'}</label>
        <input name="fastcgi_starter_script" id="fastcgi_starter_script" value="{tmpl_var name='fastcgi_starter_script'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_alias">{tmpl_var name='fastcgi_alias_txt'}</label>
        <input name="fastcgi_alias" id="fastcgi_alias" value="{tmpl_var name='fastcgi_alias'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_phpini_path">{tmpl_var name='fastcgi_phpini_path_txt'}</label>
        <input name="fastcgi_phpini_path" id="fastcgi_phpini_path" value="{tmpl_var name='fastcgi_phpini_path'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_children">{tmpl_var name='fastcgi_children_txt'}</label>
        <input name="fastcgi_children" id="fastcgi_children" value="{tmpl_var name='fastcgi_children'}" size="40" maxlength="255" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_max_requests">{tmpl_var name='fastcgi_max_requests_txt'}</label>
        <input name="fastcgi_max_requests" id="fastcgi_max_requests" value="{tmpl_var name='fastcgi_max_requests'}" size="40" maxlength="255" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_bin">{tmpl_var name='fastcgi_bin_txt'}</label>
        <input name="fastcgi_bin" id="fastcgi_bin" value="{tmpl_var name='fastcgi_bin'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="fastcgi_starter_path">{tmpl_var name='fastcgi_starter_path_txt'}</label>
        <input name="fastcgi_starter_path" id="fastcgi_starter_path" value="{tmpl_var name='fastcgi_starter_path'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_starter_script">{tmpl_var name='fastcgi_starter_script_txt'}</label>
        <input name="fastcgi_starter_script" id="fastcgi_starter_script" value="{tmpl_var name='fastcgi_starter_script'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_alias">{tmpl_var name='fastcgi_alias_txt'}</label>
        <input name="fastcgi_alias" id="fastcgi_alias" value="{tmpl_var name='fastcgi_alias'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_phpini_path">{tmpl_var name='fastcgi_phpini_path_txt'}</label>
        <input name="fastcgi_phpini_path" id="fastcgi_phpini_path" value="{tmpl_var name='fastcgi_phpini_path'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_children">{tmpl_var name='fastcgi_children_txt'}</label>
        <input name="fastcgi_children" id="fastcgi_children" value="{tmpl_var name='fastcgi_children'}" size="40" maxlength="255" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_max_requests">{tmpl_var name='fastcgi_max_requests_txt'}</label>
        <input name="fastcgi_max_requests" id="fastcgi_max_requests" value="{tmpl_var name='fastcgi_max_requests'}" size="40" maxlength="255" type="text" class="textInput formLengthLimit" />
            </div>
      <div class="ctrlHolder">
          <label for="fastcgi_bin">{tmpl_var name='fastcgi_bin_txt'}</label>
        <input name="fastcgi_bin" id="fastcgi_bin" value="{tmpl_var name='fastcgi_bin'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/server_config_getmail_edit.htm
@@ -1,22 +1,22 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="getmail_config_dir">{tmpl_var name='getmail_config_dir_txt'}</label>
        <input name="getmail_config_dir" id="getmail_config_dir" value="{tmpl_var name='getmail_config_dir'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="getmail_config_dir">{tmpl_var name='getmail_config_dir_txt'}</label>
        <input name="getmail_config_dir" id="getmail_config_dir" value="{tmpl_var name='getmail_config_dir'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/server_config_jailkit_edit.htm
@@ -1,34 +1,34 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="jailkit_chroot_home">{tmpl_var name='jailkit_chroot_home_txt'}</label>
        <input name="jailkit_chroot_home" id="jailkit_chroot_home" value="{tmpl_var name='jailkit_chroot_home'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="jailkit_chroot_app_sections">{tmpl_var name='jailkit_chroot_app_sections_txt'}</label>
        <input name="jailkit_chroot_app_sections" id="jailkit_chroot_app_sections" value="{tmpl_var name='jailkit_chroot_app_sections'}" size="40" maxlength="1000" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="jailkit_chroot_app_programs">{tmpl_var name='jailkit_chroot_app_programs_txt'}</label>
        <input name="jailkit_chroot_app_programs" id="jailkit_chroot_app_programs" value="{tmpl_var name='jailkit_chroot_app_programs'}" size="40" maxlength="1000" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
        <label for="jailkit_chroot_cron_programs">{tmpl_var name='jailkit_chroot_cron_programs_txt'}</label>
        <input name="jailkit_chroot_cron_programs" id="jailkit_chroot_cron_programs" value="{tmpl_var name='jailkit_chroot_cron_programs'}" size="40" maxlength="1000" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="jailkit_chroot_home">{tmpl_var name='jailkit_chroot_home_txt'}</label>
        <input name="jailkit_chroot_home" id="jailkit_chroot_home" value="{tmpl_var name='jailkit_chroot_home'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="jailkit_chroot_app_sections">{tmpl_var name='jailkit_chroot_app_sections_txt'}</label>
        <input name="jailkit_chroot_app_sections" id="jailkit_chroot_app_sections" value="{tmpl_var name='jailkit_chroot_app_sections'}" size="40" maxlength="1000" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="jailkit_chroot_app_programs">{tmpl_var name='jailkit_chroot_app_programs_txt'}</label>
        <input name="jailkit_chroot_app_programs" id="jailkit_chroot_app_programs" value="{tmpl_var name='jailkit_chroot_app_programs'}" size="40" maxlength="1000" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
        <label for="jailkit_chroot_cron_programs">{tmpl_var name='jailkit_chroot_cron_programs_txt'}</label>
        <input name="jailkit_chroot_cron_programs" id="jailkit_chroot_cron_programs" value="{tmpl_var name='jailkit_chroot_cron_programs'}" size="40" maxlength="1000" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/server_config_vlogger_edit.htm
@@ -1,22 +1,22 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="config_dir">{tmpl_var name='config_dir_txt'}</label>
        <input name="config_dir" id="config_dir" value="{tmpl_var name='config_dir'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_config">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="config_dir">{tmpl_var name='config_dir_txt'}</label>
        <input name="config_dir" id="config_dir" value="{tmpl_var name='config_dir'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_config_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_config_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/server_edit_config.htm
@@ -1,22 +1,22 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="config">{tmpl_var name='config_txt'}</label>
        <textarea name="config" id="config" rows='20' cols='40'>{tmpl_var name='config'}</textarea>
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="config">{tmpl_var name='config_txt'}</label>
        <textarea name="config" id="config" rows='20' cols='40'>{tmpl_var name='config'}</textarea>
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/server_ip_edit.htm
@@ -1,34 +1,34 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_ip">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput">
                    {tmpl_var name='server_id'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="ip_address">{tmpl_var name='ip_address_txt'}</label>
        <input name="ip_address" id="ip_address" value="{tmpl_var name='ip_address'}" size="15" maxlength="15" type="text" class="textInput formLengthIPv4" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='virtualhost_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='virtualhost'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_ip_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_ip_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_server_ip">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="server_id">{tmpl_var name='server_id_txt'}</label>
        <select name="server_id" id="server_id" class="selectInput">
                    {tmpl_var name='server_id'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="ip_address">{tmpl_var name='ip_address_txt'}</label>
        <input name="ip_address" id="ip_address" value="{tmpl_var name='ip_address'}" size="15" maxlength="15" type="text" class="textInput formLengthIPv4" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='virtualhost_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='virtualhost'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/server_ip_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/server_ip_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/software_package_install.htm
@@ -1,30 +1,30 @@
<h2><tmpl_var name="head_txt"></h2>
<p><tmpl_var name="desc_txt"></p>
<div class="panel panel_software_repo">
<tmpl_if name="message_err">
<div id="errorMsg"><tmpl_var name="message_err"></div>
</tmpl_if>
<tmpl_if name="message_ok">
<div id="OKMsg"><tmpl_var name="message_ok"></div>
</tmpl_if>
<tmpl_if name="insert_key">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <p>&nbsp;</p>
      <div class="ctrlHolder">
          <label for="install_key">{tmpl_var name='install_key_txt'}</label>
        <input name="install_key" id="install_key" value="{tmpl_var name='install_key'}" size="40" maxlength="40" type="text" class="textInput" />
      </div>
    <input type="hidden" name="package" value="{tmpl_var name='package_name'}">
    <input type="hidden" name="server_id" value="{tmpl_var name='server_id'}">
    <p>&nbsp;</p>
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/software_package_install.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/software_package_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
    </fieldset>
  </div>
</tmpl_if>
<h2><tmpl_var name="head_txt"></h2>
<p><tmpl_var name="desc_txt"></p>
<div class="panel panel_software_repo">
<tmpl_if name="message_err">
<div id="errorMsg"><tmpl_var name="message_err"></div>
</tmpl_if>
<tmpl_if name="message_ok">
<div id="OKMsg"><tmpl_var name="message_ok"></div>
</tmpl_if>
<tmpl_if name="insert_key">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <p>&nbsp;</p>
      <div class="ctrlHolder">
          <label for="install_key">{tmpl_var name='install_key_txt'}</label>
        <input name="install_key" id="install_key" value="{tmpl_var name='install_key'}" size="40" maxlength="40" type="text" class="textInput" />
      </div>
    <input type="hidden" name="package" value="{tmpl_var name='package_name'}">
    <input type="hidden" name="server_id" value="{tmpl_var name='server_id'}">
    <p>&nbsp;</p>
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/software_package_install.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/software_package_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
    </fieldset>
  </div>
</tmpl_if>
</div>
interface/web/admin/templates/software_package_list.htm
@@ -1,46 +1,46 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_package">
  <div class="pnl_toolsarea">
    <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
      <div class="buttons">
        <button class="iconstxt icoAdd" type="button" onClick="loadContent('admin/software_package_list.php?action=repoupdate');">
                <span>{tmpl_var name="repoupdate_txt"}</span>
            </button>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_installed" scope="col"><tmpl_var name="installed_txt"></th>
            <th class="tbl_col_package_title" scope="col"><tmpl_var name="package_title_txt"></th>
            <th class="tbl_col_package_description" scope="col"><tmpl_var name="package_description_txt"></th>
            <th class="tbl_col_package_description" scope="col"><tmpl_var name="package_id_txt"></th>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_installed">{tmpl_var name="installed"}</td>
            <td class="tbl_col_package_title">{tmpl_var name="package_title"}</td>
            <td class="tbl_col_package_description">{tmpl_var name="package_description"}</td>
            <td class="tbl_col_package_description">ispapp{tmpl_var name="package_id"}</td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="4"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_package">
  <div class="pnl_toolsarea">
    <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
      <div class="buttons">
        <button class="iconstxt icoAdd" type="button" onClick="loadContent('admin/software_package_list.php?action=repoupdate');">
                <span>{tmpl_var name="repoupdate_txt"}</span>
            </button>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_installed" scope="col"><tmpl_var name="installed_txt"></th>
            <th class="tbl_col_package_title" scope="col"><tmpl_var name="package_title_txt"></th>
            <th class="tbl_col_package_description" scope="col"><tmpl_var name="package_description_txt"></th>
            <th class="tbl_col_package_description" scope="col"><tmpl_var name="package_id_txt"></th>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_installed">{tmpl_var name="installed"}</td>
            <td class="tbl_col_package_title">{tmpl_var name="package_title"}</td>
            <td class="tbl_col_package_description">{tmpl_var name="package_description"}</td>
            <td class="tbl_col_package_description">ispapp{tmpl_var name="package_id"}</td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="4"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
interface/web/admin/templates/software_repo_edit.htm
@@ -1,40 +1,40 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_software_repo">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="repo_name">{tmpl_var name='repo_name_txt'}</label>
        <input name="repo_name" id="repo_name" value="{tmpl_var name='repo_name'}" size="40" maxlength="40" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="repo_url">{tmpl_var name='repo_url_txt'}</label>
        <input name="repo_url" id="repo_url" value="{tmpl_var name='repo_url'}" size="40" maxlength="40" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="repo_username">{tmpl_var name='repo_username_txt'}</label>
        <input name="repo_username" id="repo_username" value="{tmpl_var name='repo_username'}" size="30" maxlength="30" type="text" class="textInput formLengthHalf" />
            </div>
      <div class="ctrlHolder">
          <label for="repo_password">{tmpl_var name='repo_password_txt'}</label>
        <input name="repo_password" id="repo_password" value="{tmpl_var name='repo_password'}" size="30" maxlength="30" type="password" class="textInput formLengthHalf" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='active'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/software_repo_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/software_repo_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_software_repo">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="repo_name">{tmpl_var name='repo_name_txt'}</label>
        <input name="repo_name" id="repo_name" value="{tmpl_var name='repo_name'}" size="40" maxlength="40" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="repo_url">{tmpl_var name='repo_url_txt'}</label>
        <input name="repo_url" id="repo_url" value="{tmpl_var name='repo_url'}" size="40" maxlength="40" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="repo_username">{tmpl_var name='repo_username_txt'}</label>
        <input name="repo_username" id="repo_username" value="{tmpl_var name='repo_username'}" size="30" maxlength="30" type="text" class="textInput formLengthHalf" />
            </div>
      <div class="ctrlHolder">
          <label for="repo_password">{tmpl_var name='repo_password_txt'}</label>
        <input name="repo_password" id="repo_password" value="{tmpl_var name='repo_password'}" size="30" maxlength="30" type="password" class="textInput formLengthHalf" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='active'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/software_repo_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/software_repo_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/software_update_list.htm
@@ -1,49 +1,49 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_software_update">
  <div class="pnl_toolsarea">
    <fieldset class="inlineLabels"><legend>Tools</legend>
      <div class="buttons">
          <div class="ctrlHolder">
            <label for="server_id">{tmpl_var name='server_select_txt'}</label>
            <select name="server_id" id="server_id" class="selectInput" onChange="submitForm('pageForm','admin/software_update_list.php');">
            <tmpl_loop name="servers">
              <option value="{tmpl_var name='server_id'}" {tmpl_var name='selected'}>{tmpl_var name='server_name'}</option>
            </tmpl_loop>
                    </select>
          </div>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_installed" scope="col"><tmpl_var name="installed_txt"></th>
            <th class="tbl_col_update_title" scope="col"><tmpl_var name="update_title_txt"></th>
            <th class="tbl_col_version" scope="col"><tmpl_var name="version_txt"></th>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_installed">{tmpl_var name="installed"}</td>
            <td class="tbl_col_update_title">{tmpl_var name="update_title"}</td>
            <td class="tbl_col_version">{tmpl_var name="version"}</td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="3"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_list_software_update">
  <div class="pnl_toolsarea">
    <fieldset class="inlineLabels"><legend>Tools</legend>
      <div class="buttons">
          <div class="ctrlHolder">
            <label for="server_id">{tmpl_var name='server_select_txt'}</label>
            <select name="server_id" id="server_id" class="selectInput" onChange="submitForm('pageForm','admin/software_update_list.php');">
            <tmpl_loop name="servers">
              <option value="{tmpl_var name='server_id'}" {tmpl_var name='selected'}>{tmpl_var name='server_name'}</option>
            </tmpl_loop>
                    </select>
          </div>
      </div>
    </fieldset>
  </div>
  <div class="pnl_listarea">
    <fieldset><legend><tmpl_var name="list_head_txt"></legend>
      <table class="list">
        <thead>
          <tr>
            <th class="tbl_col_installed" scope="col"><tmpl_var name="installed_txt"></th>
            <th class="tbl_col_update_title" scope="col"><tmpl_var name="update_title_txt"></th>
            <th class="tbl_col_version" scope="col"><tmpl_var name="version_txt"></th>
          </tr>
        </thead>
        <tbody>
          <tmpl_loop name="records">
          <tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
            <td class="tbl_col_installed">{tmpl_var name="installed"}</td>
            <td class="tbl_col_update_title">{tmpl_var name="update_title"}</td>
            <td class="tbl_col_version">{tmpl_var name="version"}</td>
          </tr>
          </tmpl_loop>
        </tbody>
        <tfoot>
          <tr>
            <td class="tbl_footer tbl_paging" colspan="3"></td>
          </tr>
        </tfoot>
      </table>
    </fieldset>
  </div>
</div>
interface/web/admin/templates/users_groups_edit.htm
@@ -1,30 +1,30 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_users">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="default_group">{tmpl_var name='default_group_txt'}</label>
        <select name="default_group" id="default_group" class="selectInput">
                    {tmpl_var name='default_group'}
                </select>
      </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='groups_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='groups'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/users_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/users_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_users">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="default_group">{tmpl_var name='default_group_txt'}</label>
        <select name="default_group" id="default_group" class="selectInput">
                    {tmpl_var name='default_group'}
                </select>
      </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='groups_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='groups'}
                    </div>
            </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/users_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/users_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/admin/templates/users_user_edit.htm
@@ -1,67 +1,67 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_users">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="username">{tmpl_var name='username_txt'}</label>
        <input name="username" id="username" value="{tmpl_var name='username'}" size="15" maxlength="30" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="passwort">{tmpl_var name='passwort_txt'}</label>
        <input name="passwort" id="passwort" value="{tmpl_var name='passwort'}" size="15" maxlength="100" type="password" class="textInput"  onkeyup="pass_check(this.value)"/>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='password_strength_txt'}</p>
                <div id="passBar"></div>
                <p class="formHint"><span id="passText">&nbsp;</span></p>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='modules_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='modules'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="startmodule">{tmpl_var name='startmodule_txt'}</label>
        <select name="startmodule" id="startmodule" class="selectInput formLengthHalf">
                    {tmpl_var name='startmodule'}
                </select>
      </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='app_theme_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='app_theme'}
                    </div>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='typ_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='typ'}
                    </div>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='active'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="language">{tmpl_var name='language_txt'}</label>
        <select name="language" id="language" class="selectInput withicons">
                    {tmpl_var name='language'}
                </select>
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/users_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/users_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_users">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels">
      <div class="ctrlHolder">
          <label for="username">{tmpl_var name='username_txt'}</label>
        <input name="username" id="username" value="{tmpl_var name='username'}" size="15" maxlength="30" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="passwort">{tmpl_var name='passwort_txt'}</label>
        <input name="passwort" id="passwort" value="{tmpl_var name='passwort'}" size="15" maxlength="100" type="password" class="textInput"  onkeyup="pass_check(this.value)"/>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='password_strength_txt'}</p>
                <div id="passBar"></div>
                <p class="formHint"><span id="passText">&nbsp;</span></p>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='modules_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='modules'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="startmodule">{tmpl_var name='startmodule_txt'}</label>
        <select name="startmodule" id="startmodule" class="selectInput formLengthHalf">
                    {tmpl_var name='startmodule'}
                </select>
      </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='app_theme_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='app_theme'}
                    </div>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='typ_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='typ'}
                    </div>
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='active_txt'}</p>
                    <div class="multiField">
                        {tmpl_var name='active'}
                    </div>
            </div>
      <div class="ctrlHolder">
          <label for="language">{tmpl_var name='language_txt'}</label>
        <select name="language" id="language" class="selectInput withicons">
                    {tmpl_var name='language'}
                </select>
      </div>
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','admin/users_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('admin/users_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/capp.php
@@ -1,56 +1,56 @@
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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');
// importiere Modul
$mod = $_REQUEST["mod"];
// Checke ob User eingeloggt
if($_SESSION["s"]["user"]['active'] != 1) {
    header("Location: index.php?phpsessid=".$_SESSION["s"]["id"]);
    die();
}
// checke ob User Modul verwenden darf
$user_modules = explode(",",$_SESSION["s"]["user"]["modules"]);
if(!in_array($mod,$user_modules)) $app->error($app->lng(301));
// lade Moduldaten in Session
if(is_file($mod."/lib/module.conf.php")) {
    include_once($mod."/lib/module.conf.php");
    $_SESSION["s"]["module"] = $module;
    echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"];
} else {
    $app->error($app->lng(302));
}
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
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');
// importiere Modul
$mod = $_REQUEST["mod"];
// Checke ob User eingeloggt
if($_SESSION["s"]["user"]['active'] != 1) {
    header("Location: index.php?phpsessid=".$_SESSION["s"]["id"]);
    die();
}
// checke ob User Modul verwenden darf
$user_modules = explode(",",$_SESSION["s"]["user"]["modules"]);
if(!in_array($mod,$user_modules)) $app->error($app->lng(301));
// lade Moduldaten in Session
if(is_file($mod."/lib/module.conf.php")) {
    include_once($mod."/lib/module.conf.php");
    $_SESSION["s"]["module"] = $module;
    echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"];
} else {
    $app->error($app->lng(302));
}
?>
interface/web/client/form/client.tform.php
@@ -1,860 +1,860 @@
<?php
/*
    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).
*/
$form["title"]             = "Client";
$form["description"]     = "";
$form["name"]             = "client";
$form["action"]            = "client_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "client_list.php";
$form["auth"]            = 'yes';
$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
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/client_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'company_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '20',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_mailserver'
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_webserver'
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:web_php_options',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:ssh_chroot',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dnsserver'
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dbserver'
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
<?php
/*
    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).
*/
$form["title"]             = "Client";
$form["description"]     = "";
$form["name"]             = "client";
$form["action"]            = "client_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "client_list.php";
$form["auth"]            = 'yes';
$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
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
//* Load themes
$themes_list = array();
$handle = @opendir(ISPC_THEMES_PATH);
while ($file = @readdir ($handle)) {
    if (substr($file, 0, 1) != '.') {
        if(@is_dir(ISPC_THEMES_PATH."/$file")) {
            $themes_list[$file] = $file;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/client_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => $themes_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'company_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '20',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_mailserver'
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_webserver'
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:web_php_options',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'valuelimit' => 'client:ssh_chroot',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dnsserver'
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'client_servers'
                                     ),
            'value'        => '',
            'name'        => 'default_dbserver'
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
interface/web/client/form/client_template.tform.php
@@ -1,524 +1,524 @@
<?php
/*
    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).
*/
$form["title"]             = "Client-Templates";
$form["description"]     = "";
$form["name"]             = "client_template";
$form["action"]            = "client_template_edit.php";
$form["db_table"]        = "client_template";
$form["db_table_idx"]    = "template_id";
$form["db_history"]        = "no";
$form["tab_default"]    = "template";
$form["list_default"]    = "client_template_list.php";
$form["auth"]            = 'yes';
$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
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['template'] = array (
    'title'     => "Template",
    'width'     => 80,
    'template'     => "templates/client_template_edit_template.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'm',
            'value'        => array('m' => "Main Template",'a' => "Additional Template"),
        ),
        'template_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'error_template_name_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_template_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '0',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        /*
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        */
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
?>
<?php
/*
    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).
*/
$form["title"]             = "Client-Templates";
$form["description"]     = "";
$form["name"]             = "client_template";
$form["action"]            = "client_template_edit.php";
$form["db_table"]        = "client_template";
$form["db_table_idx"]    = "template_id";
$form["db_history"]        = "no";
$form["tab_default"]    = "template";
$form["list_default"]    = "client_template_list.php";
$form["auth"]            = 'yes';
$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
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['template'] = array (
    'title'     => "Template",
    'width'     => 80,
    'template'     => "templates/client_template_edit_template.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_type' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'm',
            'value'        => array('m' => "Main Template",'a' => "Additional Template"),
        ),
        'template_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'error_template_name_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'width'        => '30',
            'maxlength'    => '255'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/client_template_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailaliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailaliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_webdav_user_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '0',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        /*
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        */
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
?>
interface/web/client/form/reseller.tform.php
@@ -1,640 +1,640 @@
<?php
/*
    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).
*/
$form["title"]             = "Reseller";
$form["description"]     = "";
$form["name"]             = "reseller";
$form["action"]            = "reseller_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "reseller_list.php";
$form["auth"]            = 'yes';
$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
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/reseller_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => array('default' => 'default'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/reseller_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
<?php
/*
    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).
*/
$form["title"]             = "Reseller";
$form["description"]     = "";
$form["name"]             = "reseller";
$form["action"]            = "reseller_edit.php";
$form["db_table"]        = "client";
$form["db_table_idx"]    = "client_id";
$form["db_history"]        = "yes";
$form["tab_default"]    = "address";
$form["list_default"]    = "reseller_list.php";
$form["auth"]            = 'yes';
$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
//* Languages
$language_list = array();
$handle = @opendir(ISPC_ROOT_PATH.'/lib/lang');
while ($file = @readdir ($handle)) {
    if ($file != '.' && $file != '..') {
        if(@is_file(ISPC_ROOT_PATH.'/lib/lang/'.$file) and substr($file,-4,4) == '.lng') {
            $tmp = substr($file, 0, 2);
            $language_list[$tmp] = $tmp;
        }
    }
}
$form["tabs"]['address'] = array (
    'title'     => "Address",
    'width'     => 100,
    'template'     => "templates/reseller_edit_address.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'company_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'contact_name' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'contact_error_empty'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'customer_no' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'username' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'NOTEMPTY',
                                                        'errmsg'=> 'username_error_empty'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'password' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'PASSWORD',
            'encryption'=> 'CRYPT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'language' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => $conf["language"],
            'value'        => $language_list,
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'usertheme' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'default',
            'value'        => array('default' => 'default'),
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'street' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'zip' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'city' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'state' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'country' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'SELECT',
            'default'    => 'DE',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name',
                                        'keyfield'=> 'iso',
                                        'valuefield'=> 'printable_name'
                                     ),
            'value'        => ''
        ),
        'telephone' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'mobile' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'fax' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'email' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'internet' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => 'http://',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'icq' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'vat_id' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '30',
            'maxlength'    => '255',
            'rows'        => '',
            'cols'        => ''
        ),
        'notes' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'TEXTAREA',
            'default'    => '',
            'value'        => '',
            'separator'    => '',
            'width'        => '',
            'maxlength'    => '',
            'rows'        => '10',
            'cols'        => '30'
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
$form["tabs"]['limits'] = array (
    'title'     => "Limits",
    'width'     => 80,
    'template'     => "templates/reseller_edit_limits.htm",
    'fields'     => array (
    ##################################
    # Begin Datatable fields
    ##################################
        'template_master' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'CUSTOM',
                                        'class'=> 'custom_datasource',
                                        'function'=> 'master_templates'
                                     ),
            'value'        => ''
        ),
        'template_additional' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'TEXT',
        ),
        'default_mailserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE mail_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_maildomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_maildomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailmailinglist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailmailinglist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailbox' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailbox_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailalias' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailalias_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailforward' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailforward_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailcatchall' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailcatchall_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailrouting' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailrouting_error_notint'),
                                    ),
            'default'    => '0',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailfilter' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfilter_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_fetchmail' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailfetchmail_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_mailquota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_mailquota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_wblist' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_wblist_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_spamfilter_policy' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_spamfilter_policy_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_webserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE web_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_web_domain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_domain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'web_php_options' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP')
        ),
        'limit_web_aliasdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_aliasdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_web_subdomain' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_web_subdomain_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_ftp_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_ftp_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_shell_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_shell_user_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'ssh_chroot' => array (
            'datatype'    => 'VARCHAR',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'separator' => ',',
            'value'        => array('no' => 'None', 'jailkit' => 'Jailkit')
        ),
        'limit_webdav_user' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
@@ -649,177 +649,177 @@
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_reseller',
                                                        'function' => 'limit_client'),
                                    ),
            'default'    => '1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
        'default_dnsserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE dns_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_dns_zone' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_zone_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
                'limit_dns_slave_zone' => array (
                        'datatype'      => 'INTEGER',
                        'formtype'      => 'TEXT',
                        'validators'    => array (      0 => array (    'type'  => 'ISINT',
                                                                                                                'errmsg'=> 'limit_dns_slave_zone_error_notint'),
                                                                        ),
                        'default'       => '-1',
                        'value'         => '',
                        'separator'     => '',
                        'width'         => '10',
                        'maxlength'     => '10',
                        'rows'          => '',
                        'cols'          => ''
                ),
        'limit_dns_record' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_dns_record_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_client' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_client_error_notint'),
                                        1 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_reseller',
                                                        'function' => 'limit_client'),
                                    ),
            'default'    => '1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'default_dbserver' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'SELECT',
            'default'    => '1',
            'datasource'    => array (     'type'    => 'SQL',
                                        'querystring' => 'SELECT server_id,server_name FROM server WHERE db_server = 1 AND {AUTHSQL} ORDER BY server_name',
                                        'keyfield'=> 'server_id',
                                        'valuefield'=> 'server_name'
                                     ),
            'value'        => ''
        ),
        'limit_database' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_database_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
        'limit_cron' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_notint'),
                                    ),
            'default'   => '0',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_cron_type' => array (
            'datatype'  => 'VARCHAR',
            'formtype'  => 'SELECT',
            'default'   => '',
            'value'     => array('full' => 'Full Cron','chrooted' => 'Chrooted Cron','url' => 'URL Cron')
        ),
        'limit_cron_frequency' => array (
            'datatype'  => 'INTEGER',
            'formtype'  => 'TEXT',
            'validators'    => array (  0 => array (    'type'  => 'ISINT',
                                                        'errmsg'=> 'limit_cron_error_frequency'),
                                    ),
            'default'   => '-1',
            'value'     => '',
            'separator' => '',
            'width'     => '10',
            'maxlength' => '10',
            'rows'      => '',
            'cols'      => ''
        ),
        'limit_traffic_quota' => array (
            'datatype'    => 'INTEGER',
            'formtype'    => 'TEXT',
            'validators'    => array (     0 => array (    'type'    => 'ISINT',
                                                        'errmsg'=> 'limit_traffic_quota_error_notint'),
                                    ),
            'default'    => '-1',
            'value'        => '',
            'separator'    => '',
            'width'        => '10',
            'maxlength'    => '10',
            'rows'        => '',
            'cols'        => ''
        ),
    ##################################
    # END Datatable fields
    ##################################
    )
);
/*
$form["tabs"]['ipaddress'] = array (
    'title'     => "IP Addresses",
    'width'     => 100,
    'template'     => "templates/client_edit_ipaddress.htm",
    'fields'     => array (
    ##################################
    # Beginn Datatable fields
    ##################################
        'ip_address' => array (
            'datatype'    => 'TEXT',
            'formtype'    => 'CHECKBOXARRAY',
            'default'    => '',
            'value'        => array('192.168.0.1' => '192.168.0.1', '192.168.0.2' => '192.168.0.2'),
            'separator'    => ';'
        ),
    ##################################
    # ENDE Datatable fields
    ##################################
    )
);
*/
?>
interface/web/client/lib/admin.conf.php
@@ -1,2 +1,2 @@
<?php
<?php
?>
interface/web/client/templates/client_edit_address.htm
@@ -1,114 +1,114 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Address</legend>
      <div class="ctrlHolder">
          <label for="company_name">{tmpl_var name='company_name_txt'}</label>
        <input name="company_name" id="company_name" value="{tmpl_var name='company_name'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="contact_name">{tmpl_var name='contact_name_txt'}*</label>
        <input name="contact_name" id="contact_name" value="{tmpl_var name='contact_name'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="customer_no">{tmpl_var name='customer_no_txt'}</label>
        <input name="customer_no" id="customer_no" value="{tmpl_var name='customer_no'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="username">{tmpl_var name='username_txt'}*</label>
        <input name="username" id="username" value="{tmpl_var name='username'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="password">{tmpl_var name='password_txt'}</label>
        <input name="password" id="password" value="{tmpl_var name='password'}" size="30" maxlength="255" type="password" class="textInput" onkeyup="pass_check(this.value)" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='password_strength_txt'}</p>
                <div id="passBar"></div>
                <p class="formHint"><span id="passText">&nbsp;</span></p>
            </div>
      <div class="ctrlHolder">
          <label for="language">{tmpl_var name='language_txt'}</label>
        <select name="language" id="language" class="selectInput withicons">
                    {tmpl_var name='language'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="usertheme">{tmpl_var name='usertheme_txt'}</label>
        <select name="usertheme" id="usertheme" class="selectInput">
                    {tmpl_var name='usertheme'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="street">{tmpl_var name='street_txt'}</label>
        <input name="street" id="street" value="{tmpl_var name='street'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="zip">{tmpl_var name='zip_txt'}</label>
        <input name="zip" id="zip" value="{tmpl_var name='zip'}" size="10" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="city">{tmpl_var name='city_txt'}</label>
        <input name="city" id="city" value="{tmpl_var name='city'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="state">{tmpl_var name='state_txt'}</label>
        <input name="state" id="state" value="{tmpl_var name='state'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="country">{tmpl_var name='country_txt'}</label>
        <select name="country" id="country" class="selectInput withicons">
                    {tmpl_var name='country'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="telephone">{tmpl_var name='telephone_txt'}</label>
        <input name="telephone" id="telephone" value="{tmpl_var name='telephone'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="mobile">{tmpl_var name='mobile_txt'}</label>
        <input name="mobile" id="mobile" value="{tmpl_var name='mobile'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fax">{tmpl_var name='fax_txt'}</label>
        <input name="fax" id="fax" value="{tmpl_var name='fax'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="email">{tmpl_var name='email_txt'}</label>
        <input name="email" id="email" value="{tmpl_var name='email'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="internet">{tmpl_var name='internet_txt'}</label>
        <input name="internet" id="internet" value="{tmpl_var name='internet'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="icq">{tmpl_var name='icq_txt'}</label>
        <input name="icq" id="icq" value="{tmpl_var name='icq'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="vat_id">{tmpl_var name='vat_id_txt'}</label>
        <input name="vat_id" id="vat_id" value="{tmpl_var name='vat_id'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="company_id">{tmpl_var name='company_id_txt'}</label>
        <input name="company_id" id="company_id" value="{tmpl_var name='company_id'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="notes">{tmpl_var name='notes_txt'}</label>
        <textarea name="notes" id="notes" rows='10' cols='30'>{tmpl_var name='notes'}</textarea>
      </div>
      {tmpl_var name='required_fields_txt'}
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
  <div class="pnl_formsarea">
    <fieldset class="inlineLabels"><legend>Address</legend>
      <div class="ctrlHolder">
          <label for="company_name">{tmpl_var name='company_name_txt'}</label>
        <input name="company_name" id="company_name" value="{tmpl_var name='company_name'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="contact_name">{tmpl_var name='contact_name_txt'}*</label>
        <input name="contact_name" id="contact_name" value="{tmpl_var name='contact_name'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="customer_no">{tmpl_var name='customer_no_txt'}</label>
        <input name="customer_no" id="customer_no" value="{tmpl_var name='customer_no'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="username">{tmpl_var name='username_txt'}*</label>
        <input name="username" id="username" value="{tmpl_var name='username'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="password">{tmpl_var name='password_txt'}</label>
        <input name="password" id="password" value="{tmpl_var name='password'}" size="30" maxlength="255" type="password" class="textInput" onkeyup="pass_check(this.value)" />
            </div>
      <div class="ctrlHolder">
                <p class="label">{tmpl_var name='password_strength_txt'}</p>
                <div id="passBar"></div>
                <p class="formHint"><span id="passText">&nbsp;</span></p>
            </div>
      <div class="ctrlHolder">
          <label for="language">{tmpl_var name='language_txt'}</label>
        <select name="language" id="language" class="selectInput withicons">
                    {tmpl_var name='language'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="usertheme">{tmpl_var name='usertheme_txt'}</label>
        <select name="usertheme" id="usertheme" class="selectInput">
                    {tmpl_var name='usertheme'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="street">{tmpl_var name='street_txt'}</label>
        <input name="street" id="street" value="{tmpl_var name='street'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="zip">{tmpl_var name='zip_txt'}</label>
        <input name="zip" id="zip" value="{tmpl_var name='zip'}" size="10" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="city">{tmpl_var name='city_txt'}</label>
        <input name="city" id="city" value="{tmpl_var name='city'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="state">{tmpl_var name='state_txt'}</label>
        <input name="state" id="state" value="{tmpl_var name='state'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="country">{tmpl_var name='country_txt'}</label>
        <select name="country" id="country" class="selectInput withicons">
                    {tmpl_var name='country'}
                </select>
      </div>
      <div class="ctrlHolder">
          <label for="telephone">{tmpl_var name='telephone_txt'}</label>
        <input name="telephone" id="telephone" value="{tmpl_var name='telephone'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="mobile">{tmpl_var name='mobile_txt'}</label>
        <input name="mobile" id="mobile" value="{tmpl_var name='mobile'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="fax">{tmpl_var name='fax_txt'}</label>
        <input name="fax" id="fax" value="{tmpl_var name='fax'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="email">{tmpl_var name='email_txt'}</label>
        <input name="email" id="email" value="{tmpl_var name='email'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="internet">{tmpl_var name='internet_txt'}</label>
        <input name="internet" id="internet" value="{tmpl_var name='internet'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="icq">{tmpl_var name='icq_txt'}</label>
        <input name="icq" id="icq" value="{tmpl_var name='icq'}" size="30" maxlength="255" type="text" class="textInput" />
            </div>
      <div class="ctrlHolder">
          <label for="vat_id">{tmpl_var name='vat_id_txt'}</label>
        <input name="vat_id" id="vat_id" value="{tmpl_var name='vat_id'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="company_id">{tmpl_var name='company_id_txt'}</label>
        <input name="company_id" id="company_id" value="{tmpl_var name='company_id'}" size="30" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="notes">{tmpl_var name='notes_txt'}</label>
        <textarea name="notes" id="notes" rows='10' cols='30'>{tmpl_var name='notes'}</textarea>
      </div>
      {tmpl_var name='required_fields_txt'}
    </fieldset>
    <input type="hidden" name="id" value="{tmpl_var name='id'}">
    <div class="buttonHolder buttons">
      <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
      <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
    </div>
  </div>
</div>
interface/web/client/templates/client_edit_limits.htm
@@ -1,202 +1,202 @@
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
    <tmpl_if name="is_admin">
        <div class="pnl_toolsarea">
            <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
                <div class="buttons">
                    <button class="positive iconstxt icoAdd" type="button" value="Add additional template" onClick="addAdditionalTemplate();"><span>Add additional template</span></button>
                    <button class="negative iconstxt icoDelete" type="button" value="Delete additional template" onClick="delAdditionalTemplate();"><span>Delete additional template</span></button>
                </div>
            </fieldset>
        </div>
    </tmpl_if>
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Limits</legend>
            <tmpl_if name="is_admin">
                <div class="ctrlHolder">
                    <label for="template_master">{tmpl_var name='template_master_txt'}</label>
                    <select name="template_master" id="template_master" class="selectInput">
                    {tmpl_var name='template_master'}
                    </select>
                </div>
                <div class="ctrlHolder">
                    <label for="template_additional">{tmpl_var name='template_additional_txt'}</label>
                    <select name="tpl_add_select" id="tpl_add_select" class="selectInput">
                    {tmpl_var name='tpl_add_select'}
                    </select>
                    <div id="template_additional_list"><br /><br />{tmpl_var name='template_additional_list'}</div>
                    <input type="hidden" id="template_additional" name="template_additional" value="{tmpl_var name='template_additional'}">
                </div>
                <div class="ctrlHolder">
                    &nbsp;
                </div>
            </tmpl_if>
            <div class="ctrlHolder">
                <label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
                <select name="default_mailserver" id="default_mailserver" class="selectInput">
                    {tmpl_var name='default_mailserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
                <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
                <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
                <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
                <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailmailinglist">{tmpl_var name='limit_mailmailinglist_txt'}</label>
                <input name="limit_mailmailinglist" id="limit_mailmailinglist" value="{tmpl_var name='limit_mailmailinglist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
                <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
                <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
                <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
                <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
                <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
                <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
                <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
                <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
                <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
                <select name="default_webserver" id="default_webserver" class="selectInput">
                    {tmpl_var name='default_webserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
                <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
                <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='web_php_options_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='web_php_options'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
                <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
                <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
                <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
                <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssh_chroot_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='ssh_chroot'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_webdav_user">{tmpl_var name='limit_webdav_user_txt'}</label>
                <input name="limit_webdav_user" id="limit_webdav_user" value="{tmpl_var name='limit_webdav_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
                <select name="default_dnsserver" id="default_dnsserver" class="selectInput">
                    {tmpl_var name='default_dnsserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
                <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
                <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
                <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
                <select name="default_dbserver" id="default_dbserver" class="selectInput">
                    {tmpl_var name='default_dbserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
                <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
                <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
                <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
                    {tmpl_var name='limit_cron_type'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
                <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
                <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
<h2><tmpl_var name="list_head_txt"></h2>
<p><tmpl_var name="list_desc_txt"></p>
<div class="panel panel_client">
    <tmpl_if name="is_admin">
        <div class="pnl_toolsarea">
            <fieldset><legend>{tmpl_var name="toolsarea_head_txt"}</legend>
                <div class="buttons">
                    <button class="positive iconstxt icoAdd" type="button" value="Add additional template" onClick="addAdditionalTemplate();"><span>Add additional template</span></button>
                    <button class="negative iconstxt icoDelete" type="button" value="Delete additional template" onClick="delAdditionalTemplate();"><span>Delete additional template</span></button>
                </div>
            </fieldset>
        </div>
    </tmpl_if>
    <div class="pnl_formsarea">
        <fieldset class="inlineLabels"><legend>Limits</legend>
            <tmpl_if name="is_admin">
                <div class="ctrlHolder">
                    <label for="template_master">{tmpl_var name='template_master_txt'}</label>
                    <select name="template_master" id="template_master" class="selectInput">
                    {tmpl_var name='template_master'}
                    </select>
                </div>
                <div class="ctrlHolder">
                    <label for="template_additional">{tmpl_var name='template_additional_txt'}</label>
                    <select name="tpl_add_select" id="tpl_add_select" class="selectInput">
                    {tmpl_var name='tpl_add_select'}
                    </select>
                    <div id="template_additional_list"><br /><br />{tmpl_var name='template_additional_list'}</div>
                    <input type="hidden" id="template_additional" name="template_additional" value="{tmpl_var name='template_additional'}">
                </div>
                <div class="ctrlHolder">
                    &nbsp;
                </div>
            </tmpl_if>
            <div class="ctrlHolder">
                <label for="default_mailserver">{tmpl_var name='default_mailserver_txt'}</label>
                <select name="default_mailserver" id="default_mailserver" class="selectInput">
                    {tmpl_var name='default_mailserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_maildomain">{tmpl_var name='limit_maildomain_txt'}</label>
                <input name="limit_maildomain" id="limit_maildomain" value="{tmpl_var name='limit_maildomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailbox">{tmpl_var name='limit_mailbox_txt'}</label>
                <input name="limit_mailbox" id="limit_mailbox" value="{tmpl_var name='limit_mailbox'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailalias">{tmpl_var name='limit_mailalias_txt'}</label>
                <input name="limit_mailalias" id="limit_mailalias" value="{tmpl_var name='limit_mailalias'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailaliasdomain">{tmpl_var name='limit_mailaliasdomain_txt'}</label>
                <input name="limit_mailaliasdomain" id="limit_mailaliasdomain" value="{tmpl_var name='limit_mailaliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailmailinglist">{tmpl_var name='limit_mailmailinglist_txt'}</label>
                <input name="limit_mailmailinglist" id="limit_mailmailinglist" value="{tmpl_var name='limit_mailmailinglist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailforward">{tmpl_var name='limit_mailforward_txt'}</label>
                <input name="limit_mailforward" id="limit_mailforward" value="{tmpl_var name='limit_mailforward'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailcatchall">{tmpl_var name='limit_mailcatchall_txt'}</label>
                <input name="limit_mailcatchall" id="limit_mailcatchall" value="{tmpl_var name='limit_mailcatchall'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailrouting">{tmpl_var name='limit_mailrouting_txt'}</label>
                <input name="limit_mailrouting" id="limit_mailrouting" value="{tmpl_var name='limit_mailrouting'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailfilter">{tmpl_var name='limit_mailfilter_txt'}</label>
                <input name="limit_mailfilter" id="limit_mailfilter" value="{tmpl_var name='limit_mailfilter'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_fetchmail">{tmpl_var name='limit_fetchmail_txt'}</label>
                <input name="limit_fetchmail" id="limit_fetchmail" value="{tmpl_var name='limit_fetchmail'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_mailquota">{tmpl_var name='limit_mailquota_txt'}</label>
                <input name="limit_mailquota" id="limit_mailquota" value="{tmpl_var name='limit_mailquota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_wblist">{tmpl_var name='limit_spamfilter_wblist_txt'}</label>
                <input name="limit_spamfilter_wblist" id="limit_spamfilter_wblist" value="{tmpl_var name='limit_spamfilter_wblist'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_user">{tmpl_var name='limit_spamfilter_user_txt'}</label>
                <input name="limit_spamfilter_user" id="limit_spamfilter_user" value="{tmpl_var name='limit_spamfilter_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_spamfilter_policy">{tmpl_var name='limit_spamfilter_policy_txt'}</label>
                <input name="limit_spamfilter_policy" id="limit_spamfilter_policy" value="{tmpl_var name='limit_spamfilter_policy'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_webserver">{tmpl_var name='default_webserver_txt'}</label>
                <select name="default_webserver" id="default_webserver" class="selectInput">
                    {tmpl_var name='default_webserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_domain">{tmpl_var name='limit_web_domain_txt'}</label>
                <input name="limit_web_domain" id="limit_web_domain" value="{tmpl_var name='limit_web_domain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_quota">{tmpl_var name='limit_web_quota_txt'}</label>
                <input name="limit_web_quota" id="limit_web_quota" value="{tmpl_var name='limit_web_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='web_php_options_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='web_php_options'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_aliasdomain">{tmpl_var name='limit_web_aliasdomain_txt'}</label>
                <input name="limit_web_aliasdomain" id="limit_web_aliasdomain" value="{tmpl_var name='limit_web_aliasdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_web_subdomain">{tmpl_var name='limit_web_subdomain_txt'}</label>
                <input name="limit_web_subdomain" id="limit_web_subdomain" value="{tmpl_var name='limit_web_subdomain'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_ftp_user">{tmpl_var name='limit_ftp_user_txt'}</label>
                <input name="limit_ftp_user" id="limit_ftp_user" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_shell_user">{tmpl_var name='limit_shell_user_txt'}</label>
                <input name="limit_shell_user" id="limit_shell_user" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <p class="label">{tmpl_var name='ssh_chroot_txt'}</p>
                <div class="multiField">
                        {tmpl_var name='ssh_chroot'}
                </div>
            </div>
            <div class="ctrlHolder">
                <label for="limit_webdav_user">{tmpl_var name='limit_webdav_user_txt'}</label>
                <input name="limit_webdav_user" id="limit_webdav_user" value="{tmpl_var name='limit_webdav_user'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dnsserver">{tmpl_var name='default_dnsserver_txt'}</label>
                <select name="default_dnsserver" id="default_dnsserver" class="selectInput">
                    {tmpl_var name='default_dnsserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_zone">{tmpl_var name='limit_dns_zone_txt'}</label>
                <input name="limit_dns_zone" id="limit_dns_zone" value="{tmpl_var name='limit_dns_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_slave_zone">{tmpl_var name='limit_dns_slave_zone_txt'}</label>
                <input name="limit_dns_slave_zone" id="limit_dns_slave_zone" value="{tmpl_var name='limit_dns_slave_zone'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_dns_record">{tmpl_var name='limit_dns_record_txt'}</label>
                <input name="limit_dns_record" id="limit_dns_record" value="{tmpl_var name='limit_dns_record'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="default_dbserver">{tmpl_var name='default_dbserver_txt'}</label>
                <select name="default_dbserver" id="default_dbserver" class="selectInput">
                    {tmpl_var name='default_dbserver'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_database">{tmpl_var name='limit_database_txt'}</label>
                <input name="limit_database" id="limit_database" value="{tmpl_var name='limit_database'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron">{tmpl_var name='limit_cron_txt'}</label>
                <input name="limit_cron" id="limit_cron" value="{tmpl_var name='limit_cron'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_type">{tmpl_var name='limit_cron_type_txt'}</label>
                <select name="limit_cron_type" id="limit_cron_type" class="selectInput formLengthHalf">
                    {tmpl_var name='limit_cron_type'}
                </select>
            </div>
            <div class="ctrlHolder">
                <label for="limit_cron_frequency">{tmpl_var name='limit_cron_frequency_txt'}</label>
                <input name="limit_cron_frequency" id="limit_cron_frequency" value="{tmpl_var name='limit_cron_frequency'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />
            </div>
            <div class="ctrlHolder">
                <label for="limit_traffic_quota">{tmpl_var name='limit_traffic_quota_txt'}</label>
                <input name="limit_traffic_quota" id="limit_traffic_quota" value="{tmpl_var name='limit_traffic_quota'}" size="10" maxlength="10" type="text" class="textInput formLengthLimit" />&nbsp;MB
            </div>
        </fieldset>
        <input type="hidden" name="id" value="{tmpl_var name='id'}">
        <div class="buttonHolder buttons">
            <button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','client/client_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
            <button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('client/client_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
        </div>
    </div>
</div>
Diff truncated after the above file
interface/web/client/templates/client_template_edit_limits.htm interface/web/client/templates/client_template_edit_template.htm interface/web/client/templates/reseller_edit_limits.htm interface/web/dashboard/dashlets/limits.php interface/web/dashboard/dashlets/modules.php interface/web/dashboard/lib/custom_menu.inc.php interface/web/dashboard/templates/custom_menu.htm interface/web/designer/lib/admin.conf.php interface/web/designer/lib/lang/cz_module_edit.lng interface/web/designer/lib/lang/fr_module_edit.lng interface/web/designer/lib/lang/id_module_edit.lng interface/web/designer/lib/lang/nl_module_edit.lng interface/web/designer/lib/lang/pl_module_edit.lng interface/web/designer/templates/form_edit.htm interface/web/designer/templates/form_show.htm interface/web/designer/templates/paging.tpl.htm interface/web/dns/dns_a_list.php interface/web/dns/dns_rr_del.php interface/web/dns/dns_slave_del.php interface/web/dns/dns_soa_del.php interface/web/dns/dns_template_del.php interface/web/dns/dns_template_list.php interface/web/dns/form/dns_template.tform.php interface/web/dns/lib/admin.conf.php interface/web/dns/list/dns_template.list.php interface/web/dns/templates/dns_records_edit.htm interface/web/dns/templates/dns_template_edit.htm interface/web/domain/lib/admin.conf.php interface/web/domain/lib/lang/en_domain_list.lng interface/web/help/templates/support_message_edit.htm interface/web/help/templates/support_message_view.htm interface/web/index.php interface/web/js/yui/datatable/assets/datatable.css interface/web/js/yui/logger/assets/logger.css interface/web/login/templates/password_reset.htm interface/web/mail/form/mail_mailinglist.tform.php interface/web/mail/lib/admin.conf.php interface/web/mail/lib/lang/en_mail_alias_list.lng interface/web/mail/lib/lang/en_mail_blacklist_list.lng interface/web/mail/lib/lang/en_mail_domain_admin_list.lng interface/web/mail/lib/lang/en_mail_domain_catchall_list.lng interface/web/mail/lib/lang/en_mail_forward_list.lng interface/web/mail/lib/lang/en_mail_mailinglist.lng interface/web/mail/lib/lang/en_mail_mailinglist_list.lng interface/web/mail/lib/lang/en_mail_spamfilter_list.lng interface/web/mail/lib/lang/en_mail_transport_list.lng interface/web/mail/lib/lang/en_mail_whitelist_list.lng interface/web/mail/lib/lang/en_spamfilter_policy_list.lng interface/web/mail/lib/lang/en_spamfilter_users_list.lng interface/web/mail/lib/lang/en_spamfilter_whitelist_list.lng interface/web/mail/lib/lang/fr_mail_user.lng interface/web/mail/lib/lang/id_mail_alias_list.lng interface/web/mail/lib/module.conf.php interface/web/mail/list/mail_mailinglist.list.php interface/web/mail/mail_domain_del.php interface/web/mail/mail_domain_edit.php interface/web/mail/mail_mailinglist_del.php interface/web/mail/mail_mailinglist_edit.php interface/web/mail/mail_mailinglist_list.php interface/web/mail/mailinglist.php interface/web/mail/templates/mail_alias_edit.htm interface/web/mail/templates/mail_blacklist_edit.htm interface/web/mail/templates/mail_content_filter_edit.htm interface/web/mail/templates/mail_domain_admin_list.htm interface/web/mail/templates/mail_domain_catchall_edit.htm interface/web/mail/templates/mail_get_edit.htm interface/web/mail/templates/mail_mailinglist_edit.htm interface/web/mail/templates/mail_mailinglist_list.htm interface/web/mail/templates/mail_relay_recipient_list.htm interface/web/mail/templates/mail_transport_edit.htm interface/web/mail/templates/mail_user_custom_rules_edit.htm interface/web/mail/templates/mail_user_stats_list.htm interface/web/mail/templates/mail_whitelist_edit.htm interface/web/mail/templates/spamfilter_blacklist_edit.htm interface/web/mail/templates/spamfilter_config_getmail_edit.htm interface/web/mail/templates/spamfilter_config_mail_edit.htm interface/web/mail/templates/spamfilter_config_server_edit.htm interface/web/mail/templates/spamfilter_other_edit.htm interface/web/mail/templates/spamfilter_policy_edit.htm interface/web/mail/templates/spamfilter_quarantine_edit.htm interface/web/mail/templates/spamfilter_taglevel_edit.htm interface/web/mail/templates/spamfilter_users_edit.htm interface/web/mail/templates/spamfilter_whitelist_edit.htm interface/web/monitor/lib/admin.conf.php interface/web/monitor/templates/datalog_list.htm interface/web/monitor/templates/show_data.htm interface/web/monitor/templates/show_log.htm interface/web/monitor/templates/show_sys_state.htm interface/web/monitor/templates/syslog_list.htm interface/web/nav.php interface/web/sites/cron_del.php interface/web/sites/cron_list.php interface/web/sites/lib/admin.conf.php interface/web/sites/lib/lang/en_database_admin_list.lng interface/web/sites/lib/lang/en_user_quota_stats_list.lng interface/web/sites/lib/lang/en_web_domain.lng interface/web/sites/lib/lang/en_web_domain_admin_list.lng interface/web/sites/templates/cron_edit.htm interface/web/sites/templates/database_admin_list.htm interface/web/sites/templates/ftp_user_advanced.htm interface/web/sites/templates/ftp_user_advanced_client.htm interface/web/sites/templates/ftp_user_edit.htm interface/web/sites/templates/shell_user_advanced.htm interface/web/sites/templates/shell_user_edit.htm interface/web/sites/templates/user_quota_stats_list.htm interface/web/sites/templates/web_aliasdomain_edit.htm interface/web/sites/templates/web_domain_admin_list.htm interface/web/sites/templates/web_domain_redirect.htm interface/web/sites/templates/web_subdomain_edit.htm interface/web/sites/templates/webdav_user_edit.htm interface/web/temp/en.lng interface/web/themes/default/css/central.css interface/web/themes/default/css/patches/central.css interface/web/themes/default/css/print/print_100.css interface/web/themes/default/css/screen/basemod_2col_left_seo.css interface/web/themes/default/css/screen/content.css interface/web/themes/default/css/screen/uni-form-generic.css interface/web/themes/default/licences.txt interface/web/themes/default/templates/module.tpl.htm interface/web/themes/default/templates/module_tree.tpl.htm interface/web/themes/default/templates/sidenav.tpl.htm interface/web/themes/default/templates/tabbed_form.tpl.htm interface/web/themes/default/templates/topnav.tpl.htm interface/web/themes/default/yaml/!important.txt interface/web/themes/default/yaml/core/base.css interface/web/themes/default/yaml/core/iehacks.css interface/web/themes/default/yaml/core/print_base.css interface/web/themes/default/yaml/core/slim_base.css interface/web/themes/default/yaml/core/slim_iehacks.css interface/web/themes/default/yaml/core/slim_print_base.css interface/web/themes/default/yaml/debug/debug.css interface/web/themes/default/yaml/navigation/nav_vlist.css interface/web/themes/default/yaml/patches/patch_layout_draft.css interface/web/themes/default/yaml/patches/patch_nav_vlist.css interface/web/themes/default/yaml/print/print_003_draft.css interface/web/themes/default/yaml/print/print_020_draft.css interface/web/themes/default/yaml/print/print_023_draft.css interface/web/themes/default/yaml/print/print_100_draft.css interface/web/themes/default/yaml/print/print_103_draft.css interface/web/themes/default/yaml/print/print_120_draft.css interface/web/themes/default/yaml/print/print_123_draft.css interface/web/themes/default/yaml/screen/basemod_draft.css interface/web/themes/default/yaml/screen/content_default.css interface/web/themes/default_64_navimg/css/additional.css interface/web/themes/default_no_navimg/css/additional.css interface/web/tools/form/user_settings.tform.php interface/web/tools/templates/user_settings.htm server/lib/classes/tpl_cache.inc.php server/lib/classes/tpl_error.inc.php server/mods-available/mail_module.inc.php server/mods-available/remoteaction_core_module.inc.php server/plugins-available/mailman_plugin.inc.php