From b1a6a5a3991cec5cd08873b01376e45d0b247f18 Mon Sep 17 00:00:00 2001 From: Marius Cramer Date: Thu, 14 Nov 2013 15:05:33 +0100 Subject: [PATCH] Cleaning up code to match coding guidelines --- helper_scripts/dns_export_to_bind.php | 148 +- .../dns_export_to_bind_retrans_daily.php | 8 +- .../mydns_to_powerdns_migration.php | 86 +- helper_scripts/recreate_webalizer_stats.php | 48 +- install/autoupdate.php | 46 +- install/dist/conf/centos52.conf.php | 4 +- install/dist/conf/centos53.conf.php | 4 +- install/dist/conf/debian40.conf.php | 4 +- install/dist/conf/debian60.conf.php | 6 +- install/dist/conf/fedora9.conf.php | 4 +- install/dist/conf/gentoo.conf.php | 8 +- install/dist/conf/opensuse110.conf.php | 4 +- install/dist/conf/opensuse112.conf.php | 4 +- install/dist/lib/centos52.lib.php | 88 +- install/dist/lib/centos53.lib.php | 88 +- install/dist/lib/debian40.lib.php | 2 +- install/dist/lib/debian60.lib.php | 79 +- install/dist/lib/fedora.lib.php | 890 ++-- install/dist/lib/fedora9.lib.php | 2 +- install/dist/lib/gentoo.lib.php | 627 +-- install/dist/lib/opensuse.lib.php | 900 ++-- install/dist/lib/opensuse110.lib.php | 2 +- install/dist/lib/opensuse112.lib.php | 2 +- install/install.php | 206 +- install/lib/install.lib.php | 271 +- install/lib/installer_base.lib.php | 743 ++-- install/lib/mysql.lib.php | 556 +-- install/lib/update.lib.php | 108 +- install/patches/upd_0001.php | 16 +- install/setrights.php | 36 +- install/uninstall-fedora.php | 8 +- install/uninstall.php | 8 +- install/update.php | 160 +- interface/lib/app.inc.php | 48 +- interface/lib/classes/aps_base.inc.php | 122 +- interface/lib/classes/aps_crawler.inc.php | 1018 ++--- .../lib/classes/aps_guicontroller.inc.php | 1422 +++---- interface/lib/classes/auth.inc.php | 66 +- .../lib/classes/client_templates.inc.php | 437 +- interface/lib/classes/cmstree.inc.php | 18 +- .../lib/classes/custom_datasource.inc.php | 68 +- interface/lib/classes/db_firebird.inc.php | 385 +- interface/lib/classes/db_mysql.inc.php | 972 ++--- interface/lib/classes/form.inc.php | 547 +-- interface/lib/classes/functions.inc.php | 272 +- interface/lib/classes/getconf.inc.php | 7 +- interface/lib/classes/importer.inc.php | 67 +- interface/lib/classes/ini_parser.inc.php | 4 +- interface/lib/classes/ispcmail.inc.php | 1385 ++++--- .../lib/classes/ispconfig_request.inc.php | 449 +- interface/lib/classes/json_handler.inc.php | 173 +- interface/lib/classes/listform.inc.php | 824 ++-- .../lib/classes/listform_actions.inc.php | 251 +- .../classes/listform_tpl_generator.inc.php | 90 +- interface/lib/classes/plugin.inc.php | 122 +- .../lib/classes/plugin_backuplist.inc.php | 230 +- interface/lib/classes/plugin_base.inc.php | 26 +- .../lib/classes/plugin_dbhistory.inc.php | 65 +- interface/lib/classes/plugin_listview.inc.php | 257 +- interface/lib/classes/remote.d/client.inc.php | 612 +-- interface/lib/classes/remote.d/dns.inc.php | 522 +-- .../lib/classes/remote.d/domains.inc.php | 34 +- interface/lib/classes/remote.d/mail.inc.php | 816 ++-- interface/lib/classes/remote.d/openvz.inc.php | 273 +- interface/lib/classes/remote.d/server.inc.php | 52 +- interface/lib/classes/remote.d/sites.inc.php | 587 +-- interface/lib/classes/remoting.inc.php | 505 +-- interface/lib/classes/remoting_lib.inc.php | 516 +-- interface/lib/classes/searchform.inc.php | 580 +-- .../lib/classes/searchform_actions.inc.php | 99 +- .../classes/searchform_tpl_generator.inc.php | 60 +- interface/lib/classes/session.inc.php | 92 +- interface/lib/classes/simplepie.inc.php | 3667 +++++++++-------- .../lib/classes/sites_database_plugin.inc.php | 59 +- interface/lib/classes/soap_handler.inc.php | 119 +- interface/lib/classes/tform.inc.php | 506 +-- interface/lib/classes/tform_actions.inc.php | 1080 ++--- interface/lib/classes/tform_base.inc.php | 2289 +++++----- .../lib/classes/tform_tpl_generator.inc.php | 293 +- interface/lib/classes/tools_monitor.inc.php | 810 ++-- interface/lib/classes/tools_sites.inc.php | 283 +- interface/lib/classes/tpl.inc.php | 2378 +++++------ interface/lib/classes/tpl_cache.inc.php | 315 +- interface/lib/classes/tpl_error.inc.php | 113 +- interface/lib/classes/tpl_ini.inc.php | 111 +- interface/lib/classes/tree.inc.php | 358 +- .../classes/validate_autoresponder.inc.php | 27 +- interface/lib/classes/validate_client.inc.php | 72 +- interface/lib/classes/validate_cron.inc.php | 304 +- .../lib/classes/validate_database.inc.php | 72 +- .../lib/classes/validate_datetime.inc.php | 78 +- interface/lib/classes/validate_dkim.inc.php | 115 +- interface/lib/classes/validate_dns.inc.php | 498 +-- interface/lib/classes/validate_domain.inc.php | 249 +- .../lib/classes/validate_ftpuser.inc.php | 110 +- .../lib/classes/validate_reseller.inc.php | 16 +- interface/lib/config.inc.php | 54 +- .../plugins/clients_template_plugin.inc.php | 42 +- .../plugins/mail_user_filter_plugin.inc.php | 114 +- .../sites_web_database_user_plugin.inc.php | 56 +- .../plugins/sites_web_domain_plugin.inc.php | 124 +- .../sites_web_vhost_subdomain_plugin.inc.php | 58 +- .../lib/plugins/vm_openvz_plugin.inc.php | 219 +- .../web/admin/directive_snippets_del.php | 6 +- .../web/admin/directive_snippets_edit.php | 6 +- .../web/admin/directive_snippets_list.php | 6 +- interface/web/admin/firewall_del.php | 6 +- interface/web/admin/firewall_edit.php | 7 +- interface/web/admin/firewall_list.php | 6 +- interface/web/admin/form/dbsync.tform.php | 330 +- .../admin/form/directive_snippets.tform.php | 94 +- interface/web/admin/form/filesync.tform.php | 238 +- interface/web/admin/form/firewall.tform.php | 114 +- interface/web/admin/form/groups.tform.php | 86 +- interface/web/admin/form/iptables.tform.php | 168 +- .../web/admin/form/remote_user.tform.php | 126 +- interface/web/admin/form/server.tform.php | 118 +- .../web/admin/form/server_config.tform.php | 206 +- interface/web/admin/form/server_ip.tform.php | 150 +- interface/web/admin/form/server_php.tform.php | 118 +- .../web/admin/form/software_package.tform.php | 82 +- .../web/admin/form/software_repo.tform.php | 142 +- .../web/admin/form/system_config.tform.php | 588 +-- .../web/admin/form/tpl_default.tform.php | 70 +- interface/web/admin/form/users.tform.php | 348 +- interface/web/admin/groups_del.php | 6 +- interface/web/admin/groups_edit.php | 6 +- interface/web/admin/groups_list.php | 6 +- interface/web/admin/index.php | 13 +- interface/web/admin/iptables_del.php | 6 +- interface/web/admin/iptables_edit.php | 8 +- interface/web/admin/iptables_list.php | 6 +- interface/web/admin/language_add.php | 48 +- interface/web/admin/language_complete.php | 94 +- interface/web/admin/language_edit.php | 24 +- interface/web/admin/language_export.php | 52 +- interface/web/admin/language_import.php | 184 +- interface/web/admin/language_list.php | 58 +- interface/web/admin/lib/module.conf.php | 196 +- interface/web/admin/lib/remote.conf.php | 2 +- .../admin/list/directive_snippets.list.php | 78 +- interface/web/admin/list/firewall.list.php | 108 +- interface/web/admin/list/groups.list.php | 50 +- interface/web/admin/list/iptables.list.php | 182 +- interface/web/admin/list/remote_user.list.php | 49 +- interface/web/admin/list/server.list.php | 154 +- .../web/admin/list/server_config.list.php | 38 +- interface/web/admin/list/server_ip.list.php | 144 +- interface/web/admin/list/server_php.list.php | 92 +- .../web/admin/list/software_repo.list.php | 78 +- interface/web/admin/list/users.list.php | 82 +- interface/web/admin/login_as.php | 16 +- .../web/admin/remote_action_ispcupdate.php | 26 +- .../web/admin/remote_action_osupdate.php | 26 +- interface/web/admin/remote_user_del.php | 11 +- interface/web/admin/remote_user_edit.php | 16 +- interface/web/admin/remote_user_list.php | 10 +- interface/web/admin/server_config_del.php | 6 +- interface/web/admin/server_config_edit.php | 44 +- interface/web/admin/server_config_list.php | 6 +- interface/web/admin/server_del.php | 6 +- interface/web/admin/server_edit.php | 22 +- interface/web/admin/server_ip_del.php | 6 +- interface/web/admin/server_ip_edit.php | 7 +- interface/web/admin/server_ip_list.php | 6 +- interface/web/admin/server_list.php | 6 +- interface/web/admin/server_php_del.php | 6 +- interface/web/admin/server_php_edit.php | 7 +- interface/web/admin/server_php_list.php | 6 +- interface/web/admin/software_package_del.php | 8 +- interface/web/admin/software_package_edit.php | 8 +- .../web/admin/software_package_install.php | 78 +- interface/web/admin/software_package_list.php | 120 +- interface/web/admin/software_repo_del.php | 6 +- interface/web/admin/software_repo_edit.php | 8 +- interface/web/admin/software_repo_list.php | 6 +- interface/web/admin/software_update_list.php | 58 +- interface/web/admin/system_config_edit.php | 122 +- interface/web/admin/tpl_default.php | 36 +- interface/web/admin/users_del.php | 6 +- interface/web/admin/users_edit.php | 34 +- interface/web/admin/users_list.php | 6 +- interface/web/capp.php | 40 +- interface/web/client/client_circle_del.php | 4 +- interface/web/client/client_circle_edit.php | 4 +- interface/web/client/client_circle_list.php | 6 +- interface/web/client/client_del.php | 137 +- interface/web/client/client_edit.php | 398 +- interface/web/client/client_list.php | 6 +- interface/web/client/client_message.php | 58 +- interface/web/client/client_template_del.php | 17 +- interface/web/client/client_template_edit.php | 17 +- interface/web/client/client_template_list.php | 4 +- interface/web/client/domain_del.php | 15 +- interface/web/client/domain_edit.php | 11 +- interface/web/client/domain_list.php | 6 +- interface/web/client/domain_new_client.php | 4 +- interface/web/client/form/client.tform.php | 1696 ++++---- .../web/client/form/client_circle.tform.php | 126 +- .../web/client/form/client_template.tform.php | 960 ++--- interface/web/client/form/domain.tform.php | 84 +- interface/web/client/form/reseller.tform.php | 1700 ++++---- interface/web/client/lib/admin.conf.php | 2 +- interface/web/client/lib/module.conf.php | 100 +- interface/web/client/list/client.list.php | 132 +- .../web/client/list/client_circle.list.php | 94 +- .../web/client/list/client_template.list.php | 74 +- interface/web/client/list/domain.list.php | 74 +- interface/web/client/list/reseller.list.php | 152 +- interface/web/client/reseller_del.php | 33 +- interface/web/client/reseller_edit.php | 117 +- interface/web/client/reseller_list.php | 6 +- interface/web/content.php | 26 +- interface/web/dashboard/ajax_get_json.php | 224 +- interface/web/dashboard/dashboard.php | 50 +- interface/web/dashboard/dashlets/limits.php | 188 +- .../web/dashboard/dashlets/mailquota.php | 43 +- interface/web/dashboard/dashlets/modules.php | 31 +- interface/web/dashboard/dashlets/quota.php | 55 +- interface/web/dashboard/lib/admin.conf.php | 2 +- .../web/dashboard/lib/custom_menu.inc.php | 42 +- interface/web/dashboard/lib/module.conf.php | 22 +- interface/web/designer/form_edit.php | 68 +- interface/web/designer/form_list.php | 44 +- interface/web/designer/form_show.php | 46 +- interface/web/designer/index.php | 1 + interface/web/designer/lib/admin.conf.php | 2 +- interface/web/designer/lib/module.conf.php | 86 +- interface/web/designer/module_edit.php | 94 +- interface/web/designer/module_list.php | 34 +- interface/web/designer/module_nav_del.php | 50 +- interface/web/designer/module_nav_edit.php | 82 +- interface/web/designer/module_nav_flip.php | 52 +- .../web/designer/module_nav_item_del.php | 52 +- .../web/designer/module_nav_item_edit.php | 82 +- .../web/designer/module_nav_item_flip.php | 54 +- interface/web/designer/module_show.php | 44 +- interface/web/dns/ajax_get_json.php | 78 +- interface/web/dns/dns_a_edit.php | 42 +- interface/web/dns/dns_a_list.php | 6 +- interface/web/dns/dns_aaaa_edit.php | 40 +- interface/web/dns/dns_alias_edit.php | 39 +- interface/web/dns/dns_cname_edit.php | 41 +- interface/web/dns/dns_dkim_edit.php | 27 +- interface/web/dns/dns_dkim_get.php | 117 +- interface/web/dns/dns_hinfo_edit.php | 39 +- interface/web/dns/dns_import.php | 406 +- interface/web/dns/dns_mx_edit.php | 55 +- interface/web/dns/dns_ns_edit.php | 39 +- interface/web/dns/dns_ptr_edit.php | 39 +- interface/web/dns/dns_rp_edit.php | 39 +- interface/web/dns/dns_rr_del.php | 9 +- interface/web/dns/dns_slave_del.php | 15 +- interface/web/dns/dns_slave_edit.php | 100 +- interface/web/dns/dns_slave_list.php | 6 +- interface/web/dns/dns_soa_del.php | 15 +- interface/web/dns/dns_soa_edit.php | 116 +- interface/web/dns/dns_soa_list.php | 6 +- interface/web/dns/dns_srv_edit.php | 7 +- interface/web/dns/dns_template_del.php | 6 +- interface/web/dns/dns_template_edit.php | 8 +- interface/web/dns/dns_template_list.php | 6 +- interface/web/dns/dns_txt_edit.php | 39 +- interface/web/dns/dns_wizard.php | 116 +- interface/web/dns/form/dns_a.tform.php | 180 +- interface/web/dns/form/dns_aaaa.tform.php | 166 +- interface/web/dns/form/dns_alias.tform.php | 198 +- interface/web/dns/form/dns_cname.tform.php | 194 +- interface/web/dns/form/dns_dkim.tform.php | 172 +- interface/web/dns/form/dns_hinfo.tform.php | 178 +- interface/web/dns/form/dns_mx.tform.php | 210 +- interface/web/dns/form/dns_ns.tform.php | 194 +- interface/web/dns/form/dns_ptr.tform.php | 194 +- interface/web/dns/form/dns_rp.tform.php | 178 +- interface/web/dns/form/dns_slave.tform.php | 154 +- interface/web/dns/form/dns_soa.tform.php | 394 +- interface/web/dns/form/dns_srv.tform.php | 192 +- interface/web/dns/form/dns_template.tform.php | 96 +- interface/web/dns/form/dns_txt.tform.php | 174 +- interface/web/dns/lib/admin.conf.php | 2 +- interface/web/dns/lib/module.conf.php | 68 +- interface/web/dns/lib/remote.conf.php | 2 +- interface/web/dns/list/dns_a.list.php | 196 +- interface/web/dns/list/dns_slave.list.php | 116 +- interface/web/dns/list/dns_soa.list.php | 128 +- interface/web/dns/list/dns_template.list.php | 58 +- interface/web/help/faq_delete.php | 6 +- interface/web/help/faq_edit.php | 6 +- interface/web/help/faq_list.php | 8 +- .../web/help/faq_manage_questions_list.php | 6 +- interface/web/help/faq_sections_delete.php | 6 +- interface/web/help/faq_sections_edit.php | 6 +- interface/web/help/faq_sections_list.php | 6 +- interface/web/help/form/faq.tform.php | 118 +- .../web/help/form/faq_sections.tform.php | 60 +- .../web/help/form/support_message.tform.php | 144 +- interface/web/help/index.php | 2 +- interface/web/help/lib/admin.conf.php | 2 +- interface/web/help/lib/module.conf.php | 74 +- interface/web/help/list/faq_list.php | 2 +- .../help/list/faq_manage_questions_list.php | 26 +- interface/web/help/list/faq_sections_list.php | 2 +- .../web/help/list/support_message.list.php | 88 +- interface/web/help/support_message_del.php | 6 +- interface/web/help/support_message_edit.php | 58 +- interface/web/help/support_message_list.php | 6 +- interface/web/help/version.php | 6 +- interface/web/index.php | 38 +- interface/web/js/scrigo.js.php | 97 +- interface/web/keepalive.php | 6 +- interface/web/login/index.php | 158 +- interface/web/login/lib/module.conf.php | 10 +- interface/web/login/logout.php | 12 +- interface/web/login/password_reset.php | 34 +- interface/web/mail/form/mail_alias.tform.php | 142 +- .../web/mail/form/mail_aliasdomain.tform.php | 140 +- .../web/mail/form/mail_blacklist.tform.php | 106 +- .../mail/form/mail_content_filter.tform.php | 114 +- interface/web/mail/form/mail_domain.tform.php | 164 +- .../mail/form/mail_domain_catchall.tform.php | 142 +- .../web/mail/form/mail_forward.tform.php | 130 +- interface/web/mail/form/mail_get.tform.php | 206 +- .../web/mail/form/mail_mailinglist.tform.php | 166 +- .../mail/form/mail_relay_recipient.tform.php | 98 +- .../web/mail/form/mail_spamfilter.tform.php | 162 +- .../web/mail/form/mail_transport.tform.php | 116 +- interface/web/mail/form/mail_user.tform.php | 424 +- .../web/mail/form/mail_user_filter.tform.php | 142 +- .../web/mail/form/mail_whitelist.tform.php | 106 +- .../mail/form/spamfilter_blacklist.tform.php | 120 +- .../web/mail/form/spamfilter_config.tform.php | 380 +- .../web/mail/form/spamfilter_policy.tform.php | 510 +-- .../web/mail/form/spamfilter_users.tform.php | 144 +- .../mail/form/spamfilter_whitelist.tform.php | 134 +- interface/web/mail/lib/admin.conf.php | 2 +- interface/web/mail/lib/module.conf.php | 228 +- interface/web/mail/lib/remote.conf.php | 2 +- interface/web/mail/list/mail_alias.list.php | 92 +- .../web/mail/list/mail_aliasdomain.list.php | 92 +- .../web/mail/list/mail_blacklist.list.php | 112 +- .../mail/list/mail_content_filter.list.php | 112 +- interface/web/mail/list/mail_domain.list.php | 120 +- .../mail/list/mail_domain_catchall.list.php | 92 +- interface/web/mail/list/mail_forward.list.php | 92 +- interface/web/mail/list/mail_get.list.php | 132 +- .../web/mail/list/mail_mailinglist.list.php | 64 +- .../mail/list/mail_relay_recipient.list.php | 92 +- .../web/mail/list/mail_spamfilter.list.php | 92 +- .../web/mail/list/mail_transport.list.php | 134 +- interface/web/mail/list/mail_user.list.php | 92 +- .../web/mail/list/mail_user_filter.list.php | 38 +- .../web/mail/list/mail_user_stats.list.php | 44 +- .../web/mail/list/mail_whitelist.list.php | 104 +- .../mail/list/spamfilter_blacklist.list.php | 138 +- .../web/mail/list/spamfilter_config.list.php | 38 +- .../web/mail/list/spamfilter_policy.list.php | 102 +- .../web/mail/list/spamfilter_users.list.php | 138 +- .../mail/list/spamfilter_whitelist.list.php | 138 +- .../web/mail/list/user_quota_stats.list.php | 70 +- interface/web/mail/mail_alias_del.php | 6 +- interface/web/mail/mail_alias_edit.php | 64 +- interface/web/mail/mail_alias_list.php | 6 +- interface/web/mail/mail_aliasdomain_del.php | 6 +- interface/web/mail/mail_aliasdomain_edit.php | 64 +- interface/web/mail/mail_aliasdomain_list.php | 6 +- interface/web/mail/mail_blacklist_del.php | 6 +- interface/web/mail/mail_blacklist_edit.php | 18 +- interface/web/mail/mail_blacklist_list.php | 6 +- .../web/mail/mail_content_filter_del.php | 6 +- .../web/mail/mail_content_filter_edit.php | 7 +- .../web/mail/mail_content_filter_list.php | 6 +- .../web/mail/mail_domain_catchall_del.php | 6 +- .../web/mail/mail_domain_catchall_edit.php | 52 +- .../web/mail/mail_domain_catchall_list.php | 6 +- interface/web/mail/mail_domain_del.php | 33 +- .../web/mail/mail_domain_dkim_create.php | 148 +- interface/web/mail/mail_domain_edit.php | 58 +- interface/web/mail/mail_domain_list.php | 6 +- interface/web/mail/mail_forward_del.php | 6 +- interface/web/mail/mail_forward_edit.php | 54 +- interface/web/mail/mail_forward_list.php | 6 +- interface/web/mail/mail_get_del.php | 6 +- interface/web/mail/mail_get_edit.php | 34 +- interface/web/mail/mail_get_list.php | 6 +- interface/web/mail/mail_mailinglist_del.php | 6 +- interface/web/mail/mail_mailinglist_edit.php | 62 +- interface/web/mail/mail_mailinglist_list.php | 22 +- .../web/mail/mail_relay_recipient_del.php | 6 +- .../web/mail/mail_relay_recipient_edit.php | 8 +- .../web/mail/mail_relay_recipient_list.php | 8 +- interface/web/mail/mail_spamfilter_del.php | 6 +- interface/web/mail/mail_spamfilter_edit.php | 52 +- interface/web/mail/mail_spamfilter_list.php | 6 +- interface/web/mail/mail_transport_del.php | 6 +- interface/web/mail/mail_transport_edit.php | 46 +- interface/web/mail/mail_transport_list.php | 6 +- interface/web/mail/mail_user_del.php | 27 +- interface/web/mail/mail_user_edit.php | 144 +- interface/web/mail/mail_user_filter_del.php | 18 +- interface/web/mail/mail_user_filter_edit.php | 92 +- interface/web/mail/mail_user_list.php | 32 +- interface/web/mail/mail_user_stats.php | 103 +- interface/web/mail/mail_whitelist_del.php | 6 +- interface/web/mail/mail_whitelist_edit.php | 18 +- interface/web/mail/mail_whitelist_list.php | 6 +- interface/web/mail/mailinglist.php | 12 +- .../web/mail/spamfilter_blacklist_del.php | 6 +- .../web/mail/spamfilter_blacklist_edit.php | 21 +- .../web/mail/spamfilter_blacklist_list.php | 6 +- interface/web/mail/spamfilter_config_del.php | 6 +- interface/web/mail/spamfilter_config_edit.php | 38 +- interface/web/mail/spamfilter_config_list.php | 6 +- interface/web/mail/spamfilter_policy_del.php | 6 +- interface/web/mail/spamfilter_policy_edit.php | 17 +- interface/web/mail/spamfilter_policy_list.php | 6 +- interface/web/mail/spamfilter_users_del.php | 6 +- interface/web/mail/spamfilter_users_edit.php | 19 +- interface/web/mail/spamfilter_users_list.php | 6 +- .../web/mail/spamfilter_whitelist_del.php | 6 +- .../web/mail/spamfilter_whitelist_edit.php | 21 +- .../web/mail/spamfilter_whitelist_list.php | 6 +- interface/web/mail/user_quota_stats.php | 41 +- interface/web/mail/webmailer.php | 12 +- .../form/mail_user_autoresponder.tform.php | 86 +- .../web/mailuser/form/mail_user_cc.tform.php | 68 +- .../mailuser/form/mail_user_filter.tform.php | 134 +- .../form/mail_user_password.tform.php | 46 +- .../form/mail_user_spamfilter.tform.php | 44 +- interface/web/mailuser/index.php | 20 +- interface/web/mailuser/lib/admin.conf.php | 2 +- interface/web/mailuser/lib/module.conf.php | 58 +- interface/web/mailuser/lib/remote.conf.php | 2 +- .../mailuser/list/mail_user_filter.list.php | 38 +- .../mailuser/mail_user_autoresponder_edit.php | 36 +- interface/web/mailuser/mail_user_cc_edit.php | 32 +- .../web/mailuser/mail_user_filter_del.php | 8 +- .../web/mailuser/mail_user_filter_edit.php | 32 +- .../web/mailuser/mail_user_filter_list.php | 8 +- .../web/mailuser/mail_user_password_edit.php | 20 +- .../mailuser/mail_user_spamfilter_edit.php | 44 +- interface/web/monitor/datalog_del.php | 6 +- interface/web/monitor/datalog_list.php | 8 +- interface/web/monitor/lib/admin.conf.php | 2 +- interface/web/monitor/lib/module.conf.php | 306 +- interface/web/monitor/list/datalog.list.php | 110 +- interface/web/monitor/list/log.list.php | 110 +- interface/web/monitor/log_del.php | 6 +- interface/web/monitor/log_list.php | 6 +- interface/web/monitor/show_data.php | 206 +- interface/web/monitor/show_log.php | 130 +- interface/web/monitor/show_monit.php | 14 +- interface/web/monitor/show_munin.php | 14 +- interface/web/monitor/show_sys_state.php | 474 +-- interface/web/nav.php | 30 +- interface/web/remote/index.php | 6 +- interface/web/remote/json.php | 6 +- interface/web/remote/monitor.php | 140 +- interface/web/sites/ajax_get_ip.php | 10 +- interface/web/sites/ajax_get_json.php | 282 +- .../web/sites/aps_availablepackages_list.php | 8 +- .../web/sites/aps_cron_apscrawler_if.php | 6 +- interface/web/sites/aps_do_operation.php | 126 +- interface/web/sites/aps_install_package.php | 188 +- .../web/sites/aps_installedpackages_list.php | 106 +- .../web/sites/aps_packagedetails_show.php | 46 +- .../web/sites/aps_update_packagelist.php | 12 +- interface/web/sites/cron_del.php | 11 +- interface/web/sites/cron_edit.php | 202 +- interface/web/sites/cron_list.php | 6 +- interface/web/sites/database_del.php | 15 +- interface/web/sites/database_edit.php | 240 +- interface/web/sites/database_list.php | 22 +- interface/web/sites/database_phpmyadmin.php | 22 +- interface/web/sites/database_user_del.php | 51 +- interface/web/sites/database_user_edit.php | 76 +- interface/web/sites/database_user_list.php | 14 +- interface/web/sites/form/cron.tform.php | 270 +- interface/web/sites/form/database.tform.php | 214 +- .../web/sites/form/database_user.tform.php | 124 +- interface/web/sites/form/ftp_user.tform.php | 388 +- interface/web/sites/form/shell_user.tform.php | 278 +- .../web/sites/form/web_aliasdomain.tform.php | 228 +- interface/web/sites/form/web_domain.tform.php | 1088 ++--- interface/web/sites/form/web_folder.tform.php | 106 +- .../web/sites/form/web_folder_user.tform.php | 124 +- .../web/sites/form/web_subdomain.tform.php | 202 +- .../sites/form/web_vhost_subdomain.tform.php | 1080 ++--- .../web/sites/form/webdav_user.tform.php | 152 +- interface/web/sites/ftp_user_del.php | 6 +- interface/web/sites/ftp_user_edit.php | 81 +- interface/web/sites/ftp_user_list.php | 24 +- interface/web/sites/lib/admin.conf.php | 2 +- interface/web/sites/lib/module.conf.php | 244 +- interface/web/sites/lib/remote.conf.php | 2 +- .../sites/list/aps_availablepackages.list.php | 74 +- .../sites/list/aps_installedpackages.list.php | 64 +- interface/web/sites/list/cron.list.php | 178 +- interface/web/sites/list/database.list.php | 210 +- .../web/sites/list/database_user.list.php | 66 +- interface/web/sites/list/ftp_user.list.php | 124 +- interface/web/sites/list/shell_user.list.php | 124 +- .../web/sites/list/user_quota_stats.list.php | 68 +- .../web/sites/list/web_aliasdomain.list.php | 130 +- interface/web/sites/list/web_domain.list.php | 142 +- interface/web/sites/list/web_folder.list.php | 124 +- .../web/sites/list/web_folder_user.list.php | 96 +- .../web/sites/list/web_sites_stats.list.php | 44 +- .../web/sites/list/web_subdomain.list.php | 130 +- .../sites/list/web_vhost_subdomain.list.php | 130 +- interface/web/sites/list/webdav_user.list.php | 118 +- interface/web/sites/shell_user_del.php | 6 +- interface/web/sites/shell_user_edit.php | 85 +- interface/web/sites/shell_user_list.php | 6 +- interface/web/sites/user_quota_stats.php | 43 +- interface/web/sites/web_aliasdomain_del.php | 6 +- interface/web/sites/web_aliasdomain_edit.php | 90 +- interface/web/sites/web_aliasdomain_list.php | 6 +- interface/web/sites/web_domain_del.php | 77 +- interface/web/sites/web_domain_edit.php | 464 +-- interface/web/sites/web_domain_list.php | 8 +- interface/web/sites/web_folder_del.php | 15 +- interface/web/sites/web_folder_edit.php | 16 +- interface/web/sites/web_folder_list.php | 6 +- interface/web/sites/web_folder_user_del.php | 6 +- interface/web/sites/web_folder_user_edit.php | 17 +- interface/web/sites/web_folder_user_list.php | 6 +- interface/web/sites/web_sites_stats.php | 141 +- interface/web/sites/web_subdomain_del.php | 6 +- interface/web/sites/web_subdomain_edit.php | 118 +- interface/web/sites/web_subdomain_list.php | 6 +- .../web/sites/web_vhost_subdomain_del.php | 23 +- .../web/sites/web_vhost_subdomain_edit.php | 414 +- .../web/sites/web_vhost_subdomain_list.php | 6 +- interface/web/sites/webdav_user_del.php | 6 +- interface/web/sites/webdav_user_edit.php | 25 +- interface/web/sites/webdav_user_list.php | 6 +- interface/web/tools/dns_import_tupa.php | 66 +- .../tools/form/interface_settings.tform.php | 126 +- .../web/tools/form/tpl_default.tform.php | 166 +- .../web/tools/form/user_settings.tform.php | 112 +- interface/web/tools/import_ispconfig.php | 134 +- interface/web/tools/import_plesk.php | 2159 +++++----- interface/web/tools/import_vpopmail.php | 122 +- interface/web/tools/index.php | 8 +- interface/web/tools/interface_settings.php | 123 +- .../lib/interface.d/tpl_default.menu.php | 4 +- .../web/tools/lib/menu.d/import.menu.php | 28 +- .../web/tools/lib/menu.d/resync.menu.php | 18 +- .../web/tools/lib/menu.d/statistics.menu.php | 2 +- interface/web/tools/lib/module.conf.php | 38 +- interface/web/tools/resync.php | 40 +- interface/web/tools/tpl_default.php | 6 +- interface/web/tools/user_settings.php | 62 +- interface/web/vm/ajax_get_ip.php | 10 +- interface/web/vm/form/openvz_ip.tform.php | 116 +- .../web/vm/form/openvz_ostemplate.tform.php | 132 +- .../web/vm/form/openvz_template.tform.php | 684 +-- interface/web/vm/form/openvz_vm.tform.php | 454 +- interface/web/vm/lib/admin.conf.php | 2 +- interface/web/vm/lib/module.conf.php | 52 +- interface/web/vm/lib/remote.conf.php | 2 +- interface/web/vm/list/openvz_ip.list.php | 122 +- .../web/vm/list/openvz_ostemplate.list.php | 128 +- .../web/vm/list/openvz_template.list.php | 54 +- interface/web/vm/list/openvz_vm.list.php | 186 +- interface/web/vm/openvz_action.php | 130 +- interface/web/vm/openvz_ip_del.php | 6 +- interface/web/vm/openvz_ip_edit.php | 8 +- interface/web/vm/openvz_ip_list.php | 6 +- interface/web/vm/openvz_ostemplate_del.php | 6 +- interface/web/vm/openvz_ostemplate_edit.php | 8 +- interface/web/vm/openvz_ostemplate_list.php | 6 +- interface/web/vm/openvz_template_del.php | 6 +- interface/web/vm/openvz_template_edit.php | 20 +- interface/web/vm/openvz_template_list.php | 6 +- interface/web/vm/openvz_vm_del.php | 6 +- interface/web/vm/openvz_vm_edit.php | 58 +- interface/web/vm/openvz_vm_list.php | 6 +- remoting_client/examples/client_add.php | 144 +- .../examples/client_change_password.php | 20 +- remoting_client/examples/client_delete.php | 16 +- .../examples/client_delete_everything.php | 16 +- remoting_client/examples/client_get.php | 20 +- .../examples/client_get_by_username.php | 20 +- remoting_client/examples/client_get_id.php | 20 +- .../examples/client_get_sites_by_user.php | 20 +- .../examples/client_templates_get_all.php | 18 +- remoting_client/examples/client_update.php | 20 +- remoting_client/examples/dns_a_add.php | 42 +- remoting_client/examples/dns_a_delete.php | 16 +- remoting_client/examples/dns_a_get.php | 20 +- remoting_client/examples/dns_a_update.php | 18 +- remoting_client/examples/dns_aaaa_add.php | 42 +- remoting_client/examples/dns_aaaa_delete.php | 16 +- remoting_client/examples/dns_aaaa_get.php | 20 +- remoting_client/examples/dns_aaaa_update.php | 18 +- remoting_client/examples/dns_alias_add.php | 42 +- remoting_client/examples/dns_alias_delete.php | 16 +- remoting_client/examples/dns_alias_get.php | 20 +- remoting_client/examples/dns_alias_update.php | 18 +- remoting_client/examples/dns_cname_add.php | 42 +- remoting_client/examples/dns_cname_delete.php | 16 +- remoting_client/examples/dns_cname_get.php | 20 +- remoting_client/examples/dns_cname_update.php | 18 +- remoting_client/examples/dns_hinfo_add.php | 42 +- remoting_client/examples/dns_hinfo_delete.php | 16 +- remoting_client/examples/dns_hinfo_get.php | 20 +- remoting_client/examples/dns_hinfo_update.php | 18 +- remoting_client/examples/dns_mx_add.php | 42 +- remoting_client/examples/dns_mx_delete.php | 16 +- remoting_client/examples/dns_mx_get.php | 20 +- remoting_client/examples/dns_mx_update.php | 18 +- remoting_client/examples/dns_ns_add.php | 42 +- remoting_client/examples/dns_ns_delete.php | 16 +- remoting_client/examples/dns_ns_get.php | 20 +- remoting_client/examples/dns_ns_update.php | 18 +- remoting_client/examples/dns_ptr_add.php | 42 +- remoting_client/examples/dns_ptr_delete.php | 16 +- remoting_client/examples/dns_ptr_get.php | 20 +- remoting_client/examples/dns_ptr_update.php | 18 +- remoting_client/examples/dns_rp_add.php | 42 +- remoting_client/examples/dns_rp_delete.php | 16 +- remoting_client/examples/dns_rp_get.php | 20 +- remoting_client/examples/dns_rp_update.php | 18 +- .../examples/dns_rr_get_all_by_zone.php | 20 +- remoting_client/examples/dns_srv_add.php | 42 +- remoting_client/examples/dns_srv_delete.php | 16 +- remoting_client/examples/dns_srv_get.php | 20 +- remoting_client/examples/dns_srv_update.php | 18 +- remoting_client/examples/dns_txt_add.php | 42 +- remoting_client/examples/dns_txt_delete.php | 16 +- remoting_client/examples/dns_txt_get.php | 20 +- remoting_client/examples/dns_txt_update.php | 18 +- remoting_client/examples/dns_zone_add.php | 50 +- remoting_client/examples/dns_zone_delete.php | 16 +- remoting_client/examples/dns_zone_get.php | 20 +- .../examples/dns_zone_get_by_user.php | 20 +- .../examples/dns_zone_set_status.php | 20 +- remoting_client/examples/dns_zone_update.php | 18 +- .../examples/domains_domain_add.php | 24 +- .../examples/domains_domain_delete.php | 16 +- .../examples/domains_domain_get.php | 20 +- .../examples/domains_get_all_by_user.php | 20 +- .../examples/get_function_list.php | 20 +- remoting_client/examples/login.php | 18 +- remoting_client/examples/logout.php | 16 +- remoting_client/examples/mail_alias_add.php | 32 +- .../examples/mail_alias_delete.php | 16 +- remoting_client/examples/mail_alias_get.php | 20 +- .../examples/mail_alias_update.php | 18 +- .../examples/mail_blacklist_add.php | 32 +- .../examples/mail_blacklist_delete.php | 16 +- .../examples/mail_blacklist_get.php | 20 +- .../examples/mail_blacklist_update.php | 18 +- .../examples/mail_catchall_add.php | 32 +- .../examples/mail_catchall_delete.php | 16 +- .../examples/mail_catchall_get.php | 20 +- .../examples/mail_catchall_update.php | 18 +- remoting_client/examples/mail_domain_add.php | 28 +- .../examples/mail_domain_delete.php | 16 +- remoting_client/examples/mail_domain_get.php | 20 +- .../examples/mail_domain_get_by_domain.php | 20 +- .../examples/mail_domain_set_status.php | 20 +- .../examples/mail_domain_update.php | 18 +- .../examples/mail_fetchmail_add.php | 40 +- .../examples/mail_fetchmail_delete.php | 16 +- .../examples/mail_fetchmail_get.php | 20 +- .../examples/mail_fetchmail_update.php | 18 +- remoting_client/examples/mail_filter_add.php | 34 +- .../examples/mail_filter_delete.php | 16 +- remoting_client/examples/mail_filter_get.php | 20 +- .../examples/mail_filter_update.php | 18 +- remoting_client/examples/mail_forward_add.php | 32 +- .../examples/mail_forward_delete.php | 16 +- remoting_client/examples/mail_forward_get.php | 20 +- .../examples/mail_forward_update.php | 18 +- .../examples/mail_mailinglist_add.php | 32 +- .../examples/mail_mailinglist_delete.php | 16 +- .../examples/mail_mailinglist_get.php | 20 +- .../examples/mail_mailinglist_update.php | 18 +- remoting_client/examples/mail_policy_add.php | 100 +- .../examples/mail_policy_delete.php | 16 +- remoting_client/examples/mail_policy_get.php | 20 +- .../examples/mail_policy_update.php | 18 +- .../mail_spamfilter_blacklist_add.php | 34 +- .../mail_spamfilter_blacklist_delete.php | 16 +- .../mail_spamfilter_blacklist_get.php | 20 +- .../mail_spamfilter_blacklist_update.php | 18 +- .../examples/mail_spamfilter_user_add.php | 34 +- .../examples/mail_spamfilter_user_delete.php | 16 +- .../examples/mail_spamfilter_user_get.php | 20 +- .../examples/mail_spamfilter_user_update.php | 18 +- .../mail_spamfilter_whitelist_add.php | 34 +- .../mail_spamfilter_whitelist_delete.php | 16 +- .../mail_spamfilter_whitelist_get.php | 20 +- .../mail_spamfilter_whitelist_update.php | 18 +- .../examples/mail_transport_add.php | 32 +- .../examples/mail_transport_delete.php | 16 +- .../examples/mail_transport_get.php | 20 +- .../examples/mail_transport_update.php | 18 +- remoting_client/examples/mail_user_add.php | 68 +- remoting_client/examples/mail_user_delete.php | 16 +- .../examples/mail_user_filter_add.php | 38 +- .../examples/mail_user_filter_delete.php | 16 +- .../examples/mail_user_filter_get.php | 20 +- .../examples/mail_user_filter_update.php | 18 +- remoting_client/examples/mail_user_get.php | 20 +- remoting_client/examples/mail_user_update.php | 18 +- .../examples/mail_whitelist_add.php | 32 +- .../examples/mail_whitelist_delete.php | 16 +- .../examples/mail_whitelist_get.php | 20 +- .../examples/mail_whitelist_update.php | 18 +- .../examples/openvz_get_free_ip.php | 18 +- remoting_client/examples/openvz_ip_add.php | 30 +- remoting_client/examples/openvz_ip_delete.php | 16 +- remoting_client/examples/openvz_ip_get.php | 20 +- remoting_client/examples/openvz_ip_update.php | 18 +- .../examples/openvz_ostemplate_add.php | 34 +- .../examples/openvz_ostemplate_delete.php | 16 +- .../examples/openvz_ostemplate_get.php | 20 +- .../examples/openvz_ostemplate_update.php | 18 +- .../examples/openvz_template_add.php | 98 +- .../examples/openvz_template_delete.php | 16 +- .../examples/openvz_template_get.php | 20 +- .../examples/openvz_template_update.php | 18 +- remoting_client/examples/openvz_vm_add.php | 70 +- .../examples/openvz_vm_add_from_template.php | 22 +- remoting_client/examples/openvz_vm_delete.php | 16 +- remoting_client/examples/openvz_vm_get.php | 20 +- .../examples/openvz_vm_get_by_client.php | 20 +- remoting_client/examples/openvz_vm_update.php | 18 +- remoting_client/examples/server_get.php | 20 +- .../examples/server_get_serverid_by_ip.php | 20 +- remoting_client/examples/sites_cron_add.php | 46 +- .../examples/sites_cron_delete.php | 16 +- remoting_client/examples/sites_cron_get.php | 20 +- .../examples/sites_cron_update.php | 18 +- .../examples/sites_database_add.php | 44 +- .../examples/sites_database_delete.php | 16 +- .../examples/sites_database_get.php | 20 +- .../sites_database_get_all_by_user.php | 20 +- .../examples/sites_database_update.php | 18 +- .../examples/sites_database_user_add.php | 28 +- .../examples/sites_database_user_delete.php | 16 +- .../examples/sites_database_user_get.php | 20 +- .../examples/sites_database_user_update.php | 18 +- .../examples/sites_ftp_user_add.php | 54 +- .../examples/sites_ftp_user_delete.php | 16 +- .../examples/sites_ftp_user_get.php | 20 +- .../examples/sites_ftp_user_update.php | 18 +- .../examples/sites_shell_user_add.php | 48 +- .../examples/sites_shell_user_delete.php | 16 +- .../examples/sites_shell_user_get.php | 20 +- .../examples/sites_shell_user_update.php | 18 +- .../examples/sites_web_aliasdomain_add.php | 106 +- .../examples/sites_web_aliasdomain_delete.php | 16 +- .../examples/sites_web_aliasdomain_get.php | 20 +- .../examples/sites_web_aliasdomain_update.php | 18 +- .../examples/sites_web_domain_add.php | 104 +- .../examples/sites_web_domain_delete.php | 16 +- .../examples/sites_web_domain_get.php | 20 +- .../examples/sites_web_domain_set_status.php | 20 +- .../examples/sites_web_domain_update.php | 18 +- .../examples/sites_web_subdomain_add.php | 106 +- .../examples/sites_web_subdomain_delete.php | 16 +- .../examples/sites_web_subdomain_get.php | 20 +- .../examples/sites_web_subdomain_update.php | 18 +- .../examples/soap-database-add.php | 63 +- server/cron.php | 56 +- server/cron_daily.php | 2 +- server/lib/app.inc.php | 190 +- server/lib/classes/aps_base.inc.php | 122 +- server/lib/classes/aps_installer.inc.php | 1179 +++--- .../classes/cron.d/100-mailbox_stats.inc.php | 468 +-- .../cron.d/100-monitor_clamav_log.inc.php | 108 +- .../classes/cron.d/100-monitor_cpu.inc.php | 94 +- .../cron.d/100-monitor_database_size.inc.php | 159 +- .../cron.d/100-monitor_disk_usage.inc.php | 136 +- .../cron.d/100-monitor_email_quota.inc.php | 118 +- .../cron.d/100-monitor_fail2ban.inc.php | 106 +- .../cron.d/100-monitor_hd_quota.inc.php | 92 +- .../cron.d/100-monitor_iptables.inc.php | 164 +- .../cron.d/100-monitor_ispconfig_log.inc.php | 115 +- .../100-monitor_ispconfig_version.inc.php | 94 +- .../cron.d/100-monitor_mail_log.inc.php | 124 +- .../cron.d/100-monitor_mail_queue.inc.php | 96 +- .../cron.d/100-monitor_mem_usage.inc.php | 94 +- .../cron.d/100-monitor_mongodb.inc.php | 106 +- .../classes/cron.d/100-monitor_openvz.inc.php | 110 +- .../cron.d/100-monitor_os_version.inc.php | 96 +- .../classes/cron.d/100-monitor_raid.inc.php | 176 +- .../cron.d/100-monitor_rkhunter.inc.php | 94 +- .../classes/cron.d/100-monitor_server.inc.php | 94 +- .../cron.d/100-monitor_services.inc.php | 92 +- .../classes/cron.d/100-monitor_syslog.inc.php | 108 +- .../cron.d/100-monitor_system_update.inc.php | 96 +- server/lib/classes/cron.d/150-awstats.inc.php | 290 +- .../lib/classes/cron.d/150-webalizer.inc.php | 214 +- .../lib/classes/cron.d/200-logfiles.inc.php | 426 +- .../classes/cron.d/300-quota_notify.inc.php | 866 ++-- server/lib/classes/cron.d/400-openvz.inc.php | 96 +- server/lib/classes/cron.d/500-backup.inc.php | 582 +-- server/lib/classes/cron.inc.php | 475 +-- server/lib/classes/cronjob.inc.php | 250 +- server/lib/classes/db_mysql.inc.php | 1006 ++--- server/lib/classes/file.inc.php | 483 +-- server/lib/classes/functions.inc.php | 244 +- server/lib/classes/getconf.inc.php | 9 +- server/lib/classes/ini_parser.inc.php | 10 +- server/lib/classes/libdatetime.inc.php | 894 ++-- server/lib/classes/mod_mail_base.inc.php | 44 +- server/lib/classes/modules.inc.php | 152 +- server/lib/classes/monitor_tools.inc.php | 340 +- server/lib/classes/openvz_tools.inc.php | 8 +- server/lib/classes/plugins.inc.php | 92 +- server/lib/classes/services.inc.php | 35 +- server/lib/classes/system.inc.php | 2101 +++++----- server/lib/classes/tpl.inc.php | 2636 ++++++------ server/lib/classes/tpl_cache.inc.php | 315 +- server/lib/classes/tpl_error.inc.php | 113 +- server/lib/classes/tpl_ini.inc.php | 123 +- server/mods-available/client_module.inc.php | 56 +- server/mods-available/cron_module.inc.php | 56 +- server/mods-available/database_module.inc.php | 78 +- server/mods-available/dns_module.inc.php | 164 +- server/mods-available/mail_module.inc.php | 166 +- .../monitor_core_module.inc.php | 10 +- .../remoteaction_core_module.inc.php | 40 +- .../mods-available/rescue_core_module.inc.php | 20 +- server/mods-available/server_module.inc.php | 106 +- server/mods-available/vm_module.inc.php | 86 +- server/mods-available/web_module.inc.php | 260 +- .../plugins-available/apache2_plugin.inc.php | 2342 +++++------ .../apps_vhost_plugin.inc.php | 88 +- server/plugins-available/aps_plugin.inc.php | 116 +- .../plugins-available/backup_plugin.inc.php | 78 +- .../plugins-available/bind_dlz_plugin.inc.php | 265 +- server/plugins-available/bind_plugin.inc.php | 394 +- .../cron_jailkit_plugin.inc.php | 390 +- server/plugins-available/cron_plugin.inc.php | 305 +- .../plugins-available/firewall_plugin.inc.php | 228 +- .../ftpuser_base_plugin.inc.php | 140 +- .../plugins-available/getmail_plugin.inc.php | 112 +- .../plugins-available/iptables_plugin.inc.php | 74 +- server/plugins-available/mail_plugin.inc.php | 206 +- .../mail_plugin_dkim.inc.php | 310 +- .../maildeliver_plugin.inc.php | 192 +- .../plugins-available/maildrop_plugin.inc.php | 240 +- .../plugins-available/mailman_plugin.inc.php | 82 +- .../mongo_clientdb_plugin.inc.php | 139 +- .../mysql_clientdb_plugin.inc.php | 771 ++-- .../network_settings_plugin.inc.php | 202 +- server/plugins-available/nginx_plugin.inc.php | 2090 +++++----- .../nginx_reverseproxy_plugin.inc.php | 214 +- .../plugins-available/openvz_plugin.inc.php | 136 +- .../pma_symlink_plugin.inc.php | 88 +- .../postfix_filter_plugin.inc.php | 110 +- .../postfix_server_plugin.inc.php | 60 +- .../plugins-available/powerdns_plugin.inc.php | 310 +- .../shelluser_base_plugin.inc.php | 176 +- .../shelluser_jailkit_plugin.inc.php | 423 +- .../software_update_plugin.inc.php | 214 +- server/plugins-available/squid_plugin.inc.php | 134 +- .../webmail_symlink_plugin.inc.php | 88 +- .../webserver_plugin.inc.php | 191 +- server/scripts/ispconfig_update.php | 76 +- server/server.php | 42 +- 867 files changed, 55806 insertions(+), 54875 deletions(-) diff --git a/helper_scripts/dns_export_to_bind.php b/helper_scripts/dns_export_to_bind.php index ea5adf94c..6a3f59035 100644 --- a/helper_scripts/dns_export_to_bind.php +++ b/helper_scripts/dns_export_to_bind.php @@ -2,103 +2,103 @@ $host="IP_ADDRESS"; $user="USERNAME"; $password="PASSWORD"; -mysql_connect($host,$user,$password) or die(mysql_error()); +mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db("dbispconfig"); $result = ""; $result = mysql_query("SELECT id,origin,ns,ttl,mbox,serial,refresh,retry,expire,minimum FROM dns_soa;"); function hostname2ipfunktion($tmp1, $timeout = 1) - { - if ($tmp1 == 0) - { - $query = `nslookup -timeout=$timeout -retry=0 $tmp1`; - if(preg_match('/\nAddress: (.*)\n/', $query, $matches)) - return trim($matches[1]); - return $tmp1; - } - } +{ + if ($tmp1 == 0) + { + $query = `nslookup -timeout=$timeout -retry=0 $tmp1`; + if(preg_match('/\nAddress: (.*)\n/', $query, $matches)) + return trim($matches[1]); + return $tmp1; + } +} $serialsearch=date("Ymd"); $resultx12 = mysql_query("SELECT origin,serial FROM dns_soa WHERE serial LIKE '$serialsearch%' ORDER BY origin ASC;"); while ($rowx12=mysql_fetch_array($resultx12)) { - $zone=substr($rowx12["origin"],0,-1); - $filename_x1="/var/cache/bind/".$zone; - if (file_exists($filename_x1)) { - $serialvergleich[$zone]=exec("grep \";Serial\" /var/cache/bind/$zone |cut -d\" \" -f1 | awk '{print $1}'"); - } + $zone=substr($rowx12["origin"], 0, -1); + $filename_x1="/var/cache/bind/".$zone; + if (file_exists($filename_x1)) { + $serialvergleich[$zone]=exec("grep \";Serial\" /var/cache/bind/$zone |cut -d\" \" -f1 | awk '{print $1}'"); + } } while($row = mysql_fetch_array($result)) - { -### Hier ALLES Aktivieren bei Primary Nameserver TEIL 1 ################################################################################# - $varx11=substr($row["origin"],0,-1); - $filename="/var/cache/bind/".$varx11; - if (file_exists($filename)) { - unlink("/var/cache/bind/$varx11"); - } - $arr1[$x11]="zone \"$varx11\" in { type master; file \"$varx11\"; };\n"; - $x11=$x11+1; - $result2 = mysql_query("select name,type,aux,data from dns_rr where zone=$row[id] and active='Y' ORDER BY name ASC;"); - $arr3[0]="\$TTL ".$row['ttl']."\n@ IN SOA ".$row['ns']." ".$row['mbox']." (\n ".$row['serial']." ;Serial\n"." ".$row['refresh']." ;Refresh\n"." ".$row['retry']." ;Retry\n"." ".$row['expire']." ;Expire\n"." ".$row['minimum']." ) ;Minimum\n\n"; +{ + //## Hier ALLES Aktivieren bei Primary Nameserver TEIL 1 ################################################################################# + $varx11=substr($row["origin"], 0, -1); + $filename="/var/cache/bind/".$varx11; + if (file_exists($filename)) { + unlink("/var/cache/bind/$varx11"); + } + $arr1[$x11]="zone \"$varx11\" in { type master; file \"$varx11\"; };\n"; + $x11=$x11+1; + $result2 = mysql_query("select name,type,aux,data from dns_rr where zone=$row[id] and active='Y' ORDER BY name ASC;"); + $arr3[0]="\$TTL ".$row['ttl']."\n@ IN SOA ".$row['ns']." ".$row['mbox']." (\n ".$row['serial']." ;Serial\n"." ".$row['refresh']." ;Refresh\n"." ".$row['retry']." ;Retry\n"." ".$row['expire']." ;Expire\n"." ".$row['minimum']." ) ;Minimum\n\n"; - $xx1=1; - while($row2 = mysql_fetch_row($result2)) - { - $arr2[$xx1]=$row2['0']." IN ".$row2['1']." "; + $xx1=1; + while($row2 = mysql_fetch_row($result2)) + { + $arr2[$xx1]=$row2['0']." IN ".$row2['1']." "; - if ($row2['2']>0) - { - $arr3[$xx1]=$arr2[$xx1].$row2['2']." ".$row2['3']."\n"; - } - else - { - $arr3[$xx1]=$arr2[$xx1].$row2['3']."\n"; - } - $xx1=$xx1+1; - } - $f = fopen("/var/cache/bind/$varx11", "a+"); - foreach($arr3 as $values) fputs($f, $values); - fclose($f); - $arr2=array(); - $arr3=array(); -### ENDE Primärer Nameserver TEIL 2 ##################################################################################################### + if ($row2['2']>0) + { + $arr3[$xx1]=$arr2[$xx1].$row2['2']." ".$row2['3']."\n"; + } + else + { + $arr3[$xx1]=$arr2[$xx1].$row2['3']."\n"; + } + $xx1=$xx1+1; + } + $f = fopen("/var/cache/bind/$varx11", "a+"); + foreach($arr3 as $values) fputs($f, $values); + fclose($f); + $arr2=array(); + $arr3=array(); + //## ENDE Primärer Nameserver TEIL 2 ##################################################################################################### -### Hier ALLES Aktivieren bei Secondary Nameserver ###################################################################################### -# $tmp1 = substr($row["ns"],0,-1); -# $tmp2 = substr($row["origin"],0,-1); + //## Hier ALLES Aktivieren bei Secondary Nameserver ###################################################################################### + // $tmp1 = substr($row["ns"],0,-1); + // $tmp2 = substr($row["origin"],0,-1); -# if (!isset($dnscache[$tmp1])) $nsip = hostname2ipfunktion($tmp1) ; -# else $nsip=$dnscache[$tmp1] ; + // if (!isset($dnscache[$tmp1])) $nsip = hostname2ipfunktion($tmp1) ; + // else $nsip=$dnscache[$tmp1] ; -# if ($nsip == $tmp1) -# { -# echo "$tmp2 $tmp1 Not a valid Nameserver"; -# echo "\n"; -# } -# else -# { -# $dnscache[$tmp1]=$nsip; -# $arr1[$x11]="zone \"".$tmp2."\" in { type slave; file \"".$tmp2."\"; masters {".$nsip."; }; };\n"; -# $x11=$x11+1; -# } -### ENDE Secondary Nameserver ########################################################################################################### - } + // if ($nsip == $tmp1) + // { + // echo "$tmp2 $tmp1 Not a valid Nameserver"; + // echo "\n"; + // } + // else + // { + // $dnscache[$tmp1]=$nsip; + // $arr1[$x11]="zone \"".$tmp2."\" in { type slave; file \"".$tmp2."\"; masters {".$nsip."; }; };\n"; + // $x11=$x11+1; + // } + //## ENDE Secondary Nameserver ########################################################################################################### +} -unlink ("/etc/bind/named.conf.local"); +unlink("/etc/bind/named.conf.local"); $fx = fopen("/etc/bind/named.conf.local", "a+"); foreach($arr1 as $values) fputs($fx, $values); fclose($fx); system("rndc reconfig >/dev/null 2>&1"); -### ANFANG Primärer Namerserver TEIL 2 ################################################################################################## +//## ANFANG Primärer Namerserver TEIL 2 ################################################################################################## $serialsearch=date("Ymd"); $resultx13 = mysql_query("SELECT origin,serial FROM dns_soa WHERE serial LIKE '$serialsearch%' ORDER BY origin ASC;"); while ($rowx13=mysql_fetch_array($resultx13)) { - $serial_ist=($rowx13["serial"]); - $zone=substr($rowx13["origin"],0,-1); -# echo "zone: ".$zone." ist: ".$serial_ist." vergleich: ".$serialvergleich[$zone]."\n"; - if ($serialvergleich[$zone] != $serial_ist) { - $reload=system("rndc reload $zone >/dev/null 2>&1"); - } + $serial_ist=($rowx13["serial"]); + $zone=substr($rowx13["origin"], 0, -1); + // echo "zone: ".$zone." ist: ".$serial_ist." vergleich: ".$serialvergleich[$zone]."\n"; + if ($serialvergleich[$zone] != $serial_ist) { + $reload=system("rndc reload $zone >/dev/null 2>&1"); + } } -### ENDE Primärer NamerserverTEIL 2 ###################################################################################################### -?> \ No newline at end of file +//## ENDE Primärer NamerserverTEIL 2 ###################################################################################################### +?> diff --git a/helper_scripts/dns_export_to_bind_retrans_daily.php b/helper_scripts/dns_export_to_bind_retrans_daily.php index 39faf14fe..a571367f6 100644 --- a/helper_scripts/dns_export_to_bind_retrans_daily.php +++ b/helper_scripts/dns_export_to_bind_retrans_daily.php @@ -2,13 +2,13 @@ $host="IP_ADDRESS"; $user="USERNAME"; $password="PASSWORD"; -mysql_connect($host,$user,$password) or die(mysql_error()); +mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db("dbispconfig"); $result = ""; $result = mysql_query("SELECT origin FROM dns_soa ORDER BY origin ASC;"); while($row = mysql_fetch_array($result)) { - $zone=substr($row["origin"],0,-1); - system("rndc retransfer ".$zone); + $zone=substr($row["origin"], 0, -1); + system("rndc retransfer ".$zone); } -?> \ No newline at end of file +?> diff --git a/helper_scripts/mydns_to_powerdns_migration.php b/helper_scripts/mydns_to_powerdns_migration.php index 9c6526b97..ffe9e4ae8 100644 --- a/helper_scripts/mydns_to_powerdns_migration.php +++ b/helper_scripts/mydns_to_powerdns_migration.php @@ -2,15 +2,15 @@ $host="localhost"; $user="root"; $password="MYSQL-ROOT-PASSWD"; -mysql_connect($host,$user,$password) or die(mysql_error()); +mysql_connect($host, $user, $password) or die(mysql_error()); mysql_select_db("dbispconfig"); $sql1 = mysql_query("SELECT id, substr(origin,1, LENGTH(origin)-1) AS origin, substr(ns,1, LENGTH(ns)-1) AS ns, substr(mbox,1, LENGTH(mbox)-1) AS mbox,ttl FROM dns_soa order by id asc;"); mysql_select_db("powerdns"); while($row1 = mysql_fetch_array($sql1)) { -mysql_query("INSERT INTO domains (id,name,type,ispconfig_id) values ('$row1[id]','$row1[origin]','NATIVE','$row1[id]');"); -mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row1[id]','$row1[origin]','$row1[ns] $row1[mbox] 0','$row1[id]','SOA','$row1[ttl]','0','1260446221');"); + mysql_query("INSERT INTO domains (id,name,type,ispconfig_id) values ('$row1[id]','$row1[origin]','NATIVE','$row1[id]');"); + mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row1[id]','$row1[origin]','$row1[ns] $row1[mbox] 0','$row1[id]','SOA','$row1[ttl]','0','1260446221');"); } mysql_select_db("dbispconfig"); @@ -18,44 +18,44 @@ $sql2 = mysql_query("SELECT id,zone,name,data,aux,ttl,type FROM dns_rr order by mysql_select_db("powerdns"); while($row2 = mysql_fetch_array($sql2)) { -if (strlen($row2['name'])) -{ -$file1=substr($row2['data'], -1); -if ($file1==".") -{ -$text = $row2['data']; -$laenge = strlen($row2['data'])-1; -$file2 = substr($text, 0,strlen($text)-1); -} -else -{ -$file2=$row2['data']; -} -mysql_select_db("dbispconfig"); -$sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];"); -$row3 = mysql_fetch_array($sql3); -mysql_select_db("powerdns"); -mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row2[name].$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');"); -} -else -{ -$file1=substr($row2['data'], -1); -if ($file1==".") -{ -$text = $row2['data']; -$laenge = strlen($row2['data'])-1; -$file2 = substr($text, 0,strlen($text)-1); -} -else -{ -$file2=$row2['data']; -} -mysql_select_db("dbispconfig"); -$sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];"); -$row3 = mysql_fetch_array($sql3); -mysql_select_db("powerdns"); -mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');"); -} + if (strlen($row2['name'])) + { + $file1=substr($row2['data'], -1); + if ($file1==".") + { + $text = $row2['data']; + $laenge = strlen($row2['data'])-1; + $file2 = substr($text, 0, strlen($text)-1); + } + else + { + $file2=$row2['data']; + } + mysql_select_db("dbispconfig"); + $sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];"); + $row3 = mysql_fetch_array($sql3); + mysql_select_db("powerdns"); + mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row2[name].$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');"); + } + else + { + $file1=substr($row2['data'], -1); + if ($file1==".") + { + $text = $row2['data']; + $laenge = strlen($row2['data'])-1; + $file2 = substr($text, 0, strlen($text)-1); + } + else + { + $file2=$row2['data']; + } + mysql_select_db("dbispconfig"); + $sql3 = mysql_query("SELECT substr(origin,1, LENGTH(origin)-1) AS origin FROM dns_soa where id=$row2[zone];"); + $row3 = mysql_fetch_array($sql3); + mysql_select_db("powerdns"); + mysql_query("INSERT INTO records (domain_id,name,content,ispconfig_id,type,ttl,prio,change_date) values ('$row2[zone]','$row3[origin]','$file2','$row2[id]','$row2[type]','$row2[ttl]','$row2[aux]','1260446221');"); + } } mysql_select_db("powerdns"); @@ -63,8 +63,8 @@ $sql4 = mysql_query("SELECT records.id,records.content,records.type,domains.name while($row4 = mysql_fetch_array($sql4)) { -mysql_query("UPDATE records SET content = '$row4[content].$row4[name]' where id='$row4[id]';"); + mysql_query("UPDATE records SET content = '$row4[content].$row4[name]' where id='$row4[id]';"); } -?> \ No newline at end of file +?> diff --git a/helper_scripts/recreate_webalizer_stats.php b/helper_scripts/recreate_webalizer_stats.php index 2663bc26f..fbaef3809 100644 --- a/helper_scripts/recreate_webalizer_stats.php +++ b/helper_scripts/recreate_webalizer_stats.php @@ -1,39 +1,39 @@ db->queryAllRecords($sql); foreach($records as $rec) { -$domain = escapeshellcmd($rec["domain"]); -$logdir = escapeshellcmd($rec["document_root"].'/log'); -$statsdir = escapeshellcmd($rec["document_root"].'/web/stats'); -$webalizer = '/usr/bin/webalizer'; - -$webalizer_conf_main = '/etc/webalizer/webalizer.conf'; -$webalizer_conf = escapeshellcmd($rec["document_root"].'/log/webalizer.conf'); -exec("rm -rf $webalizer_conf"); -if(!@is_file($webalizer_conf)) { -exec("cp $webalizer_conf_main $webalizer_conf"); - -setConfigVar($webalizer_conf, 'Incremental', 'yes'); -setConfigVar($webalizer_conf, 'IncrementalName', $logdir.'/webalizer.current'); -setConfigVar($webalizer_conf, 'HistoryName', $logdir.'/webalizer.hist'); -} + $domain = escapeshellcmd($rec["domain"]); + $logdir = escapeshellcmd($rec["document_root"].'/log'); + $statsdir = escapeshellcmd($rec["document_root"].'/web/stats'); + $webalizer = '/usr/bin/webalizer'; + + $webalizer_conf_main = '/etc/webalizer/webalizer.conf'; + $webalizer_conf = escapeshellcmd($rec["document_root"].'/log/webalizer.conf'); + exec("rm -rf $webalizer_conf"); + if(!@is_file($webalizer_conf)) { + exec("cp $webalizer_conf_main $webalizer_conf"); + + setConfigVar($webalizer_conf, 'Incremental', 'yes'); + setConfigVar($webalizer_conf, 'IncrementalName', $logdir.'/webalizer.current'); + setConfigVar($webalizer_conf, 'HistoryName', $logdir.'/webalizer.hist'); + } -if(!@is_dir($statsdir)) mkdir($statsdir); + if(!@is_dir($statsdir)) mkdir($statsdir); -echo "Remove stats dir $statsdir ...\n"; -exec("rm -rf $statsdir/*"); + echo "Remove stats dir $statsdir ...\n"; + exec("rm -rf $statsdir/*"); -echo "Re-Create stats for $domain...\n"; -exec("for logfile in $logdir/*access*; do\n$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir ".'$logfile'."\ndone"); -echo "done.\n"; + echo "Re-Create stats for $domain...\n"; + exec("for logfile in $logdir/*access*; do\n$webalizer -c $webalizer_conf -n $domain -s $domain -r $domain -q -T -p -o $statsdir ".'$logfile'."\ndone"); + echo "done.\n"; } die("finished.\n"); -?> \ No newline at end of file +?> diff --git a/install/autoupdate.php b/install/autoupdate.php index 52cab345d..c716d1a76 100644 --- a/install/autoupdate.php +++ b/install/autoupdate.php @@ -41,7 +41,7 @@ error_reporting(E_ALL|E_STRICT); if (!file_exists('autoupdate')) { //** The banner on the command line - echo "\n\n".str_repeat('-',80)."\n"; + echo "\n\n".str_repeat('-', 80)."\n"; echo " _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / @@ -50,19 +50,19 @@ if (!file_exists('autoupdate')) { \___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ __/ | |___/ "; - echo "\n".str_repeat('-',80)."\n"; + 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'); +require_once 'lib/install.lib.php'; //** Include the library with the basic updater functions -require_once('lib/update.lib.php'); +require_once 'lib/update.lib.php'; //** Include the base class of the installer class -require_once('lib/installer_base.lib.php'); +require_once 'lib/installer_base.lib.php'; //** Ensure that current working directory is install directory $cur_dir = getcwd(); @@ -75,16 +75,16 @@ define('ISPC_INSTALL_ROOT', realpath(dirname(__FILE__).'/../')); //** Get distribution identifier $dist = get_distname(); -include_once("/usr/local/ispconfig/server/lib/config.inc.php"); +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'); +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); @@ -124,22 +124,22 @@ $inst->is_update = true; $inst->find_installed_apps(); //** Initialize the MySQL server connection -include_once('lib/mysql.lib.php'); +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"); +$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 = ''; +$clientdb_host = ''; +$clientdb_user = ''; +$clientdb_password = ''; //** There is a error if user for mysql admin_password if empty if( empty($conf["mysql"]["admin_password"]) ) { @@ -147,7 +147,7 @@ if( empty($conf["mysql"]["admin_password"]) ) { } //** Test mysql root connection -if(!@mysql_connect($conf["mysql"]["host"],$conf["mysql"]["admin_user"],$conf["mysql"]["admin_password"])) { +if(!@mysql_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) { die("internal error - MYSQL-Root passord wrong"); } @@ -157,7 +157,7 @@ if(!@mysql_connect($conf["mysql"]["host"],$conf["mysql"]["admin_user"],$conf["my checkDbHealth(); /* - * Prepare the dump of the database + * Prepare the dump of the database */ prepareDBDump(); @@ -196,7 +196,7 @@ 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'); @@ -217,7 +217,7 @@ if($conf['services']['mail'] == true) { //** Configure PAM swriteln('Configuring PAM'); $inst->configure_pam(); - + //* Configure courier swriteln('Configuring Courier'); $inst->configure_courier(); @@ -261,7 +261,7 @@ if($conf['services']['web']) { //** Configure Apache swriteln('Configuring Apache'); $inst->configure_apache(); - + //** Configure vlogger swriteln('Configuring vlogger'); $inst->configure_vlogger(); @@ -270,7 +270,7 @@ if($conf['services']['web']) { swriteln('Configuring nginx'); $inst->configure_nginx(); } - + //** Configure apps vhost swriteln('Configuring Apps vhost'); $inst->configure_apps_vhost(); diff --git a/install/dist/conf/centos52.conf.php b/install/dist/conf/centos52.conf.php index 1221a74e6..12044d3ce 100644 --- a/install/dist/conf/centos52.conf.php +++ b/install/dist/conf/centos52.conf.php @@ -63,14 +63,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* Apache $conf['apache']['installed'] = false; // will be detected automatically during installation diff --git a/install/dist/conf/centos53.conf.php b/install/dist/conf/centos53.conf.php index 1221a74e6..12044d3ce 100644 --- a/install/dist/conf/centos53.conf.php +++ b/install/dist/conf/centos53.conf.php @@ -63,14 +63,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* Apache $conf['apache']['installed'] = false; // will be detected automatically during installation diff --git a/install/dist/conf/debian40.conf.php b/install/dist/conf/debian40.conf.php index 7bdd23849..3e9fe3500 100644 --- a/install/dist/conf/debian40.conf.php +++ b/install/dist/conf/debian40.conf.php @@ -65,14 +65,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* Apache $conf['apache']['installed'] = false; // will be detected automatically during installation diff --git a/install/dist/conf/debian60.conf.php b/install/dist/conf/debian60.conf.php index 8eb3a2ca3..a3819966b 100644 --- a/install/dist/conf/debian60.conf.php +++ b/install/dist/conf/debian60.conf.php @@ -65,14 +65,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* Apache $conf['apache']['installed'] = false; // will be detected automatically during installation @@ -223,4 +223,4 @@ $conf['cron']['crontab_dir'] = '/etc/cron.d'; $conf['cron']['wget'] = '/usr/bin/wget'; -?> \ No newline at end of file +?> diff --git a/install/dist/conf/fedora9.conf.php b/install/dist/conf/fedora9.conf.php index c988d3f3c..80539a785 100644 --- a/install/dist/conf/fedora9.conf.php +++ b/install/dist/conf/fedora9.conf.php @@ -63,14 +63,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* Apache $conf['apache']['installed'] = false; // will be detected automatically during installation diff --git a/install/dist/conf/gentoo.conf.php b/install/dist/conf/gentoo.conf.php index 2a0471a52..2955cfa71 100644 --- a/install/dist/conf/gentoo.conf.php +++ b/install/dist/conf/gentoo.conf.php @@ -63,14 +63,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* SuPHP $conf['suphp']['config_file'] = '/etc/suphp.conf'; @@ -85,7 +85,7 @@ $conf['apache']['config_dir'] = '/etc/apache2'; $conf['apache']['config_file'] = $conf['apache']['config_dir'] .'/httpd.conf'; $conf['apache']['ssl_dir'] = '/etc/ssl/apache2'; $conf['apache']['vhost_conf_dir'] = $conf['apache']['config_dir'] . '/vhosts.d'; -$conf['apache']['vhost_conf_enabled_dir'] = $conf['apache']['vhost_conf_dir']; +$conf['apache']['vhost_conf_enabled_dir'] = $conf['apache']['vhost_conf_dir']; $conf['apache']['vhost_default'] = '00_default_vhost.conf'; $conf['apache']['vhost_port'] = '8080'; $conf['apache']['php_ini_path_apache'] = '/etc/php/apache2-php5/php.ini'; @@ -154,7 +154,7 @@ $conf['dovecot']['init_script'] = 'dovecot'; //* SASL $conf['saslauthd']['installed'] = false; // will be detected automatically during installation $conf['saslauthd']['config_file'] = '/etc/conf.d/saslauthd'; -$conf['saslauthd']['config_dir'] = '/etc/sasl2'; +$conf['saslauthd']['config_dir'] = '/etc/sasl2'; $conf['saslauthd']['init_script'] = 'saslauthd'; //* Amavisd diff --git a/install/dist/conf/opensuse110.conf.php b/install/dist/conf/opensuse110.conf.php index fd8ef6543..e389c3b2a 100644 --- a/install/dist/conf/opensuse110.conf.php +++ b/install/dist/conf/opensuse110.conf.php @@ -63,14 +63,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* Apache $conf['apache']['installed'] = false; // will be detected automatically during installation diff --git a/install/dist/conf/opensuse112.conf.php b/install/dist/conf/opensuse112.conf.php index 96a37d6a5..fa0504652 100644 --- a/install/dist/conf/opensuse112.conf.php +++ b/install/dist/conf/opensuse112.conf.php @@ -63,14 +63,14 @@ $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']['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())); +$conf['mysql']['master_ispconfig_password'] = md5(uniqid(rand())); //* Apache $conf['apache']['installed'] = false; // will be detected automatically during installation diff --git a/install/dist/lib/centos52.lib.php b/install/dist/lib/centos52.lib.php index a7e4f945c..f4aa4dfe9 100644 --- a/install/dist/lib/centos52.lib.php +++ b/install/dist/lib/centos52.lib.php @@ -58,26 +58,26 @@ class installer extends installer_dist { } } } - + $config_dir = $conf['mailman']['config_dir'].'/'; $full_file_name = $config_dir.'virtual_to_transport.sh'; - + //* Backup exiting virtual_to_transport.sh script if(is_file($full_file_name)) { copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); } - - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); - } else { - copy('tpl/mailman-virtual_to_transport.sh',$full_file_name); - } - chgrp($full_file_name,'mailman'); - chmod($full_file_name,0750); - + + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + } + chgrp($full_file_name, 'mailman'); + chmod($full_file_name, 0750); + if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); - + exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); $virtual_domains = ''; @@ -87,13 +87,13 @@ class installer extends installer_dist { $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); if(is_array($domainAll)) { - foreach($domainAll as $domain) - { - if ($domainAll[0]['domain'] == $domain['domain']) - $virtual_domains .= "'".$domain['domain']."'"; - else - $virtual_domains .= ", '".$domain['domain']."'"; - } + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + } } } else @@ -109,55 +109,55 @@ class installer extends installer_dist { public function configure_amavis() { global $conf; - + // amavisd user config file $configfile = 'fedora_amavisd_conf'; - if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["amavis"]["config_dir"].'/amavisd.conf~'); + if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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); - $content = str_replace('{hostname}',$conf['hostname'],$content); - $content = str_replace('/var/spool/amavisd/clamd.sock','/tmp/clamd.socket',$content); - wf($conf["amavis"]["config_dir"].'/amavisd.conf',$content); - - + $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); + $content = str_replace('{hostname}', $conf['hostname'], $content); + $content = str_replace('/var/spool/amavisd/clamd.sock', '/tmp/clamd.socket', $content); + wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); + + // 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'); - + 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~'); + 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")) { + if(!stristr($content, "127.0.0.1:10025")) { unset($content); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', "tpl/master_cf_amavis.master"); - af($conf["postfix"]["config_dir"].'/master.cf',$content); + af($conf["postfix"]["config_dir"].'/master.cf', $content); } unset($content); - - removeLine('/etc/sysconfig/freshclam','FRESHCLAM_DELAY=disabled-warn # REMOVE ME',1); - replaceLine('/etc/freshclam.conf','Example','# Example',1); - - + + removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1); + replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1); + + } } -?> \ No newline at end of file +?> diff --git a/install/dist/lib/centos53.lib.php b/install/dist/lib/centos53.lib.php index 91f1746c7..93083b518 100644 --- a/install/dist/lib/centos53.lib.php +++ b/install/dist/lib/centos53.lib.php @@ -58,26 +58,26 @@ class installer extends installer_dist { } } } - + $config_dir = $conf['mailman']['config_dir'].'/'; $full_file_name = $config_dir.'virtual_to_transport.sh'; - + //* Backup exiting virtual_to_transport.sh script if(is_file($full_file_name)) { copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); } - - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); - } else { - copy('tpl/mailman-virtual_to_transport.sh',$full_file_name); - } - chgrp($full_file_name,'mailman'); - chmod($full_file_name,0750); - + + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + } + chgrp($full_file_name, 'mailman'); + chmod($full_file_name, 0750); + if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); - + exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); $virtual_domains = ''; @@ -87,13 +87,13 @@ class installer extends installer_dist { $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); if(is_array($domainAll)) { - foreach($domainAll as $domain) - { - if ($domainAll[0]['domain'] == $domain['domain']) - $virtual_domains .= "'".$domain['domain']."'"; - else - $virtual_domains .= ", '".$domain['domain']."'"; - } + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + } } } else @@ -109,56 +109,56 @@ class installer extends installer_dist { public function configure_amavis() { global $conf; - + // amavisd user config file $configfile = 'fedora_amavisd_conf'; - if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["amavis"]["config_dir"].'/amavisd.conf~'); + if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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); - $content = str_replace('{hostname}',$conf['hostname'],$content); - $content = str_replace('/var/spool/amavisd/clamd.sock','/var/run/clamav/clamd.sock',$content); - wf($conf["amavis"]["config_dir"].'/amavisd.conf',$content); - - + $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); + $content = str_replace('{hostname}', $conf['hostname'], $content); + $content = str_replace('/var/spool/amavisd/clamd.sock', '/var/run/clamav/clamd.sock', $content); + wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); + + // 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'); - + 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~'); + 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")) { + if(!stristr($content, "127.0.0.1:10025")) { unset($content); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', "tpl/master_cf_amavis.master"); - af($conf["postfix"]["config_dir"].'/master.cf',$content); + af($conf["postfix"]["config_dir"].'/master.cf', $content); } unset($content); - - removeLine('/etc/sysconfig/freshclam','FRESHCLAM_DELAY=disabled-warn # REMOVE ME',1); - replaceLine('/etc/freshclam.conf','Example','# Example',1); - - + + removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1); + replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1); + + } } -?> \ No newline at end of file +?> diff --git a/install/dist/lib/debian40.lib.php b/install/dist/lib/debian40.lib.php index cf8e864e6..b13b98c65 100644 --- a/install/dist/lib/debian40.lib.php +++ b/install/dist/lib/debian40.lib.php @@ -33,4 +33,4 @@ class installer extends installer_base { } -?> \ No newline at end of file +?> diff --git a/install/dist/lib/debian60.lib.php b/install/dist/lib/debian60.lib.php index e1be29132..b3887cbd2 100644 --- a/install/dist/lib/debian60.lib.php +++ b/install/dist/lib/debian60.lib.php @@ -29,13 +29,13 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class installer extends installer_base { - + public function configure_dovecot() - { + { global $conf; - + $config_dir = $conf['dovecot']['config_dir']; - + //* Configure master.cf and add a line for deliver if(is_file($config_dir.'/master.cf')){ copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); @@ -45,14 +45,14 @@ class installer extends installer_base { } $content = rf($conf["postfix"]["config_dir"].'/master.cf'); // Only add the content if we had not addded it before - if(!stristr($content,"dovecot/deliver")) { + 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); + 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 ( @@ -61,44 +61,44 @@ class installer extends installer_base { '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'); - + 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.'~'); } - + //* Get the dovecot version - exec('dovecot --version',$tmp); - $parts = explode('.',trim($tmp[0])); + exec('dovecot --version', $tmp); + $parts = explode('.', trim($tmp[0])); $dovecot_version = $parts[0]; unset($tmp); unset($parts); - + //* Copy dovecot configuration file if($dovecot_version == 2) { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot2.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot2.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/debian6_dovecot2.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot2.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot2.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/debian6_dovecot2.conf.master', $config_dir.'/'.$configfile); + } } else { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/debian6_dovecot.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/debian6_dovecot.conf.master', $config_dir.'/'.$configfile); + } } - + //* dovecot-sql.conf $configfile = 'dovecot-sql.conf'; if(is_file($config_dir.'/'.$configfile)){ @@ -106,32 +106,33 @@ class installer extends installer_base { chmod($config_dir.'/'.$configfile.'~', 0400); } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian6_dovecot-sql.conf.master', 'tpl/debian6_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); + $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_apache() { global $conf; - - if(file_exists('/etc/apache2/mods-available/fcgid.conf')) replaceLine('/etc/apache2/mods-available/fcgid.conf','MaxRequestLen','MaxRequestLen 15728640',0,1); - + + if(file_exists('/etc/apache2/mods-available/fcgid.conf')) replaceLine('/etc/apache2/mods-available/fcgid.conf', 'MaxRequestLen', 'MaxRequestLen 15728640', 0, 1); + parent::configure_apache(); } - public function configure_fail2ban() { - /* + public function configure_fail2ban() { + /* copy('tpl/dovecot-pop3imap.conf.master',"/etc/fail2ban/filter.d/dovecot-pop3imap.conf"); copy('tpl/dovecot_fail2ban_jail.local.master','/etc/fail2ban/jail.local'); */ - } + } + } ?> diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php index 5e3ad3fc1..ab25741ee 100644 --- a/install/dist/lib/fedora.lib.php +++ b/install/dist/lib/fedora.lib.php @@ -58,7 +58,7 @@ class installer_dist extends installer_base { } } } - + if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); @@ -69,13 +69,13 @@ class installer_dist extends installer_base { $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); if(is_array($domainAll)) { - foreach($domainAll as $domain) - { - if ($domainAll[0]['domain'] == $domain['domain']) - $virtual_domains .= "'".$domain['domain']."'"; - else - $virtual_domains .= ", '".$domain['domain']."'"; - } + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + } } } else @@ -87,90 +87,90 @@ class installer_dist extends installer_base { $content = str_replace('{virtual_domains}', $virtual_domains, $content); wf($full_file_name, $content); - + //* Write virtual_to_transport.sh script $config_dir = $conf['mailman']['config_dir'].'/'; $full_file_name = $config_dir.'virtual_to_transport.sh'; - + //* Backup exiting virtual_to_transport.sh script if(is_file($full_file_name)) { copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); } - + if(is_dir('/etc/mailman')) { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); - } else { - copy('tpl/mailman-virtual_to_transport.sh',$full_file_name); - } - chgrp($full_file_name,'mailman'); - chmod($full_file_name,0750); + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + } + chgrp($full_file_name, 'mailman'); + chmod($full_file_name, 0750); } - + //* Create aliasaes exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); - + } - + function configure_postfix($options = '') - { - global $conf; + { + 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."); - } - + $this->error("The postfix configuration directory '$config_dir' does not exist."); + } + //* mysql-virtual_domains.cf - $this->process_postfix_config('mysql-virtual_domains.cf'); + $this->process_postfix_config('mysql-virtual_domains.cf'); //* mysql-virtual_forwardings.cf - $this->process_postfix_config('mysql-virtual_forwardings.cf'); + $this->process_postfix_config('mysql-virtual_forwardings.cf'); //* mysql-virtual_mailboxes.cf - $this->process_postfix_config('mysql-virtual_mailboxes.cf'); + $this->process_postfix_config('mysql-virtual_mailboxes.cf'); //* mysql-virtual_email2email.cf - $this->process_postfix_config('mysql-virtual_email2email.cf'); + $this->process_postfix_config('mysql-virtual_email2email.cf'); //* mysql-virtual_transports.cf - $this->process_postfix_config('mysql-virtual_transports.cf'); + $this->process_postfix_config('mysql-virtual_transports.cf'); //* mysql-virtual_recipient.cf - $this->process_postfix_config('mysql-virtual_recipient.cf'); + $this->process_postfix_config('mysql-virtual_recipient.cf'); //* mysql-virtual_sender.cf - $this->process_postfix_config('mysql-virtual_sender.cf'); + $this->process_postfix_config('mysql-virtual_sender.cf'); //* mysql-virtual_client.cf - $this->process_postfix_config('mysql-virtual_client.cf'); - + $this->process_postfix_config('mysql-virtual_client.cf'); + //* mysql-virtual_relaydomains.cf - $this->process_postfix_config('mysql-virtual_relaydomains.cf'); - + $this->process_postfix_config('mysql-virtual_relaydomains.cf'); + //* mysql-virtual_relayrecipientmaps.cf - $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf'); + $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf'); - //* postfix-dkim - $full_file_name=$config_dir.'/tag_as_originating.re'; - if(is_file($full_file_name)) { - copy($full_file_name, $config_dir.$configfile.'~'); - } - wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026'); + //* postfix-dkim + $full_file_name=$config_dir.'/tag_as_originating.re'; + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.$configfile.'~'); + } + wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026'); - $full_file_name=$config_dir.'/tag_as_foreign.re'; - if(is_file($full_file_name)) { - copy($full_file_name, $config_dir.$configfile.'~'); - } - wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024'); + $full_file_name=$config_dir.'/tag_as_foreign.re'; + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.$configfile.'~'); + } + wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024'); //* 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'); - + __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"); @@ -186,7 +186,7 @@ class installer_dist extends installer_base { //* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update $rbl_list = ''; if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') { - $rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); + $rbl_hosts = explode(",", str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); foreach ($rbl_hosts as $key => $value) { $rbl_list .= ", reject_rbl_client ". $value; } @@ -195,130 +195,130 @@ class installer_dist extends installer_base { unset($server_ini_array); //* These postconf commands will be executed on installation and update - $postconf_placeholders = array('{config_dir}' => $config_dir, - '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], - '{vmail_userid}' => $cf['vmail_userid'], - '{vmail_groupid}' => $cf['vmail_groupid'], - '{rbl_list}' => $rbl_list); - - $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_postfix.conf.master', 'tpl/fedora_postfix.conf.master'); - $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); - $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines - + $postconf_placeholders = array('{config_dir}' => $config_dir, + '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], + '{vmail_userid}' => $cf['vmail_userid'], + '{vmail_groupid}' => $cf['vmail_groupid'], + '{rbl_list}' => $rbl_list); + + $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_postfix.conf.master', 'tpl/fedora_postfix.conf.master'); + $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); + $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines + //* These postconf commands will be executed on installation only if($this->is_update == false) { - $postconf_commands = array_merge($postconf_commands,array( - 'myhostname = '.$conf['hostname'], - 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', - 'mynetworks = 127.0.0.0/8 [::1]/128' - )); + $postconf_commands = array_merge($postconf_commands, array( + 'myhostname = '.$conf['hostname'], + 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', + 'mynetworks = 127.0.0.0/8 [::1]/128' + )); } - + //* 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 if(!is_dir('/var/lib/mailman/data')) exec('mkdir -p /var/lib/mailman/data'); //if(!is_file('/var/lib/mailman/data/aliases')) touch('/var/lib/mailman/data/aliases'); if(is_file('/var/lib/mailman/data/aliases')) unlink('/var/lib/mailman/data/aliases'); - if(!is_link('/var/lib/mailman/data/aliases')) symlink('/etc/mailman/aliases','/var/lib/mailman/data/aliases'); + if(!is_link('/var/lib/mailman/data/aliases')) symlink('/etc/mailman/aliases', '/var/lib/mailman/data/aliases'); exec('postalias /var/lib/mailman/data/aliases'); if(!is_file('/var/lib/mailman/data/virtual-mailman')) touch('/var/lib/mailman/data/virtual-mailman'); exec('postmap /var/lib/mailman/data/virtual-mailman'); if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-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')) { + + 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 365 -x509'; + .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -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/spool/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~'); - } + copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); + } if(is_file($config_dir.'/master.cf~')){ - exec('chmod 400 '.$config_dir.'/master.cf~'); - } + exec('chmod 400 '.$config_dir.'/master.cf~'); + } $configfile = $config_dir.'/master.cf'; $content = rf($configfile); // if postfix package is from fedora or centios main repo - $content = str_replace('# flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', - ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', - $content); - + $content = str_replace('# flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', + ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', + $content); + // If postfix package is from centos plus repo - $content = str_replace('# flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}', - ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', - $content); - - $content = str_replace(' flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', - ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', - $content); - - - $content = str_replace('#maildrop unix - n n - - pipe', - 'maildrop unix - n n - - pipe', - $content); - + $content = str_replace('# flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}', + ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', + $content); + + $content = str_replace(' flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', + ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', + $content); + + + $content = str_replace('#maildrop unix - n n - - pipe', + 'maildrop unix - n n - - pipe', + $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.'~'); - } + copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~'); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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 $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 = 'tpl/fedora_saslauthd_smtpd_conf.master'; $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_saslauthd_smtpd_conf.master', $configfile); - wf('/usr/lib/sasl2/smtpd.conf',$content); - if(is_dir('/usr/lib64')) wf('/usr/lib64/sasl/smtpd.conf',$content); - if(is_dir('/usr/lib64')) wf('/usr/lib64/sasl2/smtpd.conf',$content); - + wf('/usr/lib/sasl2/smtpd.conf', $content); + if(is_dir('/usr/lib64')) wf('/usr/lib64/sasl/smtpd.conf', $content); + if(is_dir('/usr/lib64')) wf('/usr/lib64/sasl2/smtpd.conf', $content); + } - + public function configure_pam() - { + { global $conf; $pam = $conf['pam']; //* configure pam for SMTP authentication agains the ispconfig database @@ -336,68 +336,68 @@ class installer_dist extends installer_base { if(is_file("$pam/smtp")) exec("chmod o= $pam/smtp"); //exec("chmod 660 $pam/smtp"); //exec("chown root:root $pam/smtp"); - + } - + 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~"); - } + copy("$config_dir/$configfile", "$config_dir/$configfile~"); + } exec("chmod 400 $config_dir/$configfile~"); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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_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); - + exec("chmod 660 $config_dir/$configfile"); exec("chown root:root $config_dir/$configfile"); - + //* authdaemonrc $configfile = $conf['courier']['config_dir'].'/authdaemonrc'; if(is_file($configfile)){ - copy($configfile, $configfile.'~'); - } + copy($configfile, $configfile.'~'); + } if(is_file($configfile.'~')){ - exec('chmod 400 '.$configfile.'~'); - } + exec('chmod 400 '.$configfile.'~'); + } $content = rf($configfile); $content = str_replace('authmodulelist=', 'authmodulelist="authmysql"', $content); wf($configfile, $content); } - + public function configure_dovecot() - { + { global $conf; - + $config_dir = $conf['dovecot']['config_dir']; - + //* Use /etc/dovecot as config dir if exists if(is_dir('/etc/dovecot')) $config_dir = '/etc/dovecot'; - + //* Configure master.cf and add a line for deliver if(is_file($config_dir.'/master.cf')){ - copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); - } + copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); + } if(is_file($config_dir.'/master.cf~')){ - exec('chmod 400 '.$config_dir.'/master.cf~2'); - } + exec('chmod 400 '.$config_dir.'/master.cf~2'); + } $content = rf($conf["postfix"]["config_dir"].'/master.cf'); // Only add the content if we had not addded it before - if(!stristr($content,"dovecot/deliver")) { + if(!stristr($content, "dovecot/deliver")) { $deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'; - af($conf["postfix"]["config_dir"].'/master.cf',$deliver_content); + 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 ( @@ -407,119 +407,119 @@ class installer_dist extends installer_base { 'smtpd_sasl_path = private/auth', '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~3'); - + 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"); } - + //* backup dovecot.conf $configfile = 'dovecot.conf'; if(is_file("$config_dir/$configfile")){ - copy("$config_dir/$configfile", "$config_dir/$configfile~"); - } - + copy("$config_dir/$configfile", "$config_dir/$configfile~"); + } + //* Get the dovecot version - exec('dovecot --version',$tmp); - $parts = explode('.',trim($tmp[0])); + exec('dovecot --version', $tmp); + $parts = explode('.', trim($tmp[0])); $dovecot_version = $parts[0]; unset($tmp); unset($parts); - + //* Copy dovecot configuration file if($dovecot_version == 2) { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot2.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot2.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/fedora_dovecot2.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot2.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot2.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/fedora_dovecot2.conf.master', $config_dir.'/'.$configfile); + } } else { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/fedora_dovecot.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/fedora_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~"); + copy("$config_dir/$configfile", "$config_dir/$configfile~"); exec("chmod 400 $config_dir/$configfile~"); - } - + } + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot-sql.conf.master', "tpl/fedora_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); + $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); - + exec("chmod 600 $config_dir/$configfile"); exec("chown root:root $config_dir/$configfile"); } - + public function configure_amavis() { global $conf; - + // amavisd user config file $configfile = 'fedora_amavisd_conf'; - if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["amavis"]["config_dir"].'/amavisd.conf~'); + if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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); - $content = str_replace('{hostname}',$conf['hostname'],$content); - wf($conf["amavis"]["config_dir"].'/amavisd.conf',$content); - - + $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); + $content = str_replace('{hostname}', $conf['hostname'], $content); + wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); + + // 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'); - + 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~'); + 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")) { + if(!stristr($content, "127.0.0.1:10025")) { unset($content); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', "tpl/master_cf_amavis.master"); - af($conf["postfix"]["config_dir"].'/master.cf',$content); + af($conf["postfix"]["config_dir"].'/master.cf', $content); } unset($content); - - removeLine('/etc/sysconfig/freshclam','FRESHCLAM_DELAY=disabled-warn # REMOVE ME',1); - replaceLine('/etc/freshclam.conf','Example','# Example',1); - + + removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1); + replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1); + // Add the clamav user to the vscan group //exec('groupmod --add-user clamav vscan'); - - + + } - + public function configure_spamassassin() - { + { global $conf; - + //* Enable spamasasssin on debian and ubuntu /* $configfile = '/etc/default/spamassassin'; @@ -531,40 +531,40 @@ class installer_dist extends installer_base { wf($configfile, $content); */ } - + public function configure_getmail() - { + { global $conf; - + $config_dir = $conf['getmail']['config_dir']; - + if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir)); $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 pam for SMTP authentication agains the ispconfig database $configfile = 'pureftpd-mysql.conf'; if(is_file("$config_dir/$configfile")){ - copy("$config_dir/$configfile", "$config_dir/$configfile~"); - } + copy("$config_dir/$configfile", "$config_dir/$configfile~"); + } if(is_file("$config_dir/$configfile~")){ - exec("chmod 400 $config_dir/$configfile~"); - } + exec("chmod 400 $config_dir/$configfile~"); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/pureftpd_mysql.conf.master', '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); @@ -574,45 +574,45 @@ class installer_dist extends installer_base { wf("$config_dir/$configfile", $content); exec("chmod 600 $config_dir/$configfile"); exec("chown root:root $config_dir/$configfile"); - + // copy our customized copy of pureftpd.conf to the pure-ftpd config directory if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_pureftpd_conf.master')) { - exec("cp " . $conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_pureftpd_conf.master ' . "$config_dir/pure-ftpd.conf"); - }else { - exec("cp tpl/fedora_pureftpd_conf.master $config_dir/pure-ftpd.conf"); - } - + exec("cp " . $conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_pureftpd_conf.master ' . "$config_dir/pure-ftpd.conf"); + }else { + exec("cp tpl/fedora_pureftpd_conf.master $config_dir/pure-ftpd.conf"); + } + } - + public function configure_mydns() - { + { global $conf; - + // configure mydns $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)) copy($conf["mydns"]["config_dir"].'/'.$configfile, $conf["mydns"]["config_dir"].'/'.$configfile.'~'); if(is_file($conf["mydns"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["mydns"]["config_dir"].'/'.$configfile.'~'); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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); + $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); exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile); exec('chown root:root '.$conf["mydns"]["config_dir"].'/'.$configfile); - + } - + public function configure_bind() { global $conf; - + // add the include line at the end of named.conf. - replaceLine('/etc/named.conf','include "/etc/named.conf.local";','include "/etc/named.conf.local";',0,1); + replaceLine('/etc/named.conf', 'include "/etc/named.conf.local";', 'include "/etc/named.conf.local";', 0, 1); //* Check if the zonefile directory has a slash at the end $content=$conf['bind']['bind_zonefiles_dir']; - if(substr($content,-1,1) != '/') { + if(substr($content, -1, 1) != '/') { $content .= '/'; } @@ -624,37 +624,37 @@ class installer_dist extends installer_base { //* Chown the slave subdirectory to $conf['bind']['bind_user'] exec('chown '.$conf['bind']['bind_user'].':'.$conf['bind']['bind_group'].' '.$content); exec('chmod 770 '.$content); - + } - + public function configure_apache() - { + { global $conf; - + if($conf['apache']['installed'] == false) return; if(is_file('/etc/suphp.conf')) { //replaceLine('/etc/suphp.conf','php=php:/usr/bin','x-httpd-suphp=php:/usr/bin/php-cgi',0); - replaceLine('/etc/suphp.conf','docroot=','docroot=/var/www',0); - replaceLine('/etc/suphp.conf','umask=0077','umask=0022',0); + replaceLine('/etc/suphp.conf', 'docroot=', 'docroot=/var/www', 0); + replaceLine('/etc/suphp.conf', 'umask=0077', 'umask=0022', 0); } - + //* Create the logging directory for the vhost logfiles exec('mkdir -p /var/log/ispconfig/httpd'); - + // Sites enabled and avaulable dirs exec('mkdir -p '.$conf['apache']['vhost_conf_enabled_dir']); exec('mkdir -p '.$conf['apache']['vhost_conf_dir']); - + $content = rf('/etc/httpd/conf/httpd.conf'); - if(!stristr($content,'Include /etc/httpd/conf/sites-enabled/')) { - af('/etc/httpd/conf/httpd.conf',"\nNameVirtualHost *:80\nNameVirtualHost *:443\nInclude /etc/httpd/conf/sites-enabled/\n\n"); + if(!stristr($content, 'Include /etc/httpd/conf/sites-enabled/')) { + af('/etc/httpd/conf/httpd.conf', "\nNameVirtualHost *:80\nNameVirtualHost *:443\nInclude /etc/httpd/conf/sites-enabled/\n\n"); } unset($content); - + //* Copy the ISPConfig configuration include - $vhost_conf_dir = $conf['apache']['vhost_conf_dir']; - $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir']; - + $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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.conf.master', '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'"); @@ -666,7 +666,7 @@ class installer_dist extends installer_base { } else { $ip_address = $rec['ip_address']; } - $ports = explode(',',$rec['virtualhost_port']); + $ports = explode(',', $rec['virtualhost_port']); if(is_array($ports)) { foreach($ports as $port) { $port = intval($port); @@ -677,138 +677,138 @@ class installer_dist extends installer_base { } } } - + $content .= "\n"; - wf($vhost_conf_dir.'/ispconfig.conf',$content); - + wf($vhost_conf_dir.'/ispconfig.conf', $content); + if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) { exec("ln -s ".$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')) { exec('mkdir /etc/webalizer'); exec('ln -s /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); + 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); } - + //* 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_nginx(){ global $conf; - + if($conf['nginx']['installed'] == false) return; //* Create the logging directory for the vhost logfiles if(!@is_dir($conf['ispconfig_log_dir'].'/httpd')) mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true); - + // Sites enabled and avaulable dirs exec('mkdir -p '.$conf['nginx']['vhost_conf_enabled_dir']); exec('mkdir -p '.$conf['nginx']['vhost_conf_dir']); - wf('/etc/nginx/conf.d/ispconfig_vhosts.conf',"include /etc/nginx/sites-enabled/*.vhost;"); + wf('/etc/nginx/conf.d/ispconfig_vhosts.conf', "include /etc/nginx/sites-enabled/*.vhost;"); //* 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'); + 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); + 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); - + 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", octdec($directory_mode)); - if(is_dir("/etc/Bastille.backup/firewall.d")) caselog("cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/", __FILE__, __LINE__); - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master')) { - caselog("cp -f " . $conf['ispconfig_install_dir']."/server/conf-custom/install/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__); - } else { - 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); + @mkdir("/etc/Bastille", octdec($directory_mode)); + if(is_dir("/etc/Bastille.backup/firewall.d")) caselog("cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/", __FILE__, __LINE__); + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master')) { + caselog("cp -f " . $conf['ispconfig_install_dir']."/server/conf-custom/install/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__); + } else { + 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 = ''; - $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 443 3306 8080 10000'; - $udp_public_services = '53'; - } + + 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 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); + $content = str_replace("{TCP_PUBLIC_SERVICES}", $tcp_public_services, $content); + $content = str_replace("{UDP_PUBLIC_SERVICES}", $udp_public_services, $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__); + wf("/etc/Bastille/bastille-firewall.cfg", $content); - 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($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_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); + 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 install_ispconfig() - { + { global $conf; - + $install_dir = $conf['ispconfig_install_dir']; //* Create the ISPConfig installation directory @@ -816,68 +816,68 @@ class installer_dist extends installer_base { $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~"); - } + copy("$install_dir/interface/lib/$configfile", "$install_dir/interface/lib/$configfile~"); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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_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); $content = str_replace('{timezone}', $conf['timezone'], $content); $content = str_replace('{theme}', $conf['theme'], $content); $content = str_replace('{language_file_import_enabled}', ($conf['language_file_import_enabled'] == true)?'true':'false', $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~"); - } + copy("$install_dir/server/lib/$configfile", "$install_dir/interface/lib/$configfile~"); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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); @@ -886,24 +886,24 @@ class installer_dist extends installer_base { $content = str_replace('{language_file_import_enabled}', ($conf['language_file_import_enabled'] == true)?'true':'false', $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 = ''; 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); + 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); @@ -917,16 +917,16 @@ class installer_dist extends installer_base { closedir($dh); } } - + $dir = $install_dir.'/server/plugins-available/'; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($conf['apache']['installed'] == true && $file == 'nginx_plugin.inc.php') continue; if($conf['nginx']['installed'] == true && $file == 'apache2_plugin.inc.php') continue; - if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') { - include_once($install_dir.'/server/plugins-available/'.$file); - $plugin_name = substr($file,0,-8); + 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($tmp->onInstall()) { if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file); @@ -940,7 +940,7 @@ class installer_dist extends installer_base { closedir($dh); } } - + // Update the server config $mail_server_enabled = ($conf['services']['mail'])?1:0; $web_server_enabled = ($conf['services']['web'])?1:0; @@ -949,14 +949,14 @@ class installer_dist extends installer_base { $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"); @@ -964,48 +964,48 @@ class installer_dist extends installer_base { //* 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 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')) { + 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)) { + 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); + chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file, 0770); } } } } } - + //* Make the APS directories group writable exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages"); exec("chmod -R 770 $install_dir/server/aps_packages"); - + //* make sure that the server config file (not the interface one) is only readable by the root user chmod($install_dir.'/server/lib/config.inc.php', 0600); chown($install_dir.'/server/lib/config.inc.php', 'root'); chgrp($install_dir.'/server/lib/config.inc.php', 'root'); - + //* Make sure thet the interface config file is readable by user ispconfig only chmod($install_dir.'/interface/lib/config.inc.php', 0600); chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); chgrp($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); - + if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) { exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf"); exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf"); } - + // 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! @@ -1021,38 +1021,38 @@ class installer_dist extends installer_base { $command = 'usermod -a -G ispconfig '.$conf['nginx']['user']; caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); //if(is_user('ispapps')){ - // Allow the ispapps vhost access to /etc/squirrelmail - //$command = 'usermod -a -G '.$conf['apache']['group'].' ispapps'; - //caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); + // Allow the ispapps vhost access to /etc/squirrelmail + //$command = 'usermod -a -G '.$conf['apache']['group'].' ispapps'; + //caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); //} if(is_group('ispapps')){ $command = 'usermod -a -G ispapps '.$conf['nginx']['user']; 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"); - + if($conf['apache']['installed'] == true && $this->install_ispconfig_interface == true){ //* Copy the ISPConfig vhost for the controlpanel // TODO: These are missing! should they be "vhost_dist_*_dir" ? $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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.vhost.master', "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('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) { $content = str_replace('{ssl_comment}', '', $content); } else { @@ -1063,39 +1063,39 @@ class installer_dist extends installer_base { } else { $content = str_replace('{ssl_bundle_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->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")) { - exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost"); - } - - /* + 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")) { + exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost"); + } + + /* exec('mkdir -p /var/www/php-fcgi-scripts/ispconfig'); exec('cp 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'); exec('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig'); exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig'); - + replaceLine('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter','PHPRC=','PHPRC=/etc/',0,0); */ - //if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) { - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); - $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); - $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); - if(!is_dir('/var/www/php-fcgi-scripts/ispconfig')) exec('mkdir -p /var/www/php-fcgi-scripts/ispconfig'); - wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); - exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); - if(!is_link('/var/www/ispconfig')) exec('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig'); - exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig'); - //} + //if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) { + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); + $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); + $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); + if(!is_dir('/var/www/php-fcgi-scripts/ispconfig')) exec('mkdir -p /var/www/php-fcgi-scripts/ispconfig'); + wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); + exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); + if(!is_link('/var/www/ispconfig')) exec('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig'); + exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig'); + //} //} } - + if($conf['nginx']['installed'] == true && $this->install_ispconfig_interface == true){ //* Copy the ISPConfig vhost for the controlpanel $vhost_conf_dir = $conf['nginx']['vhost_conf_dir']; @@ -1104,7 +1104,7 @@ class installer_dist extends installer_base { // Dont just copy over the virtualhost template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/nginx_ispconfig.vhost.master', 'tpl/nginx_ispconfig.vhost.master'); $content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content); - + if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) { $content = str_replace('{ssl_on}', ' on', $content); $content = str_replace('{ssl_comment}', '', $content); @@ -1114,19 +1114,19 @@ class installer_dist extends installer_base { $content = str_replace('{ssl_comment}', '#', $content); $content = str_replace('{fastcgi_ssl}', 'off', $content); } - + $socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']); - if(substr($socket_dir,-1) != '/') $socket_dir .= '/'; + if(substr($socket_dir, -1) != '/') $socket_dir .= '/'; if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir); $fpm_socket = $socket_dir.'ispconfig.sock'; - + //$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content); $content = str_replace('{fpm_socket}', $fpm_socket, $content); wf($vhost_conf_dir.'/ispconfig.vhost', $content); - + unset($content); - + // PHP-FPM // Dont just copy over the php-fpm pool template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/php_fpm_pool.conf.master', 'tpl/php_fpm_pool.conf.master'); @@ -1142,18 +1142,18 @@ class installer_dist extends installer_base { if($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'); + symlink($vhost_conf_dir.'/ispconfig.vhost', $vhost_conf_enabled_dir.'/000-ispconfig.vhost'); } } - + // create symlink from /usr/share/phpmyadmin to /usr/share/phpMyAdmin, if it is installed - if(!@file_exists('/usr/share/phpmyadmin') && @is_dir('/usr/share/phpMyAdmin')) symlink('/usr/share/phpMyAdmin/','/usr/share/phpmyadmin'); + if(!@file_exists('/usr/share/phpmyadmin') && @is_dir('/usr/share/phpMyAdmin')) symlink('/usr/share/phpMyAdmin/', '/usr/share/phpmyadmin'); } - + // Make the Clamav log files readable by ISPConfig //exec('chmod +r /var/log/clamav/clamav.log'); //exec('chmod +r /var/log/clamav/freshclam.log'); - + //* Install the update script if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh'); exec('chown root /usr/local/ispconfig/server/scripts/update_from_svn.sh'); @@ -1164,98 +1164,98 @@ class installer_dist extends installer_base { exec('chmod 700 /usr/local/ispconfig/server/scripts/ispconfig_update.sh'); if(!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_update.sh /usr/local/bin/ispconfig_update_from_svn.sh'); if(!is_link('/usr/local/bin/ispconfig_update.sh')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_update.sh /usr/local/bin/ispconfig_update.sh'); - + // set the fast cgi starter script to executable // exec('chmod 755 '.$install_dir.'/interface/bin/php-fcgi'); - + //* Make the logs readable for the ispconfig user if(@is_file('/var/log/maillog')) exec('chmod +r /var/log/maillog'); //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'); - + //To enable apache to read the directories // exec('chmod a+rx /usr/local/ispconfig'); // exec('chmod -R 751 /usr/local/ispconfig/interface'); // exec('chmod a+rx /usr/local/ispconfig/interface/web'); - + //* Create the ispconfig log directory if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir']); if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) exec('touch '.$conf['ispconfig_log_dir'].'/ispconfig.log'); - + if(is_user('getmail')) { exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh'); exec('chown getmail /usr/local/bin/run-getmail.sh'); exec('chmod 744 /usr/local/bin/run-getmail.sh'); } - + // Edit the file Edit the file /etc/sudoers and comment out the requiregetty line, otherwise the backup function will fail - replaceLine('/etc/sudoers','Defaults requiretty','#Defaults requiretty',0,0); - + replaceLine('/etc/sudoers', 'Defaults requiretty', '#Defaults requiretty', 0, 0); + if(is_dir($install_dir.'/interface/invoices')) { exec('chmod -R 770 '.escapeshellarg($install_dir.'/interface/invoices')); exec('chown -R ispconfig:ispconfig '.escapeshellarg($install_dir.'/interface/invoices')); } - + //* Create the ispconfig auth log file and set uid/gid if(!is_file($conf['ispconfig_log_dir'].'/auth.log')) { touch($conf['ispconfig_log_dir'].'/auth.log'); } exec('chown ispconfig:ispconfig '. $conf['ispconfig_log_dir'].'/auth.log'); exec('chmod 660 '. $conf['ispconfig_log_dir'].'/auth.log'); - + //* Remove Domain module as its functions are available in the client module now if(@is_dir('/usr/local/ispconfig/interface/web/domain')) exec('rm -rf /usr/local/ispconfig/interface/web/domain'); - + } - + 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 + + // 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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mysql_clientdb.conf.master', "tpl/mysql_clientdb.conf.master"); - $content = str_replace('{hostname}',$conf['mysql']['host'],$content); - $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); + $content = str_replace('{hostname}', $conf['mysql']['host'], $content); + $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); exec('chmod 600 '."$install_dir/server/lib/mysql_clientdb.conf"); exec('chown root:root '."$install_dir/server/lib/mysql_clientdb.conf"); - + } - + public function install_crontab() - { + { global $conf; - + //* 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,'/usr/local/ispconfig')) unset($existing_root_cron_jobs[$key]); + if(stristr($val, '/usr/local/ispconfig')) unset($existing_root_cron_jobs[$key]); } - + $root_cron_jobs = array( '* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null', '30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null' ); - + if ($conf['nginx']['installed'] == true) { $root_cron_jobs[] = "0 0 * * * /usr/local/ispconfig/server/scripts/create_daily_nginx_access_logs.sh &> /dev/null"; } - + foreach($root_cron_jobs as $cron_job) { if(!in_array($cron_job."\n", $existing_root_cron_jobs)) { $existing_root_cron_jobs[] = $cron_job."\n"; @@ -1264,22 +1264,22 @@ class installer_dist extends installer_base { 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']; + $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>> /dev/null' - ); - + '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null' + ); + // 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]); + 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"; @@ -1289,7 +1289,7 @@ class installer_dist extends installer_base { exec('crontab -u getmail crontab.txt &> /dev/null'); unlink('crontab.txt'); } - + exec('touch /var/log/ispconfig/cron.log'); exec('chmod 660 /var/log/ispconfig/cron.log'); } diff --git a/install/dist/lib/fedora9.lib.php b/install/dist/lib/fedora9.lib.php index da77b423a..aeda9b9fd 100644 --- a/install/dist/lib/fedora9.lib.php +++ b/install/dist/lib/fedora9.lib.php @@ -33,4 +33,4 @@ class installer extends installer_dist { } -?> \ No newline at end of file +?> diff --git a/install/dist/lib/gentoo.lib.php b/install/dist/lib/gentoo.lib.php index 60cadad75..99670eec1 100644 --- a/install/dist/lib/gentoo.lib.php +++ b/install/dist/lib/gentoo.lib.php @@ -28,47 +28,47 @@ 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 extends installer_base +class installer extends installer_base { public function configure_jailkit() - { - global $conf; - + { + global $conf; + if (is_dir($conf['jailkit']['config_dir'])) { $jkinit_content = $this->get_template_file($conf['jailkit']['jk_init'], true); //* get contents $this->write_config_file($conf['jailkit']['config_dir'] . '/' . $conf['jailkit']['jk_init'], $jkinit_content); - + $jkchroot_content = $this->get_template_file($conf['jailkit']['jk_chrootsh'], true); //* get contents $this->write_config_file($conf['jailkit']['config_dir'] . '/' . $conf['jailkit']['jk_chrootsh'], $jkchroot_content); } - + $command = 'chown root:root /var/www'; caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); - } - + } + public function configure_postfix($options = '') - { - global $conf; - - $cf = $conf['postfix']; + { + 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."); - } - - //* Install virtual mappings - foreach (glob('tpl/mysql-virtual_*.master') as $filename) { - $this->process_postfix_config( basename($filename, '.master') ); - } - + $this->error("The postfix configuration directory '$config_dir' does not exist."); + } + + //* Install virtual mappings + foreach (glob('tpl/mysql-virtual_*.master') as $filename) { + $this->process_postfix_config( basename($filename, '.master') ); + } + //* 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'); - + __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'])) { @@ -77,81 +77,81 @@ class installer extends installer_base $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"); + caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); } //* These postconf commands will be executed on installation and update - $postconf_placeholders = array('{config_dir}' => $config_dir, - '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], - '{vmail_userid}' => $cf['vmail_userid'], - '{vmail_groupid}' => $cf['vmail_groupid'], - '{rbl_list}' => $rbl_list); - - $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/gentoo_postfix.conf.master', 'tpl/gentoo_postfix.conf.master'); - $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); - $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines - + $postconf_placeholders = array('{config_dir}' => $config_dir, + '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], + '{vmail_userid}' => $cf['vmail_userid'], + '{vmail_groupid}' => $cf['vmail_groupid'], + '{rbl_list}' => $rbl_list); + + $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/gentoo_postfix.conf.master', 'tpl/gentoo_postfix.conf.master'); + $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); + $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines + //* These postconf commands will be executed on installation only if($this->is_update == false) { - $postconf_commands = array_merge($postconf_commands,array( - 'myhostname = '.$conf['hostname'], - 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', - 'mynetworks = 127.0.0.0/8 [::1]/128' - )); + $postconf_commands = array_merge($postconf_commands, array( + 'myhostname = '.$conf['hostname'], + 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', + 'mynetworks = 127.0.0.0/8 [::1]/128' + )); } - + //* 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'); - - + + //* 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); } - + //* Create the SSL certificate - if (!stristr($options,'dont-create-certs')) + if (!stristr($options, 'dont-create-certs')) { $command = 'cd '.$config_dir.'; ' - .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509'; + .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -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/lib/courier/authdaemon/'; if (is_dir('/var/lib/courier/authdaemon')) { caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); } - + //* Changing maildrop lines in posfix master.cf $configfile = $config_dir.'/master.cf'; $content = rf($configfile); - $content = preg_replace('/^#?maildrop/m', 'maildrop', $content); - $content = preg_replace('/^#?(\s+)flags=DRhu user=vmail argv=\/usr\/bin\/maildrop -d/m', - '$1flags=DRhu user=vmail argv=/usr/bin/maildrop -d vmail \${extension} \${recipient} \${user} \${nexthop} \${sender}', - $content); - + $content = preg_replace('/^#?maildrop/m', 'maildrop', $content); + $content = preg_replace('/^#?(\s+)flags=DRhu user=vmail argv=\/usr\/bin\/maildrop -d/m', + '$1flags=DRhu user=vmail argv=/usr/bin/maildrop -d vmail \${extension} \${recipient} \${user} \${nexthop} \${sender}', + $content); + $this->write_config_file($configfile, $content); - + //* Writing the Maildrop mailfilter file $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailfilter.master', 'tpl/mailfilter.master'); $content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content); - + $this->write_config_file($cf['vmail_mailbox_base'].'/.mailfilter', $content); - + //* Create the directory for the custom mailfilters - if (!is_dir($cf['vmail_mailbox_base'].'/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"); @@ -161,127 +161,127 @@ class installer extends installer_base $full_file_name=$config_dir.'/tag_as_originating.re'; if(is_file($full_file_name)) { copy($full_file_name, $config_dir.$configfile.'~'); - } - $this->write_config_file($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026'); - - $full_file_name=$config_dir.'/tag_as_foreign.re'; - if(is_file($full_file_name)) { - copy($full_file_name, $config_dir.$configfile.'~'); - } - $this->write_config_file($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024'); - + } + $this->write_config_file($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026'); + + $full_file_name=$config_dir.'/tag_as_foreign.re'; + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.$configfile.'~'); + } + $this->write_config_file($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024'); + //* 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() + + public function configure_saslauthd() { global $conf; - + $content = $this->get_template_file('sasl_smtpd.conf', true, true); //* get contents & insert db cred $this->write_config_file($conf['saslauthd']['config_dir'].'/smtpd.conf', $content); - + //* Edit the file saslauthd config file $content = rf($conf['saslauthd']['config_file']); $content = preg_replace('/(?<=\n)SASLAUTHD_OPTS="\$\{SASLAUTHD_OPTS\}[^"]+"/', 'SASLAUTHD_OPTS="${SASLAUTHD_OPTS} -a pam -r -c -s 128 -t 30 -n 5"', $content); - + $this->write_config_file($conf['saslauthd']['config_file'], $content); } - + public function configure_courier() - { - global $conf; - + { + global $conf; + //* authmysqlrc $content = $this->get_template_file('authmysqlrc', true, true); //* get contents & insert db cred $this->write_config_file($conf['courier']['config_dir'].'/authmysqlrc', $content); - + //* authdaemonrc $configfile = $conf['courier']['config_dir'].'/authdaemonrc'; $content = rf($configfile); $content = preg_replace('/(?<=\n)authmodulelist="[^"]+"/', "authmodulelist=\"authmysql\"", $content); $this->write_config_file($configfile, $content); - + //* create certificates $command = 'mkimapdcert'; caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); - + $command = 'mkpop3dcert'; caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); - } - - public function configure_dovecot() - { - global $conf; - - $config_dir = $conf['dovecot']['config_dir']; - - $configfile = $conf['postfix']['config_dir'].'/master.cf'; - - if(is_file($configfile)) { + } + + public function configure_dovecot() + { + global $conf; + + $config_dir = $conf['dovecot']['config_dir']; + + $configfile = $conf['postfix']['config_dir'].'/master.cf'; + + if(is_file($configfile)) { copy($configfile, $configfile.'~2'); } if(is_file($configfile.'~2')) { chmod($configfile.'~2', 0400); } - - //* Configure master.cf and add a line for deliver + + //* Configure master.cf and add a line for deliver $content = rf($configfile); - - if(!stristr($content,'dovecot/deliver')) { + + if(!stristr($content, 'dovecot/deliver')) { $deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'; - af($conf['postfix']['config_dir'].'/master.cf',$deliver_content); + af($conf['postfix']['config_dir'].'/master.cf', $deliver_content); } unset($content); unset($deliver_content); unset($configfile); - + //* Reconfigure postfix to use dovecot authentication $postconf_commands = array ( - 'dovecot_destination_recipient_limit = 1', - 'virtual_transport = dovecot', - 'smtpd_sasl_type = dovecot', - 'smtpd_sasl_path = private/auth' + '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) + 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 = $config_dir.'/dovecot.conf'; $content = $this->get_template_file('dovecot.conf', true); $this->write_config_file($configfile, $content); - + //* dovecot-sql.conf $configfile = $config_dir.'/dovecot-sql.conf'; $content = $this->get_template_file('debian_dovecot-sql.conf', true, true); $this->write_config_file($configfile, $content); - } - + } + public function configure_spamassassin() - { + { return true; - } - + } + public function configure_getmail() - { + { global $conf; - + $config_dir = $conf['getmail']['config_dir']; - + if (!is_dir($config_dir)) { exec('mkdir -p '.escapeshellcmd($config_dir)); } @@ -290,86 +290,86 @@ class installer extends installer_base 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"); - + //* Getmail will be run from cron. In order to have access to cron the getmail user needs to be part of the cron group. $command = "gpasswd -a getmail " . $conf['cron']['group']; caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); } - - public function configure_amavis() - { + + public function configure_amavis() + { global $conf; - + //* Amavisd-new user config file $conf_file = 'amavisd-ispconfig.conf'; $conf_path = dirname($conf['amavis']['config_file']) . '/' . $conf_file; - + $content = $this->get_template_file($conf_file, true, true); //* get contents & insert db cred $this->write_config_file($conf_path, $content); - + //* Activate config directory in default file $amavis_conf = rf($conf['amavis']['config_file']); - if (stripos($amavis_conf, $conf_path) === false) + if (stripos($amavis_conf, $conf_path) === false) { $amavis_conf = preg_replace('/^(1;.*)$/m', "include_config_files('$conf_path');\n$1", $amavis_conf); $this->write_config_file($conf['amavis']['config_file'], $amavis_conf); } - + //* 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' ); - - foreach($postconf_commands as $cmd) { + + 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 $content = rf($conf['postfix']['config_dir'].'/master.cf'); - - if(!stristr($content,'127.0.0.1:10025')) //* Only add the content if we had not addded it before - { + + if(!stristr($content, '127.0.0.1:10025')) //* Only add the content if we had not addded it before + { unset($content); $content = $this->get_template_file('master_cf_amavis', true); af($conf['postfix']['config_dir'].'/master.cf', $content); } unset($content); - + //* Add the clamav user to the amavis group exec('usermod -a -G amavis clamav'); - } - - public function configure_pureftpd() - { + } + + public function configure_pureftpd() + { global $conf; - + //* configure pure-ftpd for MySQL authentication against the ispconfig database $content = $this->get_template_file('pureftpd_mysql.conf', true, true); //* get contents & insert db cred $content = str_replace('{server_id}', $conf['server_id'], $content); - + $this->write_config_file($conf['pureftpd']['mysql_config_file'], $content, 600, 'root', 'root'); - + //* enable pure-ftpd and server settings $content = rf($conf["pureftpd"]["config_file"]); - + $content = preg_replace('/#?IS_CONFIGURED="(?:yes|no)"/', 'IS_CONFIGURED="yes"', $content); $content = str_replace('AUTH="-l unix"', 'AUTH="-l mysql:'.$conf['pureftpd']['mysql_config_file'].'"', $content); - + //* Logging defaults to syslog's ftp facility. Override this behaviour for better compatibility with debian/ubuntu //* and specify the format. $logdir = '/var/log/pure-ftpd'; if (!is_dir($logdir)) { mkdir($logdir, 0755, true); } - + /** * @link http://download.pureftpd.org/pub/pure-ftpd/doc/README * -b brokenclientscompatibility @@ -377,45 +377,47 @@ class installer extends installer_base * -E noanonymous * -O altlog : * -Z customerproof (Add safe guards against common customer mistakes ie. like chmod 0 on their own files) - * -D displaydotfiles + * -D displaydotfiles * -H dontresolve */ + + $content = preg_replace('/MISC_OTHER="[^"]+"/', 'MISC_OTHER="-b -A -E -Z -D -H -O clf:'.$logdir.'/transfer.log"', $content); - + $this->write_config_file($conf['pureftpd']['config_file'], $content); - } - - public function configure_powerdns() + } + + 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\';'; + $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'); + 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'); + 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 $content = $this->get_template_file('pdns.local', true, true); //* get contents & insert db cred $content = str_replace('{powerdns_database}', $conf['powerdns']['database'], $content); - + $this->write_config_file($conf["powerdns"]["config_dir"].'/'.$conf["powerdns"]["config_file"], $content, 600, 'root', 'root'); //* Create symlink to init script to start the correct config file @@ -423,26 +425,26 @@ class installer extends installer_base symlink($conf['init_scripts'].'/pdns', $conf['init_scripts'].'/'.$conf['powerdns']['init_script']); } } - + 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 .= '/'; + //* Check if the zonefile directory has a slash at the end + $content=$conf['bind']['bind_zonefiles_dir']; + if(substr($content, -1, 1) != '/') { + $content .= '/'; } - + //* New default format of named.conf uses views. Check which version the system is using and include our zones file. $named_conf = rf($conf['bind']['named_conf_path']); - if (stripos($named_conf, 'include "'.$conf['bind']['named_conf_local_path'].'";') === false) + if (stripos($named_conf, 'include "'.$conf['bind']['named_conf_local_path'].'";') === false) { preg_match_all("/(?<=\n)view \"(?:public|internal)\" in \{.*\n\};/Us", $named_conf, $views); if (count($views[0]) == 2) { foreach ($views[0] as $view) { $named_conf = str_replace($view, substr($view, 0, -2)."include \"{$conf['bind']['named_conf_local_path']}\";\n};", $named_conf); } - + wf($conf['bind']['named_conf_path'], $named_conf); } else { @@ -450,48 +452,48 @@ class installer extends installer_base } } } - + public function configure_apache() - { + { global $conf; - + if($conf['apache']['installed'] == false) return; //* 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($conf['suphp']['config_file'])) + + if (is_file($conf['suphp']['config_file'])) { $content = rf($conf['suphp']['config_file']); - + if (!preg_match('|^x-httpd-suphp=php:/usr/bin/php-cgi$|m', $content)) { - $content = preg_replace('/;Handler for php-scripts/',";Handler for php-scripts\nx-httpd-suphp=php:/usr/bin/php-cgi", $content); - $content = preg_replace('/;?umask=\d+/','umask=0022', $content); + $content = preg_replace('/;Handler for php-scripts/', ";Handler for php-scripts\nx-httpd-suphp=php:/usr/bin/php-cgi", $content); + $content = preg_replace('/;?umask=\d+/', 'umask=0022', $content); } - + $this->write_config_file($conf['suphp']['config_file'], $content); } - + //* Enable ISPConfig default vhost settings $default_vhost_path = $conf['apache']['vhost_conf_dir'].'/'.$conf['apache']['vhost_default']; - if (is_file($default_vhost_path)) + if (is_file($default_vhost_path)) { $content = rf($default_vhost_path); - + $content = preg_replace('/^#?\s*NameVirtualHost.*$/m', 'NameVirtualHost *:80', $content); $content = preg_replace('/]+>/', '', $content); - + $this->write_config_file($default_vhost_path, $content); } - + //* Generate default ssl certificates if (!is_dir($conf['apache']['ssl_dir'])) { mkdir($conf['apache']['ssl_dir']); } - - if ($conf['services']['mail'] == true) + + if ($conf['services']['mail'] == true) { copy($conf['postfix']['config_dir']."/smtpd.key", $conf['apache']['ssl_dir']."/server.key"); copy($conf['postfix']['config_dir']."/smtpd.cert", $conf['apache']['ssl_dir']."/server.crt"); @@ -502,76 +504,76 @@ class installer extends installer_base exec("openssl req -new -outform PEM -out {$conf['apache']['ssl_dir']}/server.crt -newkey rsa:2048 -nodes -keyout {$conf['apache']['ssl_dir']}/server.key -keyform PEM -days 365 -x509"); } } - - - + + + //* Copy the ISPConfig configuration include $content = $this->get_template_file('apache_ispconfig.conf', true); - + $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'"); - if(is_array($records) && count($records) > 0) + 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"; } } - + $this->write_config_file($conf['apache']['vhost_conf_dir'].'/000-ispconfig.conf', $content); - + //* Gentoo by default does not include .vhost files. Add include line to config file. $content = rf($conf['apache']['config_file']); if ( strpos($content, 'Include /etc/apache2/vhosts.d/*.vhost') === false ) { - $content = preg_replace('|(Include /etc/apache2/vhosts.d/\*.conf)|',"$1\nInclude /etc/apache2/vhosts.d/*.vhost", $content); + $content = preg_replace('|(Include /etc/apache2/vhosts.d/\*.conf)|', "$1\nInclude /etc/apache2/vhosts.d/*.vhost", $content); } - + $this->write_config_file($conf['apache']['config_file'], $content); - + //* make sure that webalizer finds its config file when it is directly in /etc - if(is_file('/etc/webalizer.conf') && !is_dir('/etc/webalizer')) + if(is_file('/etc/webalizer.conf') && !is_dir('/etc/webalizer')) { mkdir('/etc/webalizer', 0755); 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); + + 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); } - + //* add a sshusers group - if (!is_group('sshusers')) + if (!is_group('sshusers')) { $command = 'groupadd sshusers'; caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); } - } - - public function configure_apps_vhost() + } + + public function configure_apps_vhost() { global $conf; - + //* Create the ispconfig apps vhost user and group if($conf['apache']['installed'] == true){ $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); } else { @@ -579,41 +581,41 @@ class installer extends installer_base } 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 = $this->get_template_file('apache_apps.vhost', true); - + $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); } - + $this->write_config_file("$vhost_conf_dir/apps.vhost", $content); - - //if ( !is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter') ) + + //if ( !is_file($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter') ) //{ - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_apps_fcgi_starter.master', 'tpl/apache_apps_fcgi_starter.master'); - $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); - $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); - 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'); - wf($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter', $content); - 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'); - + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_apps_fcgi_starter.master', 'tpl/apache_apps_fcgi_starter.master'); + $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); + $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); + 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'); + wf($conf['web']['website_basedir'].'/php-fcgi-scripts/apps/.php-fcgi-starter', $content); + 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'); + //} } if($conf['nginx']['installed'] == true){ @@ -646,15 +648,15 @@ class installer extends installer_base // Dont just copy over the virtualhost template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/nginx_apps.vhost.master', 'tpl/nginx_apps.vhost.master'); - + if($conf['web']['apps_vhost_ip'] == '_default_'){ $apps_vhost_ip = ''; } else { $apps_vhost_ip = $conf['web']['apps_vhost_ip'].':'; } - + $socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']); - if(substr($socket_dir,-1) != '/') $socket_dir .= '/'; + if(substr($socket_dir, -1) != '/') $socket_dir .= '/'; if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir); $fpm_socket = $socket_dir.'apps.sock'; $cgi_socket = escapeshellcmd($conf['nginx']['cgi_socket']); @@ -668,7 +670,7 @@ class installer extends installer_base $content = str_replace('{cgi_socket}', $cgi_socket, $content); wf($vhost_conf_dir.'/apps.vhost', $content); - + // PHP-FPM // Dont just copy over the php-fpm pool template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apps_php_fpm_pool.conf.master', 'tpl/apps_php_fpm_pool.conf.master'); @@ -683,84 +685,84 @@ class installer extends installer_base //* and create the symlink 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'); + symlink($vhost_conf_dir.'/apps.vhost', $vhost_conf_enabled_dir.'/000-apps.vhost'); } - + } } - - public function install_ispconfig() - { + + public function install_ispconfig() + { global $conf; - + $install_dir = $conf['ispconfig_install_dir']; - - //* Create the ISPConfig installation directory - if(!is_dir($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 - if (!is_group('ispconfig')) + if (!is_group('ispconfig')) { $command = 'groupadd ispconfig'; caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); } - - if (!is_user('ispconfig')) + + if (!is_user('ispconfig')) { $command = "useradd -g ispconfig -d $install_dir 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 the config file for ISPConfig interface $configfile = 'config.inc.php'; $content = $this->get_template_file($configfile, true, true); //* get contents & insert db cred - + $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); $content = str_replace('{timezone}', $conf['timezone'], $content); $content = str_replace('{theme}', $conf['theme'], $content); $content = str_replace('{language_file_import_enabled}', ($conf['language_file_import_enabled'] == true)?'true':'false', $content); - + $this->write_config_file("$install_dir/interface/lib/$configfile", $content); - + //* Create the config file for ISPConfig server $this->write_config_file("$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 = ''; wf($install_dir.'/server/lib/remote_action.inc.php', $content); } - - // Enable the server modules and plugins. + + // 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); + 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)) { @@ -787,11 +789,11 @@ class installer extends installer_base while (($file = readdir($dh)) !== false) { if($conf['apache']['installed'] == true && $file == 'nginx_plugin.inc.php') continue; if($conf['nginx']['installed'] == true && $file == 'apache2_plugin.inc.php') continue; - if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') { - include_once($install_dir.'/server/plugins-available/'.$file); - $plugin_name = substr($file,0,-8); + 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(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); } @@ -807,7 +809,7 @@ class installer extends installer_base closedir($dh); } } - + //* Update the server config $mail_server_enabled = ($conf['services']['mail'])?1:0; $web_server_enabled = ($conf['services']['web'])?1:0; @@ -815,16 +817,16 @@ class installer extends installer_base $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']); - + + $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"); @@ -832,40 +834,40 @@ class installer extends installer_base //* 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 + + //* 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')) { + 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)) { + 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); + chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file, 0770); } } } } } - + //* Make the APS directories group writable exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages"); exec("chmod -R 770 $install_dir/server/aps_packages"); - - //* make sure that the server config file (not the interface one) is only readable by the root user + + //* make sure that the server config file (not the interface one) is only readable by the root user chmod($install_dir.'/server/lib/config.inc.php', 0600); chown($install_dir.'/server/lib/config.inc.php', 'root'); chgrp($install_dir.'/server/lib/config.inc.php', 'root'); - + //* Make sure thet the interface config file is readable by user ispconfig only chmod($install_dir.'/interface/lib/config.inc.php', 0600); chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); @@ -880,12 +882,12 @@ class installer extends installer_base chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root'); chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root'); } - + if(is_dir($install_dir.'/interface/invoices')) { exec('chmod -R 770 '.escapeshellarg($install_dir.'/interface/invoices')); exec('chown -R ispconfig:ispconfig '.escapeshellarg($install_dir.'/interface/invoices')); } - + // 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! @@ -905,23 +907,23 @@ class installer extends installer_base 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"); - + if($conf['apache']['installed'] == true && $this->install_ispconfig_interface == true){ //* Copy the ISPConfig vhost for the controlpanel $content = $this->get_template_file("apache_ispconfig.vhost", true); $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 { @@ -932,10 +934,10 @@ class installer extends installer_base } else { $content = str_replace('{ssl_bundle_comment}', '#', $content); } - + $vhost_path = $conf['apache']['vhost_conf_dir'].'/ispconfig.vhost'; $this->write_config_file($vhost_path, $content); - + if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) { $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); @@ -944,7 +946,7 @@ class installer extends installer_base wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); chmod('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', 0755); - @symlink($install_dir.'/interface/web','/var/www/ispconfig'); + @symlink($install_dir.'/interface/web', '/var/www/ispconfig'); exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig'); } } @@ -957,7 +959,7 @@ class installer extends installer_base // Dont just copy over the virtualhost template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/nginx_ispconfig.vhost.master', 'tpl/nginx_ispconfig.vhost.master'); $content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content); - + if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) { $content = str_replace('{ssl_on}', ' on', $content); $content = str_replace('{ssl_comment}', '', $content); @@ -967,19 +969,19 @@ class installer extends installer_base $content = str_replace('{ssl_comment}', '#', $content); $content = str_replace('{fastcgi_ssl}', 'off', $content); } - + $socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']); - if(substr($socket_dir,-1) != '/') $socket_dir .= '/'; + if(substr($socket_dir, -1) != '/') $socket_dir .= '/'; if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir); $fpm_socket = $socket_dir.'ispconfig.sock'; - + //$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content); $content = str_replace('{fpm_socket}', $fpm_socket, $content); wf($vhost_conf_dir.'/ispconfig.vhost', $content); - + unset($content); - + // PHP-FPM // Dont just copy over the php-fpm pool template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/php_fpm_pool.conf.master', 'tpl/php_fpm_pool.conf.master'); @@ -995,31 +997,31 @@ class installer extends installer_base if($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'); + symlink($vhost_conf_dir.'/ispconfig.vhost', $vhost_conf_enabled_dir.'/000-ispconfig.vhost'); } } } - + //* 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/maillog')) { exec('chmod +r /var/log/maillog'); @@ -1033,7 +1035,7 @@ class installer extends installer_base if (is_file('/var/log/clamav/freshclam.log')) { exec('chmod +r /var/log/clamav/freshclam.log'); } - + //* Create the ispconfig log directory if (!is_dir($conf['ispconfig_log_dir'])) { mkdir($conf['ispconfig_log_dir']); @@ -1041,25 +1043,26 @@ class installer extends installer_base if (!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) { touch($conf['ispconfig_log_dir'].'/ispconfig.log'); } - + //* Create the ispconfig auth log file and set uid/gid if(!is_file($conf['ispconfig_log_dir'].'/auth.log')) { touch($conf['ispconfig_log_dir'].'/auth.log'); } exec('chown ispconfig:ispconfig '. $conf['ispconfig_log_dir'].'/auth.log'); exec('chmod 660 '. $conf['ispconfig_log_dir'].'/auth.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); - + //* Remove Domain module as its functions are available in the client module now if(@is_dir('/usr/local/ispconfig/interface/web/domain')) exec('rm -rf /usr/local/ispconfig/interface/web/domain'); - - } + + } + } ?> diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php index 1e536abd6..7663f7eb3 100644 --- a/install/dist/lib/opensuse.lib.php +++ b/install/dist/lib/opensuse.lib.php @@ -58,7 +58,7 @@ class installer_dist extends installer_base { } } } - + if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); @@ -69,13 +69,13 @@ class installer_dist extends installer_base { $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); if(is_array($domainAll)) { - foreach($domainAll as $domain) - { - if ($domainAll[0]['domain'] == $domain['domain']) - $virtual_domains .= "'".$domain['domain']."'"; - else - $virtual_domains .= ", '".$domain['domain']."'"; - } + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + } } } else @@ -87,91 +87,91 @@ class installer_dist extends installer_base { $content = str_replace('{virtual_domains}', $virtual_domains, $content); wf($full_file_name, $content); - + //* Write virtual_to_transport.sh script $config_dir = $conf['mailman']['config_dir'].'/'; $full_file_name = $config_dir.'virtual_to_transport.sh'; - + //* Backup exiting virtual_to_transport.sh script if(is_file($full_file_name)) { copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); } - + if(is_dir('/etc/mailman')) { if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); - } else { - copy('tpl/mailman-virtual_to_transport.sh',$full_file_name); - } - chgrp($full_file_name,'mailman'); - chmod($full_file_name,0750); - } - + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + } + chgrp($full_file_name, 'mailman'); + chmod($full_file_name, 0750); + } + //* Create aliasaes exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); } - + function configure_postfix($options = '') - { - global $conf; + { + 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."); - } - + $this->error("The postfix configuration directory '$config_dir' does not exist."); + } + //* mysql-virtual_domains.cf - $this->process_postfix_config('mysql-virtual_domains.cf'); + $this->process_postfix_config('mysql-virtual_domains.cf'); //* mysql-virtual_forwardings.cf - $this->process_postfix_config('mysql-virtual_forwardings.cf'); + $this->process_postfix_config('mysql-virtual_forwardings.cf'); //* mysql-virtual_mailboxes.cf - $this->process_postfix_config('mysql-virtual_mailboxes.cf'); + $this->process_postfix_config('mysql-virtual_mailboxes.cf'); //* mysql-virtual_email2email.cf - $this->process_postfix_config('mysql-virtual_email2email.cf'); + $this->process_postfix_config('mysql-virtual_email2email.cf'); //* mysql-virtual_transports.cf - $this->process_postfix_config('mysql-virtual_transports.cf'); + $this->process_postfix_config('mysql-virtual_transports.cf'); //* mysql-virtual_recipient.cf - $this->process_postfix_config('mysql-virtual_recipient.cf'); + $this->process_postfix_config('mysql-virtual_recipient.cf'); //* mysql-virtual_sender.cf - $this->process_postfix_config('mysql-virtual_sender.cf'); + $this->process_postfix_config('mysql-virtual_sender.cf'); //* mysql-virtual_client.cf - $this->process_postfix_config('mysql-virtual_client.cf'); - + $this->process_postfix_config('mysql-virtual_client.cf'); + //* mysql-virtual_relaydomains.cf - $this->process_postfix_config('mysql-virtual_relaydomains.cf'); - + $this->process_postfix_config('mysql-virtual_relaydomains.cf'); + //* mysql-virtual_relayrecipientmaps.cf - $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf'); + $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf'); - //* postfix-dkim - $full_file_name=$config_dir.'/tag_as_originating.re'; - if(is_file($full_file_name)) { - copy($full_file_name, $config_dir.$configfile.'~'); - } - wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026'); + //* postfix-dkim + $full_file_name=$config_dir.'/tag_as_originating.re'; + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.$configfile.'~'); + } + wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026'); - $full_file_name=$config_dir.'/tag_as_foreign.re'; - if(is_file($full_file_name)) { - copy($full_file_name, $config_dir.$configfile.'~'); - } - wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024'); + $full_file_name=$config_dir.'/tag_as_foreign.re'; + if(is_file($full_file_name)) { + copy($full_file_name, $config_dir.$configfile.'~'); + } + wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024'); //* 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'); - + __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'); + if(!is_dir($cf['vmail_mailbox_base'])) mkdir($cf['vmail_mailbox_base']); - + //* Creating virtual mail user and group if(is_group($cf['vmail_groupname'])) { $command = 'groupmod -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname']; @@ -180,7 +180,7 @@ class installer_dist extends installer_base { $command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname']; caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); } - + if(is_user($cf['vmail_username'])) { $command = 'usermod -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' -d '.$cf['vmail_mailbox_base'].' -s /bin/bash '.$cf['vmail_username']; caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); @@ -188,9 +188,9 @@ class installer_dist extends installer_base { $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m'; caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); } - + if($cf['vmail_mailbox_base'] != '' && strlen($cf['vmail_mailbox_base']) >= 10 && $this->is_update === false) exec('chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base']); - + //* These postconf commands will be executed on installation and update $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']); $server_ini_array = ini_to_array(stripslashes($server_ini_rec['config'])); @@ -199,40 +199,40 @@ class installer_dist extends installer_base { //* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update $rbl_list = ''; if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') { - $rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); + $rbl_hosts = explode(",", str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); foreach ($rbl_hosts as $key => $value) { $rbl_list .= ", reject_rbl_client ". $value; } } unset($rbl_hosts); unset($server_ini_array); - + //* These postconf commands will be executed on installation and update - $postconf_placeholders = array('{config_dir}' => $config_dir, - '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], - '{vmail_userid}' => $cf['vmail_userid'], - '{vmail_groupid}' => $cf['vmail_groupid'], - '{rbl_list}' => $rbl_list); - - $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_postfix.conf.master', 'tpl/opensuse_postfix.conf.master'); - $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); - $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines - + $postconf_placeholders = array('{config_dir}' => $config_dir, + '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], + '{vmail_userid}' => $cf['vmail_userid'], + '{vmail_groupid}' => $cf['vmail_groupid'], + '{rbl_list}' => $rbl_list); + + $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_postfix.conf.master', 'tpl/opensuse_postfix.conf.master'); + $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); + $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines + //* These postconf commands will be executed on installation only if($this->is_update == false) { - $postconf_commands = array_merge($postconf_commands,array( - 'myhostname = '.$conf['hostname'], - 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', - 'mynetworks = 127.0.0.0/8 [::1]/128' - )); + $postconf_commands = array_merge($postconf_commands, array( + 'myhostname = '.$conf['hostname'], + 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', + 'mynetworks = 127.0.0.0/8 [::1]/128' + )); } - + //* 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 if(!is_dir('/var/lib/mailman/data')) exec('mkdir -p /var/lib/mailman/data'); if(!is_file('/var/lib/mailman/data/aliases')) touch('/var/lib/mailman/data/aliases'); @@ -241,78 +241,78 @@ class installer_dist extends installer_base { exec('postmap /var/lib/mailman/data/virtual-mailman'); if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); exec('/usr/sbin/postmap /var/lib/mailman/data/transport-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')) { + + 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 365 -x509'; + .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -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/authdaemon.courier-imap'; caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); - - //* Changing maildrop lines in posfix master.cf + + //* Changing maildrop lines in posfix master.cf if(is_file($config_dir.'/master.cf')){ - copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); - } + copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); + } if(is_file($config_dir.'/master.cf~')){ - exec('chmod 400 '.$config_dir.'/master.cf~'); - } + exec('chmod 400 '.$config_dir.'/master.cf~'); + } $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 ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', - $content); - - $content = str_replace(' flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', - ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', - $content); - + + $content = str_replace(' flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}', + ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', + $content); + + $content = str_replace(' flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', + ' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', + $content); + // enable tlsmanager - $content = str_replace('#tlsmgr unix - - n 1000? 1 tlsmgr','tlsmgr unix - - n 1000? 1 tlsmgr',$content); - + $content = str_replace('#tlsmgr unix - - n 1000? 1 tlsmgr', 'tlsmgr unix - - n 1000? 1 tlsmgr', $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.'~'); - } + copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~'); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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 $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('/etc/sasl2/smtpd.conf')) copy('/etc/sasl2/smtpd.conf','/etc/sasl2/smtpd.conf~'); @@ -324,14 +324,14 @@ class installer_dist extends installer_base { $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content); wf('/etc/sasl2/smtpd.conf',$content); */ - + // TODO: Chmod and chown on the config file - - + + /* // Create the spool directory exec('mkdir -p /var/spool/postfix/var/run/saslauthd'); - + // Edit the file /etc/default/saslauthd $configfile = $conf["saslauthd"]["config"]; if(is_file($configfile)) copy($configfile,$configfile.'~'); @@ -341,22 +341,22 @@ class installer_dist extends installer_base { $content = str_replace('OPTIONS="-c"','OPTIONS="-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('/sbin/startproc $AUTHD_BIN -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1','/sbin/startproc $AUTHD_BIN -r -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1',$content); - $content = str_replace('/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1','/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -r -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1',$content); - - - if(is_file($configfile)) wf($configfile,$content); - - - + $content = str_replace('/sbin/startproc $AUTHD_BIN -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1', '/sbin/startproc $AUTHD_BIN -r -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1', $content); + $content = str_replace('/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1', '/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -r -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1', $content); + + + if(is_file($configfile)) wf($configfile, $content); + + + } - + public function configure_pam() - { + { global $conf; $pam = $conf['pam']; //* configure pam for SMTP authentication agains the ispconfig database @@ -374,65 +374,65 @@ class installer_dist extends installer_base { if(is_file("$pam/smtp")) exec("chmod o= $pam/smtp"); //exec("chmod 660 $pam/smtp"); //exec("chown root:root $pam/smtp"); - + } - + 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~"); - } + copy("$config_dir/$configfile", "$config_dir/$configfile~"); + } exec("chmod 400 $config_dir/$configfile~"); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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_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); - + exec("chmod 660 $config_dir/$configfile"); exec("chown root:root $config_dir/$configfile"); - + //* authdaemonrc $configfile = $conf['courier']['config_dir'].'/authdaemonrc'; if(is_file($configfile)){ - copy($configfile, $configfile.'~'); - } + copy($configfile, $configfile.'~'); + } if(is_file($configfile.'~')){ - exec('chmod 400 '.$configfile.'~'); - } + exec('chmod 400 '.$configfile.'~'); + } $content = rf($configfile); $content = str_replace('authmodulelist=', '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($config_dir.'/master.cf')){ - copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); - } + copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); + } if(is_file($config_dir.'/master.cf~')){ - exec('chmod 400 '.$config_dir.'/master.cf~2'); - } + exec('chmod 400 '.$config_dir.'/master.cf~2'); + } $content = rf($conf["postfix"]["config_dir"].'/master.cf'); // Only add the content if we had not addded it before - if(!stristr($content,"dovecot/deliver")) { + if(!stristr($content, "dovecot/deliver")) { $deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'; - af($conf["postfix"]["config_dir"].'/master.cf',$deliver_content); + 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 ( @@ -442,115 +442,115 @@ class installer_dist extends installer_base { 'smtpd_sasl_path = private/auth', '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~3'); - + 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"); } - + //* backup dovecot.conf $configfile = 'dovecot.conf'; if(is_file("$config_dir/$configfile")){ - copy("$config_dir/$configfile", "$config_dir/$configfile~"); - } - + copy("$config_dir/$configfile", "$config_dir/$configfile~"); + } + //* Get the dovecot version - exec('dovecot --version',$tmp); - $parts = explode('.',trim($tmp[0])); + exec('dovecot --version', $tmp); + $parts = explode('.', trim($tmp[0])); $dovecot_version = $parts[0]; unset($tmp); unset($parts); - + //* Copy dovecot configuration file if($dovecot_version == 2) { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot2.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot2.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/opensuse_dovecot2.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot2.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot2.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/opensuse_dovecot2.conf.master', $config_dir.'/'.$configfile); + } } else { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/opensuse_dovecot.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/opensuse_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~"); + copy("$config_dir/$configfile", "$config_dir/$configfile~"); exec("chmod 400 $config_dir/$configfile~"); - } - + } + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_dovecot-sql.conf.master', "tpl/opensuse_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); + $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); - + exec("chmod 600 $config_dir/$configfile"); exec("chown root:root $config_dir/$configfile"); } - + public function configure_amavis() { global $conf; - + // amavisd user config file $configfile = 'opensuse_amavisd_conf'; - if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) @copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["amavis"]["config_dir"].'/amavisd.conf~'); + if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) @copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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"].'/amavisd.conf',$content); - - + $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"].'/amavisd.conf', $content); + + // 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'); - + 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~'); + 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")) { + if(!stristr($content, "127.0.0.1:10025")) { unset($content); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', "tpl/master_cf_amavis.master"); - af($conf["postfix"]["config_dir"].'/master.cf',$content); + af($conf["postfix"]["config_dir"].'/master.cf', $content); } unset($content); - + // Add the clamav user to the vscan group exec('groupmod --add-user clamav vscan'); - - + + } - + public function configure_spamassassin() - { + { global $conf; - + //* Enable spamasasssin on debian and ubuntu /* $configfile = '/etc/default/spamassassin'; @@ -562,40 +562,40 @@ class installer_dist extends installer_base { wf($configfile, $content); */ } - + public function configure_getmail() - { + { global $conf; - + $config_dir = $conf['getmail']['config_dir']; - + if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir)); $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 pam for SMTP authentication agains the ispconfig database $configfile = 'db/mysql.conf'; if(is_file("$config_dir/$configfile")){ - copy("$config_dir/$configfile", "$config_dir/$configfile~"); - } + copy("$config_dir/$configfile", "$config_dir/$configfile~"); + } if(is_file("$config_dir/$configfile~")){ - exec("chmod 400 $config_dir/$configfile~"); - } + exec("chmod 400 $config_dir/$configfile~"); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/pureftpd_mysql.conf.master', '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); @@ -605,69 +605,69 @@ class installer_dist extends installer_base { wf("$config_dir/$configfile", $content); exec("chmod 600 $config_dir/$configfile"); exec("chown root:root $config_dir/$configfile"); - + // copy our customized copy of pureftpd.conf to the pure-ftpd config directory if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/opensuse_pureftpd_conf.master')) { - exec("cp " . $conf['ispconfig_install_dir']."/server/conf-custom/install/opensuse_pureftpd_conf.master $config_dir/pure-ftpd.conf"); - } else { - exec("cp tpl/opensuse_pureftpd_conf.master $config_dir/pure-ftpd.conf"); - } - + exec("cp " . $conf['ispconfig_install_dir']."/server/conf-custom/install/opensuse_pureftpd_conf.master $config_dir/pure-ftpd.conf"); + } else { + exec("cp tpl/opensuse_pureftpd_conf.master $config_dir/pure-ftpd.conf"); + } + } - + 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)) copy($conf["mydns"]["config_dir"].'/'.$configfile, $conf["mydns"]["config_dir"].'/'.$configfile.'~'); if(is_file($conf["mydns"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["mydns"]["config_dir"].'/'.$configfile.'~'); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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); + $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); exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile); exec('chown root:root '.$conf["mydns"]["config_dir"].'/'.$configfile); - + } - + public function configure_apache() - { + { global $conf; - + if($conf['apache']['installed'] == false) return; //* Create the logging directory for the vhost logfiles exec('mkdir -p /var/log/ispconfig/httpd'); - + //if(is_file('/etc/suphp.conf')) { - replaceLine('/etc/suphp.conf','php=php','x-httpd-suphp="php:/srv/www/cgi-bin/php5"',0,0); - replaceLine('/etc/suphp.conf','php="php','x-httpd-suphp="php:/srv/www/cgi-bin/php5"',0,0); - replaceLine('/etc/suphp.conf','docroot=','docroot=/srv/www',0,0); - replaceLine('/etc/suphp.conf','umask=0077','umask=0022',0); + replaceLine('/etc/suphp.conf', 'php=php', 'x-httpd-suphp="php:/srv/www/cgi-bin/php5"', 0, 0); + replaceLine('/etc/suphp.conf', 'php="php', 'x-httpd-suphp="php:/srv/www/cgi-bin/php5"', 0, 0); + replaceLine('/etc/suphp.conf', 'docroot=', 'docroot=/srv/www', 0, 0); + replaceLine('/etc/suphp.conf', 'umask=0077', 'umask=0022', 0); //} - + if(!file_exists('/srv/www/cgi-bin/php5') && file_exists('/srv/www/cgi-bin/php')) { - symlink('/srv/www/cgi-bin/php','/srv/www/cgi-bin/php5'); + symlink('/srv/www/cgi-bin/php', '/srv/www/cgi-bin/php5'); } - + // Sites enabled and available dirs exec('mkdir -p '.$conf['apache']['vhost_conf_enabled_dir']); exec('mkdir -p '.$conf['apache']['vhost_conf_dir']); - + $content = rf('/etc/apache2/httpd.conf'); - if(!stristr($content,'Include /etc/apache2/sites-enabled/')) { - af('/etc/apache2/httpd.conf',"\n\n Options FollowSymlinks\n\n\nInclude /etc/apache2/sites-enabled/\n\n"); + if(!stristr($content, 'Include /etc/apache2/sites-enabled/')) { + af('/etc/apache2/httpd.conf', "\n\n Options FollowSymlinks\n\n\nInclude /etc/apache2/sites-enabled/\n\n"); } unset($content); - + //* Copy the ISPConfig configuration include - $vhost_conf_dir = $conf['apache']['vhost_conf_dir']; - $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir']; - + $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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.conf.master', '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'"); @@ -679,7 +679,7 @@ class installer_dist extends installer_base { } else { $ip_address = $rec['ip_address']; } - $ports = explode(',',$rec['virtualhost_port']); + $ports = explode(',', $rec['virtualhost_port']); if(is_array($ports)) { foreach($ports as $port) { $port = intval($port); @@ -690,37 +690,37 @@ class installer_dist extends installer_base { } } } - + $content .= "\n"; - wf($vhost_conf_dir.'/ispconfig.conf',$content); - + wf($vhost_conf_dir.'/ispconfig.conf', $content); + if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) { exec("ln -s ".$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')) { exec('mkdir /etc/webalizer'); exec('ln -s /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); + 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); } - + //* 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"); - + // create PHP-FPM pool dir exec('mkdir -p '.$conf['nginx']['php_fpm_pool_dir']); - + $content = rf('/etc/php5/fpm/php-fpm.conf'); if(stripos($content, 'include=/etc/php5/fpm/pool.d/*.conf') === false){ - af('/etc/php5/fpm/php-fpm.conf',"\ninclude=/etc/php5/fpm/pool.d/*.conf"); + af('/etc/php5/fpm/php-fpm.conf', "\ninclude=/etc/php5/fpm/pool.d/*.conf"); } unset($content); if(!@is_file($conf['nginx']['php_fpm_ini_path'])){ @@ -732,34 +732,34 @@ class installer_dist extends installer_base { exec('cp -f /etc/php5/apache2/php.ini '.$conf['nginx']['php_fpm_ini_path']); } } - + } - + public function configure_nginx(){ global $conf; - + if($conf['nginx']['installed'] == false) return; //* Create the logging directory for the vhost logfiles if(!@is_dir($conf['ispconfig_log_dir'].'/httpd')) mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true); - + // Sites enabled and available dirs exec('mkdir -p '.$conf['nginx']['vhost_conf_enabled_dir']); exec('mkdir -p '.$conf['nginx']['vhost_conf_dir']); - + $content = rf('/etc/nginx/nginx.conf'); if(stripos($content, 'include /etc/nginx/sites-enabled/*.vhost;') === false){ $content = trim($content); - $content = substr($content,0,-1)."\n include /etc/nginx/sites-enabled/*.vhost;\n}"; - wf('/etc/nginx/nginx.conf',$content); + $content = substr($content, 0, -1)."\n include /etc/nginx/sites-enabled/*.vhost;\n}"; + wf('/etc/nginx/nginx.conf', $content); } unset($content); - + // create PHP-FPM pool dir exec('mkdir -p '.$conf['nginx']['php_fpm_pool_dir']); - + $content = rf('/etc/php5/fpm/php-fpm.conf'); if(stripos($content, 'include=/etc/php5/fpm/pool.d/*.conf') === false){ - af('/etc/php5/fpm/php-fpm.conf',"\ninclude=/etc/php5/fpm/pool.d/*.conf"); + af('/etc/php5/fpm/php-fpm.conf', "\ninclude=/etc/php5/fpm/pool.d/*.conf"); } unset($content); if(!@is_file($conf['nginx']['php_fpm_ini_path'])){ @@ -775,95 +775,95 @@ class installer_dist extends installer_base { //* 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'); + 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); + 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); - + 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", octdec($directory_mode)); - if(is_dir("/etc/Bastille.backup/firewall.d")) caselog("cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/", __FILE__, __LINE__); - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master')) { - caselog("cp -f " . $conf['ispconfig_install_dir']."/server/conf-custom/install/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__); - } else { - 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); + @mkdir("/etc/Bastille", octdec($directory_mode)); + if(is_dir("/etc/Bastille.backup/firewall.d")) caselog("cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/", __FILE__, __LINE__); + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master')) { + caselog("cp -f " . $conf['ispconfig_install_dir']."/server/conf-custom/install/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__); + } else { + 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 = ''; - $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 443 3306 8080 10000'; - $udp_public_services = '53'; - } - + + 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 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); + $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($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-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_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); + 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 install_ispconfig() - { + { global $conf; - + $install_dir = $conf['ispconfig_install_dir']; //* Create the ISPConfig installation directory @@ -871,93 +871,93 @@ class installer_dist extends installer_base { $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~"); - } + copy("$install_dir/interface/lib/$configfile", "$install_dir/interface/lib/$configfile~"); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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_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); $content = str_replace('{timezone}', $conf['timezone'], $content); $content = str_replace('{theme}', $conf['theme'], $content); $content = str_replace('{language_file_import_enabled}', ($conf['language_file_import_enabled'] == true)?'true':'false', $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~"); - } + copy("$install_dir/server/lib/$configfile", "$install_dir/interface/lib/$configfile~"); + } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "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); $content = str_replace('{timezone}', $conf['timezone'], $content); $content = str_replace('{theme}', $conf['theme'], $content); $content = str_replace('{language_file_import_enabled}', ($conf['language_file_import_enabled'] == true)?'true':'false', $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 = ''; 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); + 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); @@ -971,16 +971,16 @@ class installer_dist extends installer_base { closedir($dh); } } - + $dir = $install_dir.'/server/plugins-available/'; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if($conf['apache']['installed'] == true && $file == 'nginx_plugin.inc.php') continue; if($conf['nginx']['installed'] == true && $file == 'apache2_plugin.inc.php') continue; - if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') { - include_once($install_dir.'/server/plugins-available/'.$file); - $plugin_name = substr($file,0,-8); + 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($tmp->onInstall()) { if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file); @@ -994,7 +994,7 @@ class installer_dist extends installer_base { closedir($dh); } } - + // Update the server config $mail_server_enabled = ($conf['services']['mail'])?1:0; $web_server_enabled = ($conf['services']['web'])?1:0; @@ -1003,14 +1003,14 @@ class installer_dist extends installer_base { $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"); @@ -1018,48 +1018,48 @@ class installer_dist extends installer_base { //* 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 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')) { + 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)) { + 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); + chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file, 0770); } } } } } - + //* Make the APS directories group writable exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages"); exec("chmod -R 770 $install_dir/server/aps_packages"); - + //* make sure that the server config file (not the interface one) is only readable by the root user chmod($install_dir.'/server/lib/config.inc.php', 0600); chown($install_dir.'/server/lib/config.inc.php', 'root'); chgrp($install_dir.'/server/lib/config.inc.php', 'root'); - + //* Make sure thet the interface config file is readable by user ispconfig only chmod($install_dir.'/interface/lib/config.inc.php', 0600); chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); chgrp($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); - + if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) { exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf"); exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf"); } - + // 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! @@ -1079,31 +1079,31 @@ class installer_dist extends installer_base { 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"); - - + + if($conf['apache']['installed'] == true && $this->install_ispconfig_interface == true){ //* Copy the ISPConfig vhost for the controlpanel // TODO: These are missing! should they be "vhost_dist_*_dir" ? $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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig.vhost.master', "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('/usr/local/ispconfig/interface/ssl/ispserver.crt') && is_file('/usr/local/ispconfig/interface/ssl/ispserver.key')) { $content = str_replace('{ssl_comment}', '', $content); } else { @@ -1114,23 +1114,23 @@ class installer_dist extends installer_base { } else { $content = str_replace('{ssl_bundle_comment}', '#', $content); } - + $content = str_replace('/var/www/', '/srv/www/', $content); - + wf("$vhost_conf_dir/ispconfig.vhost", $content); - + //if(!is_file('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) { - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); - $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); - $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); - exec('mkdir -p /srv/www/php-fcgi-scripts/ispconfig'); - wf('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); - exec('chmod +x /srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); - exec('ln -s /usr/local/ispconfig/interface/web /srv/www/ispconfig'); - exec('chown -R ispconfig:ispconfig /srv/www/php-fcgi-scripts/ispconfig'); - + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); + $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); + $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); + exec('mkdir -p /srv/www/php-fcgi-scripts/ispconfig'); + wf('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); + exec('chmod +x /srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); + exec('ln -s /usr/local/ispconfig/interface/web /srv/www/ispconfig'); + exec('chown -R ispconfig:ispconfig /srv/www/php-fcgi-scripts/ispconfig'); + //} - + //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost"); //* and create the symlink if($this->is_update == false) { @@ -1138,11 +1138,11 @@ class installer_dist extends installer_base { if(!@is_link("$vhost_conf_enabled_dir/000-ispconfig.vhost")) { exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost"); } - + } - + // Fix a setting in vhost master file for suse - replaceLine('/usr/local/ispconfig/server/conf/vhost.conf.master',"suPHP_UserGroup"," suPHP_UserGroup ",0); + replaceLine('/usr/local/ispconfig/server/conf/vhost.conf.master', "suPHP_UserGroup", " suPHP_UserGroup ", 0); } if($conf['nginx']['installed'] == true && $this->install_ispconfig_interface == true){ @@ -1153,7 +1153,7 @@ class installer_dist extends installer_base { // Dont just copy over the virtualhost template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/nginx_ispconfig.vhost.master', 'tpl/nginx_ispconfig.vhost.master'); $content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content); - + if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) { $content = str_replace('{ssl_on}', ' on', $content); $content = str_replace('{ssl_comment}', '', $content); @@ -1163,19 +1163,19 @@ class installer_dist extends installer_base { $content = str_replace('{ssl_comment}', '#', $content); $content = str_replace('{fastcgi_ssl}', 'off', $content); } - + $socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']); - if(substr($socket_dir,-1) != '/') $socket_dir .= '/'; + if(substr($socket_dir, -1) != '/') $socket_dir .= '/'; if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir); $fpm_socket = $socket_dir.'ispconfig.sock'; - + //$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content); $content = str_replace('{fpm_socket}', $fpm_socket, $content); wf($vhost_conf_dir.'/ispconfig.vhost', $content); - + unset($content); - + // PHP-FPM // Dont just copy over the php-fpm pool template but add some custom settings $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/php_fpm_pool.conf.master', 'tpl/php_fpm_pool.conf.master'); @@ -1191,20 +1191,20 @@ class installer_dist extends installer_base { if($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'); + symlink($vhost_conf_dir.'/ispconfig.vhost', $vhost_conf_enabled_dir.'/000-ispconfig.vhost'); } } - + // create symlinks from /usr/share to phpMyAdmin and SquirrelMail, if they are installed - if(!@file_exists('/usr/share/phpmyadmin') && @is_dir('/srv/www/htdocs/phpMyAdmin')) symlink('/srv/www/htdocs/phpMyAdmin/','/usr/share/phpmyadmin'); - if(!@file_exists('/usr/share/squirrelmail') && @is_dir('/srv/www/htdocs/squirrelmail')) symlink('/srv/www/htdocs/squirrelmail/','/usr/share/squirrelmail'); + if(!@file_exists('/usr/share/phpmyadmin') && @is_dir('/srv/www/htdocs/phpMyAdmin')) symlink('/srv/www/htdocs/phpMyAdmin/', '/usr/share/phpmyadmin'); + if(!@file_exists('/usr/share/squirrelmail') && @is_dir('/srv/www/htdocs/squirrelmail')) symlink('/srv/www/htdocs/squirrelmail/', '/usr/share/squirrelmail'); } - - + + // Make the Clamav log files readable by ISPConfig //exec('chmod +r /var/log/clamav/clamav.log'); //exec('chmod +r /var/log/clamav/freshclam.log'); - + //* Install the update script if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh'); exec('chown root /usr/local/ispconfig/server/scripts/update_from_svn.sh'); @@ -1215,96 +1215,96 @@ class installer_dist extends installer_base { exec('chmod 700 /usr/local/ispconfig/server/scripts/ispconfig_update.sh'); if(!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_update.sh /usr/local/bin/ispconfig_update_from_svn.sh'); if(!is_link('/usr/local/bin/ispconfig_update.sh')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_update.sh /usr/local/bin/ispconfig_update.sh'); - + //set the fast cgi starter script to executable //exec('chmod 755 '.$install_dir.'/interface/bin/php-fcgi'); - + //* 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'); - + //To enable apache to read the directories exec('chmod a+rx /usr/local/ispconfig'); exec('chmod -R 751 /usr/local/ispconfig/interface'); exec('chmod a+rx /usr/local/ispconfig/interface/web'); - + //* Create the ispconfig log directory if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir']); if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) exec('touch '.$conf['ispconfig_log_dir'].'/ispconfig.log'); - + if(is_user('getmail')) { exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh'); exec('chown getmail /usr/local/bin/run-getmail.sh'); exec('chmod 744 /usr/local/bin/run-getmail.sh'); } - + if(is_dir($install_dir.'/interface/invoices')) { exec('chmod -R 770 '.escapeshellarg($install_dir.'/interface/invoices')); exec('chown -R ispconfig:ispconfig '.escapeshellarg($install_dir.'/interface/invoices')); } - + //* Create the ispconfig auth log file and set uid/gid if(!is_file($conf['ispconfig_log_dir'].'/auth.log')) { touch($conf['ispconfig_log_dir'].'/auth.log'); } exec('chown ispconfig:ispconfig '. $conf['ispconfig_log_dir'].'/auth.log'); exec('chmod 660 '. $conf['ispconfig_log_dir'].'/auth.log'); - + //* Remove Domain module as its functions are available in the client module now if(@is_dir('/usr/local/ispconfig/interface/web/domain')) exec('rm -rf /usr/local/ispconfig/interface/web/domain'); - - + + } - + 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 + + // 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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mysql_clientdb.conf.master', "tpl/mysql_clientdb.conf.master"); - $content = str_replace('{hostname}',$conf['mysql']['host'],$content); - $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); + $content = str_replace('{hostname}', $conf['mysql']['host'], $content); + $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); exec('chmod 600 '."$install_dir/server/lib/mysql_clientdb.conf"); exec('chown root:root '."$install_dir/server/lib/mysql_clientdb.conf"); - + } - + public function install_crontab() - { + { global $conf; - + //* 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,'/usr/local/ispconfig')) unset($existing_root_cron_jobs[$key]); + if(stristr($val, '/usr/local/ispconfig')) unset($existing_root_cron_jobs[$key]); } - + $root_cron_jobs = array( '* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null', '30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null' ); - + if ($conf['nginx']['installed'] == true) { $root_cron_jobs[] = "0 0 * * * /usr/local/ispconfig/server/scripts/create_daily_nginx_access_logs.sh &> /dev/null"; } - + foreach($root_cron_jobs as $cron_job) { if(!in_array($cron_job."\n", $existing_root_cron_jobs)) { $existing_root_cron_jobs[] = $cron_job."\n"; @@ -1313,22 +1313,22 @@ class installer_dist extends installer_base { 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']; + $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>> /dev/null' - ); - + '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null' + ); + // 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]); + 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"; @@ -1338,7 +1338,7 @@ class installer_dist extends installer_base { exec('crontab -u getmail crontab.txt &> /dev/null'); unlink('crontab.txt'); } - + exec('touch /var/log/ispconfig/cron.log'); exec('chmod 660 /var/log/ispconfig/cron.log'); } diff --git a/install/dist/lib/opensuse110.lib.php b/install/dist/lib/opensuse110.lib.php index da77b423a..aeda9b9fd 100644 --- a/install/dist/lib/opensuse110.lib.php +++ b/install/dist/lib/opensuse110.lib.php @@ -33,4 +33,4 @@ class installer extends installer_dist { } -?> \ No newline at end of file +?> diff --git a/install/dist/lib/opensuse112.lib.php b/install/dist/lib/opensuse112.lib.php index da77b423a..aeda9b9fd 100644 --- a/install/dist/lib/opensuse112.lib.php +++ b/install/dist/lib/opensuse112.lib.php @@ -33,4 +33,4 @@ class installer extends installer_dist { } -?> \ No newline at end of file +?> diff --git a/install/install.php b/install/install.php index 170cbdcea..9add1b3c6 100644 --- a/install/install.php +++ b/install/install.php @@ -37,7 +37,7 @@ error_reporting(E_ALL|E_STRICT); define('INSTALLER_RUN', true); //** The banner on the command line -echo "\n\n".str_repeat('-',80)."\n"; +echo "\n\n".str_repeat('-', 80)."\n"; echo " _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / @@ -46,14 +46,14 @@ echo " _____ ___________ _____ __ _ ____ \___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ __/ | |___/ "; -echo "\n".str_repeat('-',80)."\n"; +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'); +require_once 'lib/install.lib.php'; //** Include the base class of the installer class -require_once('lib/installer_base.lib.php'); +require_once 'lib/installer_base.lib.php'; //** Ensure that current working directory is install directory $cur_dir = getcwd(); @@ -76,12 +76,12 @@ $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'); +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 +//** Installer Interface //**************************************************************************************************** $inst = new installer(); swriteln($inst->lng(' Following will be a few questions for primary configuration so be careful.')); @@ -90,7 +90,7 @@ swriteln($inst->lng(' Tap in "quit" (without the quotes) to stop the installe //** 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"); + 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')) { @@ -105,7 +105,7 @@ if(is_dir('/usr/local/ispconfig')) { $inst->find_installed_apps(); //** Select the language and set default timezone -$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en'); +$conf['language'] = $inst->simple_query('Select language', array('en', 'de'), 'en'); $conf['timezone'] = get_system_timezone(); //* Set default theme @@ -113,7 +113,7 @@ $conf['theme'] = 'default'; $conf['language_file_import_enabled'] = true; //** Select installation mode -$install_mode = $inst->simple_query('Installation mode', array('standard','expert'), 'standard'); +$install_mode = $inst->simple_query('Installation mode', array('standard', 'expert'), 'standard'); //** Get the hostname @@ -133,13 +133,13 @@ do { $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']); - + if($install_mode == 'expert') { swriteln("The next two questions are about the internal ISPConfig database user and password.\nIt is recommended to accept the defaults which are 'ispconfig' as username and a random password.\nIf you use a different password, use only numbers and chars for the password.\n"); $conf['mysql']['ispconfig_user'] = $inst->free_query('ISPConfig mysql database username', $conf['mysql']['ispconfig_user']); $conf['mysql']['ispconfig_password'] = $inst->free_query('ISPConfig mysql database password', $conf['mysql']['ispconfig_password']); } - + //* 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; @@ -155,44 +155,44 @@ do { unset($finished); // Resolve the IP address of the MySQL hostname. -$tmp = explode(':',$conf['mysql']['host']); +$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'); +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(); - + //* Configure Webserver - Apache or nginx if($conf['apache']['installed'] == true && $conf['nginx']['installed'] == true) { - $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache','nginx'), 'apache'); + $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache', 'nginx'), 'apache'); if($http_server_to_use == 'apache'){ $conf['nginx']['installed'] = false; } else { $conf['apache']['installed'] = false; } } - + //* 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'); @@ -205,7 +205,7 @@ if($install_mode == 'standard') { //* Configure PAM swriteln('Configuring PAM'); $inst->configure_pam(); - + //* Configure Courier swriteln('Configuring Courier'); $inst->configure_courier(); @@ -222,7 +222,7 @@ if($install_mode == 'standard') { //* Configure Getmail swriteln('Configuring Getmail'); $inst->configure_getmail(); - + //* Configure Pureftpd swriteln('Configuring Pureftpd'); $inst->configure_pureftpd(); @@ -238,29 +238,29 @@ if($install_mode == 'standard') { swriteln('Configuring MyDNS'); $inst->configure_mydns(); } - + //* Configure Apache if($conf['apache']['installed'] == true){ swriteln('Configuring Apache'); $inst->configure_apache(); } - + //* Configure nginx if($conf['nginx']['installed'] == true){ swriteln('Configuring nginx'); $inst->configure_nginx(); } - - //** Configure Vlogger - swriteln('Configuring Vlogger'); - $inst->configure_vlogger(); - + + //** Configure Vlogger + swriteln('Configuring Vlogger'); + $inst->configure_vlogger(); + //** Configure apps vhost swriteln('Configuring Apps vhost'); $inst->configure_apps_vhost(); - + //* Configure Firewall - if($conf['ufw']['installed'] == true) { + if($conf['ufw']['installed'] == true) { //* Configure Ubuntu Firewall $conf['services']['firewall'] = true; swriteln('Configuring Ubuntu Firewall'); @@ -272,12 +272,12 @@ if($install_mode == 'standard') { $inst->configure_bastille_firewall(); } - //* Configure Fail2ban - if($conf['fail2ban']['installed'] == true) { - swriteln('Configuring Fail2ban'); - $inst->configure_fail2ban(); - } - + //* Configure Fail2ban + if($conf['fail2ban']['installed'] == true) { + swriteln('Configuring Fail2ban'); + $inst->configure_fail2ban(); + } + /* if($conf['squid']['installed'] == true) { $conf['services']['proxy'] = true; @@ -289,22 +289,22 @@ if($install_mode == 'standard') { $inst->configure_nginx(); } */ - + //* Configure ISPConfig swriteln('Installing ISPConfig'); - + //** Customize the port ISPConfig runs on $ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080'); if($conf['apache']['installed'] == true) $conf['apache']['vhost_port'] = $ispconfig_vhost_port; if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port'] = $ispconfig_vhost_port; unset($ispconfig_vhost_port); - if(strtolower($inst->simple_query('Do you want a secure (SSL) connection to the ISPConfig web interface',array('y','n'),'y')) == 'y') { - $inst->make_ispconfig_ssl_cert(); + if(strtolower($inst->simple_query('Do you want a secure (SSL) connection to the ISPConfig web interface', array('y', 'n'), 'y')) == 'y') { + $inst->make_ispconfig_ssl_cert(); } $inst->install_ispconfig(); - + //* Configure DBServer swriteln('Configuring DBServer'); $inst->configure_dbserver(); @@ -312,7 +312,7 @@ if($install_mode == 'standard') { //* Configure ISPConfig swriteln('Installing ISPConfig crontab'); $inst->install_crontab(); - + swriteln('Restarting services ...'); if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart')); if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart')); @@ -338,10 +338,10 @@ if($install_mode == 'standard') { if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null'); if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null'); if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null'); - //if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); + //if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_file($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null'); if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '') system($inst->getinitcommand($conf['ufw']['init_script'], 'restart').' &> /dev/null'); - + //* In expert mode, we select the services in the following steps, only db is always available $conf['services']['mail'] = false; $conf['services']['web'] = false; @@ -349,23 +349,23 @@ if($install_mode == 'standard') { $conf['services']['db'] = true; $conf['services']['firewall'] = false; $conf['services']['proxy'] = false; - - + + //** 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') { + + 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']); - + $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; @@ -378,7 +378,7 @@ if($install_mode == 'standard') { } } while ($finished == false); unset($finished); - + // initialize the connection to the master database $inst->dbmaster = new db(); if($inst->dbmaster->linkId) $inst->dbmaster->closeConn(); @@ -386,39 +386,39 @@ if($install_mode == 'standard') { $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(); - + //* Configure Webserver - Apache or nginx if($conf['apache']['installed'] == true && $conf['nginx']['installed'] == true) { - $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache','nginx'), 'apache'); + $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache', 'nginx'), 'apache'); if($http_server_to_use == 'apache'){ $conf['nginx']['installed'] = false; } else { $conf['apache']['installed'] = false; } } - + //* 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') { - + + 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(); @@ -428,15 +428,15 @@ if($install_mode == 'standard') { 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(); @@ -453,7 +453,7 @@ if($install_mode == 'standard') { //* Configure Getmail swriteln('Configuring Getmail'); $inst->configure_getmail(); - + if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart')); if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart')); if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart')); @@ -468,22 +468,22 @@ if($install_mode == 'standard') { if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart')); if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &'); } - + //** Configure Jailkit - if(strtolower($inst->simple_query('Configure Jailkit', array('y','n'),'y') ) == 'y') { + 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') { + if(strtolower($inst->simple_query('Configure FTP Server', array('y', 'n'), 'y') ) == 'y') { swriteln('Configuring Pureftpd'); $inst->configure_pureftpd(); if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart')); } - + //** Configure DNS - if(strtolower($inst->simple_query('Configure DNS Server',array('y','n'),'y')) == 'y') { + if(strtolower($inst->simple_query('Configure DNS Server', array('y', 'n'), 'y')) == 'y') { $conf['services']['dns'] = true; //* Configure DNS if($conf['powerdns']['installed'] == true) { @@ -499,12 +499,12 @@ if($install_mode == 'standard') { $inst->configure_mydns(); if($conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null'); } - + } - + /* //** Configure Squid - if(strtolower($inst->simple_query('Configure Proxy Server', array('y','n'),'y') ) == 'y') { + if(strtolower($inst->simple_query('Configure Proxy Server', array('y','n'),'y') ) == 'y') { if($conf['squid']['installed'] == true) { $conf['services']['proxy'] = true; swriteln('Configuring Squid'); @@ -518,45 +518,45 @@ if($install_mode == 'standard') { } } */ - + //** Configure Apache if($conf['apache']['installed'] == true){ 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') { + 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 nginx if($conf['nginx']['installed'] == true){ swriteln("\nHint: If this server shall run the ISPConfig interface, select 'y' in the 'Configure nginx Server' option.\n"); - if(strtolower($inst->simple_query('Configure nginx Server',array('y','n'),'y')) == 'y') { + if(strtolower($inst->simple_query('Configure nginx Server', array('y', 'n'), 'y')) == 'y') { $conf['services']['web'] = true; swriteln('Configuring nginx'); $inst->configure_nginx(); - + //** 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') { + if(strtolower($inst->simple_query('Configure Firewall Server', array('y', 'n'), 'y')) == 'y') { if($conf['ufw']['installed'] == true) { //* Configure Ubuntu Firewall $conf['services']['firewall'] = true; @@ -569,18 +569,18 @@ if($install_mode == 'standard') { $inst->configure_bastille_firewall(); } } - + //** Configure Firewall - /*if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') { + /*if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') { swriteln('Configuring Firewall'); $inst->configure_firewall(); }*/ - + //** Configure ISPConfig :-) $install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y'; - if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),$install_ispconfig_interface_default)) == 'y') { + if(strtolower($inst->simple_query('Install ISPConfig Web Interface', array('y', 'n'), $install_ispconfig_interface_default)) == '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 ? /* @@ -600,23 +600,23 @@ if($install_mode == 'standard') { if($conf['apache']['installed'] == true) $conf['apache']['vhost_port'] = $ispconfig_vhost_port; if($conf['nginx']['installed'] == true) $conf['nginx']['vhost_port'] = $ispconfig_vhost_port; unset($ispconfig_vhost_port); - - if(strtolower($inst->simple_query('Enable SSL for the ISPConfig web interface',array('y','n'),'y')) == 'y') { + + 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(); @@ -626,9 +626,9 @@ if($install_mode == 'standard') { if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload')); if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload')); } - - - + + + } //* << $install_mode / 'Standard' or Genius diff --git a/install/lib/install.lib.php b/install/lib/install.lib.php index 9c61759c7..30ba04ea1 100644 --- a/install/lib/install.lib.php +++ b/install/lib/install.lib.php @@ -79,66 +79,66 @@ function get_distname() { $distname = 'Ubuntu'; $distid = 'debian40'; $distbaseid = 'debian'; - $ver = explode(' ',$issue); + $ver = explode(' ', $issue); $ver = array_filter($ver); $ver = next($ver); - $mainver = explode('.',$ver); + $mainver = explode('.', $ver); $mainver = array_filter($mainver); $mainver = current($mainver).'.'.next($mainver); switch ($mainver){ - case "12.10": - $relname = "(Quantal Quetzal)"; + case "12.10": + $relname = "(Quantal Quetzal)"; break; - case "12.04": - $relname = "(Precise Pangolin)"; + case "12.04": + $relname = "(Precise Pangolin)"; break; - case "11.10": - $relname = "(Oneiric Ocelot)"; + case "11.10": + $relname = "(Oneiric Ocelot)"; break; - case "11.14": - $relname = "(Natty Narwhal)"; + case "11.14": + $relname = "(Natty Narwhal)"; break; - case "10.10": - $relname = "(Maverick Meerkat)"; + case "10.10": + $relname = "(Maverick Meerkat)"; break; - case "10.04": - $relname = "(Lucid Lynx)"; + case "10.04": + $relname = "(Lucid Lynx)"; break; - case "9.10": - $relname = "(Karmic Koala)"; + case "9.10": + $relname = "(Karmic Koala)"; break; - case "9.04": - $relname = "(Jaunty Jackpole)"; + case "9.04": + $relname = "(Jaunty Jackpole)"; break; - case "8.10": + case "8.10": $relname = "(Intrepid Ibex)"; break; - case "8.04": - $relname = "(Hardy Heron)"; + case "8.04": + $relname = "(Hardy Heron)"; break; - case "7.10": - $relname = "(Gutsy Gibbon)"; + case "7.10": + $relname = "(Gutsy Gibbon)"; break; - case "7.04": - $relname = "(Feisty Fawn)"; + case "7.04": + $relname = "(Feisty Fawn)"; break; - case "6.10": - $relname = "(Edgy Eft)"; + case "6.10": + $relname = "(Edgy Eft)"; break; - case "6.06": - $relname = "(Dapper Drake)"; + case "6.06": + $relname = "(Dapper Drake)"; break; - case "5.10": - $relname = "(Breezy Badger)"; + case "5.10": + $relname = "(Breezy Badger)"; break; - case "5.04": - $relname = "(Hoary Hedgehog)"; + case "5.04": + $relname = "(Hoary Hedgehog)"; break; - case "4.10": - $relname = "(Warty Warthog)"; + case "4.10": + $relname = "(Warty Warthog)"; break; - default: - $relname = "UNKNOWN"; + default: + $relname = "UNKNOWN"; } $distver = $ver.$lts." ".$relname; swriteln("Operating System: ".$distver."\n"); @@ -148,19 +148,19 @@ function get_distname() { $distid = 'debian40'; $distbaseid = 'debian'; swriteln("Operating System: Debian 4.0 or compatible\n"); - } elseif(strstr(trim(file_get_contents('/etc/debian_version')),'5.0')) { + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '5.0')) { $distname = 'Debian'; $distver = 'Lenny'; $distid = 'debian40'; $distbaseid = 'debian'; swriteln("Operating System: Debian Lenny or compatible\n"); - } elseif(strstr(trim(file_get_contents('/etc/debian_version')),'6.0') || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') { + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '6.0') || trim(file_get_contents('/etc/debian_version')) == 'squeeze/sid') { $distname = 'Debian'; $distver = 'Squeeze/Sid'; $distid = 'debian60'; $distbaseid = 'debian'; swriteln("Operating System: Debian 6.0 (Squeeze/Sid) or compatible\n"); - } elseif(strstr(trim(file_get_contents('/etc/debian_version')),'7.0') || strstr(trim(file_get_contents('/etc/debian_version')),'7.1') || trim(file_get_contents('/etc/debian_version')) == 'wheezy/sid') { + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '7.0') || strstr(trim(file_get_contents('/etc/debian_version')), '7.1') || trim(file_get_contents('/etc/debian_version')) == 'wheezy/sid') { $distname = 'Debian'; $distver = 'Wheezy/Sid'; $distid = 'debian60'; @@ -177,19 +177,19 @@ function get_distname() { //** OpenSuSE elseif(file_exists('/etc/SuSE-release')) { - if(stristr(file_get_contents('/etc/SuSE-release'),'11.0')) { + if(stristr(file_get_contents('/etc/SuSE-release'), '11.0')) { $distname = 'openSUSE'; $distver = '11.0'; $distid = 'opensuse110'; $distbaseid = 'opensuse'; swriteln("Operating System: openSUSE 11.0 or compatible\n"); - } elseif(stristr(file_get_contents('/etc/SuSE-release'),'11.1')) { + } elseif(stristr(file_get_contents('/etc/SuSE-release'), '11.1')) { $distname = 'openSUSE'; $distver = '11.1'; $distid = 'opensuse110'; $distbaseid = 'opensuse'; swriteln("Operating System: openSUSE 11.1 or compatible\n"); - } elseif(stristr(file_get_contents('/etc/SuSE-release'),'11.2')) { + } elseif(stristr(file_get_contents('/etc/SuSE-release'), '11.2')) { $distname = 'openSUSE'; $distver = '11.2'; $distid = 'opensuse112'; @@ -210,37 +210,37 @@ function get_distname() { $content = file_get_contents('/etc/redhat-release'); - if(stristr($content,'Fedora release 9 (Sulphur)')) { + if(stristr($content, 'Fedora release 9 (Sulphur)')) { $distname = 'Fedora'; $distver = '9'; $distid = 'fedora9'; $distbaseid = 'fedora'; swriteln("Operating System: Fedora 9 or compatible\n"); - } elseif(stristr($content,'Fedora release 10 (Cambridge)')) { + } elseif(stristr($content, 'Fedora release 10 (Cambridge)')) { $distname = 'Fedora'; $distver = '10'; $distid = 'fedora9'; $distbaseid = 'fedora'; swriteln("Operating System: Fedora 10 or compatible\n"); - } elseif(stristr($content,'Fedora release 10')) { + } elseif(stristr($content, 'Fedora release 10')) { $distname = 'Fedora'; $distver = '11'; $distid = 'fedora9'; $distbaseid = 'fedora'; swriteln("Operating System: Fedora 11 or compatible\n"); - } elseif(stristr($content,'CentOS release 5.2 (Final)')) { + } elseif(stristr($content, 'CentOS release 5.2 (Final)')) { $distname = 'CentOS'; $distver = '5.2'; $distid = 'centos52'; $distbaseid = 'fedora'; swriteln("Operating System: CentOS 5.2 or compatible\n"); - } elseif(stristr($content,'CentOS release 5.3 (Final)')) { + } elseif(stristr($content, 'CentOS release 5.3 (Final)')) { $distname = 'CentOS'; $distver = '5.3'; $distid = 'centos53'; $distbaseid = 'fedora'; swriteln("Operating System: CentOS 5.3 or compatible\n"); - } elseif(stristr($content,'CentOS release 5')) { + } elseif(stristr($content, 'CentOS release 5')) { $distname = 'CentOS'; $distver = 'Unknown'; $distid = 'centos53'; @@ -260,7 +260,7 @@ function get_distname() { $content = file_get_contents('/etc/gentoo-release'); - preg_match_all('/([0-9]{1,2})/', $content, $version); + preg_match_all('/([0-9]{1,2})/', $content, $version); $distname = 'Gentoo'; $distver = $version[0][0].$version[0][1]; $distid = 'gentoo'; @@ -275,8 +275,8 @@ function get_distname() { } function sread() { - $input = fgets(STDIN); - return rtrim($input); + $input = fgets(STDIN); + return rtrim($input); } function swrite($text = '') { @@ -288,7 +288,7 @@ function swriteln($text = '') { } function ilog($msg){ - exec("echo `date` \"- [ISPConfig] - \"".$msg.' >> '.ISPC_LOG_FILE); + exec("echo `date` \"- [ISPConfig] - \"".$msg.' >> '.ISPC_LOG_FILE); } function error($msg){ @@ -297,7 +297,7 @@ function error($msg){ } function caselog($command, $file = '', $line = '', $success = '', $failure = ''){ - exec($command,$arr,$ret_val); + exec($command, $arr, $ret_val); $arr = NULL; if(!empty($file) && !empty($line)){ $pre = $file.', Line '.$line.': '; @@ -346,15 +346,15 @@ function mkdirs($strPath, $mode = '0755'){ } function rfsel($file, $file2) { - clearstatcache(); - if(is_file($file)) return rf($file); - else return rf($file2); + clearstatcache(); + if(is_file($file)) return rf($file); + else return rf($file2); } function rf($file){ clearstatcache(); if(is_file($file)) { - if(!$fp = fopen ($file, 'rb')){ + if(!$fp = fopen($file, 'rb')){ ilog('WARNING: could not open file '.$file); } return filesize($file) > 0 ? fread($fp, filesize($file)) : ''; @@ -365,7 +365,7 @@ function rf($file){ function wf($file, $content){ mkdirs(dirname($file)); - if(!$fp = fopen ($file, 'wb')){ + if(!$fp = fopen($file, 'wb')){ ilog('WARNING: could not open file '.$file); } fwrite($fp, $content); @@ -374,18 +374,18 @@ function wf($file, $content){ function af($file, $content){ mkdirs(dirname($file)); - if(!$fp = fopen ($file, 'ab')){ + if(!$fp = fopen($file, 'ab')){ ilog('WARNING: could not open file '.$file); } - fwrite($fp,$content); + fwrite($fp, $content); fclose($fp); } function aftsl($file, $content){ - if(!$fp = fopen ($file, 'ab')){ + if(!$fp = fopen($file, 'ab')){ ilog('WARNING: could not open file '.$file); } - fwrite($fp,$content); + fwrite($fp, $content); fclose($fp); } @@ -428,7 +428,7 @@ function no_comments($file, $comment = '#'){ if(strstr($line, $comment)){ $pos = strpos($line, $comment); if($pos != 0){ - $new_lines[] = substr($line,0,$pos); + $new_lines[] = substr($line, 0, $pos); }else{ $new_lines[] = ''; } @@ -508,7 +508,7 @@ function grep($content, $string, $params = ''){ } if(is_array($find)){ $ret_val = implode("\n", $find); - if(substr($ret_val,-1) != "\n") $ret_val .= "\n"; + if(substr($ret_val, -1) != "\n") $ret_val .= "\n"; $find = NULL; return $ret_val; } else { @@ -555,7 +555,7 @@ function ini_to_array($ini) { $ini = str_replace("\r\n", "\n", $ini); $lines = explode("\n", $ini); foreach($lines as $line) { - $line = trim($line); + $line = trim($line); if($line != '') { if(preg_match("/^\[([\w\d_]+)\]$/", $line, $matches)) { $section = strtolower($matches[1]); @@ -577,8 +577,8 @@ function array_to_ini($config_array = '') { $content .= "[$section]\n"; foreach($data as $item => $value) { if($item != ''){ - $content .= "$item=$value\n"; - } + $content .= "$item=$value\n"; + } } $content .= "\n"; } @@ -617,13 +617,13 @@ function is_group($group){ return false; } -function replaceLine($filename,$search_pattern,$new_line,$strict = 0,$append = 1) { +function replaceLine($filename, $search_pattern, $new_line, $strict = 0, $append = 1) { if($lines = @file($filename)) { $out = ''; $found = 0; foreach($lines as $line) { if($strict == 0) { - if(stristr($line,$search_pattern)) { + if(stristr($line, $search_pattern)) { $out .= $new_line."\n"; $found = 1; } else { @@ -640,20 +640,20 @@ function replaceLine($filename,$search_pattern,$new_line,$strict = 0,$append = 1 } if($found == 0) { //* add \n if the last line does not end with \n or \r - if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n"; + if(substr($out, -1) != "\n" && substr($out, -1) != "\r") $out .= "\n"; //* add the new line at the end of the file if($append == 1) $out .= $new_line."\n"; } - file_put_contents($filename,$out); + file_put_contents($filename, $out); } } -function removeLine($filename,$search_pattern,$strict = 0) { +function removeLine($filename, $search_pattern, $strict = 0) { if($lines = @file($filename)) { $out = ''; foreach($lines as $line) { if($strict == 0) { - if(!stristr($line,$search_pattern)) { + if(!stristr($line, $search_pattern)) { $out .= $line; } } else { @@ -662,13 +662,13 @@ function removeLine($filename,$search_pattern,$strict = 0) { } } } - file_put_contents($filename,$out); + file_put_contents($filename, $out); } } function is_installed($appname) { - exec('which '.escapeshellcmd($appname).' 2> /dev/null',$out,$returncode); - if(isset($out[0]) && stristr($out[0],$appname) && $returncode == 0) { + exec('which '.escapeshellcmd($appname).' 2> /dev/null', $out, $returncode); + if(isset($out[0]) && stristr($out[0], $appname) && $returncode == 0) { return true; } else { return false; @@ -683,12 +683,12 @@ function is_installed($appname) { * 1 $current version is older then new version (update) */ -function compare_ispconfig_version($current,$new) { +function compare_ispconfig_version($current, $new) { if( $current == $new) { return 0; } - $p = explode('.',$current); + $p = explode('.', $current); $tmp = ''; $tmp .= str_pad(intval($p[0]), 3, '0', STR_PAD_LEFT); $tmp .= (isset($p[1]))?str_pad(intval($p[1]), 3, '0', STR_PAD_LEFT):'000'; @@ -696,7 +696,7 @@ function compare_ispconfig_version($current,$new) { $tmp .= (isset($p[3]))?str_pad(intval($p[3]), 3, '0', STR_PAD_LEFT):'000'; $current = $tmp; - $p = explode('.',$new); + $p = explode('.', $new); $tmp = ''; $tmp .= str_pad(intval($p[0]), 3, '0', STR_PAD_LEFT); $tmp .= (isset($p[1]))?str_pad(intval($p[1]), 3, '0', STR_PAD_LEFT):'000'; @@ -728,7 +728,7 @@ function get_ispconfig_port_number() { if(is_file($ispconfig_vhost_file)) { $tmp = file_get_contents($ispconfig_vhost_file); - preg_match($regex,$tmp,$matches); + preg_match($regex, $tmp, $matches); $port_number = @intval($matches[1]); if($port_number > 0) { return $port_number; @@ -748,7 +748,7 @@ function is_ispconfig_ssl_enabled() { if(is_file($ispconfig_vhost_file)) { $tmp = file_get_contents($ispconfig_vhost_file); - if(stristr($tmp,'SSLCertificateFile')) { + if(stristr($tmp, 'SSLCertificateFile')) { return true; } else { return false; @@ -756,60 +756,63 @@ function is_ispconfig_ssl_enabled() { } } -/** - Function to find the hash file for timezone detection - (c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de -*/ +/** + Function to find the hash file for timezone detection + (c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de + */ + + function find_hash_file($hash, $dir, $basedir = '') { - $res = opendir($dir); - if(!$res) return false; - - if(substr($basedir, -1) === '/') $basedir = substr($basedir, 0, strlen($basedir) - 1); - if(substr($dir, -1) === '/') $dir = substr($dir, 0, strlen($dir) - 1); - if($basedir === '') $basedir = $dir; - - while($cur = readdir($res)) { - if($cur == '.' || $cur == '..') continue; - $entry = $dir.'/'.$cur; - if(is_dir($entry)) { - $result = find_hash_file($hash, $entry, $basedir); - if($result !== false) return $result; - } elseif(md5_file($entry) === $hash) { - $entry = substr($entry, strlen($basedir) + 1); - if(substr($entry, 0, 7) === '/posix/') $entry = substr($entry, 7); - return $entry; - } - } - closedir($res); - return false; -} - -/** - Function to get the timezone of the Linux system - (c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de -*/ + $res = opendir($dir); + if(!$res) return false; + + if(substr($basedir, -1) === '/') $basedir = substr($basedir, 0, strlen($basedir) - 1); + if(substr($dir, -1) === '/') $dir = substr($dir, 0, strlen($dir) - 1); + if($basedir === '') $basedir = $dir; + + while($cur = readdir($res)) { + if($cur == '.' || $cur == '..') continue; + $entry = $dir.'/'.$cur; + if(is_dir($entry)) { + $result = find_hash_file($hash, $entry, $basedir); + if($result !== false) return $result; + } elseif(md5_file($entry) === $hash) { + $entry = substr($entry, strlen($basedir) + 1); + if(substr($entry, 0, 7) === '/posix/') $entry = substr($entry, 7); + return $entry; + } + } + closedir($res); + return false; +} + + +/** + Function to get the timezone of the Linux system + (c) 2012 Marius Cramer, pixcept KG, m.cramer@pixcept.de + */ function get_system_timezone() { - $timezone = false; - if(file_exists('/etc/timezone') && is_readable('/etc/timezone')) { - $timezone = trim(file_get_contents('/etc/timezone')); - if(file_exists('/usr/share/zoneinfo/' . $timezone) == false) $timezone = false; - } - - if(!$timezone && is_link('/etc/localtime')) { - $timezone = readlink('/etc/localtime'); - $timezone = str_replace('/usr/share/zoneinfo/', '', $timezone); - if(substr($timezone, 0, 6) === 'posix/') $timezone = substr($timezone, 6); - } elseif(!$timezone) { - $hash = md5_file('/etc/localtime'); - $timezone = find_hash_file($hash, '/usr/share/zoneinfo'); - } - - if(!$timezone) { - exec('date +%Z', $tzinfo); - $timezone = $tzinfo[0]; - } - - return $timezone; + $timezone = false; + if(file_exists('/etc/timezone') && is_readable('/etc/timezone')) { + $timezone = trim(file_get_contents('/etc/timezone')); + if(file_exists('/usr/share/zoneinfo/' . $timezone) == false) $timezone = false; + } + + if(!$timezone && is_link('/etc/localtime')) { + $timezone = readlink('/etc/localtime'); + $timezone = str_replace('/usr/share/zoneinfo/', '', $timezone); + if(substr($timezone, 0, 6) === 'posix/') $timezone = substr($timezone, 6); + } elseif(!$timezone) { + $hash = md5_file('/etc/localtime'); + $timezone = find_hash_file($hash, '/usr/share/zoneinfo'); + } + + if(!$timezone) { + exec('date +%Z', $tzinfo); + $timezone = $tzinfo[0]; + } + + return $timezone; } diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index e46d97782..ab0c96309 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -53,7 +53,7 @@ class installer_base { } public function warning($msg) { - echo('WARNING: '.$msg."\n"); + echo 'WARNING: '.$msg."\n"; } public function simple_query($query, $answers, $default) { @@ -86,7 +86,7 @@ class installer_base { return $answer; } - public function free_query($query,$default) { + public function free_query($query, $default) { swrite($this->lng($query).' ['.$default.']: '); $input = sread(); @@ -141,6 +141,8 @@ class installer_base { } /** Create the database for ISPConfig */ + + public function configure_database() { global $conf; @@ -159,10 +161,10 @@ class installer_base { } else { if($conf['mysql']['admin_password'] == '') { caselog("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null", - __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); + __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); } else { caselog("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null", - __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); + __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); } $db_tables = $this->db->getTables(); if(count($db_tables) == 0) { @@ -194,8 +196,8 @@ class installer_base { //* 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']."';"; + ."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); } @@ -360,140 +362,140 @@ class installer_base { } if(count($hosts) > 0) { - foreach($hosts as $host => $value) { - /* + 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'] . "'"; - if ($verbose){ - echo "\n\n" . $query ."\n"; + if ($value['pwd'] != ''){ + $query = "CREATE USER '".$value['user']."'@'".$host."' IDENTIFIED BY '" . $value['pwd'] . "'"; + if ($verbose){ + echo "\n\n" . $query ."\n"; + } + $this->dbmaster->query($query); // ignore the error } - $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."' "; - if ($verbose){ + $query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM '".$value['user']."'@'".$host."' "; + if ($verbose){ echo "\n\n" . $query ."\n"; - } - $this->dbmaster->query($query); // ignore the error + } + $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 ($verbose){ - echo $query ."\n"; - } - 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); - } + //* Create the ISPConfig database user in the remote database + $query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' "; + if ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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`, `error`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' "; - if ($verbose){ - echo $query ."\n"; - } - 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`, `error`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' "; + if ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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`, `ssl_key`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' "; - if ($verbose){ - echo $query ."\n"; - } - 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`, `ssl_key`) ON ".$value['db'].".`web_domain` TO '".$value['user']."'@'".$host."' "; + if ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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 ($verbose){ - echo $query ."\n"; - } - 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 ($verbose){ + echo $query ."\n"; + } + 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 ON ".$value['db'].".`aps_instances` TO '".$value['user']."'@'".$host."' "; - if ($verbose){ - echo $query ."\n"; - } - 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'].".`web_backup` TO '".$value['user']."'@'".$host."' "; - if ($verbose){ - echo $query ."\n"; - } - 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 ON ".$value['db'].".`aps_instances` TO '".$value['user']."'@'".$host."' "; + if ($verbose){ + echo $query ."\n"; + } + 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'].".`web_backup` TO '".$value['user']."'@'".$host."' "; + if ($verbose){ + echo $query ."\n"; + } + 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;'); + $this->dbmaster->query('FLUSH PRIVILEGES;'); } } @@ -528,17 +530,17 @@ class installer_base { 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.'~'); - - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_init.'.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_init.'.master', $config_dir.'/'.$jk_init); - } else { - copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init); - } - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_chrootsh.'.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh); - } else { - copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh); - } + + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_init.'.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_init.'.master', $config_dir.'/'.$jk_init); + } else { + copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init); + } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_chrootsh.'.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh); + } else { + copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh); + } } //* help jailkit fo find its ini files @@ -583,13 +585,13 @@ class installer_base { $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); if(is_array($domainAll)) { - foreach($domainAll as $domain) - { - if ($domainAll[0]['domain'] == $domain['domain']) - $virtual_domains .= "'".$domain['domain']."'"; - else - $virtual_domains .= ", '".$domain['domain']."'"; - } + foreach($domainAll as $domain) + { + if ($domainAll[0]['domain'] == $domain['domain']) + $virtual_domains .= "'".$domain['domain']."'"; + else + $virtual_domains .= ", '".$domain['domain']."'"; + } } } else @@ -599,31 +601,31 @@ class installer_base { if(!isset($old_options['DEFAULT_SERVER_LANGUAGE'])) $old_options['DEFAULT_SERVER_LANGUAGE'] = ''; $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); $content = str_replace('{virtual_domains}', $virtual_domains, $content); - + wf($full_file_name, $content); - + //* Write virtual_to_transport.sh script $config_dir = $conf['mailman']['config_dir'].'/'; $full_file_name = $config_dir.'virtual_to_transport.sh'; - + //* Backup exiting virtual_to_transport.sh script if(is_file($full_file_name)) { copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); } - + if(is_dir('/etc/mailman')) { if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); - } else { - copy('tpl/mailman-virtual_to_transport.sh',$full_file_name); - } - chgrp($full_file_name,'list'); - chmod($full_file_name,0750); - } - + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); + } else { + copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); + } + chgrp($full_file_name, 'list'); + chmod($full_file_name, 0750); + } + //* Create aliasaes exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); - + } public function configure_postfix($options = '') { @@ -667,18 +669,18 @@ class installer_base { //* postfix-dkim $full_file_name=$config_dir.'/tag_as_originating.re'; - if(is_file($full_file_name)) copy($full_file_name, $config_dir.$configfile.'~'); - wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10026'); + if(is_file($full_file_name)) copy($full_file_name, $config_dir.$configfile.'~'); + wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026'); $full_file_name=$config_dir.'/tag_as_foreign.re'; - if(is_file($full_file_name)) copy($full_file_name, $config_dir.$configfile.'~'); - wf($full_file_name,'/^/ FILTER amavis:[127.0.0.1]:10024'); + if(is_file($full_file_name)) copy($full_file_name, $config_dir.$configfile.'~'); + wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024'); //* 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'); + __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'); + __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']; @@ -695,31 +697,31 @@ class installer_base { //* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update $rbl_list = ''; if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') { - $rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); + $rbl_hosts = explode(",", str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); foreach ($rbl_hosts as $key => $value) { $rbl_list .= ", reject_rbl_client ". $value; } } unset($rbl_hosts); unset($server_ini_array); - - $postconf_placeholders = array('{config_dir}' => $config_dir, - '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], - '{vmail_userid}' => $cf['vmail_userid'], - '{vmail_groupid}' => $cf['vmail_groupid'], - '{rbl_list}' => $rbl_list); - - $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_postfix.conf.master', 'tpl/debian_postfix.conf.master'); - $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); - $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines + + $postconf_placeholders = array('{config_dir}' => $config_dir, + '{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], + '{vmail_userid}' => $cf['vmail_userid'], + '{vmail_groupid}' => $cf['vmail_groupid'], + '{rbl_list}' => $rbl_list); + + $postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_postfix.conf.master', 'tpl/debian_postfix.conf.master'); + $postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); + $postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines //* These postconf commands will be executed on installation only if($this->is_update == false) { - $postconf_commands = array_merge($postconf_commands,array( - 'myhostname = '.$conf['hostname'], - 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', - 'mynetworks = 127.0.0.0/8 [::1]/128' - )); + $postconf_commands = array_merge($postconf_commands, array( + 'myhostname = '.$conf['hostname'], + 'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', + 'mynetworks = 127.0.0.0/8 [::1]/128' + )); } //* Create the header and body check files @@ -746,10 +748,10 @@ class installer_base { caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); } - if(!stristr($options,'dont-create-certs')) { + if(!stristr($options, 'dont-create-certs')) { //* Create the SSL certificate $command = 'cd '.$config_dir.'; ' - .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:4096 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509'; + .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:4096 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509'; exec($command); $command = 'chmod o= '.$config_dir.'/smtpd.key'; @@ -770,8 +772,8 @@ class installer_base { $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); + '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 @@ -802,8 +804,8 @@ class installer_base { global $conf; //* Get saslsauthd version - exec('saslauthd -v 2>&1',$out); - $parts = explode(' ',$out[0]); + exec('saslauthd -v 2>&1', $out); + $parts = explode(' ', $out[0]); $saslversion = $parts[1]; unset($parts); unset($out); @@ -816,14 +818,14 @@ class installer_base { $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')) 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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', '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); + $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 @@ -833,21 +835,21 @@ class installer_base { // Edit the file /etc/default/saslauthd $configfile = $conf['saslauthd']['config']; - if(is_file($configfile)) copy($configfile,$configfile.'~'); + 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); + $content = str_replace('START=no', 'START=yes', $content); // Debian - $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content); + $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); + $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); + $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'); @@ -887,10 +889,10 @@ class installer_base { } chmod($config_dir.'/'.$configfile.'~', 0400); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', '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_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); @@ -924,9 +926,9 @@ class installer_base { } $content = rf($conf['postfix']['config_dir'].'/master.cf'); // Only add the content if we had not addded it before - if(!stristr($content,'dovecot/deliver')) { + if(!stristr($content, 'dovecot/deliver')) { $deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DROhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'; - af($conf['postfix']['config_dir'].'/master.cf',$deliver_content); + af($conf['postfix']['config_dir'].'/master.cf', $deliver_content); } unset($content); unset($deliver_content); @@ -935,14 +937,14 @@ class installer_base { //* 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' + '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'); + copy($conf['postfix']['config_dir'].'/main.cf', $conf['postfix']['config_dir'].'/main.cf~3'); // Executing the postconf commands foreach($postconf_commands as $cmd) { @@ -957,25 +959,25 @@ class installer_base { } //* Get the dovecot version - exec('dovecot --version',$tmp); - $parts = explode('.',trim($tmp[0])); + exec('dovecot --version', $tmp); + $parts = explode('.', trim($tmp[0])); $dovecot_version = $parts[0]; unset($tmp); unset($parts); //* Copy dovecot configuration file if($dovecot_version == 2) { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot2.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot2.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/debian_dovecot2.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot2.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot2.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/debian_dovecot2.conf.master', $config_dir.'/'.$configfile); + } } else { - if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot.conf.master')) { - copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot.conf.master', $config_dir.'/'.$configfile); - } else { - copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile); - } + if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot.conf.master')) { + copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot.conf.master', $config_dir.'/'.$configfile); + } else { + copy('tpl/debian_dovecot.conf.master', $config_dir.'/'.$configfile); + } } //* dovecot-sql.conf @@ -985,10 +987,10 @@ class installer_base { } if(is_file($config_dir.'/'.$configfile.'~')) chmod($config_dir.'/'.$configfile.'~', 0400); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/debian_dovecot-sql.conf.master', '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); + $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); @@ -1002,15 +1004,15 @@ class installer_base { // 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')) 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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', '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); + $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 @@ -1026,7 +1028,7 @@ class installer_base { } // Make a backup copy of the main.cf file - copy($conf['postfix']['config_dir'].'/main.cf',$conf['postfix']['config_dir'].'/main.cf~2'); + copy($conf['postfix']['config_dir'].'/main.cf', $conf['postfix']['config_dir'].'/main.cf~2'); // Executing the postconf commands foreach($postconf_commands as $cmd) { @@ -1035,13 +1037,13 @@ class installer_base { } // 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~'); + 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')) { + if(!stristr($content, '127.0.0.1:10025')) { unset($content); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master'); - af($conf['postfix']['config_dir'].'/master.cf',$content); + af($conf['postfix']['config_dir'].'/master.cf', $content); } unset($content); @@ -1049,17 +1051,17 @@ class installer_base { exec('adduser clamav amavis'); // Create the director for DKIM-Keys - mkdir("/var/lib/amavis/dkim",0750); + mkdir("/var/lib/amavis/dkim", 0750); // get shell-user for amavis $amavis_user=exec('grep -o "^amavis:\|^vscan:" /etc/passwd'); if(!empty($amavis_user)) { - $amavis_user=rtrim($amavis_user,":"); + $amavis_user=rtrim($amavis_user, ":"); exec('chown '.$amavis_user.'/var/lib/amavis/dkim'); } // get shell-group for amavis $amavis_group=exec('grep -o "^amavis:\|^vscan:" /etc/group'); if(!empty($amavis_group)) { - $amavis_group=rtrim($amavis_group,":"); + $amavis_group=rtrim($amavis_group, ":"); exec('chgrp '.$amavis_group.'/var/lib/amavis/dkim'); } } @@ -1125,12 +1127,12 @@ class installer_base { 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); + 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); + replaceLine('/etc/inetd.conf', '/usr/sbin/pure-ftpd-wrapper', '#ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/pure-ftpd-wrapper', 0, 0); exec($this->getinitcommand('openbsd-inetd', 'restart')); //if(is_file($conf['init_scripts'].'/'.'openbsd-inetd')) exec($conf['init_scripts'].'/'.'openbsd-inetd restart'); } @@ -1143,15 +1145,15 @@ class installer_base { // 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)) 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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', '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); + $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'); @@ -1178,22 +1180,22 @@ class installer_base { //* 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'); + __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'); + __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)) 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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', '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); + $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'); @@ -1204,19 +1206,19 @@ class installer_base { 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 .= '/'; + //* 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); + $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']); + //* Chown the slave subdirectory to $conf['bind']['bind_user'] + chown($content, $conf['bind']['bind_user']); + chgrp($content, $conf['bind']['bind_group']); } @@ -1230,19 +1232,19 @@ class installer_base { 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', '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); + 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','','',1,0); + replaceLine('/etc/apache2/sites-available/000-default', 'NameVirtualHost *', 'NameVirtualHost *:80', 1, 0); + replaceLine('/etc/apache2/sites-available/000-default', '', '', 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); + replaceLine('/etc/apache2/ports.conf', 'Listen 443', 'Listen 443', 1); } @@ -1262,7 +1264,7 @@ class installer_base { } else { $ip_address = $rec['ip_address']; } - $ports = explode(',',$rec['virtualhost_port']); + $ports = explode(',', $rec['virtualhost_port']); if(is_array($ports)) { foreach($ports as $port) { $port = intval($port); @@ -1275,29 +1277,29 @@ class installer_base { } $content .= "\n"; - wf($vhost_conf_dir.'/ispconfig.conf',$content); + 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'); + 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'); + 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); + 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); + 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'; @@ -1315,20 +1317,20 @@ class installer_base { //* 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'); + 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); + 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); + 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'; @@ -1366,8 +1368,8 @@ class installer_base { } public function configure_fail2ban() { - // To Do - } + // To Do + } public function configure_squid() { @@ -1377,13 +1379,13 @@ class installer_base { $server_name = $row["server_name"]; $configfile = 'squid.conf'; - if(is_file($conf["squid"]["config_dir"].'/'.$configfile)) copy($conf["squid"]["config_dir"].'/'.$configfile,$conf["squid"]["config_dir"].'/'.$configfile.'~'); + if(is_file($conf["squid"]["config_dir"].'/'.$configfile)) copy($conf["squid"]["config_dir"].'/'.$configfile, $conf["squid"]["config_dir"].'/'.$configfile.'~'); if(is_file($conf["squid"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["squid"]["config_dir"].'/'.$configfile.'~'); $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master"); - $content = str_replace('{server_name}',$server_name,$content); - $content = str_replace('{ip_address}',$ip_address, $content); - $content = str_replace('{config_dir}',$conf['squid']['config_dir'], $content); - wf($conf["squid"]["config_dir"].'/'.$configfile,$content); + $content = str_replace('{server_name}', $server_name, $content); + $content = str_replace('{ip_address}', $ip_address, $content); + $content = str_replace('{config_dir}', $conf['squid']['config_dir'], $content); + wf($conf["squid"]["config_dir"].'/'.$configfile, $content); exec('chmod 600 '.$conf["squid"]["config_dir"].'/'.$configfile); exec('chown root:root '.$conf["squid"]["config_dir"].'/'.$configfile); } @@ -1391,9 +1393,9 @@ class installer_base { public function configure_ufw_firewall() { $configfile = 'ufw.conf'; - if(is_file('/etc/ufw/ufw.conf')) copy('/etc/ufw/ufw.conf','/etc/ufw/ufw.conf~'); + if(is_file('/etc/ufw/ufw.conf')) copy('/etc/ufw/ufw.conf', '/etc/ufw/ufw.conf~'); $content = rf("tpl/".$configfile.".master"); - wf('/etc/ufw/ufw.conf',$content); + wf('/etc/ufw/ufw.conf', $content); exec('chmod 600 /etc/ufw/ufw.conf'); exec('chown root:root /etc/ufw/ufw.conf'); } @@ -1408,10 +1410,10 @@ class installer_base { @mkdir('/etc/Bastille', 0700); if(is_dir('/etc/Bastille.backup/firewall.d')) caselog('cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/', __FILE__, __LINE__); if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master')) { - caselog('cp -f ' . $conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__); - } else { - caselog('cp -f tpl/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__); - } + caselog('cp -f ' . $conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg', __FILE__, __LINE__); + } else { + 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); @@ -1422,8 +1424,8 @@ class installer_base { $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'])); + $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'; @@ -1467,21 +1469,21 @@ class installer_base { //** 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)) 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 = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', '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); + $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']['ip'],$content); + $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['vlogger']['config_dir'].'/'.$configfile,$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'); @@ -1543,7 +1545,7 @@ class installer_base { //* and create the symlink 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'); + 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')) { @@ -1556,7 +1558,7 @@ class installer_base { 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'); - } + } } if($conf['nginx']['installed'] == true){ $apps_vhost_user = escapeshellcmd($conf['web']['apps_vhost_user']); @@ -1596,7 +1598,7 @@ class installer_base { } $socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']); - if(substr($socket_dir,-1) != '/') $socket_dir .= '/'; + if(substr($socket_dir, -1) != '/') $socket_dir .= '/'; if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir); $fpm_socket = $socket_dir.'apps.sock'; $cgi_socket = escapeshellcmd($conf['nginx']['cgi_socket']); @@ -1608,7 +1610,7 @@ class installer_base { //$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content); $content = str_replace('{fpm_socket}', $fpm_socket, $content); $content = str_replace('{cgi_socket}', $cgi_socket, $content); - + if(file_exists('/var/run/php5-fpm.sock')){ $use_tcp = '#'; $use_socket = ''; @@ -1635,7 +1637,7 @@ class installer_base { //* and create the symlink 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'); + symlink($vhost_conf_dir.'/apps.vhost', $vhost_conf_enabled_dir.'/000-apps.vhost'); } } @@ -1652,13 +1654,13 @@ class installer_base { if(!@is_dir($install_dir.'/interface/ssl')) mkdir($install_dir.'/interface/ssl', 0755, true); - $ssl_pw = substr(md5(mt_rand()),0,6); + $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); + rename($ssl_key_file, $ssl_key_file.'.secure'); + rename($ssl_key_file.'.insecure', $ssl_key_file); } @@ -1700,7 +1702,7 @@ class installer_base { } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', '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_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); @@ -1756,9 +1758,9 @@ class installer_base { 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); + 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)) { @@ -1785,11 +1787,11 @@ class installer_base { while (($file = readdir($dh)) !== false) { if($conf['apache']['installed'] == true && $file == 'nginx_plugin.inc.php') continue; if($conf['nginx']['installed'] == true && $file == 'apache2_plugin.inc.php') continue; - if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') { - include_once($install_dir.'/server/plugins-available/'.$file); - $plugin_name = substr($file,0,-8); + 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(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); @@ -1844,14 +1846,14 @@ class installer_base { //* Make all interface language file directories group writable $handle = @opendir($install_dir.'/interface/web'); - while ($file = @readdir ($handle)) { + 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)) { + 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); + chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file, 0770); } } } @@ -1866,7 +1868,7 @@ class installer_base { chmod($install_dir.'/server/lib/config.inc.php', 0600); chown($install_dir.'/server/lib/config.inc.php', 'root'); chgrp($install_dir.'/server/lib/config.inc.php', 'root'); - + //* Make sure thet the interface config file is readable by user ispconfig only chmod($install_dir.'/interface/lib/config.inc.php', 0600); chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); @@ -1945,18 +1947,18 @@ class installer_base { if($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'); + 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')) { - $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); - $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); - $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); - @mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true); - wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); - 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'); + $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); + $content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); + $content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); + @mkdir('/var/www/php-fcgi-scripts/ispconfig', 0755, true); + wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); + 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'); //} } @@ -1980,7 +1982,7 @@ class installer_base { } $socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']); - if(substr($socket_dir,-1) != '/') $socket_dir .= '/'; + if(substr($socket_dir, -1) != '/') $socket_dir .= '/'; if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir); $fpm_socket = $socket_dir.'ispconfig.sock'; @@ -2006,7 +2008,7 @@ class installer_base { if($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'); + symlink($vhost_conf_dir.'/ispconfig.vhost', $vhost_conf_enabled_dir.'/000-ispconfig.vhost'); } } } @@ -2019,8 +2021,8 @@ class installer_base { 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'); + 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'); @@ -2044,7 +2046,7 @@ class installer_base { exec('chmod 660 '. $conf['ispconfig_log_dir'].'/auth.log'); if(is_user('getmail')) { - rename($install_dir.'/server/scripts/run-getmail.sh','/usr/local/bin/run-getmail.sh'); + 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); } @@ -2072,11 +2074,11 @@ class installer_base { fclose($fh); */ } - + //* Remove Domain module as its functions are available in the client module now if(@is_dir('/usr/local/ispconfig/interface/web/domain')) exec('rm -rf /usr/local/ispconfig/interface/web/domain'); - - + + } public function configure_dbserver() { @@ -2094,10 +2096,10 @@ class installer_base { } $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mysql_clientdb.conf.master', 'tpl/mysql_clientdb.conf.master'); - $content = str_replace('{hostname}',$conf['mysql']['host'],$content); - $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); + $content = str_replace('{hostname}', $conf['mysql']['host'], $content); + $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'); @@ -2115,12 +2117,12 @@ class installer_base { // 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]); + if(stristr($val, $install_dir)) unset($existing_root_cron_jobs[$key]); } $root_cron_jobs = array( - "* * * * * ".$install_dir."/server/server.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done", - "30 00 * * * ".$install_dir."/server/cron_daily.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done" + "* * * * * ".$install_dir."/server/server.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done", + "30 00 * * * ".$install_dir."/server/cron_daily.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done" ); if ($conf['nginx']['installed'] == true) { @@ -2143,12 +2145,12 @@ class installer_base { $existing_cron_jobs = file('crontab.txt'); $cron_jobs = array( - '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null' + '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /dev/null' ); // 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]); + if(stristr($val, 'getmail')) unset($existing_cron_jobs[$key]); } foreach($cron_jobs as $cron_job) { @@ -2165,7 +2167,7 @@ class installer_base { chmod($conf['ispconfig_log_dir'].'/cron.log', 0660); } - + public function getinitcommand($servicename, $action, $init_script_directory = ''){ global $conf; // systemd @@ -2202,17 +2204,17 @@ class installer_base { global $conf, $dist; $final_path = ''; - $dist_template = $conf['ispconfig_install_dir'] . '/server/conf-custom/install/' . $tLocal . '.master'; - if (file_exists($dist_template)) { + $dist_template = $conf['ispconfig_install_dir'] . '/server/conf-custom/install/' . $tLocal . '.master'; + if (file_exists($dist_template)) { $final_path = $dist_template; } else { - $dist_template = 'dist/tpl/'.strtolower($dist['name'])."/$tLocal.master"; - if (file_exists($dist_template)) { - $final_path = $dist_template; - } else { - $final_path = "tpl/$tLocal.master"; - } - } + $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; @@ -2250,21 +2252,21 @@ class installer_base { 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; + 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; } } @@ -2293,11 +2295,12 @@ class installer_base { $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); + $tContents = str_replace('{mysql_server_host}', $conf['mysql']['host'], $tContents); + $tContents = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $tContents); return $tContents; } + } ?> diff --git a/install/lib/mysql.lib.php b/install/lib/mysql.lib.php index b7f1ae872..c5c2a83a6 100644 --- a/install/lib/mysql.lib.php +++ b/install/lib/mysql.lib.php @@ -30,25 +30,25 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class db { - var $dbHost = ""; // hostname of the MySQL server - var $dbName = ""; // logical database name on that server - var $dbUser = ""; // database authorized user - var $dbPass = ""; // user's password + var $dbHost = ""; // hostname of the MySQL server + var $dbName = ""; // logical database name on that server + var $dbUser = ""; // database authorized user + var $dbPass = ""; // user's password var $dbCharset = ""; // what charset comes and goes to mysql: utf8 / latin1 - var $linkId = false; // last result of mysql_connect() - var $queryId = 0; // last result of mysql_query() - var $record = array(); // last record fetched - var $autoCommit = 1; // Autocommit Transactions - var $currentRow; // current row number - var $errorNumber = 0; // last error number - var $errorMessage = ""; // last error message + var $linkId = false; // last result of mysql_connect() + var $queryId = 0; // last result of mysql_query() + var $record = array(); // last record fetched + var $autoCommit = 1; // Autocommit Transactions + var $currentRow; // current row number + var $errorNumber = 0; // last error number + var $errorMessage = ""; // last error message var $errorLocation = ""; // last error location var $show_error_messages = false; // constructor function db() { - + global $conf; $this->dbHost = $conf["mysql"]["host"]; //$this->dbName = $conf["mysql"]["database"]; @@ -66,7 +66,7 @@ class db $this->errorLocation = $location; if($this->errorNumber && $this->show_error_messages) { - echo('
'.$this->errorLocation.'
'.$this->errorMessage); + echo '
'.$this->errorLocation.'
'.$this->errorMessage; flush(); } } @@ -138,7 +138,7 @@ class db // returns the next record in an array function nextRecord() { - $this->record = mysqli_fetch_assoc($this->queryId); + $this->record = mysqli_fetch_assoc($this->queryId); $this->updateError('DB::nextRecord()
mysqli_fetch_array'); if(!$this->record || !is_array($this->record)) { @@ -153,37 +153,37 @@ class db { return mysqli_num_rows($this->queryId); } - + function affectedRows() { return mysqli_affected_rows($this->linkId); } - + // returns mySQL insert id function insertID() { return mysqli_insert_id($this->linkId); } - - // Check der variablen + + // Check der variablen // deprecated, now use quote - function check($formfield) - { - return $this->quote($formfield); - } - + function check($formfield) + { + return $this->quote($formfield); + } + // Check der variablen - function quote($formfield) - { - return mysqli_real_escape_string($this->linkId, $formfield); - } - + function quote($formfield) + { + return mysqli_real_escape_string($this->linkId, $formfield); + } + // Check der variablen - function unquote($formfield) - { - return stripslashes($formfield); - } - + function unquote($formfield) + { + return stripslashes($formfield); + } + function toLower($record) { if(is_array($record)) { foreach($record as $key => $val) { @@ -191,64 +191,64 @@ class db $out[$key] = $val; } } - return $out; + return $out; } - - - function insert($tablename,$form,$debug = 0) - { - if(is_array($form)){ - foreach($form as $key => $value) - { - $sql_key .= "$key, "; - $sql_value .= "'".$this->check($value)."', "; - } - $sql_key = substr($sql_key,0,strlen($sql_key) - 2); - $sql_value = substr($sql_value,0,strlen($sql_value) - 2); - - $sql = "INSERT INTO $tablename (" . $sql_key . ") VALUES (" . $sql_value .")"; - - if($debug == 1) echo "SQL-Statement: ".$sql."

"; - $this->query($sql); - if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; - } - } - - function update($tablename,$form,$bedingung,$debug = 0) - { - - if(is_array($form)){ - foreach($form as $key => $value) - { - $insql .= "$key = '".$this->check($value)."', "; - } - $insql = substr($insql,0,strlen($insql) - 2); - $sql = "UPDATE $tablename SET " . $insql . " WHERE $bedingung"; - if($debug == 1) echo "SQL-Statement: ".$sql."

"; - $this->query($sql); - if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; - } - } - - function closeConn() { - - } - - function freeResult() { - - - } - - function delete() { - - } - - function Transaction($action) { - //action = begin, commit oder rollback - - } - - /* + + + function insert($tablename, $form, $debug = 0) + { + if(is_array($form)){ + foreach($form as $key => $value) + { + $sql_key .= "$key, "; + $sql_value .= "'".$this->check($value)."', "; + } + $sql_key = substr($sql_key, 0, strlen($sql_key) - 2); + $sql_value = substr($sql_value, 0, strlen($sql_value) - 2); + + $sql = "INSERT INTO $tablename (" . $sql_key . ") VALUES (" . $sql_value .")"; + + if($debug == 1) echo "SQL-Statement: ".$sql."

"; + $this->query($sql); + if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; + } + } + + function update($tablename, $form, $bedingung, $debug = 0) + { + + if(is_array($form)){ + foreach($form as $key => $value) + { + $insql .= "$key = '".$this->check($value)."', "; + } + $insql = substr($insql, 0, strlen($insql) - 2); + $sql = "UPDATE $tablename SET " . $insql . " WHERE $bedingung"; + if($debug == 1) echo "SQL-Statement: ".$sql."

"; + $this->query($sql); + if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; + } + } + + function closeConn() { + + } + + function freeResult() { + + + } + + function delete() { + + } + + function Transaction($action) { + //action = begin, commit oder rollback + + } + + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -258,49 +258,49 @@ class db notNull => true | false autoInc => true | false option => unique | primary | index) - - + + */ - - function createTable($table_name,$columns) { - $index = ""; - $sql = "CREATE TABLE $table_name ("; - foreach($columns as $col){ - $sql .= $col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." "; - - if($col["defaultValue"] != "") { - if($col["defaultValue"] == "NULL" or $col["defaultValue"] == "NOT NULL") { - $sql .= "DEFAULT ".$col["defaultValue"]." "; - } else { - $sql .= "DEFAULT '".$col["defaultValue"]."' "; + + function createTable($table_name, $columns) { + $index = ""; + $sql = "CREATE TABLE $table_name ("; + foreach($columns as $col){ + $sql .= $col["name"]." ".$this->mapType($col["type"], $col["typeValue"])." "; + + if($col["defaultValue"] != "") { + if($col["defaultValue"] == "NULL" or $col["defaultValue"] == "NOT NULL") { + $sql .= "DEFAULT ".$col["defaultValue"]." "; + } else { + $sql .= "DEFAULT '".$col["defaultValue"]."' "; + } + + } elseif($col["defaultValue"] != false) { + $sql .= "DEFAULT '' "; } - - } elseif($col["defaultValue"] != false) { - $sql .= "DEFAULT '' "; - } - if($col["defaultValue"] != "NULL" && $col["defaultValue"] != "NOT NULL") { - if($col["notNull"] == true) { - $sql .= "NOT NULL "; - } else { - $sql .= "NULL "; - } + if($col["defaultValue"] != "NULL" && $col["defaultValue"] != "NOT NULL") { + if($col["notNull"] == true) { + $sql .= "NOT NULL "; + } else { + $sql .= "NULL "; + } + } + if($col["autoInc"] == true) $sql .= "auto_increment "; + $sql.= ","; + // key Definitionen + if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; + if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; + if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; } - if($col["autoInc"] == true) $sql .= "auto_increment "; - $sql.= ","; - // key Definitionen - if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; - if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; - if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; - } - $sql .= $index; - $sql = substr($sql,0,-1); - $sql .= ")"; - - $this->query($sql); - return true; - } - - /* + $sql .= $index; + $sql = substr($sql, 0, -1); + $sql .= ")"; + + $this->query($sql); + return true; + } + + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -310,56 +310,56 @@ class db notNull => true | false autoInc => true | false option => unique | primary | index) - - + + */ - function alterTable($table_name,$columns) { - $index = ""; - $sql = "ALTER TABLE $table_name "; - foreach($columns as $col){ - if($col["action"] == 'add') { - $sql .= "ADD ".$col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." "; - } elseif ($col["action"] == 'alter') { - $sql .= "CHANGE ".$col["name"]." ".$col["name_new"]." ".$this->mapType($col["type"],$col["typeValue"])." "; - } elseif ($col["action"] == 'drop') { - $sql .= "DROP ".$col["name"]." "; - } - if($col["action"] != 'drop') { - if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' "; - if($col["notNull"] == true) { - $sql .= "NOT NULL "; - } else { - $sql .= "NULL "; - } - if($col["autoInc"] == true) $sql .= "auto_increment "; - $sql.= ","; - // key Definitionen - if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; - if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; - if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; - } - } - $sql .= $index; - $sql = substr($sql,0,-1); - - //die($sql); - $this->query($sql); - return true; - } - - function dropTable($table_name) { - $this->check($table_name); - $sql = "DROP TABLE '". $table_name."'"; - return $this->query($sql); - } - - // gibt Array mit Tabellennamen zur�ck - function getTables($database_name = '') { - + function alterTable($table_name, $columns) { + $index = ""; + $sql = "ALTER TABLE $table_name "; + foreach($columns as $col){ + if($col["action"] == 'add') { + $sql .= "ADD ".$col["name"]." ".$this->mapType($col["type"], $col["typeValue"])." "; + } elseif ($col["action"] == 'alter') { + $sql .= "CHANGE ".$col["name"]." ".$col["name_new"]." ".$this->mapType($col["type"], $col["typeValue"])." "; + } elseif ($col["action"] == 'drop') { + $sql .= "DROP ".$col["name"]." "; + } + if($col["action"] != 'drop') { + if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' "; + if($col["notNull"] == true) { + $sql .= "NOT NULL "; + } else { + $sql .= "NULL "; + } + if($col["autoInc"] == true) $sql .= "auto_increment "; + $sql.= ","; + // key Definitionen + if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; + if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; + if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; + } + } + $sql .= $index; + $sql = substr($sql, 0, -1); + + //die($sql); + $this->query($sql); + return true; + } + + function dropTable($table_name) { + $this->check($table_name); + $sql = "DROP TABLE '". $table_name."'"; + return $this->query($sql); + } + + // gibt Array mit Tabellennamen zur�ck + function getTables($database_name = '') { + if($database_name == ''){ - $database_name = $this->dbName; - } - + $database_name = $this->dbName; + } + $tables = $this->queryAllRecords("SHOW TABLES FROM `$database_name`"); $tb_names = array(); if(is_array($tables) && !empty($tables)){ @@ -367,7 +367,7 @@ class db $tb_names[$i] = $tables[$i]['Tables_in_'.$database_name]; } } - + /* $result = mysqli_query("SHOW TABLES FROM `$database_name`"); $tb_names = array(); @@ -375,11 +375,11 @@ class db $tb_names[$i] = mysql_tablename($result, $i); } */ - return $tb_names; - } - - // gibt Feldinformationen zur Tabelle zur�ck - /* + return $tb_names; + } + + // gibt Feldinformationen zur Tabelle zur�ck + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -389,101 +389,101 @@ class db notNull => true | false autoInc => true | false option => unique | primary | index) - - + + */ - - function tableInfo($table_name) { - - global $go_api,$go_info; - // Tabellenfelder einlesen - - if($rows = $go_api->db->queryAllRecords("SHOW FIELDS FROM ".$table_name)){ - foreach($rows as $row) { - $name = $row[0]; - $default = $row[4]; - $key = $row[3]; - $extra = $row[5]; - $isnull = $row[2]; - $type = $row[1]; - - - $column = array(); - - $column["name"] = $name; - //$column["type"] = $type; - $column["defaultValue"] = $default; - if(stristr($key,"PRI")) $column["option"] = "primary"; - if(stristr($isnull,"YES")) { - $column["notNull"] = false; - } else { - $column["notNull"] = true; - } - if($extra == 'auto_increment') $column["autoInc"] = true; - - - // Type in Metatype umsetzen - - if(stristr($type,"int(")) $metaType = 'int32'; - if(stristr($type,"bigint")) $metaType = 'int64'; - if(stristr($type,"char")) { - $metaType = 'char'; - $tmp_typeValue = explode('(',$type); - $column["typeValue"] = substr($tmp_typeValue[1],0,-1); - } - if(stristr($type,"varchar")) { - $metaType = 'varchar'; - $tmp_typeValue = explode('(',$type); - $column["typeValue"] = substr($tmp_typeValue[1],0,-1); - } - if(stristr($type,"text")) $metaType = 'text'; - if(stristr($type,"double")) $metaType = 'double'; - if(stristr($type,"blob")) $metaType = 'blob'; - - - $column["type"] = $metaType; - - $columns[] = $column; - } - return $columns; - } else { - return false; - } - - } - - function mapType($metaType,$typeValue) { - global $go_api; - $metaType = strtolower($metaType); - switch ($metaType) { - case 'int16': - return 'smallint'; - break; - case 'int32': - return 'int'; - break; - case 'int64': - return 'bigint'; - break; - case 'double': - return 'double'; - break; - case 'char': - return 'char'; - break; - case 'varchar': - if($typeValue < 1) die("Datenbank Fehler: F�r diesen Datentyp ist eine L�ngenangabe notwendig."); - return 'varchar('.$typeValue.')'; - break; - case 'text': - return 'text'; - break; - case 'blob': - return 'blob'; - break; - } - } - + + function tableInfo($table_name) { + + global $go_api, $go_info; + // Tabellenfelder einlesen + + if($rows = $go_api->db->queryAllRecords("SHOW FIELDS FROM ".$table_name)){ + foreach($rows as $row) { + $name = $row[0]; + $default = $row[4]; + $key = $row[3]; + $extra = $row[5]; + $isnull = $row[2]; + $type = $row[1]; + + + $column = array(); + + $column["name"] = $name; + //$column["type"] = $type; + $column["defaultValue"] = $default; + if(stristr($key, "PRI")) $column["option"] = "primary"; + if(stristr($isnull, "YES")) { + $column["notNull"] = false; + } else { + $column["notNull"] = true; + } + if($extra == 'auto_increment') $column["autoInc"] = true; + + + // Type in Metatype umsetzen + + if(stristr($type, "int(")) $metaType = 'int32'; + if(stristr($type, "bigint")) $metaType = 'int64'; + if(stristr($type, "char")) { + $metaType = 'char'; + $tmp_typeValue = explode('(', $type); + $column["typeValue"] = substr($tmp_typeValue[1], 0, -1); + } + if(stristr($type, "varchar")) { + $metaType = 'varchar'; + $tmp_typeValue = explode('(', $type); + $column["typeValue"] = substr($tmp_typeValue[1], 0, -1); + } + if(stristr($type, "text")) $metaType = 'text'; + if(stristr($type, "double")) $metaType = 'double'; + if(stristr($type, "blob")) $metaType = 'blob'; + + + $column["type"] = $metaType; + + $columns[] = $column; + } + return $columns; + } else { + return false; + } + + } + + function mapType($metaType, $typeValue) { + global $go_api; + $metaType = strtolower($metaType); + switch ($metaType) { + case 'int16': + return 'smallint'; + break; + case 'int32': + return 'int'; + break; + case 'int64': + return 'bigint'; + break; + case 'double': + return 'double'; + break; + case 'char': + return 'char'; + break; + case 'varchar': + if($typeValue < 1) die("Datenbank Fehler: F�r diesen Datentyp ist eine L�ngenangabe notwendig."); + return 'varchar('.$typeValue.')'; + break; + case 'text': + return 'text'; + break; + case 'blob': + return 'blob'; + break; + } + } + } ?> diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php index b4e73abb1..bc0453f7f 100644 --- a/install/lib/update.lib.php +++ b/install/lib/update.lib.php @@ -29,10 +29,12 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //* Installer patch stub class class installer_patch_update { - protected function onBeforeSQL() { - } - protected function onAfterSQL() { - } + protected function onBeforeSQL() { + } + + protected function onAfterSQL() { + } + } //* DB dump function @@ -70,25 +72,25 @@ function prepareDBDump() { } else { $backup_db_name = '/root/ispconfig_db_backup_'.@date('Y-m-d_H-i').'.sql'; } - copy('existing_db.sql',$backup_db_name); + copy('existing_db.sql', $backup_db_name); chmod($backup_db_name, 0700); chown($backup_db_name, 'root'); chgrp($backup_db_name, 'root'); if ($conf['powerdns']['installed']) { //** export the current PowerDNS database data - if( !empty($conf["mysql"]["admin_password"]) ) { - system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']); - } else { - system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']); - } + if( !empty($conf["mysql"]["admin_password"]) ) { + system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']); + } else { + system("mysqldump -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -c -t --add-drop-table --create-options --quick --result-file=existing_powerdns_db.sql ".$conf['powerdns']['database']); + } // create a backup copy of the PowerDNS database in the root folder $backup_db_name = '/root/ispconfig_powerdns_db_backup_'.@date('Y-m-d_h-i').'.sql'; - copy('existing_powerdns_db.sql',$backup_db_name); + copy('existing_powerdns_db.sql', $backup_db_name); chmod($backup_db_name, 0700); - chown($backup_db_name, 'root'); - chgrp($backup_db_name, 'root'); + chown($backup_db_name, 'root'); + chgrp($backup_db_name, 'root'); } } @@ -115,7 +117,7 @@ function checkDbHealth() { sread(); } else - echo "OK\n"; + echo "OK\n"; } function updateDbAndIni() { @@ -136,9 +138,9 @@ function updateDbAndIni() { $conf['services']['vserver'] = ($tmp['vserver_server'] == 1)?true:false; $conf['services']['proxy'] = (isset($tmp['proxy_server']) && $tmp['proxy_server'] == 1)?true:false; $conf['services']['firewall'] = (isset($tmp['firewall_server']) && $tmp['firewall_server'] == 1)?true:false; - + $conf['postfix']['vmail_mailbox_base'] = $ini_array['mail']['homedir_path']; - + if(isset($ini_array['web']['server_type']) && $ini_array['web']['server_type'] != ''){ $conf['webserver']['server_type'] = $ini_array['web']['server_type']; if($conf['webserver']['server_type'] == 'nginx'){ @@ -150,38 +152,38 @@ function updateDbAndIni() { $conf['webserver']['server_type'] = 'apache'; $conf['nginx']['installed'] = false; } - + //* Do incremental DB updates only on installed ISPConfig versions > 3.0.3 - if(compare_ispconfig_version('3.0.3',ISPC_APP_VERSION) >= 0) { - + if(compare_ispconfig_version('3.0.3', ISPC_APP_VERSION) >= 0) { + swriteln($inst->lng('Starting incremental database update.')); - - //* get the version of the db schema from the server table + + //* get the version of the db schema from the server table $found = true; while($found == true) { $next_db_version = intval($current_db_version + 1); $sql_patch_filename = realpath(dirname(__FILE__).'/../').'/sql/incremental/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.sql'; $php_patch_filename = realpath(dirname(__FILE__).'/../').'/patches/upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT).'.php'; - + if(is_file($sql_patch_filename)) { - + //* Load php patch file and instantiate object if(is_file($php_patch_filename)) { $php_patch_class_name = 'upd_'.str_pad($next_db_version, 4, '0', STR_PAD_LEFT); - include_once($php_patch_filename); + include_once $php_patch_filename; if(class_exists($php_patch_class_name)) { $php_patch = new $php_patch_class_name; } else { swriteln($inst->lng('WARNING: PHP patch file').': '.$php_patch_filename.' '.$inst->lng('contains errors.')); } } - + //* Exec onBeforeSQL function if(isset($php_patch) && is_object($php_patch)) { $php_patch->onBeforeSQL(); swriteln($inst->lng('Executing PHP patch file').': '.$php_patch_filename); } - + //* Load patch file into database if( !empty($conf["mysql"]["admin_password"]) ) { system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename); @@ -189,32 +191,32 @@ function updateDbAndIni() { system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < ".$sql_patch_filename); } swriteln($inst->lng('Loading SQL patch file').': '.$sql_patch_filename); - + //* Exec onAfterSQL function if(isset($php_patch) && is_object($php_patch)) { $php_patch->onAfterSQL(); } - + $current_db_version = $next_db_version; if(isset($php_patch)) unset($php_patch); } else { $found = false; } } - + //* update the database version in server table $inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); if($inst->db->dbHost != $inst->dbmaster->dbHost) $inst->dbmaster->query("UPDATE ".$conf["mysql"]["master_database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); - - - //* If ISPConfig Version < 3.0.3, we will do a full db update + + + //* If ISPConfig Version < 3.0.3, we will do a full db update } else { - + swriteln($inst->lng('Starting full database update.')); - + //** Delete the old database if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['mysql']['database']) ) { - $inst->error('Unable to drop MySQL database: '.$conf['mysql']['database'].'.'); + $inst->error('Unable to drop MySQL database: '.$conf['mysql']['database'].'.'); } //** Create the mysql database @@ -233,7 +235,7 @@ function updateDbAndIni() { } else { system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < existing_db.sql"); } - + //** Get the database version number based on the patchfile $found = true; while($found == true) { @@ -245,29 +247,29 @@ function updateDbAndIni() { $found = false; } } - + //* update the database version in server table $inst->db->query("UPDATE ".$conf["mysql"]["database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); if($inst->db->dbHost != $inst->dbmaster->dbHost) $inst->dbmaster->query("UPDATE ".$conf["mysql"]["master_database"].".server SET dbversion = '".$current_db_version."' WHERE server_id = ".$conf['server_id']); if ($conf['powerdns']['installed']) { - + swriteln($inst->lng('Starting full PowerDNS database update.')); - //** Delete the old PowerDNS database - if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['powerdns']['database']) ) { + //** Delete the old PowerDNS database + if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['powerdns']['database']) ) { $inst->error('Unable to drop MySQL database: '.$conf['powerdns']['database'].'.'); - } + } - //** Create the mysql database - $inst->configure_powerdns(); + //** Create the mysql database + $inst->configure_powerdns(); - //** load old data back into the PowerDNS database - if( !empty($conf["mysql"]["admin_password"]) ) { - system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['powerdns']['database'])." < existing_powerdns_db.sql"); - } else { - system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['powerdns']['database'])." < existing_powerdns_db.sql"); - } + //** load old data back into the PowerDNS database + if( !empty($conf["mysql"]["admin_password"]) ) { + system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['powerdns']['database'])." < existing_powerdns_db.sql"); + } else { + system("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." --force -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['powerdns']['database'])." < existing_powerdns_db.sql"); + } } } @@ -277,7 +279,7 @@ function updateDbAndIni() { $old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config'])); unset($tmp_server_rec); $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 installer_base.lib.php too!! $tpl_ini_array['jailkit']['jailkit_chroot_app_programs'] = $conf['jailkit']['jailkit_chroot_app_programs']; @@ -302,7 +304,7 @@ function updateDbAndIni() { $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']; - + $tpl_ini_array['web']['nginx_vhost_conf_dir'] = $conf['nginx']['vhost_conf_dir']; $tpl_ini_array['web']['nginx_vhost_conf_enabled_dir'] = $conf['nginx']['vhost_conf_enabled_dir']; $tpl_ini_array['web']['nginx_user'] = $conf['nginx']['user']; @@ -313,7 +315,7 @@ function updateDbAndIni() { $tpl_ini_array['web']['php_fpm_pool_dir'] = $conf['nginx']['php_fpm_pool_dir']; $tpl_ini_array['web']['php_fpm_start_port'] = $conf['nginx']['php_fpm_start_port']; $tpl_ini_array['web']['php_fpm_socket_dir'] = $conf['nginx']['php_fpm_socket_dir']; - + if ($conf['nginx']['installed'] == true) { $tpl_ini_array['web']['server_type'] = 'nginx'; $tpl_ini_array['global']['webserver'] = 'nginx'; @@ -331,7 +333,7 @@ function updateDbAndIni() { $new_ini = array_to_ini($tpl_ini_array); $sql = "UPDATE ".$conf["mysql"]["database"].".server SET config = '".mysql_real_escape_string($new_ini)."' WHERE server_id = ".$conf['server_id']; $inst->db->query($sql); - + if($inst->db->dbHost != $inst->dbmaster->dbHost) { $sql = "UPDATE ".$conf["mysql"]["master_database"].".server SET config = '".mysql_real_escape_string($new_ini)."' WHERE server_id = ".$conf['server_id']; $inst->dbmaster->query($sql); diff --git a/install/patches/upd_0001.php b/install/patches/upd_0001.php index 93d6967b9..596bef596 100644 --- a/install/patches/upd_0001.php +++ b/install/patches/upd_0001.php @@ -1,6 +1,6 @@ diff --git a/install/setrights.php b/install/setrights.php index 1124136ba..275401a91 100644 --- a/install/setrights.php +++ b/install/setrights.php @@ -34,7 +34,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. error_reporting(E_ALL|E_STRICT); //** The banner on the command line -echo "\n\n".str_repeat('-',80)."\n"; +echo "\n\n".str_repeat('-', 80)."\n"; echo " _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / @@ -43,17 +43,17 @@ echo " _____ ___________ _____ __ _ ____ \___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ __/ | |___/ "; - echo "\n".str_repeat('-',80)."\n"; - echo "\n\n>>This script tries to repair the client rights \n\n"; +echo "\n".str_repeat('-', 80)."\n"; +echo "\n\n>>This script tries to repair the client rights \n\n"; //** Include the library with the basic installer functions -require_once('lib/install.lib.php'); +require_once 'lib/install.lib.php'; //** Include the library with the basic updater functions -require_once('lib/update.lib.php'); +require_once 'lib/update.lib.php'; //** Include the base class of the installer class -require_once('lib/installer_base.lib.php'); +require_once 'lib/installer_base.lib.php'; //** Ensure that current working directory is install directory $cur_dir = getcwd(); @@ -62,16 +62,16 @@ if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update //** Get distribution identifier $dist = get_distname(); -include_once("/usr/local/ispconfig/server/lib/config.inc.php"); +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'); +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); @@ -87,15 +87,15 @@ if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql /* * Try to read the DB-admin settings */ -$clientdb_host = ''; -$clientdb_user = ''; -$clientdb_password = ''; -include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf"); +$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 = ''; +$clientdb_host = ''; +$clientdb_user = ''; +$clientdb_password = ''; //** There is a error if user for mysql admin_password if empty if( empty($conf["mysql"]["admin_password"]) ) { @@ -105,7 +105,7 @@ if( empty($conf["mysql"]["admin_password"]) ) { $inst = new installer(); //** Initialize the MySQL server connection -include_once('lib/mysql.lib.php'); +include_once 'lib/mysql.lib.php'; //* initialize the database $inst->db = new db(); diff --git a/install/uninstall-fedora.php b/install/uninstall-fedora.php index 4da434787..66eb3003f 100644 --- a/install/uninstall-fedora.php +++ b/install/uninstall-fedora.php @@ -35,7 +35,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. error_reporting(E_ALL|E_STRICT); //** The banner on the command line -echo "\n\n".str_repeat('-',80)."\n"; +echo "\n\n".str_repeat('-', 80)."\n"; echo " _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / @@ -44,11 +44,11 @@ echo " _____ ___________ _____ __ _ ____ \___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ __/ | |___/ "; -echo "\n".str_repeat('-',80)."\n"; +echo "\n".str_repeat('-', 80)."\n"; echo "\n\n>> Uninstall \n\n"; -require("/usr/local/ispconfig/server/lib/config.inc.php"); -require("/usr/local/ispconfig/server/lib/app.inc.php"); +require "/usr/local/ispconfig/server/lib/config.inc.php"; +require "/usr/local/ispconfig/server/lib/app.inc.php"; // Delete the ISPConfig database // $app->db->query("DROP DATABASE '".$conf["db_database"]."'"); diff --git a/install/uninstall.php b/install/uninstall.php index 415ecf4f0..96d98c7ca 100644 --- a/install/uninstall.php +++ b/install/uninstall.php @@ -35,7 +35,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. error_reporting(E_ALL|E_STRICT); //** The banner on the command line -echo "\n\n".str_repeat('-',80)."\n"; +echo "\n\n".str_repeat('-', 80)."\n"; echo " _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / @@ -44,11 +44,11 @@ echo " _____ ___________ _____ __ _ ____ \___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ __/ | |___/ "; -echo "\n".str_repeat('-',80)."\n"; +echo "\n".str_repeat('-', 80)."\n"; echo "\n\n>> Uninstall \n\n"; -require("/usr/local/ispconfig/server/lib/config.inc.php"); -require("/usr/local/ispconfig/server/lib/app.inc.php"); +require "/usr/local/ispconfig/server/lib/config.inc.php"; +require "/usr/local/ispconfig/server/lib/app.inc.php"; // Delete the ISPConfig database // $app->db->query("DROP DATABASE '".$conf["db_database"]."'"); diff --git a/install/update.php b/install/update.php index a7c8a9312..2788998dc 100644 --- a/install/update.php +++ b/install/update.php @@ -37,7 +37,7 @@ error_reporting(E_ALL|E_STRICT); define('INSTALLER_RUN', true); //** The banner on the command line -echo "\n\n".str_repeat('-',80)."\n"; +echo "\n\n".str_repeat('-', 80)."\n"; echo " _____ ___________ _____ __ _ ____ |_ _/ ___| ___ \ / __ \ / _(_) /__ \ | | \ `--.| |_/ / | / \/ ___ _ __ | |_ _ __ _ _/ / @@ -46,17 +46,17 @@ echo " _____ ___________ _____ __ _ ____ \___/\____/\_| \____/\___/|_| |_|_| |_|\__, | \____/ __/ | |___/ "; -echo "\n".str_repeat('-',80)."\n"; +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'); +require_once 'lib/install.lib.php'; //** Include the library with the basic updater functions -require_once('lib/update.lib.php'); +require_once 'lib/update.lib.php'; //** Include the base class of the installer class -require_once('lib/installer_base.lib.php'); +require_once 'lib/installer_base.lib.php'; //** Ensure that current working directory is install directory $cur_dir = getcwd(); @@ -74,16 +74,16 @@ if(is_dir('/root/ispconfig') || is_dir('/home/admispconfig')) { //** Get distribution identifier $dist = get_distname(); -include_once("/usr/local/ispconfig/server/lib/config.inc.php"); +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'); +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); @@ -128,52 +128,52 @@ $inst->find_installed_apps(); echo "This application will update ISPConfig 3 on your server.\n\n"; //* Make a backup before we start the update -$do_backup = $inst->simple_query('Shall the script create a ISPConfig backup in /var/backup/ now?', array('yes','no'),'yes'); +$do_backup = $inst->simple_query('Shall the script create a ISPConfig backup in /var/backup/ now?', array('yes', 'no'), 'yes'); if($do_backup == 'yes') { - + //* Create the backup directory $backup_path = '/var/backup/ispconfig_'.@date('Y-m-d_H-i'); $conf['backup_path'] = $backup_path; exec("mkdir -p $backup_path"); exec("chown root:root $backup_path"); exec("chmod 700 $backup_path"); - + //* Do the backup swriteln('Creating backup of "/usr/local/ispconfig" directory...'); - exec("tar pcfz $backup_path/ispconfig_software.tar.gz /usr/local/ispconfig 2> /dev/null",$out,$returnvar); + exec("tar pcfz $backup_path/ispconfig_software.tar.gz /usr/local/ispconfig 2> /dev/null", $out, $returnvar); if($returnvar != 0) die("Backup failed. We stop here...\n"); - + swriteln('Creating backup of "/etc" directory...'); - exec("tar pcfz $backup_path/etc.tar.gz /etc 2> /dev/null",$out,$returnvar); + exec("tar pcfz $backup_path/etc.tar.gz /etc 2> /dev/null", $out, $returnvar); if($returnvar != 0) die("Backup failed. We stop here...\n"); - + exec("chown root:root $backup_path/*.tar.gz"); exec("chmod 700 $backup_path/*.tar.gz"); } //** Initialize the MySQL server connection -include_once('lib/mysql.lib.php'); +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"); +$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 = ''; +$clientdb_host = ''; +$clientdb_user = ''; +$clientdb_password = ''; //** Test mysql root connection $finished = false; do { - if(@mysql_connect($conf["mysql"]["host"],$conf["mysql"]["admin_user"],$conf["mysql"]["admin_password"])) { + if(@mysql_connect($conf["mysql"]["host"], $conf["mysql"]["admin_user"], $conf["mysql"]["admin_password"])) { $finished = true; } else { swriteln($inst->lng('Unable to connect to mysql server').' '.mysql_error()); @@ -183,7 +183,7 @@ do { unset($finished); /* - * Prepare the dump of the database + * Prepare the dump of the database */ prepareDBDump(); @@ -192,34 +192,34 @@ $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"]; + //** 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; } @@ -240,28 +240,28 @@ updateDbAndIni(); * 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'); +//** 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(); - } +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'); +$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(); @@ -274,11 +274,11 @@ if($reconfigure_services_answer == 'yes') { //** Configure saslauthd swriteln('Configuring SASL'); $inst->configure_saslauthd(); - + //** Configure PAM swriteln('Configuring PAM'); $inst->configure_pam(); - + //* Configure courier swriteln('Configuring Courier'); $inst->configure_courier(); @@ -296,13 +296,13 @@ if($reconfigure_services_answer == 'yes') { swriteln('Configuring Getmail'); $inst->configure_getmail(); } - + if($conf['services']['web'] && $conf['pureftpd']['installed'] == true) { //** Configure Pureftpd swriteln('Configuring Pureftpd'); $inst->configure_pureftpd(); } - + if($conf['services']['dns']) { //* Configure DNS if($conf['powerdns']['installed'] == true) { @@ -316,13 +316,13 @@ if($reconfigure_services_answer == 'yes') { $inst->configure_mydns(); } } - + if($conf['services']['web']) { if($conf['webserver']['server_type'] == 'apache'){ //** Configure Apache swriteln('Configuring Apache'); $inst->configure_apache(); - + //** Configure vlogger swriteln('Configuring vlogger'); $inst->configure_vlogger(); @@ -331,7 +331,7 @@ if($reconfigure_services_answer == 'yes') { swriteln('Configuring nginx'); $inst->configure_nginx(); } - + //** Configure apps vhost swriteln('Configuring Apps vhost'); $inst->configure_apps_vhost(); @@ -342,7 +342,7 @@ if($reconfigure_services_answer == 'yes') { swriteln('Configuring Database'); $inst->configure_dbserver(); - + if($conf['services']['firewall']) { if($conf['ufw']['installed'] == true) { //* Configure Ubuntu Firewall @@ -355,7 +355,7 @@ if($reconfigure_services_answer == 'yes') { $inst->configure_bastille_firewall(); } } - + /* if($conf['squid']['installed'] == true) { swriteln('Configuring Squid'); @@ -384,10 +384,10 @@ if ($conf['services']['web'] && $inst->install_ispconfig_interface) { } else { $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') { + if(strtolower($inst->simple_query('Create new ISPConfig SSL certificate', array('yes', 'no'), 'no')) == 'yes') { $inst->make_ispconfig_ssl_cert(); } } @@ -395,7 +395,7 @@ if ($conf['services']['web'] && $inst->install_ispconfig_interface) { $inst->install_ispconfig(); //** Configure Crontab -$update_crontab_answer = $inst->simple_query('Reconfigure Crontab?', array('yes','no'),'yes'); +$update_crontab_answer = $inst->simple_query('Reconfigure Crontab?', array('yes', 'no'), 'yes'); if($update_crontab_answer == 'yes') { swriteln('Updating Crontab'); $inst->install_crontab(); @@ -434,14 +434,14 @@ if($reconfigure_services_answer == 'yes') { if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null'); if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null'); } - + if($conf['services']['proxy']) { - // if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); + // if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null'); } - + if($conf['services']['firewall']) { - if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['ufw']['init_script'])) system($conf['init_scripts'].'/'.$conf['ufw']['init_script'].' restart &> /dev/null'); + if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['ufw']['init_script'])) system($conf['init_scripts'].'/'.$conf['ufw']['init_script'].' restart &> /dev/null'); } } diff --git a/interface/lib/app.inc.php b/interface/lib/app.inc.php index e0b237b3b..e1929d3aa 100755 --- a/interface/lib/app.inc.php +++ b/interface/lib/app.inc.php @@ -64,15 +64,15 @@ class app { //* Start the session if($this->_conf['start_session'] == true) { - + $this->uses('session'); - session_set_save_handler( array($this->session, 'open'), - array($this->session, 'close'), - array($this->session, 'read'), - array($this->session, 'write'), - array($this->session, 'destroy'), - array($this->session, 'gc')); - + session_set_save_handler( array($this->session, 'open'), + array($this->session, 'close'), + array($this->session, 'read'), + array($this->session, 'write'), + array($this->session, 'destroy'), + array($this->session, 'gc')); + session_start(); //* Initialize session variables @@ -81,10 +81,10 @@ class app { if(empty($_SESSION['s']['language'])) $_SESSION['s']['language'] = $conf['language']; } - $this->uses('functions'); // we need this before all others! + $this->uses('functions'); // we need this before all others! $this->uses('auth,plugin'); } - + public function __destruct() { session_write_close(); } @@ -96,7 +96,7 @@ class app { $classname = trim($classname); //* Class is not loaded so load it if(!array_key_exists($classname, $this->_loaded_classes)) { - include_once(ISPC_CLASS_PATH."/$classname.inc.php"); + include_once ISPC_CLASS_PATH."/$classname.inc.php"; $this->$classname = new $classname(); $this->_loaded_classes[$classname] = true; } @@ -109,12 +109,14 @@ class app { if(is_array($fl)) { foreach($fl as $file) { $file = trim($file); - include_once(ISPC_CLASS_PATH."/$file.inc.php"); + include_once ISPC_CLASS_PATH."/$file.inc.php"; } } } /** Priority values are: 0 = DEBUG, 1 = WARNING, 2 = ERROR */ + + public function log($msg, $priority = 0) { global $conf; if($priority >= $this->_conf['log_priority']) { @@ -196,12 +198,12 @@ class app { //** Helper function to load the language files. public function load_language_file($filename) { $filename = ISPC_ROOT_PATH.'/'.$filename; - if(substr($filename,-4) != '.lng') $this->error('Language file has wrong extension.'); + if(substr($filename, -4) != '.lng') $this->error('Language file has wrong extension.'); if(file_exists($filename)) { - @include($filename); + @include $filename; if(is_array($wb)) { if(is_array($this->_wb)) { - $this->_wb = array_merge($this->_wb,$wb); + $this->_wb = array_merge($this->_wb, $wb); } else { $this->_wb = $wb; } @@ -213,12 +215,12 @@ class app { $this->tpl->setVar('app_title', $this->_conf['app_title']); if(isset($_SESSION['s']['user'])) { $this->tpl->setVar('app_version', $this->_conf['app_version']); - // get pending datalog changes - $datalog = $this->db->datalogStatus(); - $this->tpl->setVar('datalog_changes_txt', $this->lng('datalog_changes_txt')); - $this->tpl->setVar('datalog_changes_end_txt', $this->lng('datalog_changes_end_txt')); - $this->tpl->setVar('datalog_changes_count', $datalog['count']); - $this->tpl->setLoop('datalog_changes', $datalog['entries']); + // get pending datalog changes + $datalog = $this->db->datalogStatus(); + $this->tpl->setVar('datalog_changes_txt', $this->lng('datalog_changes_txt')); + $this->tpl->setVar('datalog_changes_end_txt', $this->lng('datalog_changes_end_txt')); + $this->tpl->setVar('datalog_changes_count', $datalog['count']); + $this->tpl->setLoop('datalog_changes', $datalog['entries']); } else { $this->tpl->setVar('app_version', ''); } @@ -253,13 +255,13 @@ class app { $this->tpl->setVar('cpuser', $_SESSION['s']['user']['username']); $this->tpl->setVar('logout_txt', $this->lng('logout_txt')); /* Show search field only for normal users, not mail users */ - if(stristr($_SESSION['s']['user']['username'],'@')){ + if(stristr($_SESSION['s']['user']['username'], '@')){ $this->tpl->setVar('usertype', 'mailuser'); } else { $this->tpl->setVar('usertype', 'normaluser'); } } - + /* Global Search */ $this->tpl->setVar('globalsearch_resultslimit_of_txt', $this->lng('globalsearch_resultslimit_of_txt')); $this->tpl->setVar('globalsearch_resultslimit_results_txt', $this->lng('globalsearch_resultslimit_results_txt')); diff --git a/interface/lib/classes/aps_base.inc.php b/interface/lib/classes/aps_base.inc.php index 4c1512ba2..c4aaf52fd 100644 --- a/interface/lib/classes/aps_base.inc.php +++ b/interface/lib/classes/aps_base.inc.php @@ -43,61 +43,69 @@ define('PACKAGE_ERROR_NOMETA', 4); class ApsBase { - protected $log_prefix = ''; - protected $fetch_url = ''; - protected $aps_version = ''; - protected $packages_dir = ''; - protected $temp_pkg_dir = ''; - protected $interface_pkg_dir = ''; - protected $interface_mode = false; // server mode by default - - /** - * Constructor - * - * @param $app the application instance (db handle + log method) - * @param $interface_mode act in interface (true) or server mode (false) - * @param $log_prefix a prefix to set before all log entries - */ - public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false) - { - $this->log_prefix = $log_prefix; - $this->interface_mode = $interface_mode; - $this->fetch_url = 'apscatalog.com'; - $this->aps_version = '1'; - $this->packages_dir = ISPC_ROOT_PATH.'/aps_packages'; - $this->interface_pkg_dir = ISPC_ROOT_PATH.'/web/sites/aps_meta_packages'; - } - - /** - * Converts a given value to it's native representation in 1024 units - * - * @param $value the size to convert - * @return integer and string - */ - public function convertSize($value) - { - $unit = array('Bytes', 'KB', 'MB', 'GB', 'TB'); - return @round($value/pow(1024, ($i = floor(log($value, 1024)))), 2).' '.$unit[$i]; - } - - /** - * Determine a specific xpath from a given SimpleXMLElement handle. If the - * element is found, it's string representation is returned. If not, - * the return value will stay empty - * - * @param $xml_handle the SimpleXMLElement handle - * @param $query the XPath query - * @param $array define whether to return an array or a string - * @return $ret the return string - */ - protected function getXPathValue($xml_handle, $query, $array = false) - { - $ret = ''; - - $xp_result = @($xml_handle->xpath($query)) ? $xml_handle->xpath($query) : false; - if($xp_result !== false) $ret = (($array === false) ? (string)$xp_result[0] : $xp_result); - - return $ret; - } + protected $log_prefix = ''; + protected $fetch_url = ''; + protected $aps_version = ''; + protected $packages_dir = ''; + protected $temp_pkg_dir = ''; + protected $interface_pkg_dir = ''; + protected $interface_mode = false; // server mode by default + + /** + * Constructor + * + * @param $app the application instance (db handle + log method) + * @param $interface_mode act in interface (true) or server mode (false) + * @param $log_prefix a prefix to set before all log entries + */ + + + public function __construct($app, $log_prefix = 'APS: ', $interface_mode = false) + { + $this->log_prefix = $log_prefix; + $this->interface_mode = $interface_mode; + $this->fetch_url = 'apscatalog.com'; + $this->aps_version = '1'; + $this->packages_dir = ISPC_ROOT_PATH.'/aps_packages'; + $this->interface_pkg_dir = ISPC_ROOT_PATH.'/web/sites/aps_meta_packages'; + } + + + + /** + * Converts a given value to it's native representation in 1024 units + * + * @param $value the size to convert + * @return integer and string + */ + public function convertSize($value) + { + $unit = array('Bytes', 'KB', 'MB', 'GB', 'TB'); + return @round($value/pow(1024, ($i = floor(log($value, 1024)))), 2).' '.$unit[$i]; + } + + + + /** + * Determine a specific xpath from a given SimpleXMLElement handle. If the + * element is found, it's string representation is returned. If not, + * the return value will stay empty + * + * @param $xml_handle the SimpleXMLElement handle + * @param $query the XPath query + * @param $array define whether to return an array or a string + * @return $ret the return string + */ + protected function getXPathValue($xml_handle, $query, $array = false) + { + $ret = ''; + + $xp_result = @($xml_handle->xpath($query)) ? $xml_handle->xpath($query) : false; + if($xp_result !== false) $ret = (($array === false) ? (string)$xp_result[0] : $xp_result); + + return $ret; + } + } -?> \ No newline at end of file + +?> diff --git a/interface/lib/classes/aps_crawler.inc.php b/interface/lib/classes/aps_crawler.inc.php index 2c6906efd..8260f3409 100644 --- a/interface/lib/classes/aps_crawler.inc.php +++ b/interface/lib/classes/aps_crawler.inc.php @@ -27,264 +27,277 @@ 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('aps_base.inc.php'); +require_once 'aps_base.inc.php'; @set_time_limit(0); @ignore_user_abort(1); class ApsCrawler extends ApsBase { - - //public $app_download_url_list = array(); - - /** - * Constructor - * - * @param $app the application instance (db handle + log method) - * @param $interface_mode act in interface (true) or server mode (false) - */ - public function __construct($app, $interface_mode = false) - { - parent::__construct($app, 'APS crawler: ', $interface_mode); - } - - /** - * Before the cron is executed, make sure all necessary options are set - * and all functions (i.e. cURL) are available - */ - private function checkRequirements() - { - global $app; - - try - { - // Check if allow_url_fopen is enabled - if(!@ini_get('allow_url_fopen')) throw new Exception('allow_url_fopen is not enabled'); - // Check if the cURL module is available - if(!function_exists('curl_version')) throw new Exception('cURL is not available'); - - // Check if used folders are writable - if($this->interface_mode) - { - if(!is_writable($this->interface_pkg_dir)) - throw new Exception('the folder '.basename($this->interface_pkg_dir).' is not writable'); - } - else - { - if(!is_writable($this->packages_dir)) - throw new Exception('the folder '.basename($this->packages_dir).' is not writable'); - } - - return true; - } - catch(Exception $e) - { - $app->log($this->log_prefix.'Aborting execution because '.$e->getMessage(), LOGLEVEL_ERROR); - return false; - } - } - - /** - * Remove a directory recursively - * In case of error be silent - * - * @param $dir the directory to remove - */ - private function removeDirectory($dir) - { - if(is_dir($dir)) - { - $files = scandir($dir); - foreach($files as $file) - { - if($file != '.' && $file != '..') - if(filetype($dir.'/'.$file) == 'dir') $this->removeDirectory($dir.'/'.$file); - else @unlink($dir.'/'.$file); - } - reset($files); - @rmdir($dir); - } - } - - - /** - * Fetch HTML data from one or more given URLs - * If a string is given, a string is returned, if an array of URLs should - * be fetched, the responses of the parallel queries are returned as array - * - * @param $input the string or array to fetch - * @return $ret a query response string or array - */ - private function fetchPage($input) - { - $ret = array(); - $url = array(); - $conn = array(); - - // Make sure we are working with an array, further on - if(!is_array($input)) $url[] = $input; - else $url = $input; - - // Build the single cURL handles and add them to a multi handle - $mh = curl_multi_init(); - for($i = 0; $i < count($url); $i++) - { - $conn[$i] = curl_init('http://'.$this->fetch_url.$url[$i]); - curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, true); - curl_multi_add_handle($mh, $conn[$i]); - } - - $active = 0; - do curl_multi_exec($mh, $active); - while($active > 0); - - // Get the response(s) - for($i = 0; $i < count($url); $i++) - { - $ret[$i] = curl_multi_getcontent($conn[$i]); - curl_multi_remove_handle($mh, $conn[$i]); - curl_close($conn[$i]); - } - curl_multi_close($mh); - - if(count($url) == 1) $ret = $ret[0]; - - return $ret; - } - - /** - * Fetch binary data from a given array - * The data is retrieved in binary mode and - * then directly written to an output file - * - * @param $input a specially structed array - * @see $this->startUpdate() - */ - private function fetchFiles($input) - { - $fh = array(); - $url = array(); - $conn = array(); - - // Build the single cURL handles and add them to a multi handle - $mh = curl_multi_init(); - - // Process each app - for($i = 0; $i < count($input); $i++) - { - $conn[$i] = curl_init($input[$i]['url']); - $fh[$i] = fopen($input[$i]['localtarget'], 'wb'); - - curl_setopt($conn[$i], CURLOPT_BINARYTRANSFER, true); - curl_setopt($conn[$i], CURLOPT_FILE, $fh[$i]); - curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0); - curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1); - curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1); - - curl_multi_add_handle($mh, $conn[$i]); - } - - $active = 0; - do curl_multi_exec($mh, $active); - while($active > 0); - - // Close the handles - for($i = 0; $i < count($input); $i++) - { - fclose($fh[$i]); - curl_multi_remove_handle($mh, $conn[$i]); - curl_close($conn[$i]); - } - curl_multi_close($mh); - } - - /** - * A method to build query URLs out of a list of vendors - * - */ - private function formatVendorCallback($array_item) - { - $array_item = str_replace(' ', '%20', $array_item); - $array_item = str_replace('http://', '', $array_item); - $array_item = '/'.$this->aps_version.'.atom?vendor='.$array_item.'&pageSize=100'; - return($array_item); - } - - /** - * The main method which performs the actual crawling - */ - public function startCrawler() - { - global $app; - - try - { - // Make sure the requirements are given so that this script can execute - $req_ret = $this->checkRequirements(); - if(!$req_ret) return false; - - // Execute the open task and first fetch all vendors (APS catalog API 1.1, p. 12) - $app->log($this->log_prefix.'Fetching data from '.$this->fetch_url); - - $vendor_page = $this->fetchPage('/all-app/'); //$vendor_page = $this->fetchPage('/'.$this->aps_version.'/'); - preg_match_all("/\ /1.atom?vendor=typo3.org&pageSize=100 - //array_walk($vendors, array($this, 'formatVendorCallback')); + + //public $app_download_url_list = array(); + + /** + * Constructor + * + * @param $app the application instance (db handle + log method) + * @param $interface_mode act in interface (true) or server mode (false) + */ + + + public function __construct($app, $interface_mode = false) + { + parent::__construct($app, 'APS crawler: ', $interface_mode); + } + + + + /** + * Before the cron is executed, make sure all necessary options are set + * and all functions (i.e. cURL) are available + */ + private function checkRequirements() + { + global $app; + + try + { + // Check if allow_url_fopen is enabled + if(!@ini_get('allow_url_fopen')) throw new Exception('allow_url_fopen is not enabled'); + // Check if the cURL module is available + if(!function_exists('curl_version')) throw new Exception('cURL is not available'); + + // Check if used folders are writable + if($this->interface_mode) + { + if(!is_writable($this->interface_pkg_dir)) + throw new Exception('the folder '.basename($this->interface_pkg_dir).' is not writable'); + } + else + { + if(!is_writable($this->packages_dir)) + throw new Exception('the folder '.basename($this->packages_dir).' is not writable'); + } + + return true; + } + + catch(Exception $e) + { + $app->log($this->log_prefix.'Aborting execution because '.$e->getMessage(), LOGLEVEL_ERROR); + return false; + } + } + + + + /** + * Remove a directory recursively + * In case of error be silent + * + * @param $dir the directory to remove + */ + private function removeDirectory($dir) + { + if(is_dir($dir)) + { + $files = scandir($dir); + foreach($files as $file) + { + if($file != '.' && $file != '..') + if(filetype($dir.'/'.$file) == 'dir') $this->removeDirectory($dir.'/'.$file); + else @unlink($dir.'/'.$file); + } + reset($files); + @rmdir($dir); + } + } + + + /** + * Fetch HTML data from one or more given URLs + * If a string is given, a string is returned, if an array of URLs should + * be fetched, the responses of the parallel queries are returned as array + * + * @param $input the string or array to fetch + * @return $ret a query response string or array + */ + private function fetchPage($input) + { + $ret = array(); + $url = array(); + $conn = array(); + + // Make sure we are working with an array, further on + if(!is_array($input)) $url[] = $input; + else $url = $input; + + // Build the single cURL handles and add them to a multi handle + $mh = curl_multi_init(); + for($i = 0; $i < count($url); $i++) + { + $conn[$i] = curl_init('http://'.$this->fetch_url.$url[$i]); + curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, true); + curl_multi_add_handle($mh, $conn[$i]); + } + + $active = 0; + do curl_multi_exec($mh, $active); + while($active > 0); + + // Get the response(s) + for($i = 0; $i < count($url); $i++) + { + $ret[$i] = curl_multi_getcontent($conn[$i]); + curl_multi_remove_handle($mh, $conn[$i]); + curl_close($conn[$i]); + } + curl_multi_close($mh); + + if(count($url) == 1) $ret = $ret[0]; + + return $ret; + } + + + + /** + * Fetch binary data from a given array + * The data is retrieved in binary mode and + * then directly written to an output file + * + * @param $input a specially structed array + * @see $this->startUpdate() + */ + private function fetchFiles($input) + { + $fh = array(); + $url = array(); + $conn = array(); + + // Build the single cURL handles and add them to a multi handle + $mh = curl_multi_init(); + + // Process each app + for($i = 0; $i < count($input); $i++) + { + $conn[$i] = curl_init($input[$i]['url']); + $fh[$i] = fopen($input[$i]['localtarget'], 'wb'); + + curl_setopt($conn[$i], CURLOPT_BINARYTRANSFER, true); + curl_setopt($conn[$i], CURLOPT_FILE, $fh[$i]); + curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0); + curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1); + curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1); + + curl_multi_add_handle($mh, $conn[$i]); + } + + $active = 0; + do curl_multi_exec($mh, $active); + while($active > 0); + + // Close the handles + for($i = 0; $i < count($input); $i++) + { + fclose($fh[$i]); + curl_multi_remove_handle($mh, $conn[$i]); + curl_close($conn[$i]); + } + curl_multi_close($mh); + } + + + + /** + * A method to build query URLs out of a list of vendors + * + */ + private function formatVendorCallback($array_item) + { + $array_item = str_replace(' ', '%20', $array_item); + $array_item = str_replace('http://', '', $array_item); + $array_item = '/'.$this->aps_version.'.atom?vendor='.$array_item.'&pageSize=100'; + return $array_item; + } + + + + /** + * The main method which performs the actual crawling + */ + public function startCrawler() + { + global $app; + + try + { + // Make sure the requirements are given so that this script can execute + $req_ret = $this->checkRequirements(); + if(!$req_ret) return false; + + // Execute the open task and first fetch all vendors (APS catalog API 1.1, p. 12) + $app->log($this->log_prefix.'Fetching data from '.$this->fetch_url); + + $vendor_page = $this->fetchPage('/all-app/'); //$vendor_page = $this->fetchPage('/'.$this->aps_version.'/'); + preg_match_all("/\ /1.atom?vendor=typo3.org&pageSize=100 + //array_walk($vendors, array($this, 'formatVendorCallback')); if(is_array($vendors)) { foreach($vendors as $key => $array_item) { $vendors[$key] = $this->formatVendorCallback($array_item); } } - - // Process all vendors in chunks of 50 entries - $vendor_chunks = array_chunk($vendors, 50); - //var_dump($vendor_chunks); - - // Get all known apps from the database and the highest known version - // Note: A dirty hack is used for numerical sorting of the VARCHAR field Version: +0 -> cast - // A longer but typesafe way would be: ORDER BY CAST(REPLACE(Version, '.', '') AS UNSIGNED) DESC - $existing_apps = $app->db->queryAllRecords("SELECT * FROM ( - SELECT name AS Name, CONCAT(version, '-', CAST(`release` AS CHAR)) AS CurrentVersion + + // Process all vendors in chunks of 50 entries + $vendor_chunks = array_chunk($vendors, 50); + //var_dump($vendor_chunks); + + // Get all known apps from the database and the highest known version + // Note: A dirty hack is used for numerical sorting of the VARCHAR field Version: +0 -> cast + // A longer but typesafe way would be: ORDER BY CAST(REPLACE(Version, '.', '') AS UNSIGNED) DESC + $existing_apps = $app->db->queryAllRecords("SELECT * FROM ( + SELECT name AS Name, CONCAT(version, '-', CAST(`release` AS CHAR)) AS CurrentVersion FROM aps_packages ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC ) as Versions GROUP BY name"); - //var_dump($existing_apps); - - // Used for statistics later - $apps_in_repo = 0; - $apps_updated = 0; - $apps_downloaded = 0; - - $apps_to_dl = array(); - - for($i = 0; $i < count($vendor_chunks); $i++) - { - // Fetch all apps for the current chunk of vendors - $apps = $this->fetchPage($vendor_chunks[$i]); - - for($j = 0; $j < count($apps); $j++) - { - // Before parsing, make sure it's worth the work by checking if at least one app exists - $apps_count = substr_count($apps[$j], '0'); - if($apps_count == 0) // obviously this vendor provides one or more apps - { - // Rename namespaces and register them - $xml = str_replace("xmlns=", "ns=", $apps[$j]); - $sxe = new SimpleXMLElement($xml); - $namespaces = $sxe->getDocNamespaces(true); - foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); - - // Fetching values of interest - $app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name'); - $app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version'); - $app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release'); - - // Find out a (possibly) existing package version - $ex_ver = ''; + //var_dump($existing_apps); + + // Used for statistics later + $apps_in_repo = 0; + $apps_updated = 0; + $apps_downloaded = 0; + + $apps_to_dl = array(); + + for($i = 0; $i < count($vendor_chunks); $i++) + { + // Fetch all apps for the current chunk of vendors + $apps = $this->fetchPage($vendor_chunks[$i]); + + for($j = 0; $j < count($apps); $j++) + { + // Before parsing, make sure it's worth the work by checking if at least one app exists + $apps_count = substr_count($apps[$j], '0'); + if($apps_count == 0) // obviously this vendor provides one or more apps + { + // Rename namespaces and register them + $xml = str_replace("xmlns=", "ns=", $apps[$j]); + $sxe = new SimpleXMLElement($xml); + $namespaces = $sxe->getDocNamespaces(true); + foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); + + // Fetching values of interest + $app_name = parent::getXPathValue($sxe, 'entry[position()=1]/a:name'); + $app_version = parent::getXPathValue($sxe, 'entry[position()=1]/a:version'); + $app_release = parent::getXPathValue($sxe, 'entry[position()=1]/a:release'); + + // Find out a (possibly) existing package version + $ex_ver = ''; /* - array_walk($existing_apps, + array_walk($existing_apps, create_function('$v, $k, $ex_ver', 'if($v["Name"] == "'.$app_name.'") $ex_ver = $v["CurrentVersion"];'), &$ex_ver); */ if(is_array($existing_apps)) { @@ -292,286 +305,292 @@ class ApsCrawler extends ApsBase if($v["Name"] == $app_name) $ex_ver = $v["CurrentVersion"]; } } - - $new_ver = $app_version.'-'.$app_release; - $local_intf_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$new_ver.'.app.zip/'; - - // Proceed if a newer or at least equal version has been found with server mode or - // interface mode is activated and there are no valid APP-META.xml and PKG_URL existing yet - if((!$this->interface_mode && version_compare($new_ver, $ex_ver) >= 0) || ($this->interface_mode && (!file_exists($local_intf_folder.'APP-META.xml') || filesize($local_intf_folder.'APP-META.xml') == 0 || !file_exists($local_intf_folder.'PKG_URL') || filesize($local_intf_folder.'PKG_URL') == 0))){ - // Check if we already have an old version of this app - if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) $apps_updated++; - - $app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href"); - $app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length"); - $app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href"); - + + $new_ver = $app_version.'-'.$app_release; + $local_intf_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$new_ver.'.app.zip/'; + + // Proceed if a newer or at least equal version has been found with server mode or + // interface mode is activated and there are no valid APP-META.xml and PKG_URL existing yet + if((!$this->interface_mode && version_compare($new_ver, $ex_ver) >= 0) || ($this->interface_mode && (!file_exists($local_intf_folder.'APP-META.xml') || filesize($local_intf_folder.'APP-META.xml') == 0 || !file_exists($local_intf_folder.'PKG_URL') || filesize($local_intf_folder.'PKG_URL') == 0))){ + // Check if we already have an old version of this app + if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) $apps_updated++; + + $app_dl = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@href"); + $app_filesize = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='aps']/@length"); + $app_metafile = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='meta']/@href"); + //$this->app_download_url_list[$app_name.'-'.$new_ver.'.app.zip'] = $app_dl; - // Skip ASP.net packages because they can't be used at all - $asp_handler = parent::getXPathValue($sxe, '//aspnet:handler'); - $asp_permissions = parent::getXPathValue($sxe, '//aspnet:permissions'); - $asp_version = parent::getXPathValue($sxe, '//aspnet:version'); - if(!empty($asp_handler) || !empty($asp_permissions) || !empty($asp_version)) continue; - - // Interface mode (download only parts) - if($this->interface_mode) - { - // Delete an obviously out-dated version from the system and DB - if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) - { - $old_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip'; - if(file_exists($old_folder)) $this->removeDirectory($old_folder); - + // Skip ASP.net packages because they can't be used at all + $asp_handler = parent::getXPathValue($sxe, '//aspnet:handler'); + $asp_permissions = parent::getXPathValue($sxe, '//aspnet:permissions'); + $asp_version = parent::getXPathValue($sxe, '//aspnet:version'); + if(!empty($asp_handler) || !empty($asp_permissions) || !empty($asp_version)) continue; + + // Interface mode (download only parts) + if($this->interface_mode) + { + // Delete an obviously out-dated version from the system and DB + if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) + { + $old_folder = $this->interface_pkg_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip'; + if(file_exists($old_folder)) $this->removeDirectory($old_folder); + /* $app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_OUTDATED."' WHERE name = '". $app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '". $app->db->quote($ex_ver)."';"); */ $tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = '". - $app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '". - $app->db->quote($ex_ver)."';"); + $app->db->quote($app_name)."' AND CONCAT(version, '-', CAST(`release` AS CHAR)) = '". + $app->db->quote($ex_ver)."';"); $app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']); unset($tmp); - } - - // Create the local folder if not yet existing - if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true); - + } + + // Create the local folder if not yet existing + if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true); + // Save the package URL in an extra file because it's not part of the APP-META.xml file @file_put_contents($local_intf_folder.'PKG_URL', $app_dl); - - // Download the meta file - $local_metafile = $local_intf_folder.'APP-META.xml'; - if(!file_exists($local_metafile) || filesize($local_metafile) == 0) - { - $apps_to_dl[] = array('name' => 'APP-META.xml', - 'url' => $app_metafile, - 'filesize' => 0, - 'localtarget' => $local_metafile); - $apps_downloaded++; - } - - // Download package license - $license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href"); - if($license != '') - { - $local_license = $local_intf_folder.'LICENSE'; - if(!file_exists($local_license) || filesize($local_license) == 0) - { - $apps_to_dl[] = array('name' => basename($license), - 'url' => $license, - 'filesize' => 0, - 'localtarget' => $local_license); - } - } - - // Download package icon - $icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href"); - if($icon != '') - { - $local_icon = $local_intf_folder.basename($icon); - if(!file_exists($local_icon) || filesize($local_icon) == 0) - { - $apps_to_dl[] = array('name' => basename($icon), - 'url' => $icon, - 'filesize' => 0, - 'localtarget' => $local_icon); - } - } - - // Download available screenshots - $screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true); - if(!empty($screenshots)) - { - foreach($screenshots as $screen) - { - $local_screen = $local_intf_folder.basename($screen['href']); - if(!file_exists($local_screen) || filesize($local_screen) == 0) - { - $apps_to_dl[] = array('name' => basename($screen['href']), - 'url' => $screen['href'], - 'filesize' => 0, - 'localtarget' => $local_screen); - } - } - } - } - else // Server mode (download whole ZIP archive) - { - // Delete an obviously out-dated version from the system - if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) - { - $old_file = $this->packages_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip'; - if(file_exists($old_file)) $this->removeDirectory($old_file); - } - - // Attention: $new_ver can also be == $ex_ver (according to version_compare >= 0) - $local_zip = $this->packages_dir.'/'.$app_name.'-'.$new_ver.'.app.zip'; - - // Before re-downloading a file, make sure it's not yet existing on HDD (due to DB inconsistency) - if((file_exists($local_zip) && (filesize($local_zip) == $app_filesize)) === false) - { - $apps_to_dl[] = array('name' => $app_name, - 'url' => $app_dl, - 'filesize' => $app_filesize, - 'localtarget' => $local_zip); - $apps_downloaded++; - } - } - } - - unset($sxe); - $apps_in_repo++; - } - } - //var_dump($apps); - - // For memory reasons, unset the current vendor and his apps - unset($apps); - } - - // Shuffle the download array (in order to compensate unexpected php aborts) - shuffle($apps_to_dl); - - // After collecting all provisioned apps, download them - $apps_to_dl_chunks = array_chunk($apps_to_dl, 10); - - for($i = 0; $i < count($apps_to_dl_chunks); $i++) - { - $this->fetchFiles($apps_to_dl_chunks[$i]); - - // Check the integrity of all downloaded files - // but exclude cases where no filesize is available (i.e. screenshot or metafile download) - for($j = 0; $j < count($apps_to_dl_chunks[$i]); $j++) - { - if($apps_to_dl_chunks[$i][$j]['filesize'] != 0 && - $apps_to_dl_chunks[$i][$j]['filesize'] != filesize($apps_to_dl_chunks[$i][$j]['localtarget'])) - { - $app->log($this->log_prefix.' The filesize of the package "'. - $apps_to_dl_chunks[$i][$j]['name'].'" is wrong. Download failure?', LOGLEVEL_WARN); - } - } - } - - $app->log($this->log_prefix.'Processed '.$apps_in_repo. - ' apps from the repo. Downloaded '.$apps_updated. - ' updates, '.$apps_downloaded.' new apps'); - } - catch(Exception $e) - { - $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR); - return false; - } - } - - /** - * Read in all possible packages from the interface packages folder and - * check if they are not ASP.net code (as this can't be processed). - * - * Note: There's no need to check if the packages to register are newer - * than those in the database because this already happended in startCrawler() - */ - public function parseFolderToDB() - { - global $app; - - try - { - // This method must be used in interface mode - if(!$this->interface_mode) return false; - - $pkg_list = array(); - - // Read in every package having a correct filename - $temp_handle = @dir($this->interface_pkg_dir); - if(!$temp_handle) throw new Exception('The temp directory is not accessible'); - while($folder = $temp_handle->read()) - if(substr($folder, -8) == '.app.zip') $pkg_list[] = $folder; - $temp_handle->close(); - - // If no packages are available -> exception (because at this point there should exist packages) - if(empty($pkg_list)) throw new Exception('No packages to read in'); - - // Get registered packages and mark non-existant packages with an error code to omit the install - $existing_packages = array(); - $path_query = $app->db->queryAllRecords('SELECT path AS Path FROM aps_packages;'); - foreach($path_query as $path) $existing_packages[] = $path['Path']; - $diff = array_diff($existing_packages, $pkg_list); - foreach($diff as $todelete) { - /*$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_ERROR_NOMETA."' + + // Download the meta file + $local_metafile = $local_intf_folder.'APP-META.xml'; + if(!file_exists($local_metafile) || filesize($local_metafile) == 0) + { + $apps_to_dl[] = array('name' => 'APP-META.xml', + 'url' => $app_metafile, + 'filesize' => 0, + 'localtarget' => $local_metafile); + $apps_downloaded++; + } + + // Download package license + $license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href"); + if($license != '') + { + $local_license = $local_intf_folder.'LICENSE'; + if(!file_exists($local_license) || filesize($local_license) == 0) + { + $apps_to_dl[] = array('name' => basename($license), + 'url' => $license, + 'filesize' => 0, + 'localtarget' => $local_license); + } + } + + // Download package icon + $icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href"); + if($icon != '') + { + $local_icon = $local_intf_folder.basename($icon); + if(!file_exists($local_icon) || filesize($local_icon) == 0) + { + $apps_to_dl[] = array('name' => basename($icon), + 'url' => $icon, + 'filesize' => 0, + 'localtarget' => $local_icon); + } + } + + // Download available screenshots + $screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true); + if(!empty($screenshots)) + { + foreach($screenshots as $screen) + { + $local_screen = $local_intf_folder.basename($screen['href']); + if(!file_exists($local_screen) || filesize($local_screen) == 0) + { + $apps_to_dl[] = array('name' => basename($screen['href']), + 'url' => $screen['href'], + 'filesize' => 0, + 'localtarget' => $local_screen); + } + } + } + } + else // Server mode (download whole ZIP archive) + { + // Delete an obviously out-dated version from the system + if(!empty($ex_ver) && version_compare($new_ver, $ex_ver) == 1) + { + $old_file = $this->packages_dir.'/'.$app_name.'-'.$ex_ver.'.app.zip'; + if(file_exists($old_file)) $this->removeDirectory($old_file); + } + + // Attention: $new_ver can also be == $ex_ver (according to version_compare >= 0) + $local_zip = $this->packages_dir.'/'.$app_name.'-'.$new_ver.'.app.zip'; + + // Before re-downloading a file, make sure it's not yet existing on HDD (due to DB inconsistency) + if((file_exists($local_zip) && (filesize($local_zip) == $app_filesize)) === false) + { + $apps_to_dl[] = array('name' => $app_name, + 'url' => $app_dl, + 'filesize' => $app_filesize, + 'localtarget' => $local_zip); + $apps_downloaded++; + } + } + } + + unset($sxe); + $apps_in_repo++; + } + } + //var_dump($apps); + + // For memory reasons, unset the current vendor and his apps + unset($apps); + } + + // Shuffle the download array (in order to compensate unexpected php aborts) + shuffle($apps_to_dl); + + // After collecting all provisioned apps, download them + $apps_to_dl_chunks = array_chunk($apps_to_dl, 10); + + for($i = 0; $i < count($apps_to_dl_chunks); $i++) + { + $this->fetchFiles($apps_to_dl_chunks[$i]); + + // Check the integrity of all downloaded files + // but exclude cases where no filesize is available (i.e. screenshot or metafile download) + for($j = 0; $j < count($apps_to_dl_chunks[$i]); $j++) + { + if($apps_to_dl_chunks[$i][$j]['filesize'] != 0 && + $apps_to_dl_chunks[$i][$j]['filesize'] != filesize($apps_to_dl_chunks[$i][$j]['localtarget'])) + { + $app->log($this->log_prefix.' The filesize of the package "'. + $apps_to_dl_chunks[$i][$j]['name'].'" is wrong. Download failure?', LOGLEVEL_WARN); + } + } + } + + $app->log($this->log_prefix.'Processed '.$apps_in_repo. + ' apps from the repo. Downloaded '.$apps_updated. + ' updates, '.$apps_downloaded.' new apps'); + } + + catch(Exception $e) + { + $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR); + return false; + } + } + + + + /** + * Read in all possible packages from the interface packages folder and + * check if they are not ASP.net code (as this can't be processed). + * + * Note: There's no need to check if the packages to register are newer + * than those in the database because this already happended in startCrawler() + */ + public function parseFolderToDB() + { + global $app; + + try + { + // This method must be used in interface mode + if(!$this->interface_mode) return false; + + $pkg_list = array(); + + // Read in every package having a correct filename + $temp_handle = @dir($this->interface_pkg_dir); + if(!$temp_handle) throw new Exception('The temp directory is not accessible'); + while($folder = $temp_handle->read()) + if(substr($folder, -8) == '.app.zip') $pkg_list[] = $folder; + $temp_handle->close(); + + // If no packages are available -> exception (because at this point there should exist packages) + if(empty($pkg_list)) throw new Exception('No packages to read in'); + + // Get registered packages and mark non-existant packages with an error code to omit the install + $existing_packages = array(); + $path_query = $app->db->queryAllRecords('SELECT path AS Path FROM aps_packages;'); + foreach($path_query as $path) $existing_packages[] = $path['Path']; + $diff = array_diff($existing_packages, $pkg_list); + foreach($diff as $todelete) { + /*$app->db->query("UPDATE aps_packages SET package_status = '".PACKAGE_ERROR_NOMETA."' WHERE path = '".$app->db->quote($todelete)."';");*/ $tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE path = '".$app->db->quote($todelete)."';"); $app->db->datalogUpdate('aps_packages', "package_status = ".PACKAGE_ERROR_NOMETA, 'id', $tmp['id']); unset($tmp); } - - // Register all new packages - $new_packages = array_diff($pkg_list, $existing_packages); - foreach($new_packages as $pkg) - { - // Load in meta file if existing and register its namespaces - $metafile = $this->interface_pkg_dir.'/'.$pkg.'/APP-META.xml'; - if(!file_exists($metafile)) - { - $app->log($this->log_prefix.'Cannot read metadata from '.$pkg, LOGLEVEL_ERROR); - continue; - } - - $metadata = file_get_contents($metafile); - $metadata = str_replace("xmlns=", "ns=", $metadata); - $sxe = new SimpleXMLElement($metadata); - $namespaces = $sxe->getDocNamespaces(true); - foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); - - // Insert the new package - $pkg_name = parent::getXPathValue($sxe, 'name'); - $pkg_category = parent::getXPathValue($sxe, '//category'); - $pkg_version = parent::getXPathValue($sxe, 'version'); - $pkg_release = parent::getXPathValue($sxe, 'release'); + + // Register all new packages + $new_packages = array_diff($pkg_list, $existing_packages); + foreach($new_packages as $pkg) + { + // Load in meta file if existing and register its namespaces + $metafile = $this->interface_pkg_dir.'/'.$pkg.'/APP-META.xml'; + if(!file_exists($metafile)) + { + $app->log($this->log_prefix.'Cannot read metadata from '.$pkg, LOGLEVEL_ERROR); + continue; + } + + $metadata = file_get_contents($metafile); + $metadata = str_replace("xmlns=", "ns=", $metadata); + $sxe = new SimpleXMLElement($metadata); + $namespaces = $sxe->getDocNamespaces(true); + foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); + + // Insert the new package + $pkg_name = parent::getXPathValue($sxe, 'name'); + $pkg_category = parent::getXPathValue($sxe, '//category'); + $pkg_version = parent::getXPathValue($sxe, 'version'); + $pkg_release = parent::getXPathValue($sxe, 'release'); //$pkg_url = $this->app_download_url_list[$pkg]; $pkg_url = @file_get_contents($this->interface_pkg_dir.'/'.$pkg.'/PKG_URL'); - + /* - $app->db->query("INSERT INTO `aps_packages` - (`path`, `name`, `category`, `version`, `release`, `package_status`) VALUES + $app->db->query("INSERT INTO `aps_packages` + (`path`, `name`, `category`, `version`, `release`, `package_status`) VALUES ('".$app->db->quote($pkg)."', '".$app->db->quote($pkg_name)."', '".$app->db->quote($pkg_category)."', '".$app->db->quote($pkg_version)."', ".$app->db->quote($pkg_release).", ".PACKAGE_ENABLED.");"); */ // Insert only if data is complete if($pkg != '' && $pkg_name != '' && $pkg_category != '' && $pkg_version != '' && $pkg_release != '' && $pkg_url){ - $insert_data = "(`path`, `name`, `category`, `version`, `release`, `package_url`, `package_status`) VALUES + $insert_data = "(`path`, `name`, `category`, `version`, `release`, `package_url`, `package_status`) VALUES ('".$app->db->quote($pkg)."', '".$app->db->quote($pkg_name)."', '".$app->db->quote($pkg_category)."', '".$app->db->quote($pkg_version)."', ".$app->db->quote($pkg_release).", '".$app->db->quote($pkg_url)."', ".PACKAGE_ENABLED.");"; - + $app->db->datalogInsert('aps_packages', $insert_data, 'id'); } else { if(file_exists($this->interface_pkg_dir.'/'.$pkg)) $this->removeDirectory($this->interface_pkg_dir.'/'.$pkg); } - } - } - catch(Exception $e) - { - $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR); + } + } + + catch(Exception $e) + { + $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR); $app->error($e->getMessage()); - return false; - } - } - + return false; + } + } + + + /** - * Add missing package URLs to database - */ - public function fixURLs() - { - global $app; - - try - { - // This method must be used in interface mode - if(!$this->interface_mode) return false; - - $incomplete_pkgs = $app->db->queryAllRecords("SELECT * FROM aps_packages WHERE package_url = ''"); + * Add missing package URLs to database + */ + public function fixURLs() + { + global $app; + + try + { + // This method must be used in interface mode + if(!$this->interface_mode) return false; + + $incomplete_pkgs = $app->db->queryAllRecords("SELECT * FROM aps_packages WHERE package_url = ''"); if(is_array($incomplete_pkgs) && !empty($incomplete_pkgs)){ foreach($incomplete_pkgs as $incomplete_pkg){ $pkg_url = @file_get_contents($this->interface_pkg_dir.'/'.$incomplete_pkg['path'].'/PKG_URL'); @@ -580,13 +599,16 @@ class ApsCrawler extends ApsBase } } } - } - catch(Exception $e) - { - $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR); + } + + catch(Exception $e) + { + $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_ERROR); $app->error($e->getMessage()); - return false; - } - } + return false; + } + } + } -?> \ No newline at end of file + +?> diff --git a/interface/lib/classes/aps_guicontroller.inc.php b/interface/lib/classes/aps_guicontroller.inc.php index 453caef00..47f5bd25f 100644 --- a/interface/lib/classes/aps_guicontroller.inc.php +++ b/interface/lib/classes/aps_guicontroller.inc.php @@ -27,199 +27,215 @@ 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('aps_base.inc.php'); +require_once 'aps_base.inc.php'; class ApsGUIController extends ApsBase { - /** - * Constructor - * - * @param $app the application instance (db handle) - */ - public function __construct($app) - { - parent::__construct($app); - } - - /** - * Reads in a package metadata file and registers it's namespaces - * - * @param $filename the file to read - * @return $sxe a SimpleXMLElement handle - */ - private function readInMetaFile($filename) - { - $metadata = file_get_contents($filename); - $metadata = str_replace("xmlns=", "ns=", $metadata); - $sxe = new SimpleXMLElement($metadata); - $namespaces = $sxe->getDocNamespaces(true); - foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); - - return $sxe; - } - - /** - * Applies a RegEx pattern onto a location path in order to secure it against - * code injections and invalid input - * - * @param $location_unfiltered the file path to secure - * @return $location - */ - private function secureLocation($location_unfiltered) - { - // Filter invalid slashes from string - $location = preg_replace(array('#/+#', '#\.+#', '#\0+#', '#\\\\+#'), - array('/', '', '', '/'), - $location_unfiltered); - - // Remove a beginning or trailing slash - if(substr($location, -1) == '/') $location = substr($location, 0, strlen($location) - 1); - if(substr($location, 0, 1) == '/') $location = substr($location, 1); - - return $location; - } - - /** - * Gets the CustomerID (ClientID) which belongs to a specific domain - * - * @param $domain the domain - * @return $customerid - */ - private function getCustomerIDFromDomain($domain) - { - global $app; - $customerid = 0; - - $customerdata = $app->db->queryOneRecord("SELECT client_id FROM sys_group, web_domain - WHERE web_domain.sys_groupid = sys_group.groupid + /** + * Constructor + * + * @param $app the application instance (db handle) + */ + + + public function __construct($app) + { + parent::__construct($app); + } + + + + /** + * Reads in a package metadata file and registers it's namespaces + * + * @param $filename the file to read + * @return $sxe a SimpleXMLElement handle + */ + private function readInMetaFile($filename) + { + $metadata = file_get_contents($filename); + $metadata = str_replace("xmlns=", "ns=", $metadata); + $sxe = new SimpleXMLElement($metadata); + $namespaces = $sxe->getDocNamespaces(true); + foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); + + return $sxe; + } + + + + /** + * Applies a RegEx pattern onto a location path in order to secure it against + * code injections and invalid input + * + * @param $location_unfiltered the file path to secure + * @return $location + */ + private function secureLocation($location_unfiltered) + { + // Filter invalid slashes from string + $location = preg_replace(array('#/+#', '#\.+#', '#\0+#', '#\\\\+#'), + array('/', '', '', '/'), + $location_unfiltered); + + // Remove a beginning or trailing slash + if(substr($location, -1) == '/') $location = substr($location, 0, strlen($location) - 1); + if(substr($location, 0, 1) == '/') $location = substr($location, 1); + + return $location; + } + + + + /** + * Gets the CustomerID (ClientID) which belongs to a specific domain + * + * @param $domain the domain + * @return $customerid + */ + private function getCustomerIDFromDomain($domain) + { + global $app; + $customerid = 0; + + $customerdata = $app->db->queryOneRecord("SELECT client_id FROM sys_group, web_domain + WHERE web_domain.sys_groupid = sys_group.groupid AND web_domain.domain = '".$app->db->quote($domain)."';"); - if(!empty($customerdata)) $customerid = $customerdata['client_id']; - - return $customerid; - } - - /** - * Returns the server_id for an already installed instance. Is actually - * just a little helper method to avoid redundant code - * - * @param $instanceid the instance to process - * @return $webserver_id the server_id - */ - private function getInstanceDataForDatalog($instanceid) - { - global $app; - $webserver_id = ''; - - $websrv = $app->db->queryOneRecord("SELECT server_id FROM web_domain - WHERE domain = (SELECT value FROM aps_instances_settings + if(!empty($customerdata)) $customerid = $customerdata['client_id']; + + return $customerid; + } + + + + /** + * Returns the server_id for an already installed instance. Is actually + * just a little helper method to avoid redundant code + * + * @param $instanceid the instance to process + * @return $webserver_id the server_id + */ + private function getInstanceDataForDatalog($instanceid) + { + global $app; + $webserver_id = ''; + + $websrv = $app->db->queryOneRecord("SELECT server_id FROM web_domain + WHERE domain = (SELECT value FROM aps_instances_settings WHERE name = 'main_domain' AND instance_id = ".$app->db->quote($instanceid).");"); - // If $websrv is empty, an error has occured. Domain no longer existing? Settings table damaged? - // Anyhow, remove this instance record because it's not useful at all - if(empty($websrv)) - { - $app->db->query("DELETE FROM aps_instances WHERE id = ".$app->db->quote($instanceid).";"); - $app->db->query("DELETE FROM aps_instances_settings WHERE instance_id = ".$app->db->quote($instanceid).";"); - } - else $webserver_id = $websrv['server_id']; - - return $webserver_id; - } - - /** - * Finds out if there is a newer package version for - * a given (possibly valid) package ID - * - * @param $id the ID to check - * @return $newer_pkg_id the newer package ID - */ - public function getNewestPackageID($id) - { - global $app; - - if(preg_match('/^[0-9]+$/', $id) != 1) return 0; - - $result = $app->db->queryOneRecord("SELECT id, name, - CONCAT(version, '-', CAST(`release` AS CHAR)) AS current_version - FROM aps_packages - WHERE name = (SELECT name FROM aps_packages WHERE id = ".$app->db->quote($id).") + // If $websrv is empty, an error has occured. Domain no longer existing? Settings table damaged? + // Anyhow, remove this instance record because it's not useful at all + if(empty($websrv)) + { + $app->db->query("DELETE FROM aps_instances WHERE id = ".$app->db->quote($instanceid).";"); + $app->db->query("DELETE FROM aps_instances_settings WHERE instance_id = ".$app->db->quote($instanceid).";"); + } + else $webserver_id = $websrv['server_id']; + + return $webserver_id; + } + + + + /** + * Finds out if there is a newer package version for + * a given (possibly valid) package ID + * + * @param $id the ID to check + * @return $newer_pkg_id the newer package ID + */ + public function getNewestPackageID($id) + { + global $app; + + if(preg_match('/^[0-9]+$/', $id) != 1) return 0; + + $result = $app->db->queryOneRecord("SELECT id, name, + CONCAT(version, '-', CAST(`release` AS CHAR)) AS current_version + FROM aps_packages + WHERE name = (SELECT name FROM aps_packages WHERE id = ".$app->db->quote($id).") ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC"); - - if(!empty($result) && ($id != $result['id'])) return $result['id']; - - return 0; - } - - /** - * Validates a given package ID - * - * @param $id the ID to check - * @param $is_admin a flag to allow locked IDs too (for admin calls) - * @return boolean - */ - public function isValidPackageID($id, $is_admin = false) - { - global $app; - - if(preg_match('/^[0-9]+$/', $id) != 1) return false; - - $sql_ext = (!$is_admin) ? - 'package_status = '.PACKAGE_ENABLED.' AND' : - '(package_status = '.PACKAGE_ENABLED.' OR package_status = '.PACKAGE_LOCKED.') AND'; - - $result = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE ".$sql_ext." id = ".$app->db->quote($id).";"); - if(!$result) return false; - - return true; - } - - /** - * Validates a given instance ID - * - * @param $id the ID to check - * @param $client_id the calling client ID - * @param $is_admin a flag to ignore the client ID check for admins - * @return boolean - */ - public function isValidInstanceID($id, $client_id, $is_admin = false) - { - global $app; - - if(preg_match('/^[0-9]+$/', $id) != 1) return false; - - // Only filter if not admin - $sql_ext = (!$is_admin) ? 'customer_id = '.$app->db->quote($client_id).' AND' : ''; - - $result = $app->db->queryOneRecord('SELECT id FROM aps_instances WHERE '.$sql_ext.' id = '.$app->db->quote($id).';'); - if(!$result) return false; - - return true; - } - - /** - * Creates a new database record for the package instance and - * an install task - * - * @param $settings the settings to enter into the DB - * @param $packageid the PackageID - */ - public function createPackageInstance($settings, $packageid) - { + + if(!empty($result) && ($id != $result['id'])) return $result['id']; + + return 0; + } + + /** + * Validates a given package ID + * + * @param $id the ID to check + * @param $is_admin a flag to allow locked IDs too (for admin calls) + * @return boolean + */ + public function isValidPackageID($id, $is_admin = false) + { global $app; - + + if(preg_match('/^[0-9]+$/', $id) != 1) return false; + + $sql_ext = (!$is_admin) ? + 'package_status = '.PACKAGE_ENABLED.' AND' : + '(package_status = '.PACKAGE_ENABLED.' OR package_status = '.PACKAGE_LOCKED.') AND'; + + $result = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE ".$sql_ext." id = ".$app->db->quote($id).";"); + if(!$result) return false; + + return true; + } + + + + /** + * Validates a given instance ID + * + * @param $id the ID to check + * @param $client_id the calling client ID + * @param $is_admin a flag to ignore the client ID check for admins + * @return boolean + */ + public function isValidInstanceID($id, $client_id, $is_admin = false) + { + global $app; + + if(preg_match('/^[0-9]+$/', $id) != 1) return false; + + // Only filter if not admin + $sql_ext = (!$is_admin) ? 'customer_id = '.$app->db->quote($client_id).' AND' : ''; + + $result = $app->db->queryOneRecord('SELECT id FROM aps_instances WHERE '.$sql_ext.' id = '.$app->db->quote($id).';'); + if(!$result) return false; + + return true; + } + + + + /** + * Creates a new database record for the package instance and + * an install task + * + * @param $settings the settings to enter into the DB + * @param $packageid the PackageID + */ + public function createPackageInstance($settings, $packageid) + { + global $app; + $app->uses('tools_sites'); - + $webserver_id = 0; - $websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$app->db->quote($settings['main_domain'])."';"); - if(!empty($websrv)) $webserver_id = $websrv['server_id']; - $customerid = $this->getCustomerIDFromDomain($settings['main_domain']); - - if(empty($settings) || empty($webserver_id)) return false; - + $websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$app->db->quote($settings['main_domain'])."';"); + if(!empty($websrv)) $webserver_id = $websrv['server_id']; + $customerid = $this->getCustomerIDFromDomain($settings['main_domain']); + + if(empty($settings) || empty($webserver_id)) return false; + //* Get server config of the web server $app->uses("getconf"); - $web_config = $app->getconf->get_server_config($app->functions->intval($websrv["server_id"]),'web'); - + $web_config = $app->getconf->get_server_config($app->functions->intval($websrv["server_id"]), 'web'); + //* Set PHP mode to php-fcgi and enable suexec in website on apache servers / set PHP mode to PHP-FPM on nginx servers if($web_config['server_type'] == 'apache') { if(($websrv['php'] != 'fast-cgi' || $websrv['suexec'] != 'y') && $websrv['php'] != 'php-fpm') { @@ -231,59 +247,59 @@ class ApsGUIController extends ApsBase $app->db->datalogUpdate('web_domain', "php = 'php-fpm'", 'domain_id', $websrv['domain_id']); } } - - + + //* Create the MySQL database for the application $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = '.$app->db->quote($packageid).';'); $metafile = $this->interface_pkg_dir.'/'.$pkg['path'].'/APP-META.xml'; $sxe = $this->readInMetaFile($metafile); - + $db_id = parent::getXPathValue($sxe, '//db:id'); if (!empty($db_id)) { $global_config = $app->getconf->get_global_config('sites'); - + $tmp = array(); $tmp['parent_domain_id'] = $websrv['domain_id']; $tmp['sys_groupid'] = $websrv['sys_groupid']; $dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $tmp); $dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $tmp); unset($tmp); - - // get information if the webserver is a db server, too - $web_server = $app->db->queryOneRecord("SELECT server_id,server_name,db_server FROM server WHERE server_id = ".$websrv['server_id']); - if($web_server['db_server'] == 1) { - // create database on "localhost" (webserver) + + // get information if the webserver is a db server, too + $web_server = $app->db->queryOneRecord("SELECT server_id,server_name,db_server FROM server WHERE server_id = ".$websrv['server_id']); + if($web_server['db_server'] == 1) { + // create database on "localhost" (webserver) $mysql_db_server_id = $websrv['server_id']; $mysql_db_host = 'localhost'; $mysql_db_remote_access = 'n'; $mysql_db_remote_ips = ''; - } else { - //* get the default database server of the client - $client = $app->db->queryOneRecord("SELECT default_dbserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$websrv['sys_groupid']); - if(is_array($client) && $client['default_dbserver'] > 0 && $client['default_dbserver'] != $websrv['server_id']) { - $mysql_db_server_id = $client['default_dbserver']; - $dbserver_config = $web_config = $app->getconf->get_server_config($app->functions->intval($mysql_db_server_id),'server'); - $mysql_db_host = $dbserver_config['ip_address']; - $mysql_db_remote_access = 'y'; - $webserver_config = $app->getconf->get_server_config($app->functions->intval($websrv['server_id']),'server'); - $mysql_db_remote_ips = $webserver_config['ip_address']; - } else { - /* I left this in place for a fallback that should NEVER! happen. + } else { + //* get the default database server of the client + $client = $app->db->queryOneRecord("SELECT default_dbserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$websrv['sys_groupid']); + if(is_array($client) && $client['default_dbserver'] > 0 && $client['default_dbserver'] != $websrv['server_id']) { + $mysql_db_server_id = $client['default_dbserver']; + $dbserver_config = $web_config = $app->getconf->get_server_config($app->functions->intval($mysql_db_server_id), 'server'); + $mysql_db_host = $dbserver_config['ip_address']; + $mysql_db_remote_access = 'y'; + $webserver_config = $app->getconf->get_server_config($app->functions->intval($websrv['server_id']), 'server'); + $mysql_db_remote_ips = $webserver_config['ip_address']; + } else { + /* I left this in place for a fallback that should NEVER! happen. * if we reach this point it means that there is NO default db server for the client * AND the webserver has NO db service enabled. * We have to abort the aps installation here... so I added a return false * although this does not present any error message to the user. */ - return false; - - /*$mysql_db_server_id = $websrv['server_id']; + return false; + + /*$mysql_db_server_id = $websrv['server_id']; $mysql_db_host = 'localhost'; $mysql_db_remote_access = 'n'; $mysql_db_remote_ips = '';*/ - } - } - - //* Find a free db name for the app + } + } + + //* Find a free db name for the app for($n = 1; $n <= 1000; $n++) { $mysql_db_name = ($dbname_prefix != '' ? $dbname_prefix.'aps'.$n : uniqid('aps')); $tmp = $app->db->queryOneRecord("SELECT count(database_id) as number FROM web_database WHERE database_name = '".$app->db->quote($mysql_db_name)."'"); @@ -295,30 +311,30 @@ class ApsGUIController extends ApsBase $tmp = $app->db->queryOneRecord("SELECT count(database_user_id) as number FROM web_database_user WHERE database_user = '".$app->db->quote($mysql_db_user)."'"); if($tmp['number'] == 0) break; } - + $mysql_db_password = $settings['main_database_password']; - + //* Create the mysql database user - $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `database_user`, `database_user_prefix`, `database_password`) + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `database_user`, `database_user_prefix`, `database_password`) VALUES( ".$websrv['sys_userid'].", ".$websrv['sys_groupid'].", 'riud', '".$websrv['sys_perm_group']."', '', 0, '$mysql_db_user', '".$app->db->quote($dbuser_prefix) . "', PASSWORD('$mysql_db_password'))"; $mysql_db_user_id = $app->db->datalogInsert('web_database_user', $insert_data, 'database_user_id'); - + //* Create the mysql database - $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `parent_domain_id`, `type`, `database_name`, `database_name_prefix`, `database_user_id`, `database_ro_user_id`, `database_charset`, `remote_access`, `remote_ips`, `backup_copies`, `active`, `backup_interval`) + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `parent_domain_id`, `type`, `database_name`, `database_name_prefix`, `database_user_id`, `database_ro_user_id`, `database_charset`, `remote_access`, `remote_ips`, `backup_copies`, `active`, `backup_interval`) VALUES( ".$websrv['sys_userid'].", ".$websrv['sys_groupid'].", 'riud', '".$websrv['sys_perm_group']."', '', $mysql_db_server_id, ".$websrv['domain_id'].", 'mysql', '$mysql_db_name', '" . $app->db->quote($dbname_prefix) . "', '$mysql_db_user_id', 0, '', '$mysql_db_remote_access', '$mysql_db_remote_ips', ".$websrv['backup_copies'].", 'y', '".$websrv['backup_interval']."')"; $app->db->datalogInsert('web_database', $insert_data, 'database_id'); - + //* Add db details to package settings $settings['main_database_host'] = $mysql_db_host; $settings['main_database_name'] = $mysql_db_name; $settings['main_database_login'] = $mysql_db_user; - + } - + //* Insert new package instance $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `customer_id`, `package_id`, `instance_status`) VALUES (".$websrv['sys_userid'].", ".$websrv['sys_groupid'].", 'riud', '".$websrv['sys_perm_group']."', '', ".$app->db->quote($webserver_id).",".$app->db->quote($customerid).", ".$app->db->quote($packageid).", ".INSTANCE_PENDING.")"; $InstanceID = $app->db->datalogInsert('aps_instances', $insert_data, 'id'); - + //* Insert all package settings if(is_array($settings)) { foreach($settings as $key => $value) { @@ -326,520 +342,530 @@ class ApsGUIController extends ApsBase $app->db->datalogInsert('aps_instances_settings', $insert_data, 'id'); } } - + //* Set package status to install afetr we inserted the settings $app->db->datalogUpdate('aps_instances', "instance_status = ".INSTANCE_INSTALL, 'id', $InstanceID); - } - - /** - * Sets the status of an instance to "should be removed" and creates a - * datalog entry to give the ISPConfig server a real removal advice - * - * @param $instanceid the instance to delete - */ - public function deleteInstance($instanceid) - { - global $app; + } + + + + /** + * Sets the status of an instance to "should be removed" and creates a + * datalog entry to give the ISPConfig server a real removal advice + * + * @param $instanceid the instance to delete + */ + public function deleteInstance($instanceid) + { + global $app; /* $app->db->query("UPDATE aps_instances SET instance_status = ".INSTANCE_REMOVE." WHERE id = ".$instanceid.";"); - + $webserver_id = $this->getInstanceDataForDatalog($instanceid); if($webserver_id == '') return; - + // Create a sys_datalog entry for deletion $datalog = array('Instance_id' => $instanceid, 'server_id' => $webserver_id); $app->db->datalogSave('aps', 'DELETE', 'id', $instanceid, array(), $datalog); */ - + $sql = "SELECT web_database.database_id as database_id, web_database.database_user_id as `database_user_id` FROM aps_instances_settings, web_database WHERE aps_instances_settings.value = web_database.database_name AND aps_instances_settings.name = 'main_database_name' AND aps_instances_settings.instance_id = ".$instanceid." LIMIT 0,1"; $tmp = $app->db->queryOneRecord($sql); if($tmp['database_id'] > 0) $app->db->datalogDelete('web_database', 'database_id', $tmp['database_id']); - - $database_user = $tmp['database_user_id']; - $tmp = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `database_user_id` = '" . $app->functions->intval($database_user) . "' OR `database_ro_user_id` = '" . $app->functions->intval($database_user) . "'"); - if($tmp['cnt'] < 1) $app->db->datalogDelete('web_database_user', 'database_user_id', $database_user); - + + $database_user = $tmp['database_user_id']; + $tmp = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `database_user_id` = '" . $app->functions->intval($database_user) . "' OR `database_ro_user_id` = '" . $app->functions->intval($database_user) . "'"); + if($tmp['cnt'] < 1) $app->db->datalogDelete('web_database_user', 'database_user_id', $database_user); + $app->db->datalogUpdate('aps_instances', "instance_status = ".INSTANCE_REMOVE, 'id', $instanceid); - } - - /** - * Sets the status of an instance to "installation planned" and creates a - * datalog entry to re-install the package. The existing package is simply overwritten. - * - * @param $instanceid the instance to delete - */ - public function reinstallInstance($instanceid) - { - global $app; - - /* + } + + + + /** + * Sets the status of an instance to "installation planned" and creates a + * datalog entry to re-install the package. The existing package is simply overwritten. + * + * @param $instanceid the instance to delete + */ + public function reinstallInstance($instanceid) + { + global $app; + + /* $app->db->query("UPDATE aps_instances SET instance_status = ".INSTANCE_INSTALL." WHERE id = ".$instanceid.";"); - + $webserver_id = $this->getInstanceDataForDatalog($instanceid); if($webserver_id == '') return; - + // Create a sys_datalog entry for re-installation $datalog = array('instance_id' => $instanceid, 'server_id' => $webserver_id); $app->db->datalogSave('aps', 'INSERT', 'id', $instanceid, array(), $datalog); */ - + $sql = "SELECT web_database.database_id as database_id FROM aps_instances_settings, web_database WHERE aps_instances_settings.value = web_database.database_name AND aps_instances_settings.value = aps_instances_settings.name = 'main_database_name' AND aps_instances_settings.instance_id = ".$instanceid." LIMIT 0,1"; $tmp = $app->db->queryOneRecord($sql); if($tmp['database_id'] > 0) $app->db->datalogDelete('web_database', 'database_id', $tmp['database_id']); - + $app->db->datalogUpdate('aps_instances', "instance_status = ".INSTANCE_INSTALL, 'id', $instanceid); - } - - /** - * Read the settings to be filled when installing - * - * @param $id the internal ID of the package - * @return array - */ - public function getPackageSettings($id) - { - global $app; - - $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = '.$app->db->quote($id).';'); - - // Load in meta file if existing and register its namespaces - $metafile = $this->interface_pkg_dir.'/'.$pkg['path'].'/APP-META.xml'; - if(!file_exists($metafile)) - return array('error' => 'The metafile for '.$settings['Name'].' couldn\'t be found'); - - $sxe = $this->readInMetaFile($metafile); - - $groupsettings = parent::getXPathValue($sxe, '//settings/group/setting', true); - if(empty($groupsettings)) return array(); - - $settings = array(); - foreach($groupsettings as $setting) - { - $setting_id = strval($setting['id']); - - if($setting['type'] == 'string' || $setting['type'] == 'email' || $setting['type'] == 'integer' - || $setting['type'] == 'float' || $setting['type'] == 'domain-name') - { - $settings[] = array('SettingID' => $setting_id, - 'SettingName' => $setting->name, - 'SettingDescription' => $setting->description, - 'SettingType' => $setting['type'], - 'SettingInputType' => 'string', - 'SettingDefaultValue' => strval($setting['default-value']), - 'SettingRegex' => $setting['regex'], - 'SettingMinLength' => $setting['min-length'], - 'SettingMaxLength' => $setting['max-length']); - } - else if($setting['type'] == 'password') - { - $settings[] = array('SettingID' => $setting_id, - 'SettingName' => $setting->name, - 'SettingDescription' => $setting->description, - 'SettingType' => 'password', - 'SettingInputType' => 'password', - 'SettingDefaultValue' => '', - 'SettingRegex' => $setting['regex'], - 'SettingMinLength' => $setting['min-length'], - 'SettingMaxLength' => $setting['max-length']); - } - else if($setting['type'] == 'boolean') - { - $settings[] = array('SettingID' => $setting_id, - 'SettingName' => $setting->name, - 'SettingDescription' => $setting->description, - 'SettingType' => 'boolean', - 'SettingInputType' => 'checkbox', - 'SettingDefaultValue' => strval($setting['default-value'])); - } - else if($setting['type'] == 'enum') - { - $choices = array(); - foreach($setting->choice as $choice) - { - $choices[] = array('EnumID' => strval($choice['id']), - 'EnumName' => $choice->name); - } - $settings[] = array('SettingID' => $setting_id, - 'SettingName' => $setting->name, - 'SettingDescription' => $setting->description, - 'SettingType' => 'enum', - 'SettingInputType' => 'select', - 'SettingDefaultValue' => strval($setting['default-value']), - 'SettingChoices' => $choices); - } - } - - return $settings; - } - - /** - * Validates the user input according to the settings array and - * delivers errors if occurring - * - * @param $input the user $_POST array - * @param $pkg_details the package details - * @param $settings the package settings array - * @return array in this structure: - * array(2) { - * ["input"]=> ... - * ["errors"]=> ... - * } - */ - public function validateInstallerInput($postinput, $pkg_details, $domains, $settings = array()) - { - global $app; - - $ret = array(); - $input = array(); - $error = array(); - - // Main domain (obligatory) - if(isset($postinput['main_domain'])) - { - if(!in_array($postinput['main_domain'], $domains)) $error[] = $app->lng('error_main_domain'); - else $input['main_domain'] = $postinput['main_domain']; - } - else $error[] = $app->lng('error_main_domain'); - - // Main location (not obligatory but must be supplied) - if(isset($postinput['main_location'])) - { - $temp_errstr = ''; - // It can be empty but if the user did write something, check it - $userinput = false; - if(strlen($postinput['main_location']) > 0) $userinput = true; - - // Filter invalid input slashes (twice!) - $main_location = $this->secureLocation($postinput['main_location']); - $main_location = $this->secureLocation($main_location); - // Only allow digits, words, / and - - $main_location = preg_replace("/[^\d\w\/\-]/i", "", $main_location); - if($userinput && (strlen($main_location) == 0)) $temp_errstr = $app->lng('error_inv_main_location'); - - // Find out document_root and make sure no apps are installed twice to one location - if(in_array($postinput['main_domain'], $domains)) - { - $docroot = $app->db->queryOneRecord("SELECT document_root FROM web_domain + } + + /** + * Read the settings to be filled when installing + * + * @param $id the internal ID of the package + * @return array + */ + public function getPackageSettings($id) + { + global $app; + + $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = '.$app->db->quote($id).';'); + + // Load in meta file if existing and register its namespaces + $metafile = $this->interface_pkg_dir.'/'.$pkg['path'].'/APP-META.xml'; + if(!file_exists($metafile)) + return array('error' => 'The metafile for '.$settings['Name'].' couldn\'t be found'); + + $sxe = $this->readInMetaFile($metafile); + + $groupsettings = parent::getXPathValue($sxe, '//settings/group/setting', true); + if(empty($groupsettings)) return array(); + + $settings = array(); + foreach($groupsettings as $setting) + { + $setting_id = strval($setting['id']); + + if($setting['type'] == 'string' || $setting['type'] == 'email' || $setting['type'] == 'integer' + || $setting['type'] == 'float' || $setting['type'] == 'domain-name') + { + $settings[] = array('SettingID' => $setting_id, + 'SettingName' => $setting->name, + 'SettingDescription' => $setting->description, + 'SettingType' => $setting['type'], + 'SettingInputType' => 'string', + 'SettingDefaultValue' => strval($setting['default-value']), + 'SettingRegex' => $setting['regex'], + 'SettingMinLength' => $setting['min-length'], + 'SettingMaxLength' => $setting['max-length']); + } + else if($setting['type'] == 'password') + { + $settings[] = array('SettingID' => $setting_id, + 'SettingName' => $setting->name, + 'SettingDescription' => $setting->description, + 'SettingType' => 'password', + 'SettingInputType' => 'password', + 'SettingDefaultValue' => '', + 'SettingRegex' => $setting['regex'], + 'SettingMinLength' => $setting['min-length'], + 'SettingMaxLength' => $setting['max-length']); + } + else if($setting['type'] == 'boolean') + { + $settings[] = array('SettingID' => $setting_id, + 'SettingName' => $setting->name, + 'SettingDescription' => $setting->description, + 'SettingType' => 'boolean', + 'SettingInputType' => 'checkbox', + 'SettingDefaultValue' => strval($setting['default-value'])); + } + else if($setting['type'] == 'enum') + { + $choices = array(); + foreach($setting->choice as $choice) + { + $choices[] = array('EnumID' => strval($choice['id']), + 'EnumName' => $choice->name); + } + $settings[] = array('SettingID' => $setting_id, + 'SettingName' => $setting->name, + 'SettingDescription' => $setting->description, + 'SettingType' => 'enum', + 'SettingInputType' => 'select', + 'SettingDefaultValue' => strval($setting['default-value']), + 'SettingChoices' => $choices); + } + } + + return $settings; + } + + + + /** + * Validates the user input according to the settings array and + * delivers errors if occurring + * + * @param $input the user $_POST array + * @param $pkg_details the package details + * @param $settings the package settings array + * @return array in this structure: + * array(2) { + * ["input"]=> ... + * ["errors"]=> ... + * } + */ + public function validateInstallerInput($postinput, $pkg_details, $domains, $settings = array()) + { + global $app; + + $ret = array(); + $input = array(); + $error = array(); + + // Main domain (obligatory) + if(isset($postinput['main_domain'])) + { + if(!in_array($postinput['main_domain'], $domains)) $error[] = $app->lng('error_main_domain'); + else $input['main_domain'] = $postinput['main_domain']; + } + else $error[] = $app->lng('error_main_domain'); + + // Main location (not obligatory but must be supplied) + if(isset($postinput['main_location'])) + { + $temp_errstr = ''; + // It can be empty but if the user did write something, check it + $userinput = false; + if(strlen($postinput['main_location']) > 0) $userinput = true; + + // Filter invalid input slashes (twice!) + $main_location = $this->secureLocation($postinput['main_location']); + $main_location = $this->secureLocation($main_location); + // Only allow digits, words, / and - + $main_location = preg_replace("/[^\d\w\/\-]/i", "", $main_location); + if($userinput && (strlen($main_location) == 0)) $temp_errstr = $app->lng('error_inv_main_location'); + + // Find out document_root and make sure no apps are installed twice to one location + if(in_array($postinput['main_domain'], $domains)) + { + $docroot = $app->db->queryOneRecord("SELECT document_root FROM web_domain WHERE domain = '".$app->db->quote($postinput['main_domain'])."';"); - $new_path = $docroot['document_root']; - if(substr($new_path, -1) != '/') $new_path .= '/'; - $new_path .= $main_location; - - // Get the $customerid which belongs to the selected domain - $customerid = $this->getCustomerIDFromDomain($postinput['main_domain']); - - // First get all domains used for an install, then their loop them - // and get the corresponding document roots as well as the defined - // locations. If an existing doc_root + location matches with the - // new one -> error - $instance_domains = $app->db->queryAllRecords("SELECT instance_id, s.value AS domain - FROM aps_instances AS i, aps_instances_settings AS s - WHERE i.id = s.instance_id AND s.name = 'main_domain' + $new_path = $docroot['document_root']; + if(substr($new_path, -1) != '/') $new_path .= '/'; + $new_path .= $main_location; + + // Get the $customerid which belongs to the selected domain + $customerid = $this->getCustomerIDFromDomain($postinput['main_domain']); + + // First get all domains used for an install, then their loop them + // and get the corresponding document roots as well as the defined + // locations. If an existing doc_root + location matches with the + // new one -> error + $instance_domains = $app->db->queryAllRecords("SELECT instance_id, s.value AS domain + FROM aps_instances AS i, aps_instances_settings AS s + WHERE i.id = s.instance_id AND s.name = 'main_domain' AND i.customer_id = '".$app->db->quote($customerid)."';"); - for($i = 0; $i < count($instance_domains); $i++) - { - $used_path = ''; - - $doc_root = $app->db->queryOneRecord("SELECT document_root FROM web_domain + for($i = 0; $i < count($instance_domains); $i++) + { + $used_path = ''; + + $doc_root = $app->db->queryOneRecord("SELECT document_root FROM web_domain WHERE domain = '".$app->db->quote($instance_domains[$i]['domain'])."';"); - // Probably the domain settings were changed later, so make sure the doc_root - // is not empty for further validation - if(!empty($doc_root)) - { - $used_path = $doc_root['document_root']; - if(substr($used_path, -1) != '/') $used_path .= '/'; - - $location_for_domain = $app->db->queryOneRecord("SELECT value - FROM aps_instances_settings WHERE name = 'main_location' + // Probably the domain settings were changed later, so make sure the doc_root + // is not empty for further validation + if(!empty($doc_root)) + { + $used_path = $doc_root['document_root']; + if(substr($used_path, -1) != '/') $used_path .= '/'; + + $location_for_domain = $app->db->queryOneRecord("SELECT value + FROM aps_instances_settings WHERE name = 'main_location' AND instance_id = '".$app->db->quote($instance_domains[$i]['instance_id'])."';"); - - // The location might be empty but the DB return must not be false! - if($location_for_domain) $used_path .= $location_for_domain['value']; - - if($new_path == $used_path) - { - $temp_errstr = $app->lng('error_used_location'); - break; - } - } - } - } - else $temp_errstr = $app->lng('error_main_domain'); - - if($temp_errstr == '') $input['main_location'] = htmlspecialchars($main_location); - else $error[] = $temp_errstr; - } - else $error[] = $app->lng('error_no_main_location'); - - // License (the checkbox must be set) - if(isset($pkg_details['License need agree']) - && $pkg_details['License need agree'] == 'true') - { - if(isset($postinput['license']) && $postinput['license'] == 'on') $input['license'] = 'true'; - else $error[] = $app->lng('error_license_agreement'); - } - - // Database - if(isset($pkg_details['Requirements Database']) - && $pkg_details['Requirements Database'] != '') - { - if(isset($postinput['main_database_password'])) - { - if($postinput['main_database_password'] == '') $error[] = $app->lng('error_no_database_pw'); - else if(strlen($postinput['main_database_password']) > 8) - $input['main_database_password'] = htmlspecialchars($postinput['main_database_password']); - else $error[] = $app->lng('error_short_database_pw'); - } - else $error[] = $app->lng('error_no_database_pw'); - } - - // Validate the package settings - foreach($settings as $setting) - { - $temp_errstr = ''; - $setting_id = strval($setting['SettingID']); - - // We assume that every setting must be set - if((isset($postinput[$setting_id]) && ($postinput[$setting_id] != '')) - || ($setting['SettingType'] == 'boolean')) - { - if($setting['SettingType'] == 'string' || $setting['SettingType'] == 'password') - { - if($app->functions->intval($setting['SettingMinLength'], true) != 0 - && strlen($postinput[$setting_id]) < $app->functions->intval($setting['SettingMinLength'], true)) - $temp_errstr = sprintf($app->lng('error_short_value_for'), $setting['setting_name']); - - if($app->functions->intval($setting['SettingMaxLength'], true) != 0 - && strlen($postinput[$setting_id]) > $app->functions->intval($setting['SettingMaxLength'], true)) - $temp_errstr = sprintf($app->lng('error_long_value_for'), $setting['setting_name']); - - if(isset($setting['SettingRegex']) - && !preg_match("/".$setting['SettingRegex']."/", $postinput[$setting_id])) - $temp_errstr = sprintf($app->lng('error_inv_value_for'), $setting['setting_name']); - } - else if($setting['SettingType'] == 'email') - { - if(filter_var(strtolower($postinput[$setting_id]), FILTER_VALIDATE_EMAIL) === false) - $temp_errstr = sprintf($app->lng('error_inv_email_for'), $setting['setting_name']); - } - else if($setting['SettingType'] == 'domain-name') - { - if(!preg_match("^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$", - $postinput[$setting_id])) - $temp_errstr = sprintf($app->lng('error_inv_domain_for'), $setting['setting_name']); - } - else if($setting['SettingType'] == 'integer') - { - if(filter_var($postinput[$setting_id], FILTER_VALIDATE_INT) === false) - $temp_errstr = sprintf($app->lng('error_inv_integer_for'), $setting['setting_name']); - } - else if($setting['SettingType'] == 'float') - { - if(filter_var($postinput[$setting_id], FILTER_VALIDATE_FLOAT) === false) - $temp_errstr = sprintf($app->lng('error_inv_float_for'), $setting['setting_name']); - } - else if($setting['SettingType'] == 'boolean') - { - // If we have a boolean value set, it must be either true or false - if(!isset($postinput[$setting_id])) $postinput[$setting_id] = 'false'; - else if(isset($postinput[$setting_id]) && $postinput[$setting_id] != 'true') - $postinput[$setting_id] = 'true'; - } - else if($setting['SettingType'] == 'enum') - { - $found = false; - for($i = 0; $i < count($setting['SettingChoices']); $i++) - { - if($setting['SettingChoices'][$i]['EnumID'] == $postinput[$setting_id]) - $found = true; - } - if(!$found) $temp_errstr = sprintf($app->lng('error_inv_value_for'), $setting['SettingName']); - } - - if($temp_errstr == '') $input[$setting_id] = $postinput[$setting_id]; - else $error[] = $temp_errstr; - } - else $error[] = sprintf($app->lng('error_no_value_for'), $setting['SettingName']); - } - - $ret['input'] = $input; - $ret['error'] = array_unique($error); - - return $ret; - } - - /** - * Read the metadata of a package and returns some content - * - * @param $id the internal ID of the package - * @return array - */ - public function getPackageDetails($id) - { - global $app; - - $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = '.$app->db->quote($id).';'); - - // Load in meta file if existing and register its namespaces - $metafile = $this->interface_pkg_dir.'/'.$pkg['path'].'/APP-META.xml'; - if(!file_exists($metafile)) - return array('error' => 'The metafile for '.$pkg['name'].' couldn\'t be found'); - - $metadata = file_get_contents($metafile); - $metadata = str_replace("xmlns=", "ns=", $metadata); - $sxe = new SimpleXMLElement($metadata); - $namespaces = $sxe->getDocNamespaces(true); - foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); - - $pkg['Summary'] = htmlspecialchars(parent::getXPathValue($sxe, '//summary')); - $pkg['Homepage'] = parent::getXPathValue($sxe, '//homepage'); - $pkg['Description'] = nl2br(htmlspecialchars(trim(parent::getXPathValue($sxe, '//description')))); - $pkg['Config script'] = strtoupper(parent::getXPathValue($sxe, '//configuration-script-language')); - $installed_size = parent::getXPathValue($sxe, '//installed-size'); - $pkg['Installed Size'] = (!empty($installed_size)) ? parent::convertSize((int)$installed_size) : ''; - - // License - $pkg['License need agree'] = parent::getXPathValue($sxe, '//license/@must-accept'); - $pkg['License name'] = parent::getXPathValue($sxe, '//license/text/name'); // might be empty - $pkg['License type'] = 'file'; // default type - $pkg['License content'] = ''; // default license filename on local system - $license_url = parent::getXPathValue($sxe, '//license/text/url'); - if(!empty($license_url)) - { - $pkg['License type'] = 'url'; - $pkg['License content'] = htmlspecialchars($license_url); - } - else - { - $lic = @file_get_contents($this->interface_pkg_dir.'/'.$pkg['path'].'/LICENSE'); - $pkg['License content'] = htmlentities($lic, ENT_QUOTES, 'ISO-8859-1'); - } - - // Languages - $languages = parent::getXPathValue($sxe, '//languages/language', true); - $pkg['Languages'] = (is_array($languages)) ? implode(' ', $languages) : ''; - - // Icon - $icon = parent::getXPathValue($sxe, '//icon/@path'); - if(!empty($icon)) - { - // Using parse_url() to filter malformed URLs - $path = dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH)).'/'. - basename($this->interface_pkg_dir).'/'.$pkg['path'].'/'.basename((string)$icon); + + // The location might be empty but the DB return must not be false! + if($location_for_domain) $used_path .= $location_for_domain['value']; + + if($new_path == $used_path) + { + $temp_errstr = $app->lng('error_used_location'); + break; + } + } + } + } + else $temp_errstr = $app->lng('error_main_domain'); + + if($temp_errstr == '') $input['main_location'] = htmlspecialchars($main_location); + else $error[] = $temp_errstr; + } + else $error[] = $app->lng('error_no_main_location'); + + // License (the checkbox must be set) + if(isset($pkg_details['License need agree']) + && $pkg_details['License need agree'] == 'true') + { + if(isset($postinput['license']) && $postinput['license'] == 'on') $input['license'] = 'true'; + else $error[] = $app->lng('error_license_agreement'); + } + + // Database + if(isset($pkg_details['Requirements Database']) + && $pkg_details['Requirements Database'] != '') + { + if(isset($postinput['main_database_password'])) + { + if($postinput['main_database_password'] == '') $error[] = $app->lng('error_no_database_pw'); + else if(strlen($postinput['main_database_password']) > 8) + $input['main_database_password'] = htmlspecialchars($postinput['main_database_password']); + else $error[] = $app->lng('error_short_database_pw'); + } + else $error[] = $app->lng('error_no_database_pw'); + } + + // Validate the package settings + foreach($settings as $setting) + { + $temp_errstr = ''; + $setting_id = strval($setting['SettingID']); + + // We assume that every setting must be set + if((isset($postinput[$setting_id]) && ($postinput[$setting_id] != '')) + || ($setting['SettingType'] == 'boolean')) + { + if($setting['SettingType'] == 'string' || $setting['SettingType'] == 'password') + { + if($app->functions->intval($setting['SettingMinLength'], true) != 0 + && strlen($postinput[$setting_id]) < $app->functions->intval($setting['SettingMinLength'], true)) + $temp_errstr = sprintf($app->lng('error_short_value_for'), $setting['setting_name']); + + if($app->functions->intval($setting['SettingMaxLength'], true) != 0 + && strlen($postinput[$setting_id]) > $app->functions->intval($setting['SettingMaxLength'], true)) + $temp_errstr = sprintf($app->lng('error_long_value_for'), $setting['setting_name']); + + if(isset($setting['SettingRegex']) + && !preg_match("/".$setting['SettingRegex']."/", $postinput[$setting_id])) + $temp_errstr = sprintf($app->lng('error_inv_value_for'), $setting['setting_name']); + } + else if($setting['SettingType'] == 'email') + { + if(filter_var(strtolower($postinput[$setting_id]), FILTER_VALIDATE_EMAIL) === false) + $temp_errstr = sprintf($app->lng('error_inv_email_for'), $setting['setting_name']); + } + else if($setting['SettingType'] == 'domain-name') + { + if(!preg_match("^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$", + $postinput[$setting_id])) + $temp_errstr = sprintf($app->lng('error_inv_domain_for'), $setting['setting_name']); + } + else if($setting['SettingType'] == 'integer') + { + if(filter_var($postinput[$setting_id], FILTER_VALIDATE_INT) === false) + $temp_errstr = sprintf($app->lng('error_inv_integer_for'), $setting['setting_name']); + } + else if($setting['SettingType'] == 'float') + { + if(filter_var($postinput[$setting_id], FILTER_VALIDATE_FLOAT) === false) + $temp_errstr = sprintf($app->lng('error_inv_float_for'), $setting['setting_name']); + } + else if($setting['SettingType'] == 'boolean') + { + // If we have a boolean value set, it must be either true or false + if(!isset($postinput[$setting_id])) $postinput[$setting_id] = 'false'; + else if(isset($postinput[$setting_id]) && $postinput[$setting_id] != 'true') + $postinput[$setting_id] = 'true'; + } + else if($setting['SettingType'] == 'enum') + { + $found = false; + for($i = 0; $i < count($setting['SettingChoices']); $i++) + { + if($setting['SettingChoices'][$i]['EnumID'] == $postinput[$setting_id]) + $found = true; + } + if(!$found) $temp_errstr = sprintf($app->lng('error_inv_value_for'), $setting['SettingName']); + } + + if($temp_errstr == '') $input[$setting_id] = $postinput[$setting_id]; + else $error[] = $temp_errstr; + } + else $error[] = sprintf($app->lng('error_no_value_for'), $setting['SettingName']); + } + + $ret['input'] = $input; + $ret['error'] = array_unique($error); + + return $ret; + } + + + + /** + * Read the metadata of a package and returns some content + * + * @param $id the internal ID of the package + * @return array + */ + public function getPackageDetails($id) + { + global $app; + + $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = '.$app->db->quote($id).';'); + + // Load in meta file if existing and register its namespaces + $metafile = $this->interface_pkg_dir.'/'.$pkg['path'].'/APP-META.xml'; + if(!file_exists($metafile)) + return array('error' => 'The metafile for '.$pkg['name'].' couldn\'t be found'); + + $metadata = file_get_contents($metafile); + $metadata = str_replace("xmlns=", "ns=", $metadata); + $sxe = new SimpleXMLElement($metadata); + $namespaces = $sxe->getDocNamespaces(true); + foreach($namespaces as $ns => $url) $sxe->registerXPathNamespace($ns, $url); + + $pkg['Summary'] = htmlspecialchars(parent::getXPathValue($sxe, '//summary')); + $pkg['Homepage'] = parent::getXPathValue($sxe, '//homepage'); + $pkg['Description'] = nl2br(htmlspecialchars(trim(parent::getXPathValue($sxe, '//description')))); + $pkg['Config script'] = strtoupper(parent::getXPathValue($sxe, '//configuration-script-language')); + $installed_size = parent::getXPathValue($sxe, '//installed-size'); + $pkg['Installed Size'] = (!empty($installed_size)) ? parent::convertSize((int)$installed_size) : ''; + + // License + $pkg['License need agree'] = parent::getXPathValue($sxe, '//license/@must-accept'); + $pkg['License name'] = parent::getXPathValue($sxe, '//license/text/name'); // might be empty + $pkg['License type'] = 'file'; // default type + $pkg['License content'] = ''; // default license filename on local system + $license_url = parent::getXPathValue($sxe, '//license/text/url'); + if(!empty($license_url)) + { + $pkg['License type'] = 'url'; + $pkg['License content'] = htmlspecialchars($license_url); + } + else + { + $lic = @file_get_contents($this->interface_pkg_dir.'/'.$pkg['path'].'/LICENSE'); + $pkg['License content'] = htmlentities($lic, ENT_QUOTES, 'ISO-8859-1'); + } + + // Languages + $languages = parent::getXPathValue($sxe, '//languages/language', true); + $pkg['Languages'] = (is_array($languages)) ? implode(' ', $languages) : ''; + + // Icon + $icon = parent::getXPathValue($sxe, '//icon/@path'); + if(!empty($icon)) + { + // Using parse_url() to filter malformed URLs + $path = dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH)).'/'. + basename($this->interface_pkg_dir).'/'.$pkg['path'].'/'.basename((string)$icon); // nginx: if $_SERVER['PHP_SELF'] is doubled, remove /sites/aps_packagedetails_show.php from beginning of path $path = preg_replace('@^/sites/aps_packagedetails_show.php(.*)@', '$1', $path); - $pkg['Icon'] = $path; - } - else $pkg['Icon'] = ''; - - // Screenshots - $screenshots = parent::getXPathValue($sxe, '//screenshot', true); - if(!empty($screenshots)) - { - foreach($screenshots as $screen) - { - // Using parse_url() to filter malformed URLs - $path = dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH)).'/'. - basename($this->interface_pkg_dir).'/'.$pkg['path'].'/'.basename((string)$screen['path']); - // nginx: if $_SERVER['PHP_SELF'] is doubled, remove /sites/aps_packagedetails_show.php from beginning of path + $pkg['Icon'] = $path; + } + else $pkg['Icon'] = ''; + + // Screenshots + $screenshots = parent::getXPathValue($sxe, '//screenshot', true); + if(!empty($screenshots)) + { + foreach($screenshots as $screen) + { + // Using parse_url() to filter malformed URLs + $path = dirname(parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH)).'/'. + basename($this->interface_pkg_dir).'/'.$pkg['path'].'/'.basename((string)$screen['path']); + // nginx: if $_SERVER['PHP_SELF'] is doubled, remove /sites/aps_packagedetails_show.php from beginning of path $path = preg_replace('@^/sites/aps_packagedetails_show.php(.*)@', '$1', $path); - $pkg['Screenshots'][] = array('ScreenPath' => $path, - 'ScreenDescription' => htmlspecialchars(trim((string)$screen->description))); - } - } - else $pkg['Screenshots'] = ''; // if no screenshots are available, set the variable though - - // Changelog - $changelog = parent::getXPathValue($sxe, '//changelog/version', true); - if(!empty($changelog)) - { - foreach($changelog as $change) - { - $entries = array(); - foreach($change->entry as $entry) $entries[] = htmlspecialchars(trim((string)$entry)); - - $pkg['Changelog'][] = array('ChangelogVersion' => (string)$change['version'], - 'ChangelogDescription' => implode('
', $entries)); - } - } - - else $pkg['Changelog'] = ''; - - // PHP extensions - $php_extensions = parent::getXPathValue($sxe, '//php:extension', true); - $php_ext = ''; - if(!empty($php_extensions)) - { - foreach($php_extensions as $extension) - { - if(strtolower($extension) == 'php') continue; - $php_ext .= $extension.' '; - } - } - $pkg['Requirements PHP extensions'] = trim($php_ext); - - // PHP bool options - $pkg['Requirements PHP settings'] = ''; - $php_bool_options = array('allow-url-fopen', 'file-uploads', 'magic-quotes-gpc', - 'register-globals', 'safe-mode', 'short-open-tag'); - foreach($php_bool_options as $option) - { - $value = parent::getXPathValue($sxe, '//php:'.$option); - if(!empty($value)) - { - $option = str_replace('-', '_', $option); - $value = str_replace(array('false', 'true'), array('off', 'on'), $value); - $pkg['Requirements PHP settings'][] = array('PHPSettingName' => $option, - 'PHPSettingValue' => $value); - } - } - - // PHP integer value settings - $memory_limit = parent::getXPathValue($sxe, '//php:memory-limit'); - if(!empty($memory_limit)) - $pkg['Requirements PHP settings'][] = array('PHPSettingName' => 'memory_limit', - 'PHPSettingValue' => parent::convertSize((int)$memory_limit)); - - $max_exec_time = parent::getXPathValue($sxe, '//php:max-execution-time'); - if(!empty($max_exec_time)) - $pkg['Requirements PHP settings'][] = array('PHPSettingName' => 'max-execution-time', - 'PHPSettingValue' => $max_exec_time); - - $post_max_size = parent::getXPathValue($sxe, '//php:post-max-size'); - if(!empty($post_max_size)) - $pkg['Requirements PHP settings'][] = array('PHPSettingName' => 'post_max_size', - 'PHPSettingValue' => parent::convertSize((int)$post_max_size)); - - // Get supported PHP versions - $pkg['Requirements Supported PHP versions'] = ''; - $php_min_version = parent::getXPathValue($sxe, '//php:version/@min'); - $php_max_not_including = parent::getXPathValue($sxe, '//php:version/@max-not-including'); - if(!empty($php_min_version) && !empty($php_max_not_including)) - $pkg['Requirements Supported PHP versions'] = $php_min_version.' - '.$php_max_not_including; - else if(!empty($php_min_version)) - $pkg['Requirements Supported PHP versions'] = '> '.$php_min_version; - else if(!empty($php_max_not_including)) - $pkg['Requirements Supported PHP versions'] = '< '.$php_min_version; - - // Database - $db_id = parent::getXPathValue($sxe, '//db:id'); - $db_server_type = parent::getXPathValue($sxe, '//db:server-type'); - $db_min_version = parent::getXPathValue($sxe, '//db:server-min-version'); - if(!empty($db_id)) - { - $db_server_type = str_replace('postgresql', 'PostgreSQL', $db_server_type); - $db_server_type = str_replace('microsoft:sqlserver', 'MSSQL', $db_server_type); - $db_server_type = str_replace('mysql', 'MySQL', $db_server_type); - - $pkg['Requirements Database'] = $db_server_type; - if(!empty($db_min_version)) $pkg['Requirements Database'] .= ' > '.$db_min_version; - } - else $pkg['Requirements Database'] = ''; - - return $pkg; - } + $pkg['Screenshots'][] = array('ScreenPath' => $path, + 'ScreenDescription' => htmlspecialchars(trim((string)$screen->description))); + } + } + else $pkg['Screenshots'] = ''; // if no screenshots are available, set the variable though + + // Changelog + $changelog = parent::getXPathValue($sxe, '//changelog/version', true); + if(!empty($changelog)) + { + foreach($changelog as $change) + { + $entries = array(); + foreach($change->entry as $entry) $entries[] = htmlspecialchars(trim((string)$entry)); + + $pkg['Changelog'][] = array('ChangelogVersion' => (string)$change['version'], + 'ChangelogDescription' => implode('
', $entries)); + } + } + + else $pkg['Changelog'] = ''; + + // PHP extensions + $php_extensions = parent::getXPathValue($sxe, '//php:extension', true); + $php_ext = ''; + if(!empty($php_extensions)) + { + foreach($php_extensions as $extension) + { + if(strtolower($extension) == 'php') continue; + $php_ext .= $extension.' '; + } + } + $pkg['Requirements PHP extensions'] = trim($php_ext); + + // PHP bool options + $pkg['Requirements PHP settings'] = ''; + $php_bool_options = array('allow-url-fopen', 'file-uploads', 'magic-quotes-gpc', + 'register-globals', 'safe-mode', 'short-open-tag'); + foreach($php_bool_options as $option) + { + $value = parent::getXPathValue($sxe, '//php:'.$option); + if(!empty($value)) + { + $option = str_replace('-', '_', $option); + $value = str_replace(array('false', 'true'), array('off', 'on'), $value); + $pkg['Requirements PHP settings'][] = array('PHPSettingName' => $option, + 'PHPSettingValue' => $value); + } + } + + // PHP integer value settings + $memory_limit = parent::getXPathValue($sxe, '//php:memory-limit'); + if(!empty($memory_limit)) + $pkg['Requirements PHP settings'][] = array('PHPSettingName' => 'memory_limit', + 'PHPSettingValue' => parent::convertSize((int)$memory_limit)); + + $max_exec_time = parent::getXPathValue($sxe, '//php:max-execution-time'); + if(!empty($max_exec_time)) + $pkg['Requirements PHP settings'][] = array('PHPSettingName' => 'max-execution-time', + 'PHPSettingValue' => $max_exec_time); + + $post_max_size = parent::getXPathValue($sxe, '//php:post-max-size'); + if(!empty($post_max_size)) + $pkg['Requirements PHP settings'][] = array('PHPSettingName' => 'post_max_size', + 'PHPSettingValue' => parent::convertSize((int)$post_max_size)); + + // Get supported PHP versions + $pkg['Requirements Supported PHP versions'] = ''; + $php_min_version = parent::getXPathValue($sxe, '//php:version/@min'); + $php_max_not_including = parent::getXPathValue($sxe, '//php:version/@max-not-including'); + if(!empty($php_min_version) && !empty($php_max_not_including)) + $pkg['Requirements Supported PHP versions'] = $php_min_version.' - '.$php_max_not_including; + else if(!empty($php_min_version)) + $pkg['Requirements Supported PHP versions'] = '> '.$php_min_version; + else if(!empty($php_max_not_including)) + $pkg['Requirements Supported PHP versions'] = '< '.$php_min_version; + + // Database + $db_id = parent::getXPathValue($sxe, '//db:id'); + $db_server_type = parent::getXPathValue($sxe, '//db:server-type'); + $db_min_version = parent::getXPathValue($sxe, '//db:server-min-version'); + if(!empty($db_id)) + { + $db_server_type = str_replace('postgresql', 'PostgreSQL', $db_server_type); + $db_server_type = str_replace('microsoft:sqlserver', 'MSSQL', $db_server_type); + $db_server_type = str_replace('mysql', 'MySQL', $db_server_type); + + $pkg['Requirements Database'] = $db_server_type; + if(!empty($db_min_version)) $pkg['Requirements Database'] .= ' > '.$db_min_version; + } + else $pkg['Requirements Database'] = ''; + + return $pkg; + } + } + ?> diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php index 50d49503e..96e30b4da 100644 --- a/interface/lib/classes/auth.inc.php +++ b/interface/lib/classes/auth.inc.php @@ -35,18 +35,18 @@ class auth { { 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 = $app->functions->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) { @@ -55,19 +55,19 @@ class auth { return false; } } - + //** This function adds a given group id to a given user. - public function add_group_to_user($userid,$groupid) { + public function add_group_to_user($userid, $groupid) { global $app; - + $userid = $app->functions->intval($userid); $groupid = $app->functions->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); + $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; @@ -80,33 +80,33 @@ class auth { public function get_client_limit($userid, $limitname) { global $app; - + // simple query cache - if($this->client_limits===null) + 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) { + public function remove_group_from_user($userid, $groupid) { global $app; - + $userid = $app->functions->intval($userid); $groupid = $app->functions->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); + $groups = explode(',', $user['groups']); + $key = array_search($groupid, $groups); unset($groups[$key]); - $groups_string = implode(',',$groups); + $groups_string = implode(',', $groups); $sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid"; $app->db->query($sql); return true; @@ -114,35 +114,35 @@ class auth { 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)) { + if(!stristr($_SESSION["s"]["user"]["modules"], $module)) { // echo "LOGIN_REDIRECT:/index.php"; header("Location: /index.php"); exit; } } - + public function get_random_password($length = 8) { $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; $password = ''; for ($n=0;$n<$length;$n++) { - $password.=$base64_alphabet[mt_rand(0,63)]; + $password.=$base64_alphabet[mt_rand(0, 63)]; } return $password; } - + public function crypt_password($cleartext_password) { $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n=0;$n<8;$n++) { - $salt.=$base64_alphabet[mt_rand(0,63)]; + $salt.=$base64_alphabet[mt_rand(0, 63)]; } $salt.="$"; - return crypt($cleartext_password,$salt); + return crypt($cleartext_password, $salt); } - + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/client_templates.inc.php b/interface/lib/classes/client_templates.inc.php index cdd9ea952..77f6af564 100644 --- a/interface/lib/classes/client_templates.inc.php +++ b/interface/lib/classes/client_templates.inc.php @@ -1,236 +1,239 @@ pixcept KG * @author (original tools.inc.php) Till Brehm, projektfarm Gmbh * @author (original tools.inc.php) Oliver Vogel www.muv.com */ - + + class client_templates { - /** - * - check for old-style templates and change to new style - * - update assigned templates - */ + + /** + * - check for old-style templates and change to new style + * - update assigned templates + */ function update_client_templates($clientId, $templates = array()) { - global $app, $conf; - - if(!is_array($templates)) return false; - - $new_tpl = array(); - $used_assigned = array(); - $needed_types = array(); - $old_style = true; - foreach($templates as $item) { - $item = trim($item); - if($item == '') continue; - - $tpl_id = 0; - $assigned_id = 0; - if(strpos($item, ':') === false) { - $tpl_id = $item; - } else { - $old_style = false; // has new-style assigns - list($assigned_id, $tpl_id) = explode(':', $item, 2); - if(substr($assigned_id, 0, 1) === 'n') $assigned_id = 0; // newly inserted items - } - if(array_key_exists($tpl_id, $needed_types) == false) $needed_types[$tpl_id] = 0; - $needed_types[$tpl_id]++; - - if($assigned_id > 0) { - $used_assigned[] = $assigned_id; // for comparison with database - } else { - $new_tpl[] = $tpl_id; - } - } - - if($old_style == true) { - // we have to take care of this in an other way - $in_db = $app->db->queryAllRecords('SELECT `assigned_template_id`, `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ' . $clientId); - if(is_array($in_db) && count($in_db) > 0) { - foreach($in_db as $item) { - if(array_key_exists($item['client_template_id'], $needed_types) == false) $needed_types[$item['client_template_id']] = 0; - $needed_types[$item['client_template_id']]--; - } - } - - foreach($needed_types as $tpl_id => $count) { - if($count > 0) { - // add new template to client (includes those from old-style without assigned_template_id) - for($i = $count; $i > 0; $i--) { - $app->db->query('INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (' . $clientId . ', ' . $tpl_id . ')'); - } - } elseif($count < 0) { - // remove old ones - for($i = $count; $i < 0; $i++) { - $app->db->query('DELETE FROM `client_template_assigned` WHERE client_id = ' . $clientId . ' AND client_template_id = ' . $tpl_id . ' LIMIT 1'); - } - } - } - } else { - // we have to take care of this in an other way - $in_db = $app->db->queryAllRecords('SELECT `assigned_template_id`, `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ' . $clientId); - if(is_array($in_db) && count($in_db) > 0) { - // check which templates were removed from this client - foreach($in_db as $item) { - if(in_array($item['assigned_template_id'], $used_assigned) == false) { - // delete this one - $app->db->query('DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = ' . $item['assigned_template_id']); - } - } - } - - if(count($new_tpl) > 0) { - foreach($new_tpl as $item) { - // add new template to client (includes those from old-style without assigned_template_id) - $app->db->query('INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (' . $clientId . ', ' . $item . ')'); - } - } - } - - unset($new_tpl); - unset($in_db); - unset($templates); - unset($used_assigned); - return true; - } - - function apply_client_templates($clientId) { - global $app; - - include('../client/form/client.tform.php'); - - /* + global $app, $conf; + + if(!is_array($templates)) return false; + + $new_tpl = array(); + $used_assigned = array(); + $needed_types = array(); + $old_style = true; + foreach($templates as $item) { + $item = trim($item); + if($item == '') continue; + + $tpl_id = 0; + $assigned_id = 0; + if(strpos($item, ':') === false) { + $tpl_id = $item; + } else { + $old_style = false; // has new-style assigns + list($assigned_id, $tpl_id) = explode(':', $item, 2); + if(substr($assigned_id, 0, 1) === 'n') $assigned_id = 0; // newly inserted items + } + if(array_key_exists($tpl_id, $needed_types) == false) $needed_types[$tpl_id] = 0; + $needed_types[$tpl_id]++; + + if($assigned_id > 0) { + $used_assigned[] = $assigned_id; // for comparison with database + } else { + $new_tpl[] = $tpl_id; + } + } + + if($old_style == true) { + // we have to take care of this in an other way + $in_db = $app->db->queryAllRecords('SELECT `assigned_template_id`, `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ' . $clientId); + if(is_array($in_db) && count($in_db) > 0) { + foreach($in_db as $item) { + if(array_key_exists($item['client_template_id'], $needed_types) == false) $needed_types[$item['client_template_id']] = 0; + $needed_types[$item['client_template_id']]--; + } + } + + foreach($needed_types as $tpl_id => $count) { + if($count > 0) { + // add new template to client (includes those from old-style without assigned_template_id) + for($i = $count; $i > 0; $i--) { + $app->db->query('INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (' . $clientId . ', ' . $tpl_id . ')'); + } + } elseif($count < 0) { + // remove old ones + for($i = $count; $i < 0; $i++) { + $app->db->query('DELETE FROM `client_template_assigned` WHERE client_id = ' . $clientId . ' AND client_template_id = ' . $tpl_id . ' LIMIT 1'); + } + } + } + } else { + // we have to take care of this in an other way + $in_db = $app->db->queryAllRecords('SELECT `assigned_template_id`, `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ' . $clientId); + if(is_array($in_db) && count($in_db) > 0) { + // check which templates were removed from this client + foreach($in_db as $item) { + if(in_array($item['assigned_template_id'], $used_assigned) == false) { + // delete this one + $app->db->query('DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = ' . $item['assigned_template_id']); + } + } + } + + if(count($new_tpl) > 0) { + foreach($new_tpl as $item) { + // add new template to client (includes those from old-style without assigned_template_id) + $app->db->query('INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (' . $clientId . ', ' . $item . ')'); + } + } + } + + unset($new_tpl); + unset($in_db); + unset($templates); + unset($used_assigned); + return true; + } + + function apply_client_templates($clientId) { + global $app; + + include '../client/form/client.tform.php'; + + /* * Get the master-template for the client */ - $sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . $app->functions->intval($clientId); - $record = $app->db->queryOneRecord($sql); - $masterTemplateId = $record['template_master']; - - if($record['template_additional'] != '') { - // we have to call the update_client_templates function - $templates = explode('/', $record['template_additional']); - $this->update_client_templates($clientId, $templates); - $app->db->query('UPDATE `client` SET `template_additional` = \'\' WHERE `client_id` = ' . $app->functions->intval($clientId)); - } - - /* + $sql = "SELECT template_master, template_additional FROM client WHERE client_id = " . $app->functions->intval($clientId); + $record = $app->db->queryOneRecord($sql); + $masterTemplateId = $record['template_master']; + + if($record['template_additional'] != '') { + // we have to call the update_client_templates function + $templates = explode('/', $record['template_additional']); + $this->update_client_templates($clientId, $templates); + $app->db->query('UPDATE `client` SET `template_additional` = \'\' WHERE `client_id` = ' . $app->functions->intval($clientId)); + } + + /* * if the master-Template is custom there is NO changing */ - if ($masterTemplateId > 0){ - $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($masterTemplateId); - $limits = $app->db->queryOneRecord($sql); - } else { - // if there is no master template it makes NO SENSE adding sub templates. - // adding subtemplates are stored in client limits, so they would add up - // on every save action for the client -> too high limits! - return; - } - - /* + if ($masterTemplateId > 0){ + $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($masterTemplateId); + $limits = $app->db->queryOneRecord($sql); + } else { + // if there is no master template it makes NO SENSE adding sub templates. + // adding subtemplates are stored in client limits, so they would add up + // on every save action for the client -> too high limits! + return; + } + + /* * Process the additional tempaltes here (add them to the limits * if != -1) */ - $addTpl = explode('/', $additionalTemplateStr); - $addTpls = $app->db->queryAllRecords('SELECT `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ' . $app->functions->intval($clientId)); - foreach ($addTpls as $addTpl){ - $item = $addTpl['client_template_id']; - $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($item); - $addLimits = $app->db->queryOneRecord($sql); - $app->log('Template processing subtemplate ' . $item . ' for client ' . $clientId, LOGLEVEL_DEBUG); - /* maybe the template is deleted in the meantime */ - if (is_array($addLimits)){ - foreach($addLimits as $k => $v){ - /* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */ - if (strpos($k, 'limit') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec'){ - $app->log('Template processing key ' . $k . ' for client ' . $clientId, LOGLEVEL_DEBUG); - - /* process the numerical limits */ - if (is_numeric($v)){ - /* switch for special cases */ - switch ($k){ - case 'limit_cron_frequency': - if ($v < $limits[$k]) $limits[$k] = $v; - /* silent adjustment of the minimum cron frequency to 1 minute */ - /* maybe this control test should be done via validator definition in tform.php file, but I don't know how */ - if ($limits[$k] < 1) $limits[$k] = 1; - break; - - default: - if ($limits[$k] > -1){ - if ($v == -1){ - $limits[$k] = -1; - } - else { - $limits[$k] += $v; - } - } - } - } - /* process the string limits (CHECKBOXARRAY, SELECT etc.) */ - elseif (is_string($v)){ - switch ($form["tabs"]["limits"]["fields"][$k]['formtype']){ - case 'CHECKBOXARRAY': - if (!isset($limits[$k])){ - $limits[$k] = array(); - } - - $limits_values = $limits[$k]; - if (is_string($limits[$k])){ - $limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"],$limits[$k]); - } - $additional_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"],$v); - $app->log('Template processing key ' . $k . ' type CHECKBOXARRAY, lim / add: ' . implode(',', $limits_values) . ' / ' . implode(',', $additional_values) . ' for client ' . $clientId, LOGLEVEL_DEBUG); - /* unification of limits_values (master template) and additional_values (additional template) */ - $limits_unified = array(); - foreach($form["tabs"]["limits"]["fields"][$k]["value"] as $key => $val){ - if (in_array($key,$limits_values) || in_array($key,$additional_values)) $limits_unified[] = $key; - } - $limits[$k] = implode($form["tabs"]["limits"]["fields"][$k]["separator"],$limits_unified); - break; - case 'CHECKBOX': - if($k == 'force_suexec') { - // 'n' is less limited than y - if (!isset($limits[$k])){ - $limits[$k] = 'y'; - } - if($limits[$k] == 'n' || $v == 'n') $limits[$k] = 'n'; - } else { - // 'y' is less limited than n - if (!isset($limits[$k])){ - $limits[$k] = 'n'; - } - if($limits[$k] == 'y' || $v == 'y') $limits[$k] = 'y'; - } - break; - case 'SELECT': - $limit_values = array_keys($form["tabs"]["limits"]["fields"][$k]["value"]); - /* choose the lower index of the two SELECT items */ - $limits[$k] = $limit_values[min(array_search($limits[$k], $limit_values), array_search($v, $limit_values))]; - break; - } - } - } - } - } - } - - /* + $addTpl = explode('/', $additionalTemplateStr); + $addTpls = $app->db->queryAllRecords('SELECT `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ' . $app->functions->intval($clientId)); + foreach ($addTpls as $addTpl){ + $item = $addTpl['client_template_id']; + $sql = "SELECT * FROM client_template WHERE template_id = " . $app->functions->intval($item); + $addLimits = $app->db->queryOneRecord($sql); + $app->log('Template processing subtemplate ' . $item . ' for client ' . $clientId, LOGLEVEL_DEBUG); + /* maybe the template is deleted in the meantime */ + if (is_array($addLimits)){ + foreach($addLimits as $k => $v){ + /* we can remove this condition, but it is easier to debug with it (don't add ids and other non-limit values) */ + if (strpos($k, 'limit') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec'){ + $app->log('Template processing key ' . $k . ' for client ' . $clientId, LOGLEVEL_DEBUG); + + /* process the numerical limits */ + if (is_numeric($v)){ + /* switch for special cases */ + switch ($k){ + case 'limit_cron_frequency': + if ($v < $limits[$k]) $limits[$k] = $v; + /* silent adjustment of the minimum cron frequency to 1 minute */ + /* maybe this control test should be done via validator definition in tform.php file, but I don't know how */ + if ($limits[$k] < 1) $limits[$k] = 1; + break; + + default: + if ($limits[$k] > -1){ + if ($v == -1){ + $limits[$k] = -1; + } + else { + $limits[$k] += $v; + } + } + } + } + /* process the string limits (CHECKBOXARRAY, SELECT etc.) */ + elseif (is_string($v)){ + switch ($form["tabs"]["limits"]["fields"][$k]['formtype']){ + case 'CHECKBOXARRAY': + if (!isset($limits[$k])){ + $limits[$k] = array(); + } + + $limits_values = $limits[$k]; + if (is_string($limits[$k])){ + $limits_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits[$k]); + } + $additional_values = explode($form["tabs"]["limits"]["fields"][$k]["separator"], $v); + $app->log('Template processing key ' . $k . ' type CHECKBOXARRAY, lim / add: ' . implode(',', $limits_values) . ' / ' . implode(',', $additional_values) . ' for client ' . $clientId, LOGLEVEL_DEBUG); + /* unification of limits_values (master template) and additional_values (additional template) */ + $limits_unified = array(); + foreach($form["tabs"]["limits"]["fields"][$k]["value"] as $key => $val){ + if (in_array($key, $limits_values) || in_array($key, $additional_values)) $limits_unified[] = $key; + } + $limits[$k] = implode($form["tabs"]["limits"]["fields"][$k]["separator"], $limits_unified); + break; + case 'CHECKBOX': + if($k == 'force_suexec') { + // 'n' is less limited than y + if (!isset($limits[$k])){ + $limits[$k] = 'y'; + } + if($limits[$k] == 'n' || $v == 'n') $limits[$k] = 'n'; + } else { + // 'y' is less limited than n + if (!isset($limits[$k])){ + $limits[$k] = 'n'; + } + if($limits[$k] == 'y' || $v == 'y') $limits[$k] = 'y'; + } + break; + case 'SELECT': + $limit_values = array_keys($form["tabs"]["limits"]["fields"][$k]["value"]); + /* choose the lower index of the two SELECT items */ + $limits[$k] = $limit_values[min(array_search($limits[$k], $limit_values), array_search($v, $limit_values))]; + break; + } + } + } + } + } + } + + /* * Write all back to the database */ - $update = ''; - foreach($limits as $k => $v){ - if ((strpos($k, 'limit') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec') && !is_array($v)){ - if ($update != '') $update .= ', '; - $update .= '`' . $k . "`='" . $v . "'"; - } - } - $app->log('Template processed for client ' . $clientId . ', update string: ' . $update, LOGLEVEL_DEBUG); - if($update != '') { - $sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . $app->functions->intval($clientId); - $app->db->query($sql); - } - unset($form); - } -} \ No newline at end of file + $update = ''; + foreach($limits as $k => $v){ + if ((strpos($k, 'limit') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec') && !is_array($v)){ + if ($update != '') $update .= ', '; + $update .= '`' . $k . "`='" . $v . "'"; + } + } + $app->log('Template processed for client ' . $clientId . ', update string: ' . $update, LOGLEVEL_DEBUG); + if($update != '') { + $sql = 'UPDATE client SET ' . $update . " WHERE client_id = " . $app->functions->intval($clientId); + $app->db->query($sql); + } + unset($form); + } + +} diff --git a/interface/lib/classes/cmstree.inc.php b/interface/lib/classes/cmstree.inc.php index d83fb297e..ead780ebf 100644 --- a/interface/lib/classes/cmstree.inc.php +++ b/interface/lib/classes/cmstree.inc.php @@ -48,13 +48,13 @@ class cmstree // - icon :icon im node-tree, optional // - modul :modul des Eintrages, noch nicht verwendet // - doc_id :id des zugeh�rigen Dokumentes - + public function node_list() { global $app; - + $nodes = $app->db->queryAllRecords('SELECT * FROM media_cat order by sort, name'); - + $optionlist = array(); $my0 = new nodetree(); @@ -74,11 +74,11 @@ class cmstree $$ordner->childs[] = &$$id; } } - - $this->ptree($my0, 0, $optionlist); + + $this->ptree($my0, 0, $optionlist); return is_array($nodes) ? $optionlist : false; } - + private function ptree($myobj, $tiefe, &$optionlist){ global $_SESSION; $tiefe += 1; @@ -87,7 +87,7 @@ class cmstree if(is_array($myobj->childs) and ($_SESSION['s']['cat_open'][$id] == 1 or $tiefe <= 1)) { foreach($myobj->childs as $val) { // kategorie => str_repeat('-  ',$tiefe) . $val->btext, - + // Ergebnisse Formatieren /* if($tiefe == 0) { @@ -104,7 +104,7 @@ class cmstree } else { $kategorie = "
"; } - + $optionlist[] = array( media_cat => $kategorie, media_cat_id => $val->id, depth => $tiefe); @@ -114,4 +114,4 @@ class cmstree } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/custom_datasource.inc.php b/interface/lib/classes/custom_datasource.inc.php index 44fee19d9..fda355cfc 100644 --- a/interface/lib/classes/custom_datasource.inc.php +++ b/interface/lib/classes/custom_datasource.inc.php @@ -29,7 +29,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class custom_datasource { - + function master_templates($field, $record) { global $app, $conf; $records = $app->db->queryAllRecords("SELECT template_id,template_name FROM client_template WHERE template_type ='m'"); @@ -40,10 +40,10 @@ class custom_datasource { } return $records_new; } - + function dns_servers($field, $record) { global $app, $conf; - + if($_SESSION["s"]["user"]["typ"] == 'user') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; @@ -62,10 +62,10 @@ class custom_datasource { } return $records_new; } - + function slave_dns_servers($field, $record) { global $app, $conf; - + if($_SESSION["s"]["user"]["typ"] == 'user') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; @@ -84,10 +84,10 @@ class custom_datasource { } return $records_new; } - + function webdav_domains($field, $record) { global $app, $conf; - + $servers = $app->db->queryAllRecords("SELECT * FROM server WHERE active = 1 AND mirror_server_id = 0"); $server_ids = array(); $app->uses('getconf'); @@ -100,7 +100,7 @@ class custom_datasource { if(count($server_ids) == 0) return array(); $server_ids = implode(',', $server_ids); $records = $app->db->queryAllRecords("SELECT web_domain.domain_id, CONCAT(web_domain.domain, ' :: ', server.server_name) AS parent_domain FROM web_domain, server WHERE web_domain.type = 'vhost' AND web_domain.server_id IN (".$server_ids.") AND web_domain.server_id = server.server_id AND ".$app->tform->getAuthSQL('r', 'web_domain')." ORDER BY web_domain.domain"); - + $records_new = array(); if(is_array($records)) { foreach($records as $rec) { @@ -110,40 +110,40 @@ class custom_datasource { } return $records_new; } - - + + function client_servers($field, $record) { global $app, $conf; - + $server_type = $field['name']; - + switch($server_type) { - case 'default_mailserver': - $field = 'mail_server'; + case 'default_mailserver': + $field = 'mail_server'; break; - case 'default_webserver': - $field = 'web_server'; + case 'default_webserver': + $field = 'web_server'; break; - case 'default_dnsserver': - $field = 'dns_server'; + case 'default_dnsserver': + $field = 'dns_server'; break; - case 'default_slave_dnsserver': - $field = 'dns_server'; + case 'default_slave_dnsserver': + $field = 'dns_server'; break; - case 'default_fileserver': - $field = 'file_server'; + case 'default_fileserver': + $field = 'file_server'; break; - case 'default_dbserver': - $field = 'db_server'; + case 'default_dbserver': + $field = 'db_server'; break; - case 'default_vserverserver': - $field = 'vserver_server'; + case 'default_vserverserver': + $field = 'vserver_server'; break; - default: - $field = 'web_server'; + default: + $field = 'web_server'; break; } - + if($_SESSION["s"]["user"]["typ"] == 'user') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; @@ -154,14 +154,14 @@ class custom_datasource { $sql = "SELECT server_id,server_name FROM server WHERE server_id = ".$client['server_id']; } else { //* Not able to find the clients defaults, use this as fallback and add a warning message to the log - $app->log('Unable to find default server for client in custom_datasource.inc.php',1); + $app->log('Unable to find default server for client in custom_datasource.inc.php', 1); $sql = "SELECT server_id,server_name FROM server WHERE $field = 1 ORDER BY server_name"; } } else { //* The logged in user is admin, so we show him all available servers of a specific type. $sql = "SELECT server_id,server_name FROM server WHERE $field = 1 ORDER BY server_name"; } - + $records = $app->db->queryAllRecords($sql); $records_new = array(); if(is_array($records)) { @@ -172,9 +172,9 @@ class custom_datasource { } return $records_new; } - - + + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/db_firebird.inc.php b/interface/lib/classes/db_firebird.inc.php index 883e7ba0e..fda4ef8e6 100644 --- a/interface/lib/classes/db_firebird.inc.php +++ b/interface/lib/classes/db_firebird.inc.php @@ -29,17 +29,17 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class db { - var $dbHost = ""; // hostname of the MySQL server - var $dbName = ""; // logical database name on that server - var $dbUser = ""; // database authorized user - var $dbPass = ""; // user's password - var $linkId = 0; // last result of mysql_connect() - var $queryId = 0; // last result of mysql_query() - var $record = array(); // last record fetched - var $autoCommit = 1; // Autocommit Transactions - var $currentRow; // current row number - var $errorNumber = 0; // last error number - var $errorMessage = ""; // last error message + var $dbHost = ""; // hostname of the MySQL server + var $dbName = ""; // logical database name on that server + var $dbUser = ""; // database authorized user + var $dbPass = ""; // user's password + var $linkId = 0; // last result of mysql_connect() + var $queryId = 0; // last result of mysql_query() + var $record = array(); // last record fetched + var $autoCommit = 1; // Autocommit Transactions + var $currentRow; // current row number + var $errorNumber = 0; // last error number + var $errorMessage = ""; // last error message var $errorLocation = "";// last error location var $show_error_messages = false; var $transID; @@ -47,7 +47,7 @@ class db { // constructor function __construct() { - + global $conf; $this->dbHost = $conf["db_host"]; $this->dbName = $conf["db_database"]; @@ -55,9 +55,10 @@ class db { $this->dbPass = $conf["db_password"]; $this->connect(); } + function __destruct() { $this->closeConn(); - } + } // error handler function updateError($location) @@ -67,7 +68,7 @@ class db { $this->errorLocation = $location; if($this->errorNumber && $this->show_error_messages) { - echo('
'.$this->errorLocation.'
'.$this->errorMessage); + echo '
'.$this->errorLocation.'
'.$this->errorMessage; flush(); } } @@ -76,7 +77,7 @@ class db { { if($this->linkId == 0) { - $this->linkId = ibase_connect( $this->dbHost.":".$this->dbName , $this->dbUser, $this->dbPass,'ISO8859_1',0,3 ); + $this->linkId = ibase_connect( $this->dbHost.":".$this->dbName , $this->dbUser, $this->dbPass, 'ISO8859_1', 0, 3 ); if(!$this->linkId) { $this->updateError('DB::connect()
ibase_pconnect'); @@ -91,16 +92,16 @@ class db { if(!$this->connect()) { return false; } - + if($this->autoCommit == 1) { //$transID = ibase_trans(); - $this->queryId = @ibase_query($this->linkId,$queryString); + $this->queryId = @ibase_query($this->linkId, $queryString); //ibase_commit(); } else { - $this->queryId = @ibase_query($this->linkId,$queryString); + $this->queryId = @ibase_query($this->linkId, $queryString); } - - + + $this->updateError('DB::query('.$queryString.')
ibase_query'); if(!$this->queryId) { return false; @@ -141,7 +142,7 @@ class db { // returns the next record in an array function nextRecord() { - $this->record = ibase_fetch_assoc($this->queryId); + $this->record = ibase_fetch_assoc($this->queryId); $this->updateError('DB::nextRecord()
ibase_fetch_assoc'); if(!$this->record || !is_array($this->record)) { @@ -156,32 +157,32 @@ class db { { return false; } - + // returns mySQL insert id function insertID() { return false; } - - // Check der variablen + + // Check der variablen // deprecated, now use quote - function check($formfield) - { - return $this->quote($formfield); - } - + function check($formfield) + { + return $this->quote($formfield); + } + // Check der variablen - function quote($formfield) - { - return str_replace("'","''",$formfield); - } - + function quote($formfield) + { + return str_replace("'", "''", $formfield); + } + // Check der variablen - function unquote($formfield) - { - return str_replace("''","'",$formfield); - } - + function unquote($formfield) + { + return str_replace("''", "'", $formfield); + } + function toLower($record) { if(is_array($record)) { foreach($record as $key => $val) { @@ -189,76 +190,76 @@ class db { $out[$key] = $val; } } - return $out; + return $out; + } + + + function insert($tablename, $form, $debug = 0) + { + if(is_array($form)){ + foreach($form as $key => $value) + { + $sql_key .= "$key, "; + $sql_value .= "'".$this->quote($value)."', "; + } + $sql_key = substr($sql_key, 0, strlen($sql_key) - 2); + $sql_value = substr($sql_value, 0, strlen($sql_value) - 2); + + $sql = "INSERT INTO $tablename (" . $sql_key . ") VALUES (" . $sql_value .")"; + + if($debug == 1) echo "SQL-Statement: ".$sql."

"; + $this->query($sql); + if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; + } + } + + function update($tablename, $form, $bedingung, $debug = 0) + { + + if(is_array($form)){ + foreach($form as $key => $value) + { + $insql .= "$key = '".$this->quote($value)."', "; + } + $insql = substr($insql, 0, strlen($insql) - 2); + $sql = "UPDATE $tablename SET " . $insql . " WHERE $bedingung"; + if($debug == 1) echo "SQL-Statement: ".$sql."

"; + $this->query($sql); + if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; + } + } + + function closeConn() { + ibase_close($this->linkId); + } + + function freeResult() { + //ibase_free_result(); + } + + function delete() { + } - - - function insert($tablename,$form,$debug = 0) - { - if(is_array($form)){ - foreach($form as $key => $value) - { - $sql_key .= "$key, "; - $sql_value .= "'".$this->quote($value)."', "; - } - $sql_key = substr($sql_key,0,strlen($sql_key) - 2); - $sql_value = substr($sql_value,0,strlen($sql_value) - 2); - - $sql = "INSERT INTO $tablename (" . $sql_key . ") VALUES (" . $sql_value .")"; - - if($debug == 1) echo "SQL-Statement: ".$sql."

"; - $this->query($sql); - if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; - } - } - - function update($tablename,$form,$bedingung,$debug = 0) - { - - if(is_array($form)){ - foreach($form as $key => $value) - { - $insql .= "$key = '".$this->quote($value)."', "; - } - $insql = substr($insql,0,strlen($insql) - 2); - $sql = "UPDATE $tablename SET " . $insql . " WHERE $bedingung"; - if($debug == 1) echo "SQL-Statement: ".$sql."

"; - $this->query($sql); - if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; - } - } - - function closeConn() { - ibase_close($this->linkId); - } - - function freeResult() { - //ibase_free_result(); - } - - function delete() { - - } - - function trans($action,$transID = null) { - //action = begin, commit oder rollback - - if($action == 'begin') { - $this->transID = ibase_trans($this->linkId); + + function trans($action, $transID = null) { + //action = begin, commit oder rollback + + if($action == 'begin') { + $this->transID = ibase_trans($this->linkId); return $this->transID; - } - + } + if($action == 'commit' and !empty($this->transID)) { - ibase_commit($this->linkId,$this->transID); + ibase_commit($this->linkId, $this->transID); } - + if($action == 'rollback') { - ibase_rollback($this->linkId,$this->transID); + ibase_rollback($this->linkId, $this->transID); } - - } - - /* + + } + + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -268,38 +269,38 @@ class db { notNull => true | false autoInc => true | false option => unique | primary | index) - - + + */ - - function createTable($table_name,$columns) { - $index = ""; - $sql = "CREATE TABLE $table_name ("; - foreach($columns as $col){ - $sql .= $col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." "; - - if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' "; - if($col["notNull"] == true) { - $sql .= "NOT NULL "; - } else { - $sql .= "NULL "; - } - if($col["autoInc"] == true) $sql .= "auto_increment "; - $sql.= ","; - // key Definitionen - if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; - if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; - if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; - } - $sql .= $index; - $sql = substr($sql,0,-1); - $sql .= ")"; - - $this->query($sql); - return true; - } - - /* + + function createTable($table_name, $columns) { + $index = ""; + $sql = "CREATE TABLE $table_name ("; + foreach($columns as $col){ + $sql .= $col["name"]." ".$this->mapType($col["type"], $col["typeValue"])." "; + + if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' "; + if($col["notNull"] == true) { + $sql .= "NOT NULL "; + } else { + $sql .= "NULL "; + } + if($col["autoInc"] == true) $sql .= "auto_increment "; + $sql.= ","; + // key Definitionen + if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; + if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; + if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; + } + $sql .= $index; + $sql = substr($sql, 0, -1); + $sql .= ")"; + + $this->query($sql); + return true; + } + + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -309,26 +310,26 @@ class db { notNull => true | false autoInc => true | false option => unique | primary | index) - - + + */ - function alterTable($table_name,$columns) { - return false; - } - - function dropTable($table_name) { - $this->check($table_name); - $sql = "DROP TABLE '". $table_name."'"; - return $this->query($sql); - } - - // gibt Array mit Tabellennamen zurück - function getTables($database_name) { - return false; - } - - // gibt Feldinformationen zur Tabelle zurück - /* + function alterTable($table_name, $columns) { + return false; + } + + function dropTable($table_name) { + $this->check($table_name); + $sql = "DROP TABLE '". $table_name."'"; + return $this->query($sql); + } + + // gibt Array mit Tabellennamen zurück + function getTables($database_name) { + return false; + } + + // gibt Feldinformationen zur Tabelle zurück + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -338,46 +339,46 @@ class db { notNull => true | false autoInc => true | false option => unique | primary | index) - - + + */ - - function tableInfo($table_name) { - return false; - } - - function mapType($metaType,$typeValue) { - global $go_api; - $metaType = strtolower($metaType); - switch ($metaType) { - case 'int16': - return 'smallint'; - break; - case 'int32': - return 'int'; - break; - case 'int64': - return 'bigint'; - break; - case 'double': - return 'double'; - break; - case 'char': - return 'char'; - break; - case 'varchar': - if($typeValue < 1) $go_api->errorMessage("Datenbank Fehler: Für diesen Datentyp ist eine Längenangabe notwendig."); - return 'varchar('.$typeValue.')'; - break; - case 'text': - return 'text'; - break; - case 'blob': - return 'blob'; - break; - } - } - + + function tableInfo($table_name) { + return false; + } + + function mapType($metaType, $typeValue) { + global $go_api; + $metaType = strtolower($metaType); + switch ($metaType) { + case 'int16': + return 'smallint'; + break; + case 'int32': + return 'int'; + break; + case 'int64': + return 'bigint'; + break; + case 'double': + return 'double'; + break; + case 'char': + return 'char'; + break; + case 'varchar': + if($typeValue < 1) $go_api->errorMessage("Datenbank Fehler: Für diesen Datentyp ist eine Längenangabe notwendig."); + return 'varchar('.$typeValue.')'; + break; + case 'text': + return 'text'; + break; + case 'blob': + return 'blob'; + break; + } + } + } ?> diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index 46729988e..1636cab5d 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -29,64 +29,64 @@ class db extends mysqli { - private $dbHost = ''; // hostname of the MySQL server - private $dbName = ''; // logical database name on that server - private $dbUser = ''; // database authorized user - private $dbPass = ''; // user's password - private $dbCharset = 'utf8';// Database charset - private $dbNewLink = false; // Return a new linkID when connect is called again - private $dbClientFlags = 0; // MySQL Client falgs - private $linkId = 0; // last result of mysqli_connect() - private $queryId = 0; // last result of mysqli_query() - private $record = array(); // last record fetched - private $autoCommit = 1; // Autocommit Transactions - private $currentRow; // current row number - private $errorNumber = 0; // last error number - public $errorMessage = ''; // last error message - private $errorLocation = '';// last error location - public $show_error_messages = false; // false in server, true in interface - private $isConnected = false; // needed to know if we have a valid mysqli object from the constructor - - // constructor - public function __construct($prefix = '') { - global $conf; - if($prefix != '') $prefix .= '_'; - $this->dbHost = $conf[$prefix.'db_host']; - $this->dbName = $conf[$prefix.'db_database']; - $this->dbUser = $conf[$prefix.'db_user']; - $this->dbPass = $conf[$prefix.'db_password']; - $this->dbCharset = $conf[$prefix.'db_charset']; - $this->dbNewLink = $conf[$prefix.'db_new_link']; - $this->dbClientFlags = $conf[$prefix.'db_client_flags']; - parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'],$conf[$prefix.'db_password'],$conf[$prefix.'db_database']); - $try = 0; - //while(!is_null($this->connect_error) && $try < 5) { - while(mysqli_connect_error() && $try < 5) { - if($try > 0) sleep(1); - - $try++; - $this->updateError('DB::__construct'); - - parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'],$conf[$prefix.'db_password'],$conf[$prefix.'db_database']); - } - - //if(is_null($this->connect_error)) $this->isConnected = true; - //else return false; - if(!mysqli_connect_error()) $this->isConnected = true; - else return false; - - $this->setCharacterEncoding(); - } - - public function __destruct() { - $this->close(); // helps avoid memory leaks, and persitent connections that don't go away. - } - - // error handler - public function updateError($location) { - global $app, $conf; + private $dbHost = ''; // hostname of the MySQL server + private $dbName = ''; // logical database name on that server + private $dbUser = ''; // database authorized user + private $dbPass = ''; // user's password + private $dbCharset = 'utf8';// Database charset + private $dbNewLink = false; // Return a new linkID when connect is called again + private $dbClientFlags = 0; // MySQL Client falgs + private $linkId = 0; // last result of mysqli_connect() + private $queryId = 0; // last result of mysqli_query() + private $record = array(); // last record fetched + private $autoCommit = 1; // Autocommit Transactions + private $currentRow; // current row number + private $errorNumber = 0; // last error number + public $errorMessage = ''; // last error message + private $errorLocation = '';// last error location + public $show_error_messages = false; // false in server, true in interface + private $isConnected = false; // needed to know if we have a valid mysqli object from the constructor + + // constructor + public function __construct($prefix = '') { + global $conf; + if($prefix != '') $prefix .= '_'; + $this->dbHost = $conf[$prefix.'db_host']; + $this->dbName = $conf[$prefix.'db_database']; + $this->dbUser = $conf[$prefix.'db_user']; + $this->dbPass = $conf[$prefix.'db_password']; + $this->dbCharset = $conf[$prefix.'db_charset']; + $this->dbNewLink = $conf[$prefix.'db_new_link']; + $this->dbClientFlags = $conf[$prefix.'db_client_flags']; + parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'], $conf[$prefix.'db_password'], $conf[$prefix.'db_database']); + $try = 0; + //while(!is_null($this->connect_error) && $try < 5) { + while(mysqli_connect_error() && $try < 5) { + if($try > 0) sleep(1); + + $try++; + $this->updateError('DB::__construct'); + + parent::__construct($conf[$prefix.'db_host'], $conf[$prefix.'db_user'], $conf[$prefix.'db_password'], $conf[$prefix.'db_database']); + } - /* + //if(is_null($this->connect_error)) $this->isConnected = true; + //else return false; + if(!mysqli_connect_error()) $this->isConnected = true; + else return false; + + $this->setCharacterEncoding(); + } + + public function __destruct() { + $this->close(); // helps avoid memory leaks, and persitent connections that don't go away. + } + + // error handler + public function updateError($location) { + global $app, $conf; + + /* if(!is_null($this->connect_error)) { $this->errorNumber = $this->connect_errno; $this->errorMessage = $this->connect_error; @@ -95,183 +95,183 @@ class db extends mysqli $this->errorMessage = $this->error; } */ - if(mysqli_connect_error()) { - $this->errorNumber = mysqli_connect_errno(); - $this->errorMessage = mysqli_connect_error(); - } else { - $this->errorNumber = mysqli_errno($this); - $this->errorMessage = mysqli_error($this); - } + if(mysqli_connect_error()) { + $this->errorNumber = mysqli_connect_errno(); + $this->errorMessage = mysqli_connect_error(); + } else { + $this->errorNumber = mysqli_errno($this); + $this->errorMessage = mysqli_error($this); + } - $this->errorLocation = $location; - if($this->errorNumber) { - $error_msg = $this->errorLocation .' '. $this->errorMessage; - // This right here will allow us to use the same file for server & interface - if($this->show_error_messages && $conf['demo_mode'] === false) { - echo $error_msg; - } else if(is_object($app) && method_exists($app, 'log')) { - $app->log($error_msg, LOGLEVEL_WARN); - } - } - } - - private function setCharacterEncoding() { - if($this->isConnected == false) return false; - parent::query( 'SET NAMES '.$this->dbCharset); - parent::query( "SET character_set_results = '".$this->dbCharset."', character_set_client = '".$this->dbCharset."', character_set_connection = '".$this->dbCharset."', character_set_database = '".$this->dbCharset."', character_set_server = '".$this->dbCharset."'"); - } - - public function query($queryString) { - global $conf; - if($this->isConnected == false) return false; - $try = 0; - do { - $try++; - $ok = $this->ping(); - if(!$ok) { - if(!$this->real_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) { - if($try > 4) { - $this->updateError('DB::query -> reconnect'); - return false; - } else { - sleep(1); - } - } else { - $this->setCharacterEncoding(); - $ok = true; - } - } - } while($ok == false); - $this->queryId = parent::query($queryString); - $this->updateError('DB::query('.$queryString.') -> mysqli_query'); - if($this->errorNumber && $conf['demo_mode'] === false) debug_print_backtrace(); - if(!$this->queryId) { - return false; - } - $this->currentRow = 0; - return $this->queryId; - } - - // returns all records in an array - public function queryAllRecords($queryString) { - if(!$this->query($queryString)) - { - return false; - } - $ret = array(); - while($line = $this->nextRecord()) - { - $ret[] = $line; - } - return $ret; - } - - // returns one record in an array - public function queryOneRecord($queryString) { - if(!$this->query($queryString) || $this->numRows() == 0) - { - return false; - } - return $this->nextRecord(); - } - - // returns the next record in an array - public function nextRecord() { - $this->record = $this->queryId->fetch_assoc(); - $this->updateError('DB::nextRecord()-> mysql_fetch_array'); - if(!$this->record || !is_array($this->record)) - { - return false; - } - $this->currentRow++; - return $this->record; - } - - // returns number of rows returned by the last select query - public function numRows() { - return intval($this->queryId->num_rows); - } - - public function affectedRows() { - return intval($this->queryId->affected_rows); - } - - // returns mySQL insert id - public function insertID() { - return $this->insert_id; - } - - - //* Function to quote strings - public function quote($formfield) { - return $this->escape_string($formfield); - } - - //* Function to unquotae strings - public function unquote($formfield) { - return stripslashes($formfield); - } - -public function toLower($record) { - if(is_array($record)) { - foreach($record as $key => $val) { - $key = strtolower($key); - $out[$key] = $val; - } - } - return $out; - } - - public function diffrec($record_old, $record_new) { - $diffrec_full = array(); - $diff_num = 0; - - if(is_array($record_old) && count($record_old) > 0) { - foreach($record_old as $key => $val) { - // if(!isset($record_new[$key]) || $record_new[$key] != $val) { - if(@$record_new[$key] != $val) { - // Record has changed - $diffrec_full['old'][$key] = $val; - $diffrec_full['new'][$key] = @$record_new[$key]; - $diff_num++; - } else { - $diffrec_full['old'][$key] = $val; - $diffrec_full['new'][$key] = $val; + $this->errorLocation = $location; + if($this->errorNumber) { + $error_msg = $this->errorLocation .' '. $this->errorMessage; + // This right here will allow us to use the same file for server & interface + if($this->show_error_messages && $conf['demo_mode'] === false) { + echo $error_msg; + } else if(is_object($app) && method_exists($app, 'log')) { + $app->log($error_msg, LOGLEVEL_WARN); + } + } } - } - } elseif(is_array($record_new)) { - foreach($record_new as $key => $val) { - if(isset($record_new[$key]) && @$record_old[$key] != $val) { - // Record has changed - $diffrec_full['new'][$key] = $val; - $diffrec_full['old'][$key] = @$record_old[$key]; - $diff_num++; - } else { - $diffrec_full['new'][$key] = $val; - $diffrec_full['old'][$key] = $val; - } + + private function setCharacterEncoding() { + if($this->isConnected == false) return false; + parent::query( 'SET NAMES '.$this->dbCharset); + parent::query( "SET character_set_results = '".$this->dbCharset."', character_set_client = '".$this->dbCharset."', character_set_connection = '".$this->dbCharset."', character_set_database = '".$this->dbCharset."', character_set_server = '".$this->dbCharset."'"); } - } - return array('diff_num' => $diff_num, 'diff_rec' => $diffrec_full); + public function query($queryString) { + global $conf; + if($this->isConnected == false) return false; + $try = 0; + do { + $try++; + $ok = $this->ping(); + if(!$ok) { + if(!$this->real_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) { + if($try > 4) { + $this->updateError('DB::query -> reconnect'); + return false; + } else { + sleep(1); + } + } else { + $this->setCharacterEncoding(); + $ok = true; + } + } + } while($ok == false); + $this->queryId = parent::query($queryString); + $this->updateError('DB::query('.$queryString.') -> mysqli_query'); + if($this->errorNumber && $conf['demo_mode'] === false) debug_print_backtrace(); + if(!$this->queryId) { + return false; + } + $this->currentRow = 0; + return $this->queryId; + } - } + // returns all records in an array + public function queryAllRecords($queryString) { + if(!$this->query($queryString)) + { + return false; + } + $ret = array(); + while($line = $this->nextRecord()) + { + $ret[] = $line; + } + return $ret; + } + + // returns one record in an array + public function queryOneRecord($queryString) { + if(!$this->query($queryString) || $this->numRows() == 0) + { + return false; + } + return $this->nextRecord(); + } + + // returns the next record in an array + public function nextRecord() { + $this->record = $this->queryId->fetch_assoc(); + $this->updateError('DB::nextRecord()-> mysql_fetch_array'); + if(!$this->record || !is_array($this->record)) + { + return false; + } + $this->currentRow++; + return $this->record; + } + + // returns number of rows returned by the last select query + public function numRows() { + return intval($this->queryId->num_rows); + } + + public function affectedRows() { + return intval($this->queryId->affected_rows); + } - //** Function to fill the datalog with a full differential record. - public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new, $force_update = false) { - global $app,$conf; + // returns mySQL insert id + public function insertID() { + return $this->insert_id; + } + + + //* Function to quote strings + public function quote($formfield) { + return $this->escape_string($formfield); + } - // Insert backticks only for incomplete table names. - if(stristr($db_table,'.')) { - $escape = ''; - } else { - $escape = '`'; - } + //* Function to unquotae strings + public function unquote($formfield) { + return stripslashes($formfield); + } + + public function toLower($record) { + if(is_array($record)) { + foreach($record as $key => $val) { + $key = strtolower($key); + $out[$key] = $val; + } + } + return $out; + } + + public function diffrec($record_old, $record_new) { + $diffrec_full = array(); + $diff_num = 0; + + if(is_array($record_old) && count($record_old) > 0) { + foreach($record_old as $key => $val) { + // if(!isset($record_new[$key]) || $record_new[$key] != $val) { + if(@$record_new[$key] != $val) { + // Record has changed + $diffrec_full['old'][$key] = $val; + $diffrec_full['new'][$key] = @$record_new[$key]; + $diff_num++; + } else { + $diffrec_full['old'][$key] = $val; + $diffrec_full['new'][$key] = $val; + } + } + } elseif(is_array($record_new)) { + foreach($record_new as $key => $val) { + if(isset($record_new[$key]) && @$record_old[$key] != $val) { + // Record has changed + $diffrec_full['new'][$key] = $val; + $diffrec_full['old'][$key] = @$record_old[$key]; + $diff_num++; + } else { + $diffrec_full['new'][$key] = $val; + $diffrec_full['old'][$key] = $val; + } + } + } + + return array('diff_num' => $diff_num, 'diff_rec' => $diffrec_full); + + } + + //** Function to fill the datalog with a full differential record. + public function datalogSave($db_table, $action, $primary_field, $primary_id, $record_old, $record_new, $force_update = false) { + global $app, $conf; + + // Insert backticks only for incomplete table names. + if(stristr($db_table, '.')) { + $escape = ''; + } else { + $escape = '`'; + } if($force_update == true) { //* We force a update even if no record has changed - $diffrec_full = array('new' => $record_new,'old' => $record_old); + $diffrec_full = array('new' => $record_new, 'old' => $record_old); $diff_num = count($record_new); } else { //* get the difference record between old and new record @@ -281,135 +281,135 @@ public function toLower($record) { unset($tmp); } - // Insert the server_id, if the record has a server_id - $server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0; - if(isset($record_new['server_id'])) $server_id = $record_new['server_id']; + // Insert the server_id, if the record has a server_id + $server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0; + if(isset($record_new['server_id'])) $server_id = $record_new['server_id']; - if($diff_num > 0) { - //print_r($diff_num); - //print_r($diffrec_full); - $diffstr = $app->db->quote(serialize($diffrec_full)); - $username = $app->db->quote($_SESSION['s']['user']['username']); - $dbidx = $primary_field.':'.$primary_id; + if($diff_num > 0) { + //print_r($diff_num); + //print_r($diffrec_full); + $diffstr = $app->db->quote(serialize($diffrec_full)); + $username = $app->db->quote($_SESSION['s']['user']['username']); + $dbidx = $primary_field.':'.$primary_id; - if($action == 'INSERT') $action = 'i'; - if($action == 'UPDATE') $action = 'u'; - if($action == 'DELETE') $action = 'd'; - $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')"; - $app->db->query($sql); - } + if($action == 'INSERT') $action = 'i'; + if($action == 'UPDATE') $action = 'u'; + if($action == 'DELETE') $action = 'd'; + $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$db_table."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')"; + $app->db->query($sql); + } - return true; - } + return true; + } - //** Inserts a record and saves the changes into the datalog - public function datalogInsert($tablename, $insert_data, $index_field) { - global $app; - - if(is_array($insert_data)) { + //** Inserts a record and saves the changes into the datalog + public function datalogInsert($tablename, $insert_data, $index_field) { + global $app; + + if(is_array($insert_data)) { $key_str = ''; $val_str = ''; foreach($insert_data as $key => $val) { $key_str .= "`".$key ."`,"; $val_str .= "'".$this->quote($val)."',"; } - $key_str = substr($key_str,0,-1); - $val_str = substr($val_str,0,-1); + $key_str = substr($key_str, 0, -1); + $val_str = substr($val_str, 0, -1); $insert_data_str = '('.$key_str.') VALUES ('.$val_str.')'; } else { $insert_data_str = $insert_data; } - $old_rec = array(); - $this->query("INSERT INTO $tablename $insert_data_str"); - $index_value = $this->insertID(); - $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); - $this->datalogSave($tablename, 'INSERT', $index_field, $index_value, $old_rec, $new_rec); + $old_rec = array(); + $this->query("INSERT INTO $tablename $insert_data_str"); + $index_value = $this->insertID(); + $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); + $this->datalogSave($tablename, 'INSERT', $index_field, $index_value, $old_rec, $new_rec); - return $index_value; - } + return $index_value; + } - //** Updates a record and saves the changes into the datalog - public function datalogUpdate($tablename, $update_data, $index_field, $index_value, $force_update = false) { + //** Updates a record and saves the changes into the datalog + public function datalogUpdate($tablename, $update_data, $index_field, $index_value, $force_update = false) { global $app; - - $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); - - if(is_array($update_data)) { + + $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); + + if(is_array($update_data)) { $update_data_str = ''; foreach($update_data as $key => $val) { $update_data_str .= "`".$key ."` = '".$this->quote($val)."',"; } - $update_data_str = substr($update_data_str,0,-1); + $update_data_str = substr($update_data_str, 0, -1); } else { $update_data_str = $update_data; } - - $this->query("UPDATE $tablename SET $update_data_str WHERE $index_field = '$index_value'"); - $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); - $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec, $force_update); - return true; - } + $this->query("UPDATE $tablename SET $update_data_str WHERE $index_field = '$index_value'"); + $new_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); + $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec, $force_update); - //** Deletes a record and saves the changes into the datalog - public function datalogDelete($tablename, $index_field, $index_value) { - global $app; + return true; + } - $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); - $this->query("DELETE FROM $tablename WHERE $index_field = '$index_value'"); - $new_rec = array(); - $this->datalogSave($tablename, 'DELETE', $index_field, $index_value, $old_rec, $new_rec); + //** Deletes a record and saves the changes into the datalog + public function datalogDelete($tablename, $index_field, $index_value) { + global $app; - return true; - } - - //* get the current datalog status for the specified login (or currently logged in user) - public function datalogStatus($login = '') { - global $app; - - $return = array('count' => 0, 'entries' => array()); - if($_SESSION['s']['user']['typ'] == 'admin') return $return; // these information should not be displayed to admin users - - if($login == '' && isset($_SESSION['s']['user'])) { - $login = $_SESSION['s']['user']['username']; - } - - $result = $this->queryAllRecords("SELECT COUNT( * ) AS cnt, sys_datalog.action, sys_datalog.dbtable FROM sys_datalog, server WHERE server.server_id = sys_datalog.server_id AND sys_datalog.user = '" . $this->quote($login) . "' AND sys_datalog.datalog_id > server.updated GROUP BY sys_datalog.dbtable, sys_datalog.action"); - foreach($result as $row) { - if(!$row['dbtable'] || in_array($row['dbtable'], array('aps_instances', 'aps_instances_settings', 'mail_access', 'mail_content_filter'))) continue; // ignore some entries, maybe more to come - $return['entries'][] = array('table' => $row['dbtable'], 'action' => $row['action'], 'count' => $row['cnt'], 'text' => $app->lng('datalog_status_' . $row['action'] . '_' . $row['dbtable'])); - $return['count'] += $row['cnt']; - } - unset($result); - - return $return; - } + $old_rec = $this->queryOneRecord("SELECT * FROM $tablename WHERE $index_field = '$index_value'"); + $this->query("DELETE FROM $tablename WHERE $index_field = '$index_value'"); + $new_rec = array(); + $this->datalogSave($tablename, 'DELETE', $index_field, $index_value, $old_rec, $new_rec); + return true; + } - public function freeResult($query) - { - if(is_object($query) && (get_class($query) == "mysqli_result")) { - $query->free(); - return true; - } else { - return false; - } - } + //* get the current datalog status for the specified login (or currently logged in user) + public function datalogStatus($login = '') { + global $app; - /* TODO: Does anything use this? */ - public function delete() { + $return = array('count' => 0, 'entries' => array()); + if($_SESSION['s']['user']['typ'] == 'admin') return $return; // these information should not be displayed to admin users - } + if($login == '' && isset($_SESSION['s']['user'])) { + $login = $_SESSION['s']['user']['username']; + } - /* TODO: Does anything use this? */ - public function Transaction($action) { - //action = begin, commit oder rollback + $result = $this->queryAllRecords("SELECT COUNT( * ) AS cnt, sys_datalog.action, sys_datalog.dbtable FROM sys_datalog, server WHERE server.server_id = sys_datalog.server_id AND sys_datalog.user = '" . $this->quote($login) . "' AND sys_datalog.datalog_id > server.updated GROUP BY sys_datalog.dbtable, sys_datalog.action"); + foreach($result as $row) { + if(!$row['dbtable'] || in_array($row['dbtable'], array('aps_instances', 'aps_instances_settings', 'mail_access', 'mail_content_filter'))) continue; // ignore some entries, maybe more to come + $return['entries'][] = array('table' => $row['dbtable'], 'action' => $row['action'], 'count' => $row['cnt'], 'text' => $app->lng('datalog_status_' . $row['action'] . '_' . $row['dbtable'])); + $return['count'] += $row['cnt']; + } + unset($result); - } + return $return; + } + + + public function freeResult($query) + { + if(is_object($query) && (get_class($query) == "mysqli_result")) { + $query->free(); + return true; + } else { + return false; + } + } - /* + /* TODO: Does anything use this? */ + public function delete() { + + } + + /* TODO: Does anything use this? */ + public function Transaction($action) { + //action = begin, commit oder rollback + + } + + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -423,33 +423,33 @@ public function toLower($record) { */ - public function createTable($table_name,$columns) { - $index = ''; - $sql = "CREATE TABLE $table_name ("; - foreach($columns as $col){ - $sql .= $col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' '; - - if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' "; - if($col['notNull'] == true) { - $sql .= 'NOT NULL '; - } else { - $sql .= 'NULL '; + public function createTable($table_name, $columns) { + $index = ''; + $sql = "CREATE TABLE $table_name ("; + foreach($columns as $col){ + $sql .= $col['name'].' '.$this->mapType($col['type'], $col['typeValue']).' '; + + if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' "; + if($col['notNull'] == true) { + $sql .= 'NOT NULL '; + } else { + $sql .= 'NULL '; + } + if($col['autoInc'] == true) $sql .= 'auto_increment '; + $sql.= ','; + // key Definitionen + if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),'; + if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),'; + if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),'; + } + $sql .= $index; + $sql = substr($sql, 0, -1); + $sql .= ')'; + $this->query($sql); + return true; } - if($col['autoInc'] == true) $sql .= 'auto_increment '; - $sql.= ','; - // key Definitionen - if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),'; - if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),'; - if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),'; - } - $sql .= $index; - $sql = substr($sql,0,-1); - $sql .= ')'; - $this->query($sql); - return true; - } - /* + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -462,59 +462,59 @@ public function toLower($record) { */ - public function alterTable($table_name,$columns) { - $index = ''; - $sql = "ALTER TABLE $table_name "; - foreach($columns as $col){ - if($col['action'] == 'add') { - $sql .= 'ADD '.$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' '; - } elseif ($col['action'] == 'alter') { - $sql .= 'CHANGE '.$col['name'].' '.$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' '; - } elseif ($col['action'] == 'drop') { - $sql .= 'DROP '.$col['name'].' '; - } - if($col['action'] != 'drop') { - if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' "; - if($col['notNull'] == true) { - $sql .= 'NOT NULL '; - } else { - $sql .= 'NULL '; - } - if($col['autoInc'] == true) $sql .= 'auto_increment '; - $sql.= ','; - // Index definitions - if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),'; - if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),'; - if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),'; - } - } - $sql .= $index; - $sql = substr($sql,0,-1); + public function alterTable($table_name, $columns) { + $index = ''; + $sql = "ALTER TABLE $table_name "; + foreach($columns as $col){ + if($col['action'] == 'add') { + $sql .= 'ADD '.$col['name'].' '.$this->mapType($col['type'], $col['typeValue']).' '; + } elseif ($col['action'] == 'alter') { + $sql .= 'CHANGE '.$col['name'].' '.$col['name_new'].' '.$this->mapType($col['type'], $col['typeValue']).' '; + } elseif ($col['action'] == 'drop') { + $sql .= 'DROP '.$col['name'].' '; + } + if($col['action'] != 'drop') { + if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' "; + if($col['notNull'] == true) { + $sql .= 'NOT NULL '; + } else { + $sql .= 'NULL '; + } + if($col['autoInc'] == true) $sql .= 'auto_increment '; + $sql.= ','; + // Index definitions + if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),'; + if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),'; + if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),'; + } + } + $sql .= $index; + $sql = substr($sql, 0, -1); - //die($sql); - $this->query($sql); - return true; - } + //die($sql); + $this->query($sql); + return true; + } - public function dropTable($table_name) { - $this->check($table_name); - $sql = "DROP TABLE '". $table_name."'"; - return $this->query($sql); - } + public function dropTable($table_name) { + $this->check($table_name); + $sql = "DROP TABLE '". $table_name."'"; + return $this->query($sql); + } - // gibt Array mit Tabellennamen zur�ck - public function getTables($database_name = '') { - if($this->isConnected == false) return false; - if($database_name == '') $database_name = $this->dbName; - $result = parent::query("SHOW TABLES FROM $database_name"); - for ($i = 0; $i < $result->num_rows; $i++) { - $tb_names[$i] = (($result->data_seek( $i) && (($___mysqli_tmp = $result->fetch_row()) !== NULL)) ? array_shift($___mysqli_tmp) : false); - } - return $tb_names; - } + // gibt Array mit Tabellennamen zur�ck + public function getTables($database_name = '') { + if($this->isConnected == false) return false; + if($database_name == '') $database_name = $this->dbName; + $result = parent::query("SHOW TABLES FROM $database_name"); + for ($i = 0; $i < $result->num_rows; $i++) { + $tb_names[$i] = (($result->data_seek( $i) && (($___mysqli_tmp = $result->fetch_row()) !== NULL)) ? array_shift($___mysqli_tmp) : false); + } + return $tb_names; + } - // gibt Feldinformationen zur Tabelle zur�ck - /* + // gibt Feldinformationen zur Tabelle zur�ck + /* $columns = array(action => add | alter | drop name => Spaltenname name_new => neuer Spaltenname, nur bei 'alter' belegt @@ -528,14 +528,14 @@ public function toLower($record) { */ - function tableInfo($table_name) { + function tableInfo($table_name) { - global $go_api,$go_info,$app; - // Tabellenfelder einlesen + global $go_api, $go_info, $app; + // Tabellenfelder einlesen - if($rows = $app->db->queryAllRecords('SHOW FIELDS FROM '.$table_name)){ - foreach($rows as $row) { - /* + if($rows = $app->db->queryAllRecords('SHOW FIELDS FROM '.$table_name)){ + foreach($rows as $row) { + /* $name = $row[0]; $default = $row[4]; $key = $row[3]; @@ -543,61 +543,61 @@ public function toLower($record) { $isnull = $row[2]; $type = $row[1]; */ - - $name = $row['Field']; - $default = $row['Default']; - $key = $row['Key']; - $extra = $row['Extra']; - $isnull = $row['Null']; - $type = $row['Type']; - - - $column = array(); - - $column['name'] = $name; - //$column['type'] = $type; - $column['defaultValue'] = $default; - if(stristr($key,'PRI')) $column['option'] = 'primary'; - if(stristr($isnull,'YES')) { - $column['notNull'] = false; - } else { - $column['notNull'] = true; - } - if($extra == 'auto_increment') $column['autoInc'] = true; - - - // Type in Metatype umsetzen - - if(stristr($type,'int(')) $metaType = 'int32'; - if(stristr($type,'bigint')) $metaType = 'int64'; - if(stristr($type,'char')) { - $metaType = 'char'; - $tmp_typeValue = explode('(',$type); - $column['typeValue'] = substr($tmp_typeValue[1],0,-1); - } - if(stristr($type,'varchar')) { - $metaType = 'varchar'; - $tmp_typeValue = explode('(',$type); - $column['typeValue'] = substr($tmp_typeValue[1],0,-1); - } - if(stristr($type,'text')) $metaType = 'text'; - if(stristr($type,'double')) $metaType = 'double'; - if(stristr($type,'blob')) $metaType = 'blob'; - - - $column['type'] = $metaType; - - $columns[] = $column; - } - return $columns; - } else { - return false; - } - - - //$this->createTable('tester',$columns); - - /* + + $name = $row['Field']; + $default = $row['Default']; + $key = $row['Key']; + $extra = $row['Extra']; + $isnull = $row['Null']; + $type = $row['Type']; + + + $column = array(); + + $column['name'] = $name; + //$column['type'] = $type; + $column['defaultValue'] = $default; + if(stristr($key, 'PRI')) $column['option'] = 'primary'; + if(stristr($isnull, 'YES')) { + $column['notNull'] = false; + } else { + $column['notNull'] = true; + } + if($extra == 'auto_increment') $column['autoInc'] = true; + + + // Type in Metatype umsetzen + + if(stristr($type, 'int(')) $metaType = 'int32'; + if(stristr($type, 'bigint')) $metaType = 'int64'; + if(stristr($type, 'char')) { + $metaType = 'char'; + $tmp_typeValue = explode('(', $type); + $column['typeValue'] = substr($tmp_typeValue[1], 0, -1); + } + if(stristr($type, 'varchar')) { + $metaType = 'varchar'; + $tmp_typeValue = explode('(', $type); + $column['typeValue'] = substr($tmp_typeValue[1], 0, -1); + } + if(stristr($type, 'text')) $metaType = 'text'; + if(stristr($type, 'double')) $metaType = 'double'; + if(stristr($type, 'blob')) $metaType = 'blob'; + + + $column['type'] = $metaType; + + $columns[] = $column; + } + return $columns; + } else { + return false; + } + + + //$this->createTable('tester',$columns); + + /* $result = mysql_list_fields($go_info["server"]["db_name"],$table_name); $fields = mysql_num_fields ($result); $i = 0; @@ -622,40 +622,40 @@ public function toLower($record) { - } + } + + public function mapType($metaType, $typeValue) { + global $go_api; + $metaType = strtolower($metaType); + switch ($metaType) { + case 'int16': + return 'smallint'; + break; + case 'int32': + return 'int'; + break; + case 'int64': + return 'bigint'; + break; + case 'double': + return 'double'; + break; + case 'char': + return 'char'; + break; + case 'varchar': + if($typeValue < 1) die('Database failure: Lenght required for these data types.'); + return 'varchar('.$typeValue.')'; + break; + case 'text': + return 'text'; + break; + case 'blob': + return 'blob'; + break; + } + } + +} - public function mapType($metaType,$typeValue) { - global $go_api; - $metaType = strtolower($metaType); - switch ($metaType) { - case 'int16': - return 'smallint'; - break; - case 'int32': - return 'int'; - break; - case 'int64': - return 'bigint'; - break; - case 'double': - return 'double'; - break; - case 'char': - return 'char'; - break; - case 'varchar': - if($typeValue < 1) die('Database failure: Lenght required for these data types.'); - return 'varchar('.$typeValue.')'; - break; - case 'text': - return 'text'; - break; - case 'blob': - return 'blob'; - break; - } - } - - } - - ?> \ No newline at end of file +?> diff --git a/interface/lib/classes/form.inc.php b/interface/lib/classes/form.inc.php index 898cbe6c0..34c0b626c 100644 --- a/interface/lib/classes/form.inc.php +++ b/interface/lib/classes/form.inc.php @@ -29,165 +29,192 @@ 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 -*/ + * 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 - */ + * Definition der Tabelle (array) + * @var tableDef + */ var $tableDef; - + + + /** - * Private - * @var action - */ + * Private + * @var action + */ var $action; - + + + /** - * Tabellenname (String) - * @var table_name - */ + * Tabellenname (String) + * @var table_name + */ var $table_name; - + + + /** - * Debug Variable - * @var debug - */ + * Debug Variable + * @var debug + */ var $debug = 0; - + + + /** - * name des primary Field der Tabelle (string) - * @var table_index - */ + * 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 - */ + * enthält die Fehlermeldung bei Überprüfung + * der Variablen mit Regex + * @var errorMessage + */ var $errorMessage; - + var $dateformat = "d.m.Y"; - var $formDef; - + var $formDef; + + + + + /** - * Laden der Tabellendefinition - * - * @param file: Pfad zur Tabellendefinition - * @return true - */ + * Laden der Tabellendefinition + * + * @param file: Pfad zur Tabellendefinition + * @return true + */ function loadTableDef($file) { - global $app,$conf; - - include_once($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); + + 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 - */ + * 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) { - global $app; + global $app; if(is_array($record)) { foreach($record as $key => $val) { switch ($this->tableDef[$key]['datatype']) { case 'VARCHAR': $new_record[$key] = stripslashes($val); - break; - + break; + case 'DATE': if($val > 0) { - $new_record[$key] = date($this->dateformat,$val); + $new_record[$key] = date($this->dateformat, $val); } - break; - + break; + case 'INTEGER': $new_record[$key] = $app->functions->intval($val); - break; - + break; + case 'DOUBLE': $new_record[$key] = $val; - break; - + break; + case 'CURRENCY': $new_record[$key] = number_format($val, 2, ',', ''); - break; - + break; + default: $new_record[$key] = stripslashes($val); } } - + } - return $new_record; + 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') { - + * 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); @@ -203,32 +230,32 @@ class form { } } $new_record[$key] = $out; - break; + break; case 'MULTIPLE': if(is_array($this->tableDef[$key]['value'])) { - + // aufsplitten ergebnisse - $vals = explode($this->tableDef[$key]['separator'],$val); - + $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 .= "\r\n"; } } $new_record[$key] = $out; - break; - + break; + case 'PASSWORD': $new_record[$key] = ''; - break; - + break; + default: $new_record[$key] = htmlspecialchars($val); } @@ -246,50 +273,54 @@ class form { } } $new_record[$key] = $out; - break; + 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 .= "\r\n"; - } + 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 .= "\r\n"; } - $new_record[$key] = $out; + } + $new_record[$key] = $out; break; - + case 'PASSWORD': $new_record[$key] = ''; - break; - + 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 - */ + * 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) { global $app; $this->errorMessage = ''; - + if(is_array($record)) { foreach($record as $key => $val) { switch ($this->tableDef[$key]['datatype']) { @@ -297,26 +328,26 @@ class form { if(!is_array($val)) { $new_record[$key] = $app->db->quote($val); } else { - $new_record[$key] = implode($this->tableDef[$key]['separator'],$val); + $new_record[$key] = implode($this->tableDef[$key]['separator'], $val); } - break; + break; case 'DATE': if($val > 0) { - list($tag,$monat,$jahr) = explode('.',$val); - $new_record[$key] = mktime(0,0,0,$monat,$tag,$jahr); + list($tag, $monat, $jahr) = explode('.', $val); + $new_record[$key] = mktime(0, 0, 0, $monat, $tag, $jahr); } - break; + break; case 'INTEGER': $new_record[$key] = $app->functions->intval($val); - break; + break; case 'DOUBLE': $new_record[$key] = $app->db->quote($val); - break; + break; case 'CURRENCY': - $new_record[$key] = str_replace(",",".",$val); - break; + $new_record[$key] = str_replace(",", ".", $val); + break; } - + if($this->tableDef[$key]['regex'] != '') { // Enable that "." matches also newlines $this->tableDef[$key]['regex'] .= 's'; @@ -325,152 +356,160 @@ class form { } } } - + } return $new_record; } - + + + + + /** - * SQL Statement für Record erzeugen. - * - * @param record = Datensatz als Array - * @param action = INSERT oder UPDATE - * @param primary_id - * @return 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', "; + 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 { - $sql_update .= "`$key` = '$val', "; + + 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,'.')) { + 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_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 = 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 - */ + * Debugging arrays. + * + * @param array_data + */ function dbg($array_data) { - + echo "
";
 		print_r($array_data);
 		echo "
"; - + } - - - function showForm() { - global $app,$conf; - - if(!is_array($this->formDef)) die("Form Definition wurde nicht geladen."); - - if($this->errorMessage == '') { - // wenn kein Fehler vorliegt + + + 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"]; - } + // 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"]; + // 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; } - - // 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); + + // setze Loop + $app->tpl->setLoop("formTab", $frmTab); // Formular action setzen - $app->tpl->setVar('form_action',$this->formDef["action"]); - } - - + $app->tpl->setVar('form_action', $this->formDef["action"]); + } + + } ?> diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 0028b3974..48aa3619f 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -33,14 +33,14 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class functions { var $idn_converter = null; - var $idn_converter_name = ''; + var $idn_converter_name = ''; public function mail($to, $subject, $text, $from, $filepath = '', $filetype = 'application/pdf', $filename = '', $cc = '', $bcc = '', $from_name = '') { - global $app,$conf; - + global $app, $conf; + if($conf['demo_mode'] == true) $app->error("Mail sending disabled in demo mode."); - - $app->uses('getconf,ispcmail'); + + $app->uses('getconf,ispcmail'); $mail_config = $app->getconf->get_global_config('mail'); if($mail_config['smtp_enabled'] == 'y') { $mail_config['use_smtp'] = true; @@ -49,58 +49,58 @@ class functions { $app->ispcmail->setSender($from, $from_name); $app->ispcmail->setSubject($subject); $app->ispcmail->setMailText($text); - + if($filepath != '') { if(!file_exists($filepath)) $app->error("Mail attachement does not exist ".$filepath); $app->ispcmail->readAttachFile($filepath); } - + if($cc != '') $app->ispcmail->setHeader('Cc', $cc); if($bcc != '') $app->ispcmail->setHeader('Bcc', $bcc); - + $app->ispcmail->send($to); $app->ispcmail->finish(); - + return true; } - - public function array_merge($array1,$array2) { + + public function array_merge($array1, $array2) { $out = $array1; foreach($array2 as $key => $val) { $out[$key] = $val; } return $out; } - + public function currency_format($number, $view = '') { global $app; if($view != '') $number_format_decimals = (int)$app->lng('number_format_decimals_'.$view); - if(!$number_format_decimals) $number_format_decimals = (int)$app->lng('number_format_decimals'); - + if(!$number_format_decimals) $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); } - + //* convert currency formatted number back to floating number public function currency_unformat($number) { global $app; - + $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 = ''; - + if($number_format_thousands_sep != '') $number = str_replace($number_format_thousands_sep, '', $number); if($number_format_dec_point != '.' && $number_format_dec_point != '') $number = str_replace($number_format_dec_point, '.', $number); - + return (double)$number; } - + public function get_ispconfig_url() { global $app; - - $url = (stristr($_SERVER['SERVER_PROTOCOL'],'HTTPS') || stristr($_SERVER['HTTPS'],'on'))?'https':'http'; + + $url = (stristr($_SERVER['SERVER_PROTOCOL'], 'HTTPS') || stristr($_SERVER['HTTPS'], 'on'))?'https':'http'; if($_SERVER['SERVER_NAME'] != '_') { $url .= '://'.$_SERVER['SERVER_NAME']; if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { @@ -108,7 +108,7 @@ class functions { } } else { $app->uses("getconf"); - $server_config = $app->getconf->get_server_config(1,'server'); + $server_config = $app->getconf->get_server_config(1, 'server'); $url .= '://'.$server_config['hostname']; if($_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) { $url .= ':'.$_SERVER['SERVER_PORT']; @@ -116,53 +116,53 @@ class functions { } return $url; } - - public function json_encode($data) { + + public function json_encode($data) { if(!function_exists('json_encode')){ if(is_array($data) || is_object($data)){ - $islist = is_array($data) && (empty($data) || array_keys($data) === range(0,count($data)-1)); + $islist = is_array($data) && (empty($data) || array_keys($data) === range(0, count($data)-1)); if($islist){ $json = '[' . implode(',', array_map(array($this, "json_encode"), $data) ) . ']'; } else { - $items = Array(); + $items = array(); foreach( $data as $key => $value ) { $items[] = $this->json_encode("$key") . ':' . $this->json_encode($value); } $json = '{' . implode(',', $items) . '}'; } } elseif(is_string($data)){ - # Escape non-printable or Non-ASCII characters. - # I also put the \\ character first, as suggested in comments on the 'addclashes' page. + // Escape non-printable or Non-ASCII characters. + // I also put the \\ character first, as suggested in comments on the 'addclashes' page. $string = '"'.addcslashes($data, "\\\"\n\r\t/".chr(8).chr(12)).'"'; $json = ''; $len = strlen($string); - # Convert UTF-8 to Hexadecimal Codepoints. + // Convert UTF-8 to Hexadecimal Codepoints. for($i = 0; $i < $len; $i++){ $char = $string[$i]; $c1 = ord($char); - # Single byte; + // Single byte; if($c1 <128){ $json .= ($c1 > 31) ? $char : sprintf("\\u%04x", $c1); continue; } - # Double byte + // Double byte $c2 = ord($string[++$i]); if(($c1 & 32) === 0){ $json .= sprintf("\\u%04x", ($c1 - 192) * 64 + $c2 - 128); continue; } - # Triple + // Triple $c3 = ord($string[++$i]); if(($c1 & 16) === 0){ $json .= sprintf("\\u%04x", (($c1 - 224) <<12) + (($c2 - 128) << 6) + ($c3 - 128)); continue; } - # Quadruple + // Quadruple $c4 = ord($string[++$i]); if(($c1 & 8) === 0){ $u = (($c1 & 15) << 2) + (($c2>>4) & 3) - 1; @@ -173,25 +173,25 @@ class functions { } } } else { - # int, floats, bools, null + // int, floats, bools, null $json = strtolower(var_export($data, true)); } return $json; } else { return json_encode($data); } - } - + } + public function suggest_ips($type = 'IPv4'){ global $app; - + if($type == 'IPv4'){ $regex = "/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/"; } else { // IPv6 $regex = "/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i"; } - + $server_by_id = array(); $server_by_ip = array(); $servers = $app->db->queryAllRecords("SELECT * FROM server"); @@ -200,7 +200,7 @@ class functions { $server_by_id[$server['server_id']] = $server['server_name']; } } - + $ips = array(); $results = $app->db->queryAllRecords("SELECT ip_address AS ip, server_id FROM server_ip WHERE ip_type = '".$type."'"); if(!empty($results) && is_array($results)){ @@ -229,7 +229,7 @@ class functions { if(preg_match($regex, $result['ip'])) $ips[] = $result['ip']; } } - + $results = $app->db->queryAllRecords("SELECT xfer FROM dns_slave WHERE xfer != ''"); if(!empty($results) && is_array($results)){ foreach($results as $result){ @@ -274,117 +274,119 @@ class functions { sort($ips, SORT_NUMERIC); $result_array = array('cheader' => array(), 'cdata' => array()); - + if(!empty($ips)){ $result_array['cheader'] = array('title' => 'IPs', - 'total' => count($ips), - 'limit' => count($ips) - ); - + 'total' => count($ips), + 'limit' => count($ips) + ); + foreach($ips as $ip){ - $result_array['cdata'][] = array( 'title' => $ip, - 'description' => $type.($server_by_ip[$ip] != ''? ' > '.$server_by_ip[$ip] : ''), - 'onclick' => '', - 'fill_text' => $ip - ); + $result_array['cdata'][] = array( 'title' => $ip, + 'description' => $type.($server_by_ip[$ip] != ''? ' > '.$server_by_ip[$ip] : ''), + 'onclick' => '', + 'fill_text' => $ip + ); } } - + return $result_array; } - public function intval($string, $force_numeric = false) { - if(intval($string) == 2147483647 || ($string > 0 && intval($string) < 0)) { - if($force_numeric == true) return floatval($string); - elseif(preg_match('/^([-]?)[0]*([1-9][0-9]*)([^0-9].*)*$/', $string, $match)) return $match[1].$match[2]; - else return 0; - } else { - return intval($string); - } - } - - /** - * Function to change bytes to kB, MB, GB or TB - * @param int $size - size in bytes - * @param int precicion - after-comma-numbers (default: 2) - * @return string - formated bytes - */ - public function formatBytes($size, $precision = 2) { - $base=log($size)/log(1024); - $suffixes=array('','k','M','G','T'); - return round(pow(1024,$base-floor($base)),$precision).$suffixes[floor($base)]; - } - - /** IDN converter wrapper. - * all converter classes should be placed in ISPC_CLASS_PATH.'/idn/' - */ - private function _idn_encode_decode($domain, $encode = true) { - if($domain == '') return ''; - if(preg_match('/^[0-9\.]+$/', $domain)) return $domain; // may be an ip address - anyway does not need to bee encoded - - // get domain and user part if it is an email - $user_part = false; - if(strpos($domain, '@') !== false) { - $user_part = substr($domain, 0, strrpos($domain, '@')); - $domain = substr($domain, strrpos($domain, '@') + 1); - } - - if($encode == true) { - if(function_exists('idn_to_ascii')) { - $domain = idn_to_ascii($domain); - } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { - /* use idna class: + public function intval($string, $force_numeric = false) { + if(intval($string) == 2147483647 || ($string > 0 && intval($string) < 0)) { + if($force_numeric == true) return floatval($string); + elseif(preg_match('/^([-]?)[0]*([1-9][0-9]*)([^0-9].*)*$/', $string, $match)) return $match[1].$match[2]; + else return 0; + } else { + return intval($string); + } + } + + /** + * Function to change bytes to kB, MB, GB or TB + * @param int $size - size in bytes + * @param int precicion - after-comma-numbers (default: 2) + * @return string - formated bytes + */ + + + public function formatBytes($size, $precision = 2) { + $base=log($size)/log(1024); + $suffixes=array('', 'k', 'M', 'G', 'T'); + return round(pow(1024, $base-floor($base)), $precision).$suffixes[floor($base)]; + } + + /** IDN converter wrapper. + * all converter classes should be placed in ISPC_CLASS_PATH.'/idn/' + */ + private function _idn_encode_decode($domain, $encode = true) { + if($domain == '') return ''; + if(preg_match('/^[0-9\.]+$/', $domain)) return $domain; // may be an ip address - anyway does not need to bee encoded + + // get domain and user part if it is an email + $user_part = false; + if(strpos($domain, '@') !== false) { + $user_part = substr($domain, 0, strrpos($domain, '@')); + $domain = substr($domain, strrpos($domain, '@') + 1); + } + + if($encode == true) { + if(function_exists('idn_to_ascii')) { + $domain = idn_to_ascii($domain); + } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { + /* use idna class: * @author Matthias Sommerfeld * @copyright 2004-2011 phlyLabs Berlin, http://phlylabs.de * @version 0.8.0 2011-03-11 */ - - if(!is_object($this->idn_converter) || $this->idn_converter_name != 'idna_convert.class') { - include_once(ISPC_CLASS_PATH.'/idn/idna_convert.class.php'); - $this->idn_converter = new idna_convert(array('idn_version' => 2008)); - $this->idn_converter_name = 'idna_convert.class'; - } - $domain = $this->idn_converter->encode($domain); - } - } else { - if(function_exists('idn_to_utf8')) { - $domain = idn_to_utf8($domain); - } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { - /* use idna class: + + if(!is_object($this->idn_converter) || $this->idn_converter_name != 'idna_convert.class') { + include_once ISPC_CLASS_PATH.'/idn/idna_convert.class.php'; + $this->idn_converter = new idna_convert(array('idn_version' => 2008)); + $this->idn_converter_name = 'idna_convert.class'; + } + $domain = $this->idn_converter->encode($domain); + } + } else { + if(function_exists('idn_to_utf8')) { + $domain = idn_to_utf8($domain); + } elseif(file_exists(ISPC_CLASS_PATH.'/idn/idna_convert.class.php')) { + /* use idna class: * @author Matthias Sommerfeld * @copyright 2004-2011 phlyLabs Berlin, http://phlylabs.de * @version 0.8.0 2011-03-11 */ - - if(!is_object($this->idn_converter) || $this->idn_converter_name != 'idna_convert.class') { - include_once(ISPC_CLASS_PATH.'/idn/idna_convert.class.php'); - $this->idn_converter = new idna_convert(array('idn_version' => 2008)); - $this->idn_converter_name = 'idna_convert.class'; - } - $domain = $this->idn_converter->decode($domain); - } - } - - if($user_part !== false) return $user_part . '@' . $domain; - else return $domain; - } - - public function idn_encode($domain) { - $domains = explode("\n", $domain); - for($d = 0; $d < count($domains); $d++) { - $domains[$d] = $this->_idn_encode_decode($domains[$d], true); - } - return implode("\n", $domains); - } - - public function idn_decode($domain) { - $domains = explode("\n", $domain); - for($d = 0; $d < count($domains); $d++) { - $domains[$d] = $this->_idn_encode_decode($domains[$d], false); - } - return implode("\n", $domains); - } - + + if(!is_object($this->idn_converter) || $this->idn_converter_name != 'idna_convert.class') { + include_once ISPC_CLASS_PATH.'/idn/idna_convert.class.php'; + $this->idn_converter = new idna_convert(array('idn_version' => 2008)); + $this->idn_converter_name = 'idna_convert.class'; + } + $domain = $this->idn_converter->decode($domain); + } + } + + if($user_part !== false) return $user_part . '@' . $domain; + else return $domain; + } + + public function idn_encode($domain) { + $domains = explode("\n", $domain); + for($d = 0; $d < count($domains); $d++) { + $domains[$d] = $this->_idn_encode_decode($domains[$d], true); + } + return implode("\n", $domains); + } + + public function idn_decode($domain) { + $domains = explode("\n", $domain); + for($d = 0; $d < count($domains); $d++) { + $domains[$d] = $this->_idn_encode_decode($domains[$d], false); + } + return implode("\n", $domains); + } + } ?> diff --git a/interface/lib/classes/getconf.inc.php b/interface/lib/classes/getconf.inc.php index ad2a30231..45fefa601 100644 --- a/interface/lib/classes/getconf.inc.php +++ b/interface/lib/classes/getconf.inc.php @@ -31,7 +31,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class getconf { private $config; - + public function get_server_config($server_id, $section = '') { global $app; @@ -43,10 +43,10 @@ class getconf { } return ($section == '') ? $this->config[$server_id] : $this->config[$server_id][$section]; } - + public function get_global_config($section = '') { global $app; - + if(!isset($this->config['global'])) { $app->uses('ini_parser'); $tmp = $app->db->queryOneRecord('SELECT config FROM sys_ini WHERE sysini_id = 1'); @@ -54,6 +54,7 @@ class getconf { } return ($section == '') ? $this->config['global'] : $this->config['global'][$section]; } + } ?> diff --git a/interface/lib/classes/importer.inc.php b/interface/lib/classes/importer.inc.php index e74c0993a..f6cbab570 100644 --- a/interface/lib/classes/importer.inc.php +++ b/interface/lib/classes/importer.inc.php @@ -30,56 +30,59 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -require_once(realpath(dirname(__FILE__)) . '/remoting.inc.php'); +require_once realpath(dirname(__FILE__)) . '/remoting.inc.php'; class fakeserver { - private $faultMessage; - private $faultText; - public function fault($message = '', $text = '') { - $this->faultMessage = $message; - $this->faultText = $text; - } - - public function getFault() { - $ret = $this->faultMessage . ' (' . $this->faultText . ')'; - $this->faultMessage = null; - $this->faultText = null; - return $ret; - } + private $faultMessage; + private $faultText; + public function fault($message = '', $text = '') { + $this->faultMessage = $message; + $this->faultText = $text; + } + + public function getFault() { + $ret = $this->faultMessage . ' (' . $this->faultText . ')'; + $this->faultMessage = null; + $this->faultText = null; + return $ret; + } + } class importer extends remoting { public function __construct() - { - $this->server = new fakeserver(); - } + { + $this->server = new fakeserver(); + } //* remote login function - overridden just to make sure it cannot be called from importer scripts public function login($username, $password) - { - + { + } - + //* remote logout function - overridden just to make sure it cannot be called from importer scripts public function logout($session_id) - { - + { + } - + public function getFault() { - return $this->server->getFault(); - } - + return $this->server->getFault(); + } + protected function checkPerm($session_id, $function_name) - { - // always return true as this is used from inside the application not through remote calls - return true; + { + // always return true as this is used from inside the application not through remote calls + return true; } - - + + protected function getSession($session_id) - { + { return array(); // we have no sessions here } + } + ?> diff --git a/interface/lib/classes/ini_parser.inc.php b/interface/lib/classes/ini_parser.inc.php index 630311575..b8dffbafa 100644 --- a/interface/lib/classes/ini_parser.inc.php +++ b/interface/lib/classes/ini_parser.inc.php @@ -59,8 +59,8 @@ class ini_parser{ $content .= "[$section]\n"; foreach($data as $item => $value) { if($item != ''){ - $value = trim($value); - $item = trim($item); + $value = trim($value); + $item = trim($item); $content .= "$item=$value\n"; } } diff --git a/interface/lib/classes/ispcmail.inc.php b/interface/lib/classes/ispcmail.inc.php index d49af96fc..dff71f3b8 100644 --- a/interface/lib/classes/ispcmail.inc.php +++ b/interface/lib/classes/ispcmail.inc.php @@ -30,498 +30,544 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** * email class - * + * * @package pxFramework * */ + + class ispcmail { - - /**#@+ + + /**#@+ * @access private */ - private $html_part; - private $text_part; - - private $headers; - - private $_logged_in = false; - private $_smtp_conn = null; - - private $_crlf = "\n"; - - private $attach_type = 'application/octet-stream'; - private $attachments; - private $mime_boundary; - private $body = ''; - private $_mail_sender = ''; - private $_sent_mails = 0; - private $user_agent = 'ISPConfig/3 (Mailer Class)'; - /**#@-*/ - - /** - * set the mail charset - */ - private $mail_charset = 'UTF-8';//'ISO-8859-1'; - - /**#@+ + private $html_part; + private $text_part; + + private $headers; + + private $_logged_in = false; + private $_smtp_conn = null; + + private $_crlf = "\n"; + + private $attach_type = 'application/octet-stream'; + private $attachments; + private $mime_boundary; + private $body = ''; + private $_mail_sender = ''; + private $_sent_mails = 0; + private $user_agent = 'ISPConfig/3 (Mailer Class)'; + /**#@-*/ + + + + /** + * set the mail charset + */ + private $mail_charset = 'UTF-8';//'ISO-8859-1'; + + /**#@+ * Provide smtp credentials for smtp mail sending * * @access public */ - /** - * if set to true smtp is used instead of mail() to send emails - * @see mail - */ - private $use_smtp = false; - /** - * the smtp helo string - use the mail server name here! - */ - private $smtp_helo = ''; - /** - * the smtp server to send mails - */ - private $smtp_host = ''; - /** - * the smtp port - */ - private $smtp_port = 25; - /** - * if the smtp server needs authentication you can set the smtp user here - */ - private $smtp_user = ''; - /** - * if the smtp server needs authentication you can set the smtp password here - */ - private $smtp_pass = ''; - /** - * If you want to use tls/ssl specify it here - */ - private $smtp_crypt = ''; // tls or ssl - /** - * How many mails should be sent via one single smtp connection - */ - private $smtp_max_mails = 20; - /** - * Should the mail be signed - */ - private $sign_email = false; - /** - * The cert and key to use for email signing - */ - private $sign_key = ''; - private $sign_key_pass = ''; - private $sign_cert = ''; - private $sign_bundle = ''; - private $_is_signed = false; - /** - * get disposition notification - */ - private $notification = false; - /**#@-*/ - - public function __construct($options = array()) { - $rand = md5(microtime()); - $this->mime_boundary = '==Multipart_Boundary_x' . $rand . 'x'; - - $this->headers = array(); - $this->attachments = array(); - - $this->headers['MIME-Version'] = '1.0'; - $this->headers['User-Agent'] = $this->user_agent; - if(is_array($options) && count($options) > 0) $this->setOptions($options); - } - - public function __destruct() { - $this->finish(); - } - - /** - * Set option - * - * @param string $key the option to set - * @param string $value the option value to set - */ - public function setOption($key, $value) { - switch($key) { - case 'smtp_helo': - $this->smtp_helo = $value; - break; - case 'smtp_host': - $this->smtp_host = $value; - break; - case 'smtp_server': - $this->smtp_host = $value; - break; - case 'smtp_port': - $this->smtp_port = $value; - break; - case 'smtp_user': - $this->smtp_user = $value; - break; - case 'smtp_pass': - $this->smtp_pass = $value; - break; - case 'smtp_max_mails': - $this->smtp_max_mails = intval($value); - if($this->smtp_max_mails < 1) $this->smtp_max_mails = 1; - break; - case 'use_smtp': - $this->use_smtp = ($value == true ? true : false); - if($value == true) $this->_crlf = "\r\n"; - break; - case 'smtp_crypt': - if($value != 'ssl' && $value != 'tls') $value = ''; - $this->smtp_crypt = $value; - break; - case 'sign_email': - $this->sign_email = ($value == true ? true : false); - break; - case 'sign_key': - $this->sign_key = $value; - break; - case 'sign_key_pass': - $this->sign_key_pass = $value; - break; - case 'sign_cert': - $this->sign_cert = $value; - break; - case 'sign_bundle': - $this->sign_bundle = $value; - break; - case 'mail_charset': - $this->mail_charset = $value; - break; - case 'notify': - $this->notification = ($value == true ? true : false); - break; - } - } - - /** Detect the helo string if none given - * - */ - private function detectHelo() { - if(isset($_SERVER['HTTP_HOST'])) $this->smtp_helo = $_SERVER['HTTP_HOST']; - elseif(isset($_SERVER['SERVER_NAME'])) $this->smtp_helo = $_SERVER['SERVER_NAME']; - else $this->smtp_helo = php_uname('n'); - if($this->smtp_helo == '') $this->smtp_helo = 'localhost'; - } - - /** - * Set options - * - * @param array $options the options to set as an associative array key => value - */ - public function setOptions($options) { - foreach($options as $key => $value) $this->setOption($key, $value); - } - - /** - * Read a file's contents - * - * Simply gets the file's content - * - * @access public - * @param string $filename name and path of file to read - * @return string file content (can be binary) - */ - public function read_File($filename) { - $content = ''; - - $fp = fopen($filename, 'r'); - if(!$fp) return false; - - while(!feof($fp)) { - $content .= fread($fp, 1024); - } - fclose($fp); - - return $content; - } - - /** - * set smtp connection encryption - * - * @access public - * @param string $mode encryption mode (tls, ssl or empty string) - */ - public function setSMTPEncryption($mode = '') { - if($mode != 'ssl' && $mode != 'tls') $mode = ''; - $this->smtp_crypt = $mode; - } - /** - * set a mail header - * - * Sets a single mail header to a given value - * - * @access public - * @param string $header header name to set - * @param string $value value to set in header field - */ - public function setHeader($header, $value) { - if(strtolower($header) == 'bcc') $header = 'Bcc'; - elseif(strtolower($header) == 'cc') $header = 'Cc'; - elseif(strtolower($header) == 'from') $header = 'From'; - $this->headers["$header"] = $value; - } - - /** - * get a mail header value - * - * Returns a value of a single mail header - * - * @access public - * @param string $header header name to get - * @return string header value - */ - public function getHeader($header) { - if(strtolower($header) == 'bcc') $header = 'Bcc'; - elseif(strtolower($header) == 'cc') $header = 'Cc'; - elseif(strtolower($header) == 'from') $header = 'From'; - return (isset($this->headers["$header"]) ? $this->headers["$header"] : ''); - } - - /** - * Set email sender - * - * Sets the email sender and optionally the sender's name - * - * @access public - * @param string $email sender email address - * @param string $name sender name - */ - public function setSender($email, $name = '') { - if($name) $header = '"' . $name . '" <' . $email . '>'; - else $header = '<' . $email . '>'; - - $this->_mail_sender = $email; - - $this->setHeader('From', $header); - } - - /** - * Set mail subject - * - * @access public - * @param string $subject the mail subject - * @return string where-string for db query - */ - public function setSubject($subject) { - $this->setHeader('Subject', $subject); - } - - /** - * Get current mail subject - * - * @access public - * @return string mail subject - */ - public function getSubject() { - return $this->headers['Subject']; - } - - /** - * Set mail content - * - * Sets the mail html and plain text content - * - * @access public - * @param string $text plain text mail content (can be empty) - * @param string $html html mail content - */ - public function setMailText($text, $html = '') { - $this->text_part = $text; - $this->html_part = $html; - } - - /** - * Read and attach a file - * - * Reads a file and attaches it to the current email - * - * @access public - * @param string $filename the file to read and attach - * @param string $display_name the name that will be displayed in the mail - * @see read_File - */ - public function readAttachFile($filename, $display_name = '') { - if($display_name == '') { - $path_parts = pathinfo($filename); - $display_name = $path_parts["basename"]; - unset($path_parts); - } - $this->attachFile($this->read_File($filename), $display_name); - } - - /** - * Attach a file - * - * Attaches a string (can be binary) as a file to the mail - * - * @access public - * @param string $content attachment data string - * @param string $filename name for file attachment - */ - public function attachFile($content, $filename) { - $attachment = array('content' => $content, - 'filename' => $filename, - 'type' => 'application/octet-stream', - 'encoding' => 'base64' - ); - $this->attachments[] = $attachment; - } - - /** - * @access private - */ - private function create() { - $attach = false; - $html = false; - $text = false; - - if($this->html_part) $html = true; - if($this->text_part) $text = true; - if(count($this->attachments) > 0) $attach = true; - - $textonly = false; - $htmlonly = false; - if($text == true && $html == false && $attach == false) { - // only text - $content_type = 'text/plain; charset="' . strtolower($this->mail_charset) . '"'; - $textonly = true; - } elseif($text == true && $html == false && $attach == true) { - // text and attachment - $content_type = 'multipart/mixed;'; - $content_type .= "\n" . ' boundary="' . $this->mime_boundary . '"'; - } elseif($html == true && $text == true && $attach == false) { - // html only (or text too) - $content_type = 'multipart/alternative;'; - $content_type .= "\n" . ' boundary="' . $this->mime_boundary . '"'; - } elseif($html == true && $text == false && $attach == false) { - // html only (or text too) - $content_type = 'text/html; charset="' . strtolower($this->mail_charset) . '"'; - $htmlonly = true; - } elseif($html == true && $attach == true) { - // html and attachments - $content_type = 'multipart/mixed;'; - $content_type .= "\n" . ' boundary="' . $this->mime_boundary . '"'; - } - - $this->headers['Content-Type'] = $content_type; - - if($textonly == false && $htmlonly == false) { - $this->body = "This is a multi-part message in MIME format.\n\n"; - - if($text) { - /*$this->body .= "--{$this->mime_boundary}\n" . + /** + * if set to true smtp is used instead of mail() to send emails + * @see mail + */ + private $use_smtp = false; + + /** + * the smtp helo string - use the mail server name here! + */ + private $smtp_helo = ''; + + /** + * the smtp server to send mails + */ + private $smtp_host = ''; + + /** + * the smtp port + */ + private $smtp_port = 25; + + /** + * if the smtp server needs authentication you can set the smtp user here + */ + private $smtp_user = ''; + + /** + * if the smtp server needs authentication you can set the smtp password here + */ + private $smtp_pass = ''; + + /** + * If you want to use tls/ssl specify it here + */ + private $smtp_crypt = ''; // tls or ssl + /** + * How many mails should be sent via one single smtp connection + */ + private $smtp_max_mails = 20; + + /** + * Should the mail be signed + */ + private $sign_email = false; + + /** + * The cert and key to use for email signing + */ + private $sign_key = ''; + private $sign_key_pass = ''; + private $sign_cert = ''; + private $sign_bundle = ''; + private $_is_signed = false; + + /** + * get disposition notification + */ + private $notification = false; + /**#@-*/ + + public function __construct($options = array()) { + $rand = md5(microtime()); + $this->mime_boundary = '==Multipart_Boundary_x' . $rand . 'x'; + + $this->headers = array(); + $this->attachments = array(); + + $this->headers['MIME-Version'] = '1.0'; + $this->headers['User-Agent'] = $this->user_agent; + if(is_array($options) && count($options) > 0) $this->setOptions($options); + } + + public function __destruct() { + $this->finish(); + } + + + + /** + * Set option + * + * @param string $key the option to set + * @param string $value the option value to set + */ + public function setOption($key, $value) { + switch($key) { + case 'smtp_helo': + $this->smtp_helo = $value; + break; + case 'smtp_host': + $this->smtp_host = $value; + break; + case 'smtp_server': + $this->smtp_host = $value; + break; + case 'smtp_port': + $this->smtp_port = $value; + break; + case 'smtp_user': + $this->smtp_user = $value; + break; + case 'smtp_pass': + $this->smtp_pass = $value; + break; + case 'smtp_max_mails': + $this->smtp_max_mails = intval($value); + if($this->smtp_max_mails < 1) $this->smtp_max_mails = 1; + break; + case 'use_smtp': + $this->use_smtp = ($value == true ? true : false); + if($value == true) $this->_crlf = "\r\n"; + break; + case 'smtp_crypt': + if($value != 'ssl' && $value != 'tls') $value = ''; + $this->smtp_crypt = $value; + break; + case 'sign_email': + $this->sign_email = ($value == true ? true : false); + break; + case 'sign_key': + $this->sign_key = $value; + break; + case 'sign_key_pass': + $this->sign_key_pass = $value; + break; + case 'sign_cert': + $this->sign_cert = $value; + break; + case 'sign_bundle': + $this->sign_bundle = $value; + break; + case 'mail_charset': + $this->mail_charset = $value; + break; + case 'notify': + $this->notification = ($value == true ? true : false); + break; + } + } + + + + /** Detect the helo string if none given + * + */ + private function detectHelo() { + if(isset($_SERVER['HTTP_HOST'])) $this->smtp_helo = $_SERVER['HTTP_HOST']; + elseif(isset($_SERVER['SERVER_NAME'])) $this->smtp_helo = $_SERVER['SERVER_NAME']; + else $this->smtp_helo = php_uname('n'); + if($this->smtp_helo == '') $this->smtp_helo = 'localhost'; + } + + + + /** + * Set options + * + * @param array $options the options to set as an associative array key => value + */ + public function setOptions($options) { + foreach($options as $key => $value) $this->setOption($key, $value); + } + + + + /** + * Read a file's contents + * + * Simply gets the file's content + * + * @access public + * @param string $filename name and path of file to read + * @return string file content (can be binary) + */ + public function read_File($filename) { + $content = ''; + + $fp = fopen($filename, 'r'); + if(!$fp) return false; + + while(!feof($fp)) { + $content .= fread($fp, 1024); + } + fclose($fp); + + return $content; + } + + + + /** + * set smtp connection encryption + * + * @access public + * @param string $mode encryption mode (tls, ssl or empty string) + */ + public function setSMTPEncryption($mode = '') { + if($mode != 'ssl' && $mode != 'tls') $mode = ''; + $this->smtp_crypt = $mode; + } + + /** + * set a mail header + * + * Sets a single mail header to a given value + * + * @access public + * @param string $header header name to set + * @param string $value value to set in header field + */ + public function setHeader($header, $value) { + if(strtolower($header) == 'bcc') $header = 'Bcc'; + elseif(strtolower($header) == 'cc') $header = 'Cc'; + elseif(strtolower($header) == 'from') $header = 'From'; + $this->headers["$header"] = $value; + } + + + + /** + * get a mail header value + * + * Returns a value of a single mail header + * + * @access public + * @param string $header header name to get + * @return string header value + */ + public function getHeader($header) { + if(strtolower($header) == 'bcc') $header = 'Bcc'; + elseif(strtolower($header) == 'cc') $header = 'Cc'; + elseif(strtolower($header) == 'from') $header = 'From'; + return isset($this->headers["$header"]) ? $this->headers["$header"] : ''; + } + + + + /** + * Set email sender + * + * Sets the email sender and optionally the sender's name + * + * @access public + * @param string $email sender email address + * @param string $name sender name + */ + public function setSender($email, $name = '') { + if($name) $header = '"' . $name . '" <' . $email . '>'; + else $header = '<' . $email . '>'; + + $this->_mail_sender = $email; + + $this->setHeader('From', $header); + } + + + + /** + * Set mail subject + * + * @access public + * @param string $subject the mail subject + * @return string where-string for db query + */ + public function setSubject($subject) { + $this->setHeader('Subject', $subject); + } + + + + /** + * Get current mail subject + * + * @access public + * @return string mail subject + */ + public function getSubject() { + return $this->headers['Subject']; + } + + + + /** + * Set mail content + * + * Sets the mail html and plain text content + * + * @access public + * @param string $text plain text mail content (can be empty) + * @param string $html html mail content + */ + public function setMailText($text, $html = '') { + $this->text_part = $text; + $this->html_part = $html; + } + + + + /** + * Read and attach a file + * + * Reads a file and attaches it to the current email + * + * @access public + * @param string $filename the file to read and attach + * @param string $display_name the name that will be displayed in the mail + * @see read_File + */ + public function readAttachFile($filename, $display_name = '') { + if($display_name == '') { + $path_parts = pathinfo($filename); + $display_name = $path_parts["basename"]; + unset($path_parts); + } + $this->attachFile($this->read_File($filename), $display_name); + } + + + + /** + * Attach a file + * + * Attaches a string (can be binary) as a file to the mail + * + * @access public + * @param string $content attachment data string + * @param string $filename name for file attachment + */ + public function attachFile($content, $filename) { + $attachment = array('content' => $content, + 'filename' => $filename, + 'type' => 'application/octet-stream', + 'encoding' => 'base64' + ); + $this->attachments[] = $attachment; + } + + + + /** + * @access private + */ + private function create() { + $attach = false; + $html = false; + $text = false; + + if($this->html_part) $html = true; + if($this->text_part) $text = true; + if(count($this->attachments) > 0) $attach = true; + + $textonly = false; + $htmlonly = false; + if($text == true && $html == false && $attach == false) { + // only text + $content_type = 'text/plain; charset="' . strtolower($this->mail_charset) . '"'; + $textonly = true; + } elseif($text == true && $html == false && $attach == true) { + // text and attachment + $content_type = 'multipart/mixed;'; + $content_type .= "\n" . ' boundary="' . $this->mime_boundary . '"'; + } elseif($html == true && $text == true && $attach == false) { + // html only (or text too) + $content_type = 'multipart/alternative;'; + $content_type .= "\n" . ' boundary="' . $this->mime_boundary . '"'; + } elseif($html == true && $text == false && $attach == false) { + // html only (or text too) + $content_type = 'text/html; charset="' . strtolower($this->mail_charset) . '"'; + $htmlonly = true; + } elseif($html == true && $attach == true) { + // html and attachments + $content_type = 'multipart/mixed;'; + $content_type .= "\n" . ' boundary="' . $this->mime_boundary . '"'; + } + + $this->headers['Content-Type'] = $content_type; + + if($textonly == false && $htmlonly == false) { + $this->body = "This is a multi-part message in MIME format.\n\n"; + + if($text) { + /*$this->body .= "--{$this->mime_boundary}\n" . "Content-Type:text/plain; charset=\"" . strtolower($this->mail_charset) . "\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $this->text_part . "\n\n";*/ $this->body .= "--{$this->mime_boundary}\n" . - "Content-Type:text/plain; charset=\"UTF-8\"\n" . - "Content-Transfer-Encoding: 8bit\n\n" . $this->text_part . "\n\n"; + "Content-Type:text/plain; charset=\"UTF-8\"\n" . + "Content-Transfer-Encoding: 8bit\n\n" . $this->text_part . "\n\n"; } - - if($html) { - /*$this->body .= "--{$this->mime_boundary}\n" . - "Content-Type:text/html; charset=\"" . strtolower($this->mail_charset) . "\"\n" . + + if($html) { + /*$this->body .= "--{$this->mime_boundary}\n" . + "Content-Type:text/html; charset=\"" . strtolower($this->mail_charset) . "\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $this->html_part . "\n\n";*/ $this->body .= "--{$this->mime_boundary}\n" . - "Content-Type:text/html; charset=\"UTF-8\"\n" . - "Content-Transfer-Encoding: 8bit\n\n" . $this->html_part . "\n\n"; + "Content-Type:text/html; charset=\"UTF-8\"\n" . + "Content-Transfer-Encoding: 8bit\n\n" . $this->html_part . "\n\n"; } - - if($attach) { - foreach($this->attachments as $att) { - $this->body .= "--{$this->mime_boundary}\n" . - "Content-Type: " . $att['type'] . ";\n" . - " name=\"" . $att['filename'] . "\"\n" . - "Content-Transfer-Encoding: base64\n" . - "Content-Disposition: attachment;\n\n" . - chunk_split(base64_encode($att['content'])) . "\n\n"; - } - } - $this->body .= "--{$this->mime_boundary}--\n"; - } elseif($htmlonly == true) { - $this->body = $this->html_part; - } else { - $this->body = $this->text_part; - } - - if (isset($this->body)) { - // Add message ID header - $message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36), base_convert(rand(), 10, 36), $this->smtp_helo != '' ? $this->smtp_helo : $this->detectHelo()); - $this->headers['Message-ID'] = $message_id; - return true; - } else { - return false; - } - } - - /** - * Function to sign an email body - */ - private function sign() { - if($this->sign_email == false || $this->sign_key == '' || $this->sign_cert == '') return false; - if(function_exists('openssl_pkcs7_sign') == false) return false; - - $tmpin = tempnam(sys_get_temp_dir(), 'sign'); - $tmpout = tempnam(sys_get_temp_dir(), 'sign'); - if(!file_exists($tmpin) || !is_writable($tmpin)) return false; - - file_put_contents($tmpin, 'Content-Type: ' . $this->getHeader('Content-Type') . "\n\n" . $this->body); - $tmpf_key = tempnam(sys_get_temp_dir(), 'sign'); - file_put_contents($tmpf_key, $this->sign_key); - $tmpf_cert = tempnam(sys_get_temp_dir(), 'sign'); - file_put_contents($tmpf_cert, $this->sign_cert); - if($this->sign_bundle != '') { - $tmpf_bundle = tempnam(sys_get_temp_dir(), 'sign'); - file_put_contents($tmpf_bundle, $this->sign_bundle); - openssl_pkcs7_sign($tmpin, $tmpout, 'file://' . realpath($tmpf_cert), array('file://' . realpath($tmpf_key), $this->sign_key_pass), array(), PKCS7_DETACHED, realpath($tmpf_bundle)); - } else { - openssl_pkcs7_sign($tmpin, $tmpout, 'file://' . realpath($tmpf_cert), array('file://' . realpath($tmpf_key), $this->sign_key_pass), array()); - } - unlink($tmpin); - unlink($tmpf_cert); - unlink($tmpf_key); - if(file_exists($tmpf_bundle)) unlink($tmpf_bundle); - - if(!file_exists($tmpout) || !is_readable($tmpout)) return false; - $this->body = file_get_contents($tmpout); - unlink($tmpout); - - unset($this->headers['Content-Type']); - unset($this->headers['MIME-Version']); - - $this->_is_signed = true; - } - - private function _char_to_hex($matches) { - return '=' . strtoupper(dechex(ord($matches[1]))); - } - - /** - * Function to encode a header if necessary - * according to RFC2047 - * @access private - */ - private function _encodeHeader($input, $charset = 'ISO-8859-1') { + + if($attach) { + foreach($this->attachments as $att) { + $this->body .= "--{$this->mime_boundary}\n" . + "Content-Type: " . $att['type'] . ";\n" . + " name=\"" . $att['filename'] . "\"\n" . + "Content-Transfer-Encoding: base64\n" . + "Content-Disposition: attachment;\n\n" . + chunk_split(base64_encode($att['content'])) . "\n\n"; + } + } + $this->body .= "--{$this->mime_boundary}--\n"; + } elseif($htmlonly == true) { + $this->body = $this->html_part; + } else { + $this->body = $this->text_part; + } + + if (isset($this->body)) { + // Add message ID header + $message_id = sprintf('<%s.%s@%s>', base_convert(time(), 10, 36), base_convert(rand(), 10, 36), $this->smtp_helo != '' ? $this->smtp_helo : $this->detectHelo()); + $this->headers['Message-ID'] = $message_id; + return true; + } else { + return false; + } + } + + + + /** + * Function to sign an email body + */ + private function sign() { + if($this->sign_email == false || $this->sign_key == '' || $this->sign_cert == '') return false; + if(function_exists('openssl_pkcs7_sign') == false) return false; + + $tmpin = tempnam(sys_get_temp_dir(), 'sign'); + $tmpout = tempnam(sys_get_temp_dir(), 'sign'); + if(!file_exists($tmpin) || !is_writable($tmpin)) return false; + + file_put_contents($tmpin, 'Content-Type: ' . $this->getHeader('Content-Type') . "\n\n" . $this->body); + $tmpf_key = tempnam(sys_get_temp_dir(), 'sign'); + file_put_contents($tmpf_key, $this->sign_key); + $tmpf_cert = tempnam(sys_get_temp_dir(), 'sign'); + file_put_contents($tmpf_cert, $this->sign_cert); + if($this->sign_bundle != '') { + $tmpf_bundle = tempnam(sys_get_temp_dir(), 'sign'); + file_put_contents($tmpf_bundle, $this->sign_bundle); + openssl_pkcs7_sign($tmpin, $tmpout, 'file://' . realpath($tmpf_cert), array('file://' . realpath($tmpf_key), $this->sign_key_pass), array(), PKCS7_DETACHED, realpath($tmpf_bundle)); + } else { + openssl_pkcs7_sign($tmpin, $tmpout, 'file://' . realpath($tmpf_cert), array('file://' . realpath($tmpf_key), $this->sign_key_pass), array()); + } + unlink($tmpin); + unlink($tmpf_cert); + unlink($tmpf_key); + if(file_exists($tmpf_bundle)) unlink($tmpf_bundle); + + if(!file_exists($tmpout) || !is_readable($tmpout)) return false; + $this->body = file_get_contents($tmpout); + unlink($tmpout); + + unset($this->headers['Content-Type']); + unset($this->headers['MIME-Version']); + + $this->_is_signed = true; + } + + private function _char_to_hex($matches) { + return '=' . strtoupper(dechex(ord($matches[1]))); + } + + + + /** + * Function to encode a header if necessary + * according to RFC2047 + * @access private + */ + private function _encodeHeader($input, $charset = 'ISO-8859-1') { preg_match_all('/(\s?\w*[\x80-\xFF]+\w*\s?)/', $input, $matches); foreach ($matches[1] as $value) { $replacement = preg_replace_callback('/([\x20\x80-\xFF])/', array($this, '_char_to_hex'), $value); $input = str_replace($value, '=?' . $charset . '?Q?' . $replacement . '?=', $input); } - - return $input; - } - - /** - * Function to encode the subject if necessary - * according to RFC2047 - * @access private - */ - private function _encodeSubject($input, $charset = 'ISO-8859-1') { - /* + + return $input; + } + + + + /** + * Function to encode the subject if necessary + * according to RFC2047 + * @access private + */ + private function _encodeSubject($input, $charset = 'ISO-8859-1') { + /* if($charset == 'UTF-8' && function_exists('imap_8bit')) { $input = "=?utf-8?Q?" . imap_8bit($input) . "?="; } else { @@ -532,204 +578,213 @@ class ispcmail { } }*/ $input='=?UTF-8?B?'.base64_encode($input).'?='; - - return $input; - } - - /** - * @access private - */ - private function _smtp_login() { - $this->_smtp_conn = fsockopen(($this->smtp_crypt == 'ssl' ? 'ssl://' : '') . $this->smtp_host, $this->smtp_port, $errno, $errstr, 30); - $response = fgets($this->_smtp_conn, 515); - if(empty($this->_smtp_conn)) return false; - - // ENCRYPTED? - if($this->smtp_crypt == 'tls') { - fputs($this->_smtp_conn, 'STARTTLS' . $this->_crlf); - fgets($this->_smtp_conn, 515); - stream_socket_enable_crypto($this->_smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); - } - - //Say Hello to SMTP - if($this->smtp_helo == '') $this->detectHelo(); - fputs($this->_smtp_conn, 'HELO ' . $this->smtp_helo . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - //AUTH LOGIN - fputs($this->_smtp_conn, 'AUTH LOGIN' . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - //Send username - fputs($this->_smtp_conn, base64_encode($this->smtp_user) . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - //Send password - fputs($this->_smtp_conn, base64_encode($this->smtp_pass) . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - $this->_logged_in = true; - return true; - } - - /** - * @access private - */ - private function _smtp_close() { - $this->_logged_in = false; - - if(empty($this->_smtp_conn)) { - return false; - } - - fputs($this->_smtp_conn, 'QUIT' . $this->_crlf); - $response = @fgets($this->_smtp_conn, 515); - return true; - } - - /** - * Send the mail to one or more recipients - * - * The recipients can be either a string (1 recipient email without name) or an associative array of recipients with names as keys and email addresses as values. - * - * @access public - * @param mixed $recipients one email address or array of recipients with names as keys and email addresses as values - */ - public function send($recipients) { - if(!is_array($recipients)) $recipients = array($recipients); - - if($this->use_smtp == true) $this->_crlf = "\r\n"; - else $this->_crlf = "\n"; - - $this->create(); - if($this->sign_email == true) $this->sign(); - - $subject = ''; - if (!empty($this->headers['Subject'])) { - //$subject = $this->_encodeHeader($this->headers['Subject'], $this->mail_charset); - $subject = $this->headers['Subject']; - - //$enc_subject = $this->_encodeHeader($subject, $this->mail_charset); + + return $input; + } + + + + /** + * @access private + */ + private function _smtp_login() { + $this->_smtp_conn = fsockopen(($this->smtp_crypt == 'ssl' ? 'ssl://' : '') . $this->smtp_host, $this->smtp_port, $errno, $errstr, 30); + $response = fgets($this->_smtp_conn, 515); + if(empty($this->_smtp_conn)) return false; + + // ENCRYPTED? + if($this->smtp_crypt == 'tls') { + fputs($this->_smtp_conn, 'STARTTLS' . $this->_crlf); + fgets($this->_smtp_conn, 515); + stream_socket_enable_crypto($this->_smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT); + } + + //Say Hello to SMTP + if($this->smtp_helo == '') $this->detectHelo(); + fputs($this->_smtp_conn, 'HELO ' . $this->smtp_helo . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + //AUTH LOGIN + fputs($this->_smtp_conn, 'AUTH LOGIN' . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + //Send username + fputs($this->_smtp_conn, base64_encode($this->smtp_user) . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + //Send password + fputs($this->_smtp_conn, base64_encode($this->smtp_pass) . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + $this->_logged_in = true; + return true; + } + + + + /** + * @access private + */ + private function _smtp_close() { + $this->_logged_in = false; + + if(empty($this->_smtp_conn)) { + return false; + } + + fputs($this->_smtp_conn, 'QUIT' . $this->_crlf); + $response = @fgets($this->_smtp_conn, 515); + return true; + } + + + + /** + * Send the mail to one or more recipients + * + * The recipients can be either a string (1 recipient email without name) or an associative array of recipients with names as keys and email addresses as values. + * + * @access public + * @param mixed $recipients one email address or array of recipients with names as keys and email addresses as values + */ + public function send($recipients) { + if(!is_array($recipients)) $recipients = array($recipients); + + if($this->use_smtp == true) $this->_crlf = "\r\n"; + else $this->_crlf = "\n"; + + $this->create(); + if($this->sign_email == true) $this->sign(); + + $subject = ''; + if (!empty($this->headers['Subject'])) { + //$subject = $this->_encodeHeader($this->headers['Subject'], $this->mail_charset); + $subject = $this->headers['Subject']; + + //$enc_subject = $this->_encodeHeader($subject, $this->mail_charset); $enc_subject = $this->_encodeSubject($subject, $this->mail_charset); - unset($this->headers['Subject']); - } - - if($this->notification == true) $this->setHeader('Disposition-Notification-To', $this->getHeader('From')); - - unset($this->headers['To']); // always reset the To header to prevent from sending to multiple users at once - $this->headers['Date'] = date('r'); //date('D, d M Y H:i:s O'); - - // Get flat representation of headers - foreach ($this->headers as $name => $value) { - if(strtolower($name) == 'to' || strtolower($name) == 'cc' || strtolower($name) == 'bcc') continue; // never add the To header - $headers[] = $name . ': ' . $this->_encodeHeader($value, $this->mail_charset); - } - - if($this->use_smtp == true) { - if(!$this->_logged_in || !$this->_smtp_conn) { - $result = $this->_smtp_login(); - if(!$result) return false; - } - foreach($recipients as $recipname => $recip) { - if($this->_sent_mails >= $this->smtp_max_mails) { - // close connection to smtp and reconnect - $this->_sent_mails = 0; - $this->_smtp_close(); - $result = $this->_smtp_login(); - if(!$result) return false; - } - $this->_sent_mails += 1; - - $recipname = trim(str_replace('"', '', $recipname)); - $recip = $this->_encodeHeader($recip, $this->mail_charset); - $recipname = $this->_encodeHeader($recipname, $this->mail_charset); - - //Email From - fputs($this->_smtp_conn, 'MAIL FROM: ' . $this->_mail_sender . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - //Email To - fputs($this->_smtp_conn, 'RCPT TO: ' . $recip . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - //The Email - fputs($this->_smtp_conn, 'DATA' . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - //Construct Headers - if($recipname && !is_numeric($recipname)) $this->setHeader('To', $recipname . ' <' . $recip . '>'); - else $this->setHeader('To', $recip); - - $mail_content = 'Subject: ' . $enc_subject . $this->_crlf; - $mail_content .= 'To: ' . $this->getHeader('To') . $this->_crlf; - if($this->getHeader('Bcc') != '') $mail_content .= 'Bcc: ' . $this->_encodeHeader($this->getHeader('Bcc'), $this->mail_charset) . $this->_crlf; - if($this->getHeader('Cc') != '') $mail_content .= 'Cc: ' . $this->_encodeHeader($this->getHeader('Cc'), $this->mail_charset) . $this->_crlf; - $mail_content .= implode($this->_crlf, $headers) . $this->_crlf . ($this->_is_signed == false ? $this->_crlf : '') . $this->body; - - fputs($this->_smtp_conn, $mail_content . $this->_crlf . '.' . $this->_crlf); - $response = fgets($this->_smtp_conn, 515); - - // hopefully message was correctly sent now - $result = true; - } - } else { - if($this->getHeader('Bcc') != '') $headers[] = 'Bcc: ' . $this->_encodeHeader($this->getHeader('Bcc'), $this->mail_charset); - if($this->getHeader('Cc') != '') $headers[] = 'Cc: ' . $this->_encodeHeader($this->getHeader('Cc'), $this->mail_charset); - $rec_string = ''; - foreach($recipients as $recipname => $recip) { - $recipname = trim(str_replace('"', '', $recipname)); - - if($rec_string != '') $rec_string .= ', '; - if($recipname && !is_numeric($recipname)) $rec_string .= $recipname . '<' . $recip . '>'; - else $rec_string .= $recip; - } - $to = $this->_encodeHeader($rec_string, $this->mail_charset); - //$result = mail($to, $subject, $this->body, implode($this->_crlf, $headers)); + unset($this->headers['Subject']); + } + + if($this->notification == true) $this->setHeader('Disposition-Notification-To', $this->getHeader('From')); + + unset($this->headers['To']); // always reset the To header to prevent from sending to multiple users at once + $this->headers['Date'] = date('r'); //date('D, d M Y H:i:s O'); + + // Get flat representation of headers + foreach ($this->headers as $name => $value) { + if(strtolower($name) == 'to' || strtolower($name) == 'cc' || strtolower($name) == 'bcc') continue; // never add the To header + $headers[] = $name . ': ' . $this->_encodeHeader($value, $this->mail_charset); + } + + if($this->use_smtp == true) { + if(!$this->_logged_in || !$this->_smtp_conn) { + $result = $this->_smtp_login(); + if(!$result) return false; + } + foreach($recipients as $recipname => $recip) { + if($this->_sent_mails >= $this->smtp_max_mails) { + // close connection to smtp and reconnect + $this->_sent_mails = 0; + $this->_smtp_close(); + $result = $this->_smtp_login(); + if(!$result) return false; + } + $this->_sent_mails += 1; + + $recipname = trim(str_replace('"', '', $recipname)); + $recip = $this->_encodeHeader($recip, $this->mail_charset); + $recipname = $this->_encodeHeader($recipname, $this->mail_charset); + + //Email From + fputs($this->_smtp_conn, 'MAIL FROM: ' . $this->_mail_sender . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + //Email To + fputs($this->_smtp_conn, 'RCPT TO: ' . $recip . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + //The Email + fputs($this->_smtp_conn, 'DATA' . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + //Construct Headers + if($recipname && !is_numeric($recipname)) $this->setHeader('To', $recipname . ' <' . $recip . '>'); + else $this->setHeader('To', $recip); + + $mail_content = 'Subject: ' . $enc_subject . $this->_crlf; + $mail_content .= 'To: ' . $this->getHeader('To') . $this->_crlf; + if($this->getHeader('Bcc') != '') $mail_content .= 'Bcc: ' . $this->_encodeHeader($this->getHeader('Bcc'), $this->mail_charset) . $this->_crlf; + if($this->getHeader('Cc') != '') $mail_content .= 'Cc: ' . $this->_encodeHeader($this->getHeader('Cc'), $this->mail_charset) . $this->_crlf; + $mail_content .= implode($this->_crlf, $headers) . $this->_crlf . ($this->_is_signed == false ? $this->_crlf : '') . $this->body; + + fputs($this->_smtp_conn, $mail_content . $this->_crlf . '.' . $this->_crlf); + $response = fgets($this->_smtp_conn, 515); + + // hopefully message was correctly sent now + $result = true; + } + } else { + if($this->getHeader('Bcc') != '') $headers[] = 'Bcc: ' . $this->_encodeHeader($this->getHeader('Bcc'), $this->mail_charset); + if($this->getHeader('Cc') != '') $headers[] = 'Cc: ' . $this->_encodeHeader($this->getHeader('Cc'), $this->mail_charset); + $rec_string = ''; + foreach($recipients as $recipname => $recip) { + $recipname = trim(str_replace('"', '', $recipname)); + + if($rec_string != '') $rec_string .= ', '; + if($recipname && !is_numeric($recipname)) $rec_string .= $recipname . '<' . $recip . '>'; + else $rec_string .= $recip; + } + $to = $this->_encodeHeader($rec_string, $this->mail_charset); + //$result = mail($to, $subject, $this->body, implode($this->_crlf, $headers)); $result = mail($to, $enc_subject, $this->body, implode($this->_crlf, $headers)); - } - - // Reset the subject in case mail is resent - if ($subject !== '') { - $this->headers['Subject'] = $subject; - } - - // Return - return $result; - } - - /** - * Close mail connections - * - * This closes an open smtp connection so you should always call this function in your script if you have finished sending all emails - * - * @access public - */ - public function finish() { - if($this->use_smtp == true) $this->_smtp_close(); - - $rand = md5(microtime()); - $this->mime_boundary = '==Multipart_Boundary_x' . $rand . 'x'; - - $this->headers = array(); - $this->attachments = array(); - $this->text_part = ''; - $this->html_part = ''; - - $this->headers['MIME-Version'] = '1.0'; - $this->headers['User-Agent'] = $this->user_agent; - - $this->smtp_helo = ''; - $this->smtp_host = ''; - $this->smtp_port = ''; - $this->smtp_user = ''; - $this->smtp_pass = ''; - $this->use_smtp = false; - $this->smtp_crypt = false; - $this->mail_charset = 'UTF-8'; - $this->_sent_mails = 0; - - return; - } + } + + // Reset the subject in case mail is resent + if ($subject !== '') { + $this->headers['Subject'] = $subject; + } + + // Return + return $result; + } + + + + /** + * Close mail connections + * + * This closes an open smtp connection so you should always call this function in your script if you have finished sending all emails + * + * @access public + */ + public function finish() { + if($this->use_smtp == true) $this->_smtp_close(); + + $rand = md5(microtime()); + $this->mime_boundary = '==Multipart_Boundary_x' . $rand . 'x'; + + $this->headers = array(); + $this->attachments = array(); + $this->text_part = ''; + $this->html_part = ''; + + $this->headers['MIME-Version'] = '1.0'; + $this->headers['User-Agent'] = $this->user_agent; + + $this->smtp_helo = ''; + $this->smtp_host = ''; + $this->smtp_port = ''; + $this->smtp_user = ''; + $this->smtp_pass = ''; + $this->use_smtp = false; + $this->smtp_crypt = false; + $this->mail_charset = 'UTF-8'; + $this->_sent_mails = 0; + + return; + } + } ?> diff --git a/interface/lib/classes/ispconfig_request.inc.php b/interface/lib/classes/ispconfig_request.inc.php index 75e06eef9..b29ae2398 100644 --- a/interface/lib/classes/ispconfig_request.inc.php +++ b/interface/lib/classes/ispconfig_request.inc.php @@ -32,229 +32,232 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //* This class is loaded automatically by the ispconfig framework. abstract class ISPConfigRequest { - /** - * Get header data and contents from an url - * - * Calls an url and returns an array containing the http header and the page content - * - * @access public - * @param string $url the url to call - * @param string $store_in the file to store the data in instead of returning them - * @return array The array with header data at index 0 and page content at index 1, returns boolean false on error. If $store_in is set only the headers are returned - */ - public static function get_with_headers($url, $store_in = null, $follow_redirects = false, $user_agent = false) { - if($follow_redirects === true) $follow_redirects = 5; - elseif($follow_redirects !== false) $follow_redirects--; - - if(!$user_agent) $user_agent = 'pxFW GET proxy'; - - $url_info = parse_url($url); - if(isset($url_info['scheme']) && $url_info['scheme'] == 'https') { - $port = isset($url_info['port']) ? $url_info['port'] : 443; - //@$fp = stream_socket_client('ssl://' . $url_info['host'] . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, stream_context_create(array('ssl' => array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH')))); - @$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10); - } else { - $port = isset($url_info['port']) ? $url_info['port'] : 80; - @$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10); - } - - if($store_in) { - $outfp = fopen($store_in, 'w'); - if(!$outfp) return false; - } - if($fp) { - stream_set_timeout($fp, 10); - $head = 'GET ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . $url_info['query'] : ''); - $head .= " HTTP/1.0\r\nHost: " . (isset($url_info['host']) ? $url_info['host'] : '') . "\r\n"; - $head .= "User-Agent: " . $user_agent . "\r\n"; - if(isset($url_info['user'])) { - if(!array_key_exists('pass', $url_info)) $url_info['pass'] = ''; - $head .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n"; - } - $head .= "Connection: Close\r\n"; - $head .= "Accept: */*\r\n\r\n"; - - $data = ''; - $eoheader = false; - fputs($fp, $head); - while(!feof($fp)) { - if($header = fgets($fp, 1024)) { - if($eoheader == true) { - if($store_in) fputs($outfp, $header); - else $data .= $header; - continue; - } - - if ($header == "\r\n") { - $eoheader = true; - continue; - } else { - $header = trim($header); - } - $sc_pos = strpos($header, ':'); - if($sc_pos === false) { - $headers['status'] = $header; - $headers['http_code'] = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $header)); - } else { - $label = substr($header, 0, $sc_pos); - $value = substr($header, $sc_pos + 1); - $headers[strtolower($label)] = trim($value); - } - } - } - fclose($fp); - if(isset($headers['http_code']) && isset($headers['location']) && ($headers['http_code'] == 301 || $headers['http_code'] == 302) && $follow_redirects > 0) { - if($store_in) fclose($outfp); - return $self::get_with_headers($headers['location'], $store_in, $follow_redirects); - } - if($store_in) { - fclose($outfp); - - $code = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $headers['status'])); - if($code != 200) { - return false; - } - return $headers; - } else { - return array($headers, $data); - } - } else { - if($store_in) { - fclose($outfp); - @unlink($store_in); - } - return false; - } - } - - /** - * Gets the content of an url - * - * Checks for the php function file_get_contents and uses an alternative if not found - * - * @access public - * @param string $url url to get - * @return string url data including headers - * @see file_get_contents - */ - public static function get($url) { - if(function_exists('file_get_contents')) return file_get_contents($url); - - $fp = fopen($url, 'r'); - $data = ''; - while(!feof($fp)) { - $data .= fgets($fp, 8192); - } - fclose($fp); - - return $data; - } - - - /** - * Make a post request and get data - * - * Calls an url with a post request and returns the data - and optionally the header content - * - * @access public - * @param string $url the url to call - * @param string $data the post data to send - * @param bool $get_headers if true, the function will return an array like PXUrl::get_with_headers(), otherwise the content is returned as a string - * @return mixed Content data as string or - if get_headers is true - the array with header data at index 0 and page content at index 1 - * @see get_url_and_headers - */ - public static function post($url, $data, $get_headers = false, $user_agent = false) { - $url_info = parse_url($url); - if((isset($url_info['scheme']) && $url_info['scheme'] == 'https') || $url_info['port'] == 443) { - $port = (!isset($url_info['port']) || !$url_info['port'] || $url_info['port'] == 443 || $url_info['port'] == 80) ? 443 : $url_info['port']; - //@$fp = stream_socket_client('ssl://' . $url_info['host'] . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, stream_context_create(array('ssl' => array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH')))); - @$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10); - } else { - $port = isset($url_info['port']) ? $url_info['port'] : 80; - @$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10); - } - - if(!$fp) return ''; - - if(!$user_agent) $user_agent = 'pxFW GET proxy'; - - $header = 'POST ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . @$url_info['query'] : '') . " HTTP/1.1\r\n"; - $header .= "Host: " . @$url_info['host'] . "\r\n"; - $header .= "User-Agent: " . $user_agent . "\r\n"; - if(isset($url_info['user'])) { - if(!array_key_exists('pass', $url_info)) $url_info['pass'] = ''; - $header .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n"; - } - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($data) . "\r\n"; - $header .= "Connection: close\r\n\r\n"; - $header .= $data . "\r\n\r\n"; - - fwrite($fp, $header); - - $response = ''; - $eoheader = false; - $header = ''; - $tmpdata = ''; - $chunked = false; - $chunklen = 0; - - while(!feof($fp)) { - if($header = @fgets($fp, 1024)) { - if($eoheader == true) { - $response .= $header; - continue; - } - - if ($header == "\r\n") { - $eoheader = true; - continue; - } else { - $tmpdata .= $header; - if(preg_match('/Transfer-Encoding:\s+chunked/i', $tmpdata)) $chunked = true; - } - } - } - //var_dump($response, $chunked, $header); - if($chunked == true) { - $lines = explode("\n", $response); - $response = ''; - $chunklen = 0; - foreach($lines as $line) { - $line .= "\n"; - if($chunklen <= 0) { - if(preg_match('/^([0-9a-f]+)\s*$/is', $line, $matches)) { - $chunklen = hexdec($matches[1]); - } - continue; - } - - if(strlen($line) > $chunklen) { - //echo "Warnung: " . strlen($line) . " > " . $chunklen . "\n"; - $line = substr($line, 0, $chunklen); - } - $response .= $line; - $chunklen -= strlen($line); - } - - $start = strpos($response,''); - if($start !== false && $end !== false) $response = substr($response, $start, $end - $start + 1); - } - - fclose($fp); - - if($get_headers == true) { - $tmpheaders = explode("\n", $tmpdata); - $headers = array(); - foreach($tmpheaders as $cur) { - if(preg_match('/^(\w+)\:\s*(.*)$/is', $cur, $matches)) { - $headers["$matches[1]"] = trim($matches[2]); - } - } - return array($headers, $response); - } else return $response; - } + /** + * Get header data and contents from an url + * + * Calls an url and returns an array containing the http header and the page content + * + * @access public + * @param string $url the url to call + * @param string $store_in the file to store the data in instead of returning them + * @return array The array with header data at index 0 and page content at index 1, returns boolean false on error. If $store_in is set only the headers are returned + */ + + + public static function get_with_headers($url, $store_in = null, $follow_redirects = false, $user_agent = false) { + if($follow_redirects === true) $follow_redirects = 5; + elseif($follow_redirects !== false) $follow_redirects--; + + if(!$user_agent) $user_agent = 'pxFW GET proxy'; + + $url_info = parse_url($url); + if(isset($url_info['scheme']) && $url_info['scheme'] == 'https') { + $port = isset($url_info['port']) ? $url_info['port'] : 443; + //@$fp = stream_socket_client('ssl://' . $url_info['host'] . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, stream_context_create(array('ssl' => array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH')))); + @$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10); + } else { + $port = isset($url_info['port']) ? $url_info['port'] : 80; + @$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10); + } + + if($store_in) { + $outfp = fopen($store_in, 'w'); + if(!$outfp) return false; + } + if($fp) { + stream_set_timeout($fp, 10); + $head = 'GET ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . $url_info['query'] : ''); + $head .= " HTTP/1.0\r\nHost: " . (isset($url_info['host']) ? $url_info['host'] : '') . "\r\n"; + $head .= "User-Agent: " . $user_agent . "\r\n"; + if(isset($url_info['user'])) { + if(!array_key_exists('pass', $url_info)) $url_info['pass'] = ''; + $head .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n"; + } + $head .= "Connection: Close\r\n"; + $head .= "Accept: */*\r\n\r\n"; + + $data = ''; + $eoheader = false; + fputs($fp, $head); + while(!feof($fp)) { + if($header = fgets($fp, 1024)) { + if($eoheader == true) { + if($store_in) fputs($outfp, $header); + else $data .= $header; + continue; + } + + if ($header == "\r\n") { + $eoheader = true; + continue; + } else { + $header = trim($header); + } + $sc_pos = strpos($header, ':'); + if($sc_pos === false) { + $headers['status'] = $header; + $headers['http_code'] = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $header)); + } else { + $label = substr($header, 0, $sc_pos); + $value = substr($header, $sc_pos + 1); + $headers[strtolower($label)] = trim($value); + } + } + } + fclose($fp); + if(isset($headers['http_code']) && isset($headers['location']) && ($headers['http_code'] == 301 || $headers['http_code'] == 302) && $follow_redirects > 0) { + if($store_in) fclose($outfp); + return $self::get_with_headers($headers['location'], $store_in, $follow_redirects); + } + if($store_in) { + fclose($outfp); + + $code = intval(preg_replace('/^HTTP\/\d+\.\d+\s+(\d+)\s+.*$/', '$1', $headers['status'])); + if($code != 200) { + return false; + } + return $headers; + } else { + return array($headers, $data); + } + } else { + if($store_in) { + fclose($outfp); + @unlink($store_in); + } + return false; + } + } + + /** + * Gets the content of an url + * + * Checks for the php function file_get_contents and uses an alternative if not found + * + * @access public + * @param string $url url to get + * @return string url data including headers + * @see file_get_contents + */ + public static function get($url) { + if(function_exists('file_get_contents')) return file_get_contents($url); + + $fp = fopen($url, 'r'); + $data = ''; + while(!feof($fp)) { + $data .= fgets($fp, 8192); + } + fclose($fp); + + return $data; + } + + + /** + * Make a post request and get data + * + * Calls an url with a post request and returns the data - and optionally the header content + * + * @access public + * @param string $url the url to call + * @param string $data the post data to send + * @param bool $get_headers if true, the function will return an array like PXUrl::get_with_headers(), otherwise the content is returned as a string + * @return mixed Content data as string or - if get_headers is true - the array with header data at index 0 and page content at index 1 + * @see get_url_and_headers + */ + public static function post($url, $data, $get_headers = false, $user_agent = false) { + $url_info = parse_url($url); + if((isset($url_info['scheme']) && $url_info['scheme'] == 'https') || $url_info['port'] == 443) { + $port = (!isset($url_info['port']) || !$url_info['port'] || $url_info['port'] == 443 || $url_info['port'] == 80) ? 443 : $url_info['port']; + //@$fp = stream_socket_client('ssl://' . $url_info['host'] . ':' . $port, $errno, $errstr, 10, STREAM_CLIENT_CONNECT, stream_context_create(array('ssl' => array('ciphers' => 'ALL:!AES:!3DES:!RC4:@STRENGTH')))); + @$fp = fsockopen('sslv3://' . $url_info['host'], $port, $errno, $errstr, 10); + } else { + $port = isset($url_info['port']) ? $url_info['port'] : 80; + @$fp = fsockopen($url_info['host'], $port, $errno, $errstr, 10); + } + + if(!$fp) return ''; + + if(!$user_agent) $user_agent = 'pxFW GET proxy'; + + $header = 'POST ' . (isset($url_info['path']) ? $url_info['path'] : '/') . (isset($url_info['query']) ? '?' . @$url_info['query'] : '') . " HTTP/1.1\r\n"; + $header .= "Host: " . @$url_info['host'] . "\r\n"; + $header .= "User-Agent: " . $user_agent . "\r\n"; + if(isset($url_info['user'])) { + if(!array_key_exists('pass', $url_info)) $url_info['pass'] = ''; + $header .= "Authorization: basic " . base64_encode($url_info['user'] . ':' . $url_info['pass']) . "\r\n"; + } + $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; + $header .= "Content-Length: " . strlen($data) . "\r\n"; + $header .= "Connection: close\r\n\r\n"; + $header .= $data . "\r\n\r\n"; + + fwrite($fp, $header); + + $response = ''; + $eoheader = false; + $header = ''; + $tmpdata = ''; + $chunked = false; + $chunklen = 0; + + while(!feof($fp)) { + if($header = @fgets($fp, 1024)) { + if($eoheader == true) { + $response .= $header; + continue; + } + + if ($header == "\r\n") { + $eoheader = true; + continue; + } else { + $tmpdata .= $header; + if(preg_match('/Transfer-Encoding:\s+chunked/i', $tmpdata)) $chunked = true; + } + } + } + //var_dump($response, $chunked, $header); + if($chunked == true) { + $lines = explode("\n", $response); + $response = ''; + $chunklen = 0; + foreach($lines as $line) { + $line .= "\n"; + if($chunklen <= 0) { + if(preg_match('/^([0-9a-f]+)\s*$/is', $line, $matches)) { + $chunklen = hexdec($matches[1]); + } + continue; + } + + if(strlen($line) > $chunklen) { + //echo "Warnung: " . strlen($line) . " > " . $chunklen . "\n"; + $line = substr($line, 0, $chunklen); + } + $response .= $line; + $chunklen -= strlen($line); + } + + $start = strpos($response, ''); + if($start !== false && $end !== false) $response = substr($response, $start, $end - $start + 1); + } + + fclose($fp); + + if($get_headers == true) { + $tmpheaders = explode("\n", $tmpdata); + $headers = array(); + foreach($tmpheaders as $cur) { + if(preg_match('/^(\w+)\:\s*(.*)$/is', $cur, $matches)) { + $headers["$matches[1]"] = trim($matches[2]); + } + } + return array($headers, $response); + } else return $response; + } + } ?> diff --git a/interface/lib/classes/json_handler.inc.php b/interface/lib/classes/json_handler.inc.php index 9f3452207..1df58980f 100644 --- a/interface/lib/classes/json_handler.inc.php +++ b/interface/lib/classes/json_handler.inc.php @@ -31,91 +31,92 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class ISPConfigJSONHandler { - private $methods = array(); - private $classes = array(); - - public function __construct() { - global $app; - - // load main remoting file - $app->load('remoting'); - - // load all remote classes and get their methods - $dir = dirname(realpath(__FILE__)) . '/remote.d'; - $d = opendir($dir); - while($f = readdir($d)) { - if($f == '.' || $f == '..') continue; - if(!is_file($dir . '/' . $f) || substr($f, strrpos($f, '.')) != '.php') continue; - - $name = substr($f, 0, strpos($f, '.')); - - include($dir . '/' . $f); - $class_name = 'remoting_' . $name; - if(class_exists($class_name, false)) { - $this->classes[$class_name] = new $class_name(); - foreach(get_class_methods($this->classes[$class_name]) as $method) { - $this->methods[$method] = $class_name; - } - } - } - closedir($d); - - // add main methods - $this->methods['login'] = 'remoting'; - $this->methods['logout'] = 'remoting'; - $this->methods['get_function_list'] = 'remoting'; - - // create main class - $this->classes['remoting'] = new remoting(array_keys($this->methods)); - } - - private function _return_json($code, $message, $data = false) { - $ret = new stdClass; - $ret->code = $code; - $ret->message = $message; - $ret->response = $data; - - header('Content-Type: application/json; charset="utf-8"'); - print json_encode($ret); - exit; - } - - public function run() { - - if(!isset($_GET) || !is_array($_GET) || count($_GET) < 1) { - $this->_return_json('invalid_method', 'Method not provided in json call'); - } - $keys = array_keys($_GET); - $method = reset($keys); - $params = array(); - - if(is_array($_POST)) { - foreach($_POST as $key => $val) { - $tmp = json_decode($val); - if(!$tmp) $params[] = $val; - else $params[] = (array)$tmp; - } - } - - if(array_key_exists($method, $this->methods) == false) { - $this->_return_json('invalid_method', 'Method ' . $method . ' does not exist'); - } - - $class_name = $this->methods[$method]; - if(array_key_exists($class_name, $this->classes) == false) { - $this->_return_json('invalid_class', 'Class ' . $class_name . ' does not exist'); - } - - if(method_exists($this->classes[$class_name], $method) == false) { - $this->_return_json('invalid_method', 'Method ' . $method . ' does not exist in the class it was expected (' . $class_name . ')'); - } - - try { - $this->_return_json('ok', '', call_user_func_array(array($this->classes[$class_name], $method), $params)); - } catch(SoapFault $e) { - $this->_return_json('remote_fault', $e->getMessage()); - } - } + private $methods = array(); + private $classes = array(); + + public function __construct() { + global $app; + + // load main remoting file + $app->load('remoting'); + + // load all remote classes and get their methods + $dir = dirname(realpath(__FILE__)) . '/remote.d'; + $d = opendir($dir); + while($f = readdir($d)) { + if($f == '.' || $f == '..') continue; + if(!is_file($dir . '/' . $f) || substr($f, strrpos($f, '.')) != '.php') continue; + + $name = substr($f, 0, strpos($f, '.')); + + include $dir . '/' . $f; + $class_name = 'remoting_' . $name; + if(class_exists($class_name, false)) { + $this->classes[$class_name] = new $class_name(); + foreach(get_class_methods($this->classes[$class_name]) as $method) { + $this->methods[$method] = $class_name; + } + } + } + closedir($d); + + // add main methods + $this->methods['login'] = 'remoting'; + $this->methods['logout'] = 'remoting'; + $this->methods['get_function_list'] = 'remoting'; + + // create main class + $this->classes['remoting'] = new remoting(array_keys($this->methods)); + } + + private function _return_json($code, $message, $data = false) { + $ret = new stdClass; + $ret->code = $code; + $ret->message = $message; + $ret->response = $data; + + header('Content-Type: application/json; charset="utf-8"'); + print json_encode($ret); + exit; + } + + public function run() { + + if(!isset($_GET) || !is_array($_GET) || count($_GET) < 1) { + $this->_return_json('invalid_method', 'Method not provided in json call'); + } + $keys = array_keys($_GET); + $method = reset($keys); + $params = array(); + + if(is_array($_POST)) { + foreach($_POST as $key => $val) { + $tmp = json_decode($val); + if(!$tmp) $params[] = $val; + else $params[] = (array)$tmp; + } + } + + if(array_key_exists($method, $this->methods) == false) { + $this->_return_json('invalid_method', 'Method ' . $method . ' does not exist'); + } + + $class_name = $this->methods[$method]; + if(array_key_exists($class_name, $this->classes) == false) { + $this->_return_json('invalid_class', 'Class ' . $class_name . ' does not exist'); + } + + if(method_exists($this->classes[$class_name], $method) == false) { + $this->_return_json('invalid_method', 'Method ' . $method . ' does not exist in the class it was expected (' . $class_name . ')'); + } + + try { + $this->_return_json('ok', '', call_user_func_array(array($this->classes[$class_name], $method), $params)); + } catch(SoapFault $e) { + $this->_return_json('remote_fault', $e->getMessage()); + } + } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index cf8f6410f..14c1a13f7 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -30,158 +30,160 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class listform { - private $debug = 0; - private $errorMessage; - public $listDef; - public $searchValues; - public $pagingHTML; - private $pagingValues; - private $searchChanged = 0; - private $module; + private $debug = 0; + private $errorMessage; + public $listDef; + public $searchValues; + public $pagingHTML; + private $pagingValues; + private $searchChanged = 0; + private $module; public $wordbook; - public function loadListDef($file, $module = '') - { - global $app,$conf; - if(!is_file($file)){ - die("List-Definition: $file not found."); - } - require_once($file); - $this->listDef = $liste; - $this->module = $module; - + public function loadListDef($file, $module = '') + { + global $app, $conf; + if(!is_file($file)){ + die("List-Definition: $file not found."); + } + require_once $file; + $this->listDef = $liste; + $this->module = $module; + //* Fill datasources - if(@is_array($this->listDef['item'])) { - foreach($this->listDef['item'] as $key => $field) { - if(@is_array($field['datasource'])) { - $this->listDef['item'][$key]['value'] = $this->getDatasourceData($field); - } - } + if(@is_array($this->listDef['item'])) { + foreach($this->listDef['item'] as $key => $field) { + if(@is_array($field['datasource'])) { + $this->listDef['item'][$key]['value'] = $this->getDatasourceData($field); + } + } } - + //* Set local Language File $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_'.$this->listDef['name'].'_list.lng'; if(!file_exists($lng_file)) $lng_file = 'lib/lang/en_'.$this->listDef['name'].'_list.lng'; - include($lng_file); - + include $lng_file; + $this->wordbook = $wb; - - return true; - } - + + return true; + } + /** - * Get the key => value array of a form filed from a datasource definitiom - * - * @param field = array with field definition - * @param record = Dataset as array - * @return array key => value array for the value field of a form - */ - private function getDatasourceData($field) - { - global $app; - $values = array(); - - if($field['datasource']['type'] == 'SQL') { - - //** Preparing SQL string. We will replace some common placeholders - $querystring = $field['datasource']['querystring']; - $querystring = str_replace('{USERID}', $_SESSION['s']['user']['userid'], $querystring); - $querystring = str_replace('{GROUPID}', $_SESSION['s']['user']['default_group'], $querystring); - $querystring = str_replace('{GROUPS}', $_SESSION['s']['user']['groups'], $querystring); - //TODO: - //$table_idx = $this->formDef['db_table_idx']; - //$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring); + * Get the key => value array of a form filed from a datasource definitiom + * + * @param field = array with field definition + * @param record = Dataset as array + * @return array key => value array for the value field of a form + */ + + + private function getDatasourceData($field) + { + global $app; + $values = array(); + + if($field['datasource']['type'] == 'SQL') { + + //** Preparing SQL string. We will replace some common placeholders + $querystring = $field['datasource']['querystring']; + $querystring = str_replace('{USERID}', $_SESSION['s']['user']['userid'], $querystring); + $querystring = str_replace('{GROUPID}', $_SESSION['s']['user']['default_group'], $querystring); + $querystring = str_replace('{GROUPS}', $_SESSION['s']['user']['groups'], $querystring); + //TODO: + //$table_idx = $this->formDef['db_table_idx']; + //$querystring = str_replace("{RECORDID}",$record[$table_idx],$querystring); $app->uses('tform'); - $querystring = str_replace("{AUTHSQL}",$app->tform->getAuthSQL('r'),$querystring); - $querystring = str_replace("{AUTHSQL-A}",$app->tform->getAuthSQL('r','a'),$querystring); - $querystring = str_replace("{AUTHSQL-B}",$app->tform->getAuthSQL('r','b'),$querystring); - - //* Getting the records - $tmp_records = $app->db->queryAllRecords($querystring); - if($app->db->errorMessage != '') die($app->db->errorMessage); - if(is_array($tmp_records)) { - $key_field = $field['datasource']['keyfield']; - $value_field = $field['datasource']['valuefield']; - foreach($tmp_records as $tmp_rec) { - $tmp_id = $tmp_rec[$key_field]; - $values[$tmp_id] = $tmp_rec[$value_field]; - } - } - } - - if($field['datasource']['type'] == 'CUSTOM') { - //* Calls a custom class to validate this record - if($field['datasource']['class'] != '' and $field['datasource']['function'] != '') { - $datasource_class = $field['datasource']['class']; - $datasource_function = $field['datasource']['function']; - $app->uses($datasource_class); + $querystring = str_replace("{AUTHSQL}", $app->tform->getAuthSQL('r'), $querystring); + $querystring = str_replace("{AUTHSQL-A}", $app->tform->getAuthSQL('r', 'a'), $querystring); + $querystring = str_replace("{AUTHSQL-B}", $app->tform->getAuthSQL('r', 'b'), $querystring); + + //* Getting the records + $tmp_records = $app->db->queryAllRecords($querystring); + if($app->db->errorMessage != '') die($app->db->errorMessage); + if(is_array($tmp_records)) { + $key_field = $field['datasource']['keyfield']; + $value_field = $field['datasource']['valuefield']; + foreach($tmp_records as $tmp_rec) { + $tmp_id = $tmp_rec[$key_field]; + $values[$tmp_id] = $tmp_rec[$value_field]; + } + } + } + + if($field['datasource']['type'] == 'CUSTOM') { + //* Calls a custom class to validate this record + if($field['datasource']['class'] != '' and $field['datasource']['function'] != '') { + $datasource_class = $field['datasource']['class']; + $datasource_function = $field['datasource']['function']; + $app->uses($datasource_class); $record = array(); - $values = $app->$datasource_class->$datasource_function($field, $record); - } else { - $this->errorMessage .= "Custom datasource class or function is empty
\r\n"; - } - } - return $values; - } - - public function getSearchSQL($sql_where = '') - { - global $app, $db; - - //* Get config variable - $list_name = $this->listDef['name']; - $search_prefix = $this->listDef['search_prefix']; - + $values = $app->$datasource_class->$datasource_function($field, $record); + } else { + $this->errorMessage .= "Custom datasource class or function is empty
\r\n"; + } + } + return $values; + } + + public function getSearchSQL($sql_where = '') + { + global $app, $db; + + //* Get config variable + $list_name = $this->listDef['name']; + $search_prefix = $this->listDef['search_prefix']; + if(isset($_REQUEST['Filter']) && !isset($_SESSION['search'][$list_name])) { //* Jump back to page 1 of the list when a new search gets started. $_SESSION['search'][$list_name]['page'] = 0; } - //* store retrieval query - if(@is_array($this->listDef['item'])) { - foreach($this->listDef['item'] as $i) { - $field = $i['field']; - - //* The search string has been changed - if(isset($_REQUEST[$search_prefix.$field]) && isset($_SESSION['search'][$list_name][$search_prefix.$field]) && $_REQUEST[$search_prefix.$field] != $_SESSION['search'][$list_name][$search_prefix.$field]){ - $this->searchChanged = 1; - - //* Jump back to page 1 of the list when search has changed. - $_SESSION['search'][$list_name]['page'] = 0; - } - - //* Store field in session - if(isset($_REQUEST[$search_prefix.$field]) && !stristr($_REQUEST[$search_prefix.$field],"'")){ - $_SESSION['search'][$list_name][$search_prefix.$field] = $_REQUEST[$search_prefix.$field]; + //* store retrieval query + if(@is_array($this->listDef['item'])) { + foreach($this->listDef['item'] as $i) { + $field = $i['field']; + + //* The search string has been changed + if(isset($_REQUEST[$search_prefix.$field]) && isset($_SESSION['search'][$list_name][$search_prefix.$field]) && $_REQUEST[$search_prefix.$field] != $_SESSION['search'][$list_name][$search_prefix.$field]){ + $this->searchChanged = 1; + + //* Jump back to page 1 of the list when search has changed. + $_SESSION['search'][$list_name]['page'] = 0; + } + + //* Store field in session + if(isset($_REQUEST[$search_prefix.$field]) && !stristr($_REQUEST[$search_prefix.$field], "'")){ + $_SESSION['search'][$list_name][$search_prefix.$field] = $_REQUEST[$search_prefix.$field]; if(preg_match("/['\\\\]/", $_SESSION['search'][$list_name][$search_prefix.$field])) $_SESSION['search'][$list_name][$search_prefix.$field] = ''; } - if(isset($i['formtype']) && $i['formtype'] == 'SELECT'){ - if(is_array($i['value'])) { - $out = ''; - foreach($i['value'] as $k => $v) { - // TODO: this could be more elegant - $selected = (isset($_SESSION['search'][$list_name][$search_prefix.$field]) - && $k == $_SESSION['search'][$list_name][$search_prefix.$field] - && $_SESSION['search'][$list_name][$search_prefix.$field] != '') - ? ' SELECTED' : ''; - $out .= "\r\n"; - } - } - $this->searchValues[$search_prefix.$field] = $out; - } else { - if(isset($_SESSION['search'][$list_name][$search_prefix.$field])){ - $this->searchValues[$search_prefix.$field] = htmlspecialchars($_SESSION['search'][$list_name][$search_prefix.$field]); - } - } - } - } - //* Store variables in object | $this->searchValues = $_SESSION["search"][$list_name]; - if(@is_array($this->listDef['item'])) { - foreach($this->listDef['item'] as $i) { - $field = $i['field']; + if(isset($i['formtype']) && $i['formtype'] == 'SELECT'){ + if(is_array($i['value'])) { + $out = ''; + foreach($i['value'] as $k => $v) { + // TODO: this could be more elegant + $selected = (isset($_SESSION['search'][$list_name][$search_prefix.$field]) + && $k == $_SESSION['search'][$list_name][$search_prefix.$field] + && $_SESSION['search'][$list_name][$search_prefix.$field] != '') + ? ' SELECTED' : ''; + $out .= "\r\n"; + } + } + $this->searchValues[$search_prefix.$field] = $out; + } else { + if(isset($_SESSION['search'][$list_name][$search_prefix.$field])){ + $this->searchValues[$search_prefix.$field] = htmlspecialchars($_SESSION['search'][$list_name][$search_prefix.$field]); + } + } + } + } + //* Store variables in object | $this->searchValues = $_SESSION["search"][$list_name]; + if(@is_array($this->listDef['item'])) { + foreach($this->listDef['item'] as $i) { + $field = $i['field']; $table = $i['table']; - + $searchval = $_SESSION['search'][$list_name][$search_prefix.$field]; // format user date format to MySQL date format 0000-00-00 if($i['datatype'] == 'DATE' && $this->lng('conf_format_dateshort') != 'Y-m-d'){ @@ -189,15 +191,15 @@ class listform { $yearpos = strpos($dateformat, 'Y') + 1; $monthpos = strpos($dateformat, 'm') + 1; $daypos = strpos($dateformat, 'd') + 1; - - $full_date_trans = array ('Y' => '((?:19|20)\d\d)', - 'm' => '(0[1-9]|1[012])', - 'd' => '(0[1-9]|[12][0-9]|3[01])' - ); - // d.m.Y Y/m/d + + $full_date_trans = array ('Y' => '((?:19|20)\d\d)', + 'm' => '(0[1-9]|1[012])', + 'd' => '(0[1-9]|[12][0-9]|3[01])' + ); + // d.m.Y Y/m/d $full_date_regex = strtr(preg_replace("@[^Ymd]@", "[^0-9]", $this->lng('conf_format_dateshort')), $full_date_trans); //echo $full_date_regex; - + if (preg_match("@^\d+$@", $_SESSION['search'][$list_name][$search_prefix.$field])) { // we just have digits $searchval = $_SESSION['search'][$list_name][$search_prefix.$field]; } elseif(preg_match("@^[^0-9]?\d+[^0-9]?$@", $_SESSION['search'][$list_name][$search_prefix.$field])){ // 10. or .10. @@ -212,8 +214,8 @@ class listform { $searchval = $year.'-'.$month; } elseif(preg_match("@^[^0-9]?(\d{1,2})[^0-9](\d{1,2})[^0-9]?$@", $_SESSION['search'][$list_name][$search_prefix.$field], $matches)){ // 04.10. if($monthpos < $daypos){ - $month = $matches[1]; - $day = $matches[2]; + $month = $matches[1]; + $day = $matches[2]; } else { $month = $matches[2]; $day = $matches[1]; @@ -227,332 +229,332 @@ class listform { $searchval = $year.'-'.$month.'-'.$day; } } - - // if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and"; - if(isset($searchval) && $searchval != ''){ - $sql_where .= " ".($table != ''? $table.'.' : $this->listDef['table'].'.')."$field ".$i['op']." '".$app->db->quote($i['prefix'].$searchval.$i['suffix'])."' and"; - } - } - } - return ( $sql_where != '' ) ? $sql_where = substr($sql_where,0,-3) : '1'; - } - + + // if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and"; + if(isset($searchval) && $searchval != ''){ + $sql_where .= " ".($table != ''? $table.'.' : $this->listDef['table'].'.')."$field ".$i['op']." '".$app->db->quote($i['prefix'].$searchval.$i['suffix'])."' and"; + } + } + } + return ( $sql_where != '' ) ? $sql_where = substr($sql_where, 0, -3) : '1'; + } + public function getPagingValue($key) { if(!is_array($this->pagingValues)) return null; if(!array_key_exists($key, $this->pagingValues)) return null; return $this->pagingValues[$key]; } - - public function getPagingSQL($sql_where = '1') - { - global $app, $conf; - + + public function getPagingSQL($sql_where = '1') + { + global $app, $conf; + //* Add Global Limit from selectbox - if(!empty($_POST['search_limit']) AND $app->functions->intval($_POST['search_limit']) > 0){ + if(!empty($_POST['search_limit']) and $app->functions->intval($_POST['search_limit']) > 0){ $_SESSION['search']['limit'] = $app->functions->intval($_POST['search_limit']); } - + //if(preg_match('{^[0-9]$}',$_SESSION['search']['limit'])){ - // $_SESSION['search']['limit'] = 15; + // $_SESSION['search']['limit'] = 15; //} if(intval($_SESSION['search']['limit']) < 1) $_SESSION['search']['limit'] = 15; - //* Get Config variables - $list_name = $this->listDef['name']; - $search_prefix = $this->listDef['search_prefix']; - $records_per_page = (empty($_SESSION['search']['limit']) ? $app->functions->intval($this->listDef['records_per_page']) : $app->functions->intval($_SESSION['search']['limit'])) ; - $table = $this->listDef['table']; - - //* set PAGE to zero, if in session not set - if(!isset($_SESSION['search'][$list_name]['page']) || $_SESSION['search'][$list_name]['page'] == ''){ - $_SESSION['search'][$list_name]['page'] = 0; - } - - //* set PAGE to worth request variable "PAGE" - ? setze page auf wert der request variablen "page" - if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = $app->functions->intval($_REQUEST["page"]); - - //* PAGE to 0 set, if look for themselves ? page auf 0 setzen, wenn suche sich ge�ndert hat. - if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0; - - $sql_von = $app->functions->intval($_SESSION['search'][$list_name]['page'] * $records_per_page); - $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table".($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')." WHERE $sql_where"); - $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); - - - $vars['list_file'] = $_SESSION['s']['module']['name'].'/'.$this->listDef['file']; - $vars['page'] = $_SESSION['search'][$list_name]['page']; - $vars['last_page'] = $_SESSION['search'][$list_name]['page'] - 1; - $vars['next_page'] = $_SESSION['search'][$list_name]['page'] + 1; - $vars['pages'] = $pages; - $vars['max_pages'] = $pages + 1; - $vars['records_gesamt'] = $record_count['anzahl']; - $vars['page_params'] = (isset($this->listDef['page_params'])) ? $this->listDef['page_params'] : ''; - $vars['offset'] = $sql_von; - $vars['records_per_page'] = $records_per_page; - //$vars['module'] = $_SESSION['s']['module']['name']; - - if($_SESSION['search'][$list_name]['page'] > 0) $vars['show_page_back'] = 1; - if($_SESSION['search'][$list_name]['page'] <= $vars['pages'] - 1) $vars['show_page_next'] = 1; - - $this->pagingValues = $vars; - $this->pagingHTML = $this->getPagingHTML($vars); - - //* Return limit sql - return "LIMIT $sql_von, $records_per_page"; - } - - public function getPagingHTML($vars) - { - global $app; - - // we want to show at max 17 page numbers (8 left, current, 8 right) - $show_pages_count = 17; - - $show_pages = array(0); // first page - if($vars['pages'] > 0) $show_pages[] = $vars['pages']; // last page - for($p = $vars['page'] - 2; $p <= $vars['page'] + 2; $p++) { // surrounding pages - if($p > 0 && $p < $vars['pages']) $show_pages[] = $p; - } - - $l_start = $vars['page'] - 13; - $l_start -= ($l_start % 10) + 1; - $h_end = $vars['page'] + 23; - $h_end -= ($h_end % 10) + 1; - for($p = $l_start; $p <= $h_end; $p += 10) { // surrounding pages - if($p > 0 && $p < $vars['pages'] && !in_array($p, $show_pages, true) && count($show_pages) < $show_pages_count) $show_pages[] = $p; - } - - $l_start = $vars['page'] - 503; - $l_start -= ($l_start % 100) + 1; - $h_end = $vars['page'] + 603; - $h_end -= ($h_end % 100) + 1; - for($p = $l_start; $p <= $h_end; $p += 100) { // surrounding pages - if($p > 0 && $p < $vars['pages'] && !in_array($p, $show_pages, true) && count($show_pages) < $show_pages_count) $show_pages[] = $p; - } - - $l_start = $vars['page'] - 203; - $l_start -= ($l_start % 25) + 1; - $h_end = $vars['page'] + 228; - $h_end -= ($h_end % 25) + 1; - for($p = $l_start; $p <= $h_end; $p += 25) { // surrounding pages - if($p > 0 && $p < $vars['pages'] && abs($p - $vars['page']) > 30 && !in_array($p, $show_pages, true) && count($show_pages) < $show_pages_count) $show_pages[] = $p; - } - - sort($show_pages); - $show_pages = array_unique($show_pages); - - //* Show Back - if(isset($vars['show_page_back']) && $vars['show_page_back'] == 1){ - $content = '' - .'   '; - $content .= '' - .'   '; - } - $content .= ' '.$this->lng('page_txt').' '; - $prev = -1; - foreach($show_pages as $p) { - if($prev != -1 && $p > $prev + 1) $content .= '...'; - $content .= ''. ($p+1) .''; - $prev = $p; - } - //.$vars['next_page'].' '.$this->lng('page_of_txt').' '.$vars['max_pages'].'   '; - //* Show Next - if(isset($vars['show_page_next']) && $vars['show_page_next'] == 1){ - $content .= '' - .'   '; - $content .= '' - .''; - } - return $content; - } - + //* Get Config variables + $list_name = $this->listDef['name']; + $search_prefix = $this->listDef['search_prefix']; + $records_per_page = (empty($_SESSION['search']['limit']) ? $app->functions->intval($this->listDef['records_per_page']) : $app->functions->intval($_SESSION['search']['limit'])) ; + $table = $this->listDef['table']; + + //* set PAGE to zero, if in session not set + if(!isset($_SESSION['search'][$list_name]['page']) || $_SESSION['search'][$list_name]['page'] == ''){ + $_SESSION['search'][$list_name]['page'] = 0; + } + + //* set PAGE to worth request variable "PAGE" - ? setze page auf wert der request variablen "page" + if(isset($_REQUEST["page"])) $_SESSION["search"][$list_name]["page"] = $app->functions->intval($_REQUEST["page"]); + + //* PAGE to 0 set, if look for themselves ? page auf 0 setzen, wenn suche sich ge�ndert hat. + if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0; + + $sql_von = $app->functions->intval($_SESSION['search'][$list_name]['page'] * $records_per_page); + $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table".($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')." WHERE $sql_where"); + $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); + + + $vars['list_file'] = $_SESSION['s']['module']['name'].'/'.$this->listDef['file']; + $vars['page'] = $_SESSION['search'][$list_name]['page']; + $vars['last_page'] = $_SESSION['search'][$list_name]['page'] - 1; + $vars['next_page'] = $_SESSION['search'][$list_name]['page'] + 1; + $vars['pages'] = $pages; + $vars['max_pages'] = $pages + 1; + $vars['records_gesamt'] = $record_count['anzahl']; + $vars['page_params'] = (isset($this->listDef['page_params'])) ? $this->listDef['page_params'] : ''; + $vars['offset'] = $sql_von; + $vars['records_per_page'] = $records_per_page; + //$vars['module'] = $_SESSION['s']['module']['name']; + + if($_SESSION['search'][$list_name]['page'] > 0) $vars['show_page_back'] = 1; + if($_SESSION['search'][$list_name]['page'] <= $vars['pages'] - 1) $vars['show_page_next'] = 1; + + $this->pagingValues = $vars; + $this->pagingHTML = $this->getPagingHTML($vars); + + //* Return limit sql + return "LIMIT $sql_von, $records_per_page"; + } + + public function getPagingHTML($vars) + { + global $app; + + // we want to show at max 17 page numbers (8 left, current, 8 right) + $show_pages_count = 17; + + $show_pages = array(0); // first page + if($vars['pages'] > 0) $show_pages[] = $vars['pages']; // last page + for($p = $vars['page'] - 2; $p <= $vars['page'] + 2; $p++) { // surrounding pages + if($p > 0 && $p < $vars['pages']) $show_pages[] = $p; + } + + $l_start = $vars['page'] - 13; + $l_start -= ($l_start % 10) + 1; + $h_end = $vars['page'] + 23; + $h_end -= ($h_end % 10) + 1; + for($p = $l_start; $p <= $h_end; $p += 10) { // surrounding pages + if($p > 0 && $p < $vars['pages'] && !in_array($p, $show_pages, true) && count($show_pages) < $show_pages_count) $show_pages[] = $p; + } + + $l_start = $vars['page'] - 503; + $l_start -= ($l_start % 100) + 1; + $h_end = $vars['page'] + 603; + $h_end -= ($h_end % 100) + 1; + for($p = $l_start; $p <= $h_end; $p += 100) { // surrounding pages + if($p > 0 && $p < $vars['pages'] && !in_array($p, $show_pages, true) && count($show_pages) < $show_pages_count) $show_pages[] = $p; + } + + $l_start = $vars['page'] - 203; + $l_start -= ($l_start % 25) + 1; + $h_end = $vars['page'] + 228; + $h_end -= ($h_end % 25) + 1; + for($p = $l_start; $p <= $h_end; $p += 25) { // surrounding pages + if($p > 0 && $p < $vars['pages'] && abs($p - $vars['page']) > 30 && !in_array($p, $show_pages, true) && count($show_pages) < $show_pages_count) $show_pages[] = $p; + } + + sort($show_pages); + $show_pages = array_unique($show_pages); + + //* Show Back + if(isset($vars['show_page_back']) && $vars['show_page_back'] == 1){ + $content = '' + .'   '; + $content .= '' + .'   '; + } + $content .= ' '.$this->lng('page_txt').' '; + $prev = -1; + foreach($show_pages as $p) { + if($prev != -1 && $p > $prev + 1) $content .= '...'; + $content .= ''. ($p+1) .''; + $prev = $p; + } + //.$vars['next_page'].' '.$this->lng('page_of_txt').' '.$vars['max_pages'].'   '; + //* Show Next + if(isset($vars['show_page_next']) && $vars['show_page_next'] == 1){ + $content .= '' + .'   '; + $content .= '' + .''; + } + return $content; + } + public function getPagingHTMLasTXT($vars) - { - global $app; - $content = '[|<< ]'; - if($vars['show_page_back'] == 1){ - $content .= '[<< '.$app->lng('page_back_txt').'] '; - } - $content .= ' '.$this->lng('page_txt').' '.$vars['next_page'].' '.$this->lng('page_of_txt').' '.$vars['max_pages'].' '; - if($vars['show_page_next'] == 1){ - $content .= '['.$app->lng('page_next_txt').' >>] '; - } - $content .= '[ >>|]'; - return $content; - } - - public function getSortSQL() - { - global $app, $conf; - //* Get config vars - $sort_field = $this->listDef['sort_field']; - $sort_direction = $this->listDef['sort_direction']; - return ($sort_field != '' && $sort_direction != '') ? "ORDER BY $sort_field $sort_direction" : ''; - } - - public function decode($record) - { - global $conf, $app; - if(is_array($record) && count($record) > 0 && is_array($this->listDef['item'])) { - foreach($this->listDef['item'] as $field){ - $key = $field['field']; - //* Apply filter to record value. - if(isset($field['filters']) && is_array($field['filters'])) { - $app->uses('tform'); - $record[$key] = $app->tform->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SHOW'); - } + { + global $app; + $content = '[|<< ]'; + if($vars['show_page_back'] == 1){ + $content .= '[<< '.$app->lng('page_back_txt').'] '; + } + $content .= ' '.$this->lng('page_txt').' '.$vars['next_page'].' '.$this->lng('page_of_txt').' '.$vars['max_pages'].' '; + if($vars['show_page_next'] == 1){ + $content .= '['.$app->lng('page_next_txt').' >>] '; + } + $content .= '[ >>|]'; + return $content; + } + + public function getSortSQL() + { + global $app, $conf; + //* Get config vars + $sort_field = $this->listDef['sort_field']; + $sort_direction = $this->listDef['sort_direction']; + return ($sort_field != '' && $sort_direction != '') ? "ORDER BY $sort_field $sort_direction" : ''; + } + + public function decode($record) + { + global $conf, $app; + if(is_array($record) && count($record) > 0 && is_array($this->listDef['item'])) { + foreach($this->listDef['item'] as $field){ + $key = $field['field']; + //* Apply filter to record value. + if(isset($field['filters']) && is_array($field['filters'])) { + $app->uses('tform'); + $record[$key] = $app->tform->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SHOW'); + } if(isset($record[$key])) { - switch ($field['datatype']){ - case 'VARCHAR': - case 'TEXT': - $record[$key] = htmlentities(stripslashes($record[$key]),ENT_QUOTES,$conf["html_content_encoding"]); - break; - - case 'DATETSTAMP': - if ($record[$key] > 0) { + switch ($field['datatype']){ + case 'VARCHAR': + case 'TEXT': + $record[$key] = htmlentities(stripslashes($record[$key]), ENT_QUOTES, $conf["html_content_encoding"]); + break; + + case 'DATETSTAMP': + if ($record[$key] > 0) { // is value int? if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { - $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); + $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); } else { - $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); + $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); } } - break; + break; case 'DATETIMETSTAMP': - if ($record[$key] > 0) { + if ($record[$key] > 0) { // is value int? if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { - $record[$key] = date($this->lng('conf_format_datetime'), $record[$key]); + $record[$key] = date($this->lng('conf_format_datetime'), $record[$key]); } else { - $record[$key] = date($this->lng('conf_format_datetime'), strtotime($record[$key])); + $record[$key] = date($this->lng('conf_format_datetime'), strtotime($record[$key])); } } - break; + break; case 'DATE': - if ($record[$key] > 0) { + if ($record[$key] > 0) { // is value int? if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { - $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); + $record[$key] = date($this->lng('conf_format_dateshort'), $record[$key]); } else { - $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); + $record[$key] = date($this->lng('conf_format_dateshort'), strtotime($record[$key])); } } - break; - - case 'DATETIME': - if ($record[$key] > 0) { + break; + + case 'DATETIME': + if ($record[$key] > 0) { // is value int? if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record[$key], $p)) { - $record[$key] = date($this->lng('conf_format_datetime'), $record[$key]); + $record[$key] = date($this->lng('conf_format_datetime'), $record[$key]); } else { - $record[$key] = date($this->lng('conf_format_datetime'), strtotime($record[$key])); + $record[$key] = date($this->lng('conf_format_datetime'), strtotime($record[$key])); } } - break; + break; - case 'INTEGER': - $record[$key] = $app->functions->intval($record[$key]); - break; + case 'INTEGER': + $record[$key] = $app->functions->intval($record[$key]); + break; - case 'DOUBLE': - $record[$key] = htmlentities($record[$key],ENT_QUOTES,$conf["html_content_encoding"]); - break; + case 'DOUBLE': + $record[$key] = htmlentities($record[$key], ENT_QUOTES, $conf["html_content_encoding"]); + break; - case 'CURRENCY': - $record[$key] = $app->functions->currency_format($record[$key]); - break; + case 'CURRENCY': + $record[$key] = $app->functions->currency_format($record[$key]); + break; - default: - $record[$key] = htmlentities(stripslashes($record[$key]),ENT_QUOTES,$conf["html_content_encoding"]); - } + default: + $record[$key] = htmlentities(stripslashes($record[$key]), ENT_QUOTES, $conf["html_content_encoding"]); + } } - } - } - return $record; - } - - public function encode($record) - { - global $app; - if(is_array($record)) { - foreach($this->listDef['item'] as $field){ - $key = $field['field']; - switch($field['datatype']){ - - case 'VARCHAR': - case 'TEXT': - if(!is_array($record[$key])) { - $record[$key] = $app->db->quote($record[$key]); - } else { - $record[$key] = implode($this->tableDef[$key]['separator'],$record[$key]); - } - break; - - case 'DATETSTAMP': - if($record[$key] > 0) { - $record[$key] = date('Y-m-d',strtotime($record[$key])); - } - break; - - case 'DATETIMETSTAMP': - if($record[$key] > 0) { - $record[$key] = date('Y-m-d H:i:s',strtotime($record[$key])); - } - break; - - case 'DATE': - if($record[$key] != '' && $record[$key] != '0000-00-00') { - $record[$key] = $record[$key]; - } - break; - - case 'DATETIME': - if($record[$key] > 0) { - $record[$key] = date('Y-m-d H:i:s',strtotime($record[$key])); - } - break; - - case 'INTEGER': - $record[$key] = $app->functions->intval($record[$key]); - break; - - case 'DOUBLE': - $record[$key] = $app->db->quote($record[$key]); - break; - - case 'CURRENCY': - $record[$key] = str_replace(',', '.', $record[$key]); - break; - } - } - } - return $record; - } - + } + } + return $record; + } + + public function encode($record) + { + global $app; + if(is_array($record)) { + foreach($this->listDef['item'] as $field){ + $key = $field['field']; + switch($field['datatype']){ + + case 'VARCHAR': + case 'TEXT': + if(!is_array($record[$key])) { + $record[$key] = $app->db->quote($record[$key]); + } else { + $record[$key] = implode($this->tableDef[$key]['separator'], $record[$key]); + } + break; + + case 'DATETSTAMP': + if($record[$key] > 0) { + $record[$key] = date('Y-m-d', strtotime($record[$key])); + } + break; + + case 'DATETIMETSTAMP': + if($record[$key] > 0) { + $record[$key] = date('Y-m-d H:i:s', strtotime($record[$key])); + } + break; + + case 'DATE': + if($record[$key] != '' && $record[$key] != '0000-00-00') { + $record[$key] = $record[$key]; + } + break; + + case 'DATETIME': + if($record[$key] > 0) { + $record[$key] = date('Y-m-d H:i:s', strtotime($record[$key])); + } + break; + + case 'INTEGER': + $record[$key] = $app->functions->intval($record[$key]); + break; + + case 'DOUBLE': + $record[$key] = $app->db->quote($record[$key]); + break; + + case 'CURRENCY': + $record[$key] = str_replace(',', '.', $record[$key]); + break; + } + } + } + return $record; + } + function lng($msg) { global $app; - + if(isset($this->wordbook[$msg])) { return $this->wordbook[$msg]; } else { return $app->lng($msg); - } + } } - + function escapeArrayValues($search_values) { - global $conf; - + global $conf; + $out = array(); if(is_array($search_values)) { foreach($search_values as $key => $val) { - $out[$key] = htmlentities($val,ENT_QUOTES,$conf["html_content_encoding"]); + $out[$key] = htmlentities($val, ENT_QUOTES, $conf["html_content_encoding"]); } } - + return $out; - + } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php index fe167a90a..0062d8e3a 100644 --- a/interface/lib/classes/listform_actions.inc.php +++ b/interface/lib/classes/listform_actions.inc.php @@ -29,7 +29,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class listform_actions { - + private $id; public $idx_key; public $DataRowColor; @@ -37,139 +37,139 @@ class listform_actions { public $SQLOrderBy = ''; public $SQLExtSelect = ''; private $sortKeys; - - private function _sort($aOne, $aTwo) { - if(!is_array($aOne) || !is_array($aTwo)) return 0; - - if(!is_array($this->sortKeys)) $this->sortKeys = array($this->sortKeys); - foreach($this->sortKeys as $sKey => $sDir) { - if(is_numeric($sKey)) { - $sKey = $sDir; - $sDir = 'ASC'; - } - $a = $aOne[$sKey]; - $b = $aTwo[$sKey]; - if(is_string($a)) $a = strtolower($a); - if(is_string($b)) $b = strtolower($b); - if($a < $b) return ($sDir == 'DESC' ? 1 : -1); - elseif($a > $b) return ($sDir == 'DESC' ? -1 : 1); - } - return 0; - } - + + private function _sort($aOne, $aTwo) { + if(!is_array($aOne) || !is_array($aTwo)) return 0; + + if(!is_array($this->sortKeys)) $this->sortKeys = array($this->sortKeys); + foreach($this->sortKeys as $sKey => $sDir) { + if(is_numeric($sKey)) { + $sKey = $sDir; + $sDir = 'ASC'; + } + $a = $aOne[$sKey]; + $b = $aTwo[$sKey]; + if(is_string($a)) $a = strtolower($a); + if(is_string($b)) $b = strtolower($b); + if($a < $b) return $sDir == 'DESC' ? 1 : -1; + elseif($a > $b) return $sDir == 'DESC' ? -1 : 1; + } + return 0; + } + public function onLoad() - { + { global $app, $conf, $list_def_file; - + $app->uses('tpl,listform,tform'); - + //* Clear session variable that is used when lists are embedded with the listview plugin $_SESSION['s']['form']['return_to'] = ''; - + // Load list definition $app->listform->loadListDef($list_def_file); - + if(!is_file('templates/'.$app->listform->listDef["name"].'_list.htm')) { $app->uses('listform_tpl_generator'); $app->listform_tpl_generator->buildHTML($app->listform->listDef); } - + $app->tpl->newTemplate("listpage.tpl.htm"); - $app->tpl->setInclude('content_tpl','templates/'.$app->listform->listDef["name"].'_list.htm'); - + $app->tpl->setInclude('content_tpl', 'templates/'.$app->listform->listDef["name"].'_list.htm'); + //* Manipulate order by for sorting / Every list has a stored value //* Against notice error if(!isset($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'])){ - $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = ''; + $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = ''; } - - $php_sort = false; - + + $php_sort = false; + if(!empty($_GET['orderby'])){ - $order = str_replace('tbl_col_','',$_GET['orderby']); - - //* Check the css class submited value - if (preg_match("/^[a-z\_]{1,}$/",$order)) { - - if(isset($app->listform->listDef['phpsort']) && is_array($app->listform->listDef['phpsort']) && in_array($order, $app->listform->listDef['phpsort'])) { - $php_sort = true; - } else { - // prepend correct table - $prepend_table = $app->listform->listDef['table']; - if(trim($app->listform->listDef['additional_tables']) != '' && is_array($app->listform->listDef['item']) && count($app->listform->listDef['item']) > 0) { - foreach($app->listform->listDef['item'] as $field) { - if($field['field'] == $order && $field['table'] != ''){ - $prepend_table = $field['table']; - break; - } - } - } - $order = $prepend_table.'.'.$order; - } - - if($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] == $order){ - $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = $order.' DESC'; - } else { - $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = $order; - } - $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php'] = $php_sort; - } + $order = str_replace('tbl_col_', '', $_GET['orderby']); + + //* Check the css class submited value + if (preg_match("/^[a-z\_]{1,}$/", $order)) { + + if(isset($app->listform->listDef['phpsort']) && is_array($app->listform->listDef['phpsort']) && in_array($order, $app->listform->listDef['phpsort'])) { + $php_sort = true; + } else { + // prepend correct table + $prepend_table = $app->listform->listDef['table']; + if(trim($app->listform->listDef['additional_tables']) != '' && is_array($app->listform->listDef['item']) && count($app->listform->listDef['item']) > 0) { + foreach($app->listform->listDef['item'] as $field) { + if($field['field'] == $order && $field['table'] != ''){ + $prepend_table = $field['table']; + break; + } + } + } + $order = $prepend_table.'.'.$order; + } + + if($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] == $order){ + $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = $order.' DESC'; + } else { + $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'] = $order; + } + $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php'] = $php_sort; + } } // If a manuel oder by like customers isset the sorting will be infront if(!empty($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']) && !$_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']){ - if(empty($this->SQLOrderBy)){ - $this->SQLOrderBy = "ORDER BY ".$_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']; - } else { - $this->SQLOrderBy = str_replace("ORDER BY ","ORDER BY ".$_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'].', ',$this->SQLOrderBy); - } + if(empty($this->SQLOrderBy)){ + $this->SQLOrderBy = "ORDER BY ".$_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']; + } else { + $this->SQLOrderBy = str_replace("ORDER BY ", "ORDER BY ".$_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order'].', ', $this->SQLOrderBy); + } } - + if($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) $php_sort = true; - + // Getting Datasets from DB $records = $app->db->queryAllRecords($this->getQueryString($php_sort)); $this->DataRowColor = "#FFFFFF"; $records_new = ''; if(is_array($records)) { - $this->idx_key = $app->listform->listDef["table_idx"]; + $this->idx_key = $app->listform->listDef["table_idx"]; foreach($records as $rec) { $records_new[] = $this->prepareDataRow($rec); } } - - if(!empty($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']) && $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) { - $order_by = $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']; - $order_dir = 'ASC'; - if(substr($order_by, -5) === ' DESC') { - $order_by = substr($order_by, 0, -5); - $order_dir = 'DESC'; - } - $this->sortKeys = array($order_by => $order_dir); - uasort($records_new, array($this, '_sort')); - } - if($php_sort) { + + if(!empty($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']) && $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) { + $order_by = $_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order']; + $order_dir = 'ASC'; + if(substr($order_by, -5) === ' DESC') { + $order_by = substr($order_by, 0, -5); + $order_dir = 'DESC'; + } + $this->sortKeys = array($order_by => $order_dir); + uasort($records_new, array($this, '_sort')); + } + if($php_sort) { $records_new = array_slice($records_new, $app->listform->getPagingValue('offset'), $app->listform->getPagingValue('records_per_page')); } - - $app->tpl->setLoop('records',$records_new); + + $app->tpl->setLoop('records', $records_new); $this->onShow(); - - + + } - + public function prepareDataRow($rec) - { + { global $app; - + $rec = $app->listform->decode($rec); //* Alternating datarow colors $this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF'; $rec['bgcolor'] = $this->DataRowColor; - + //* substitute value for select fields if(is_array($app->listform->listDef['item']) && count($app->listform->listDef['item']) > 0) { foreach($app->listform->listDef['item'] as $field) { @@ -184,12 +184,12 @@ class listform_actions { } } } - + //* The variable "id" contains always the index variable $rec['id'] = $rec[$this->idx_key]; return $rec; } - + public function getQueryString($no_limit = false) { global $app; $sql_where = ''; @@ -199,32 +199,32 @@ class listform_actions { if($_SESSION['s']['user']['typ'] == "admin") { $sql_where = ''; } else { - $sql_where = $app->tform->getAuthSQL('r', $app->listform->listDef['table']).' and'; - //$sql_where = $app->tform->getAuthSQL('r').' and'; + $sql_where = $app->tform->getAuthSQL('r', $app->listform->listDef['table']).' and'; + //$sql_where = $app->tform->getAuthSQL('r').' and'; } - } + } if($this->SQLExtWhere != '') { $sql_where .= ' '.$this->SQLExtWhere.' and'; } - + $sql_where = $app->listform->getSearchSQL($sql_where); if($app->listform->listDef['join_sql']) $sql_where .= ' AND '.$app->listform->listDef['join_sql']; $app->tpl->setVar($app->listform->searchValues); - + $order_by_sql = $this->SQLOrderBy; //* Generate SQL for paging $limit_sql = $app->listform->getPagingSQL($sql_where); - $app->tpl->setVar('paging',$app->listform->pagingHTML); + $app->tpl->setVar('paging', $app->listform->pagingHTML); $extselect = ''; $join = ''; - + if($this->SQLExtSelect != '') { - if(substr($this->SQLExtSelect,0,1) != ',') $this->SQLExtSelect = ','.$this->SQLExtSelect; + if(substr($this->SQLExtSelect, 0, 1) != ',') $this->SQLExtSelect = ','.$this->SQLExtSelect; $extselect .= $this->SQLExtSelect; } - + $table_selects = array(); $table_selects[] = trim($app->listform->listDef['table']).'.*'; $app->listform->listDef['additional_tables'] = trim($app->listform->listDef['additional_tables']); @@ -241,53 +241,54 @@ class listform_actions { //echo $sql; return $sql; } - - + + public function onShow() - { + { global $app; - + //* Set global Language File $lng_file = ISPC_LIB_PATH.'/lang/'.$_SESSION['s']['language'].'.lng'; if(!file_exists($lng_file)) - $lng_file = ISPC_LIB_PATH.'/lang/en.lng'; - include($lng_file); + $lng_file = ISPC_LIB_PATH.'/lang/en.lng'; + include $lng_file; $app->tpl->setVar($wb); - + //* Limit each page - $limits = array('5'=>'5','15'=>'15','25'=>'25','50'=>'50','100'=>'100','999999999' => 'all'); + $limits = array('5'=>'5', '15'=>'15', '25'=>'25', '50'=>'50', '100'=>'100', '999999999' => 'all'); //* create options and set selected, if default -> 15 is selected $options = ''; foreach($limits as $key => $val){ - $options .= ''; + $options .= ''; } - $app->tpl->setVar('search_limit',''); - - $app->tpl->setVar('toolsarea_head_txt',$app->lng('toolsarea_head_txt')); + $app->tpl->setVar('search_limit', ''); + + $app->tpl->setVar('toolsarea_head_txt', $app->lng('toolsarea_head_txt')); $app->tpl->setVar($app->listform->wordbook); $app->tpl->setVar('form_action', $app->listform->listDef['file']); - - if(isset($_SESSION['show_info_msg'])) { - $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); - unset($_SESSION['show_info_msg']); - } - if(isset($_SESSION['show_error_msg'])) { - $app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']); - unset($_SESSION['show_error_msg']); - } - + + if(isset($_SESSION['show_info_msg'])) { + $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); + unset($_SESSION['show_info_msg']); + } + if(isset($_SESSION['show_error_msg'])) { + $app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']); + unset($_SESSION['show_error_msg']); + } + //* Parse the templates and send output to the browser $this->onShowEnd(); } - + public function onShowEnd() - { + { global $app; $app->tpl_defaults(); $app->tpl->pparse(); } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/listform_tpl_generator.inc.php b/interface/lib/classes/listform_tpl_generator.inc.php index e19b52c3f..b8a26a73a 100644 --- a/interface/lib/classes/listform_tpl_generator.inc.php +++ b/interface/lib/classes/listform_tpl_generator.inc.php @@ -29,11 +29,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class listform_tpl_generator { - - function buildHTML($listDef,$module = '') { - + + function buildHTML($listDef, $module = '') { + global $app; - + if($module == '') $module = $_SESSION["s"]["module"]["name"]; $lang = array(); @@ -57,22 +57,22 @@ class listform_tpl_generator { '; - + $lang["list_head_txt"] = $listDef["name"]; - $colcount = 0; + $colcount = 0; foreach($listDef["item"] as $field) { $key = $field["field"]; $html .= " \n"; $lang[$key."_txt"] = $key; - $colcount++; + $colcount++; } - + $html .= '   '; - - foreach($listDef["item"] as $field) { + + foreach($listDef["item"] as $field) { $key = $field["field"]; if($field["formtype"] == 'SELECT') { $html .= " \n"; @@ -80,7 +80,7 @@ class listform_tpl_generator { $html .= " \n"; } } - + $html .= '
@@ -88,14 +88,14 @@ class listform_tpl_generator { '; - + foreach($listDef["item"] as $field) { $key = $field["field"]; $html .= " {tmpl_var name=\"".$key."\"}\n"; } - + $html .= " -
+ @@ -107,7 +107,7 @@ class listform_tpl_generator { "; - $html .= ' + $html .= ' @@ -119,26 +119,26 @@ class listform_tpl_generator {
'; - + if($module == '') { $filename = 'templates/'.$listDef["name"].'_list.htm'; } else { $filename = '../'.$module.'/templates/'.$listDef["name"].'_list.htm'; } - - + + // save template - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - - if (!fwrite($handle, $html)) { - print "Cannot write to file ($filename)"; - exit; + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + + if (!fwrite($handle, $html)) { + print "Cannot write to file ($filename)"; + exit; } fclose($handle); - + /*$lang["page_txt"] = 'Page'; $lang["page_of_txt"] = 'of'; $lang["page_next_txt"] = 'Next'; @@ -147,41 +147,41 @@ class listform_tpl_generator { $lang["filter_txt"] = 'Filter'; $lang["add_new_record_txt"] = 'Add new record'; */ - + // save language file - $this->lng_add($lang,$listDef,$module); - } - - function lng_add($lang,$listDef,$module = '') { - global $go_api, $go_info,$conf; - + $this->lng_add($lang, $listDef, $module); + } + + function lng_add($lang, $listDef, $module = '') { + global $go_api, $go_info, $conf; + if($module == '') { $lng_file = "lib/lang/".$conf["language"]."_".$listDef['name']."_list.lng"; } else { $lng_file = '../'.$module."/lib/lang/en_".$listDef['name']."_list.lng"; } - + if(is_file($lng_file)) { - include_once($lng_file); + include_once $lng_file; } else { $wb = array(); } - - $wb_out = array_merge($lang,$wb); - + + $wb_out = array_merge($lang, $wb); + if(is_array($wb_out)) { - $fp = fopen ($lng_file, "w"); - fwrite($fp," $val) { $new_line = '$wb["'.$key.'"] = '."'$val';\n"; - fwrite($fp,$new_line); - + fwrite($fp, $new_line); + } - fwrite($fp,"?>"); + fwrite($fp, "?>"); fclose($fp); } } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/plugin.inc.php b/interface/lib/classes/plugin.inc.php index 341b18622..aaaf56797 100644 --- a/interface/lib/classes/plugin.inc.php +++ b/interface/lib/classes/plugin.inc.php @@ -29,92 +29,92 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class plugin { - + private $subscribed_events = array(); private $debug = false; - - + + /* This function is called to load the plugins from the plugins folder and update the plugin cache */ - + private function loadPluginCache() { - global $app,$conf; - - + global $app, $conf; + + if(isset($_SESSION['s']['plugin_cache'])) unset($_SESSION['s']['plugin_cache']); - + $plugins_dir = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV; $_SESSION['s']['plugin_cache'] = array(); $tmp_plugins = array(); - + if (is_dir($plugins_dir)) { if ($dh = opendir($plugins_dir)) { //** Go trough all files in the plugin dir while (($file = readdir($dh)) !== false) { - if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') { - $plugin_name = substr($file,0,-8); + if($file != '.' && $file != '..' && substr($file, -8, 8) == '.inc.php') { + $plugin_name = substr($file, 0, -8); $tmp_plugins[$plugin_name] = $file; } } //** sort the plugins by name ksort($tmp_plugins); - + //** load the plugins foreach($tmp_plugins as $plugin_name => $file) { - include_once($plugins_dir.$file); - if($this->debug) $app->log('Loading plugin: '.$plugin_name,LOGLEVEL_DEBUG); + include_once $plugins_dir.$file; + if($this->debug) $app->log('Loading plugin: '.$plugin_name, LOGLEVEL_DEBUG); $app->loaded_plugins[$plugin_name] = new $plugin_name; $app->loaded_plugins[$plugin_name]->onLoad(); } } else { - $app->log('Unable to open the plugins directory: '.$plugins_dir,LOGLEVEL_ERROR); + $app->log('Unable to open the plugins directory: '.$plugins_dir, LOGLEVEL_ERROR); } } else { - $app->log('Plugins directory missing: '.$plugins_dir,LOGLEVEL_ERROR); + $app->log('Plugins directory missing: '.$plugins_dir, LOGLEVEL_ERROR); } - + } - + /* - This function is called by the plugin to register for an event which is saved into the plugin cache + This function is called by the plugin to register for an event which is saved into the plugin cache for faster lookups without the need to load all plugins for every page. */ - - public function registerEvent($event_name,$plugin_name,$function_name) { + + public function registerEvent($event_name, $plugin_name, $function_name) { global $app; - + $_SESSION['s']['plugin_cache'][$event_name][] = array('plugin' => $plugin_name, 'function' => $function_name); - if($this->debug) $app->log("Plugin '$plugin_name' has registered the function '$function_name' for the event '$event_name'",LOGLEVEL_DEBUG); + if($this->debug) $app->log("Plugin '$plugin_name' has registered the function '$function_name' for the event '$event_name'", LOGLEVEL_DEBUG); } - + /* This function is called when a certian action occurs, e.g. a form gets saved or a user is logged in. */ - - public function raiseEvent($event_name,$data) { + + public function raiseEvent($event_name, $data) { global $app; - + if(!isset($_SESSION['s']['plugin_cache'])) { $this->loadPluginCache(); - if($this->debug) $app->log('Loaded the plugin cache.',LOGLEVEL_DEBUG); + if($this->debug) $app->log('Loaded the plugin cache.', LOGLEVEL_DEBUG); } - - - $sub_events = explode(':',$event_name); - + + + $sub_events = explode(':', $event_name); + if(is_array($sub_events)) { if(count($sub_events) == 3) { $tmp_event = $sub_events[2]; - if($this->debug) $app->log("Called Event '$tmp_event'",LOGLEVEL_DEBUG); - $this->callPluginEvent($tmp_event,$data); + if($this->debug) $app->log("Called Event '$tmp_event'", LOGLEVEL_DEBUG); + $this->callPluginEvent($tmp_event, $data); $tmp_event = $sub_events[0].':'.$sub_events[2]; - if($this->debug) $app->log("Called Event '$tmp_event'",LOGLEVEL_DEBUG); - $this->callPluginEvent($tmp_event,$data); + if($this->debug) $app->log("Called Event '$tmp_event'", LOGLEVEL_DEBUG); + $this->callPluginEvent($tmp_event, $data); $tmp_event = $sub_events[0].':'.$sub_events[1].':'.$sub_events[2]; - if($this->debug) $app->log("Called Event '$tmp_event'",LOGLEVEL_DEBUG); - $this->callPluginEvent($tmp_event,$data); - + if($this->debug) $app->log("Called Event '$tmp_event'", LOGLEVEL_DEBUG); + $this->callPluginEvent($tmp_event, $data); + /*$sub_events = array_reverse($sub_events); $tmp_event = ''; foreach($sub_events as $n => $sub_event) { @@ -124,44 +124,44 @@ class plugin { } */ } else { - if($this->debug) $app->log("Called Event '$sub_events[0]'",LOGLEVEL_DEBUG); - $this->callPluginEvent($sub_events[0],$data); + if($this->debug) $app->log("Called Event '$sub_events[0]'", LOGLEVEL_DEBUG); + $this->callPluginEvent($sub_events[0], $data); } } - - } // end function raiseEvent - - //* Internal function to load the plugin and call the event function in the plugin. - private function callPluginEvent($event_name,$data) { - global $app; - - //* execute the functions for the events + + } // end function raiseEvent + + //* Internal function to load the plugin and call the event function in the plugin. + private function callPluginEvent($event_name, $data) { + global $app; + + //* execute the functions for the events if(@is_array($_SESSION['s']['plugin_cache'][$event_name])) { foreach($_SESSION['s']['plugin_cache'][$event_name] as $rec) { $plugin_name = $rec['plugin']; $function_name = $rec['function']; $plugin_file = ISPC_LIB_PATH.FS_DIV.'plugins'.FS_DIV.$plugin_name.'.inc.php'; - - + + if(is_file($plugin_file)) { if(!isset($app->loaded_plugins[$plugin_name])) { - include_once($plugin_file); + include_once $plugin_file; $app->loaded_plugins[$plugin_name] = new $plugin_name; } - - if($this->debug) $app->log("Called method: '$function_name' in plugin '$plugin_name' for event '$event_name'",LOGLEVEL_DEBUG); + + if($this->debug) $app->log("Called method: '$function_name' in plugin '$plugin_name' for event '$event_name'", LOGLEVEL_DEBUG); // call_user_method($function_name,$app->loaded_plugins[$plugin_name],$event_name,$data); - call_user_func(array($app->loaded_plugins[$plugin_name],$function_name),$event_name,$data); - + call_user_func(array($app->loaded_plugins[$plugin_name], $function_name), $event_name, $data); + } } - + } - - } // end functiom callPluginEvent - - + + } // end functiom callPluginEvent + + } ?> diff --git a/interface/lib/classes/plugin_backuplist.inc.php b/interface/lib/classes/plugin_backuplist.inc.php index 1f9049614..6d3cdd3a0 100644 --- a/interface/lib/classes/plugin_backuplist.inc.php +++ b/interface/lib/classes/plugin_backuplist.inc.php @@ -30,121 +30,121 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class plugin_backuplist extends plugin_base { - var $module; - var $form; - var $tab; - var $record_id; - var $formdef; - var $options; - - function onShow() { - - global $app; - - $listTpl = new tpl; - $listTpl->newTemplate('templates/web_backup_list.htm'); - - //* Loading language file - $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_web_backup_list.lng"; - include($lng_file); - $listTpl->setVar($wb); - - $message = ''; - $error = ''; - - if(isset($_GET['backup_action'])) { - $backup_id = $app->functions->intval($_GET['backup_id']); - - //* check if the user is owner of the parent domain - $domain_backup = $app->db->queryOneRecord("SELECT parent_domain_id FROM web_backup WHERE backup_id = ".$backup_id); - - $check_perm = 'u'; - if($_GET['backup_action'] == 'download') $check_perm = 'r'; // only check read permissions on download, not update permissions - - $get_domain = $app->db->queryOneRecord("SELECT domain_id FROM web_domain WHERE domain_id = ".$app->functions->intval($domain_backup["parent_domain_id"])." AND ".$app->tform->getAuthSQL($check_perm)); - if(empty($get_domain) || !$get_domain) { - $app->error($app->tform->lng('no_domain_perm')); - } - - if($_GET['backup_action'] == 'download' && $backup_id > 0) { - $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'"; - $tmp = $app->db->queryOneRecord($sql); - if($tmp['number'] == 0) { - $message .= $wb['download_info_txt']; - $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$this->form->dataRecord['server_id'] . ", " . - time() . ", " . - "'backup_download', " . - "'".$backup_id."', " . - "'pending', " . - "''" . - ")"; - $app->db->query($sql); - } else { - $error .= $wb['download_pending_txt']; - } - } - if($_GET['backup_action'] == 'restore' && $backup_id > 0) { - $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore' AND action_param = '$backup_id'"; - $tmp = $app->db->queryOneRecord($sql); - if($tmp['number'] == 0) { - $message .= $wb['restore_info_txt']; - $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$this->form->dataRecord['server_id'] . ", " . - time() . ", " . - "'backup_restore', " . - "'".$backup_id."', " . - "'pending', " . - "''" . - ")"; - $app->db->query($sql); - } else { - $error .= $wb['restore_pending_txt']; - } - } - + var $module; + var $form; + var $tab; + var $record_id; + var $formdef; + var $options; + + function onShow() { + + global $app; + + $listTpl = new tpl; + $listTpl->newTemplate('templates/web_backup_list.htm'); + + //* Loading language file + $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_web_backup_list.lng"; + include $lng_file; + $listTpl->setVar($wb); + + $message = ''; + $error = ''; + + if(isset($_GET['backup_action'])) { + $backup_id = $app->functions->intval($_GET['backup_id']); + + //* check if the user is owner of the parent domain + $domain_backup = $app->db->queryOneRecord("SELECT parent_domain_id FROM web_backup WHERE backup_id = ".$backup_id); + + $check_perm = 'u'; + if($_GET['backup_action'] == 'download') $check_perm = 'r'; // only check read permissions on download, not update permissions + + $get_domain = $app->db->queryOneRecord("SELECT domain_id FROM web_domain WHERE domain_id = ".$app->functions->intval($domain_backup["parent_domain_id"])." AND ".$app->tform->getAuthSQL($check_perm)); + if(empty($get_domain) || !$get_domain) { + $app->error($app->tform->lng('no_domain_perm')); + } + + if($_GET['backup_action'] == 'download' && $backup_id > 0) { + $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'"; + $tmp = $app->db->queryOneRecord($sql); + if($tmp['number'] == 0) { + $message .= $wb['download_info_txt']; + $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . + "VALUES (". + (int)$this->form->dataRecord['server_id'] . ", " . + time() . ", " . + "'backup_download', " . + "'".$backup_id."', " . + "'pending', " . + "''" . + ")"; + $app->db->query($sql); + } else { + $error .= $wb['download_pending_txt']; + } + } + if($_GET['backup_action'] == 'restore' && $backup_id > 0) { + $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore' AND action_param = '$backup_id'"; + $tmp = $app->db->queryOneRecord($sql); + if($tmp['number'] == 0) { + $message .= $wb['restore_info_txt']; + $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . + "VALUES (". + (int)$this->form->dataRecord['server_id'] . ", " . + time() . ", " . + "'backup_restore', " . + "'".$backup_id."', " . + "'pending', " . + "''" . + ")"; + $app->db->query($sql); + } else { + $error .= $wb['restore_pending_txt']; } - - //* Get the data - $web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".$this->form->id); - $sql = "SELECT * FROM web_backup WHERE parent_domain_id = ".$this->form->id." AND server_id = ".$web['server_id']." ORDER BY tstamp DESC, backup_type ASC"; - $records = $app->db->queryAllRecords($sql); - - $bgcolor = "#FFFFFF"; - if(is_array($records)) { - foreach($records as $rec) { - - // Change of color - $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF"; - $rec["bgcolor"] = $bgcolor; - - $rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']); - $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])]; - - $records_new[] = $rec; - } - } - - $listTpl->setLoop('records',@$records_new); - - $listTpl->setVar('parent_id',$this->form->id); - $listTpl->setVar('msg',$message); - $listTpl->setVar('error',$error); - - // Setting Returnto information in the session - $list_name = 'backup_list'; - // $_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id; - $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id; - $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"]; - $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"]; - $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"]; - $_SESSION["s"]["form"]["return_to"] = $list_name; - - return $listTpl->grab(); - } - + } + + } + + //* Get the data + $web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".$this->form->id); + $sql = "SELECT * FROM web_backup WHERE parent_domain_id = ".$this->form->id." AND server_id = ".$web['server_id']." ORDER BY tstamp DESC, backup_type ASC"; + $records = $app->db->queryAllRecords($sql); + + $bgcolor = "#FFFFFF"; + if(is_array($records)) { + foreach($records as $rec) { + + // Change of color + $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF"; + $rec["bgcolor"] = $bgcolor; + + $rec['date'] = date($app->lng('conf_format_datetime'), $rec['tstamp']); + $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])]; + + $records_new[] = $rec; + } + } + + $listTpl->setLoop('records', @$records_new); + + $listTpl->setVar('parent_id', $this->form->id); + $listTpl->setVar('msg', $message); + $listTpl->setVar('error', $error); + + // Setting Returnto information in the session + $list_name = 'backup_list'; + // $_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id; + $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id; + $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"]; + $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"]; + $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"]; + $_SESSION["s"]["form"]["return_to"] = $list_name; + + return $listTpl->grab(); + } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/plugin_base.inc.php b/interface/lib/classes/plugin_base.inc.php index 5b69e03c4..92b874437 100644 --- a/interface/lib/classes/plugin_base.inc.php +++ b/interface/lib/classes/plugin_base.inc.php @@ -29,31 +29,31 @@ 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; @@ -61,4 +61,4 @@ class plugin_base { } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/plugin_dbhistory.inc.php b/interface/lib/classes/plugin_dbhistory.inc.php index ebd9e745e..c65473111 100644 --- a/interface/lib/classes/plugin_dbhistory.inc.php +++ b/interface/lib/classes/plugin_dbhistory.inc.php @@ -30,40 +30,41 @@ 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; + 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 .= ''; - foreach($records as $rec) { - $content .= ""; - } - $content .= '
".date("d.m.Y",$rec["tstamp"])."".$rec["user"]."
'; + 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 .= ''; + foreach($records as $rec) { + $content .= ""; } - - return $content; + $content .= '
".date("d.m.Y", $rec["tstamp"])."".$rec["user"]."
'; + } + + return $content; + + } - } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/plugin_listview.inc.php b/interface/lib/classes/plugin_listview.inc.php index 30932b90f..e7d576cd1 100644 --- a/interface/lib/classes/plugin_listview.inc.php +++ b/interface/lib/classes/plugin_listview.inc.php @@ -30,153 +30,154 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class plugin_listview extends plugin_base { - var $module; - var $form; - var $tab; - var $record_id; - var $formdef; - var $options; - - function onShow() { - - global $app; - - $app->uses('listform'); - $app->listform->loadListDef($this->options["listdef"]); - - //$app->listform->SQLExtWhere = "type = 'alias'"; - - $listTpl = new tpl; - $listTpl->newTemplate('templates/'.$app->listform->listDef["name"].'_list.htm'); - - //die(print_r($app->tform_actions)); - - // Changing some of the list values to reflect that the list is called within a tform page - $app->listform->listDef["file"] = $app->tform->formDef["action"]; - // $app->listform->listDef["page_params"] = "&id=".$app->tform_actions->id."&next_tab=".$_SESSION["s"]["form"]["tab"]; - $app->listform->listDef["page_params"] = "&id=".$this->form->id."&next_tab=".$_SESSION["s"]["form"]["tab"]; - $listTpl->setVar('parent_id',$this->form->id); - $listTpl->setVar('theme', $_SESSION['s']['theme']); - - // Generate the SQL for searching - $sql_where = ""; - if($app->listform->listDef["auth"] != 'no') { - if($_SESSION["s"]["user"]["typ"] != "admin") { + var $module; + var $form; + var $tab; + var $record_id; + var $formdef; + var $options; + + function onShow() { + + global $app; + + $app->uses('listform'); + $app->listform->loadListDef($this->options["listdef"]); + + //$app->listform->SQLExtWhere = "type = 'alias'"; + + $listTpl = new tpl; + $listTpl->newTemplate('templates/'.$app->listform->listDef["name"].'_list.htm'); + + //die(print_r($app->tform_actions)); + + // Changing some of the list values to reflect that the list is called within a tform page + $app->listform->listDef["file"] = $app->tform->formDef["action"]; + // $app->listform->listDef["page_params"] = "&id=".$app->tform_actions->id."&next_tab=".$_SESSION["s"]["form"]["tab"]; + $app->listform->listDef["page_params"] = "&id=".$this->form->id."&next_tab=".$_SESSION["s"]["form"]["tab"]; + $listTpl->setVar('parent_id', $this->form->id); + $listTpl->setVar('theme', $_SESSION['s']['theme']); + + // Generate the SQL for searching + $sql_where = ""; + if($app->listform->listDef["auth"] != 'no') { + if($_SESSION["s"]["user"]["typ"] != "admin") { $sql_where = $app->tform->getAuthSQL('r')." and"; - } - } - - if($this->options["sqlextwhere"] != '') { - $sql_where .= " ".$this->options["sqlextwhere"]." and"; - } - - $sql_where = $app->listform->getSearchSQL($sql_where); - $listTpl->setVar($app->listform->searchValues); - - // Generate SQL for paging - $limit_sql = $app->listform->getPagingSQL($sql_where); - $listTpl->setVar("paging",$app->listform->pagingHTML); - - $sql_order_by = ''; - if(isset($this->options["sql_order_by"])) { - $sql_order_by = $this->options["sql_order_by"]; - } + } + } + + if($this->options["sqlextwhere"] != '') { + $sql_where .= " ".$this->options["sqlextwhere"]." and"; + } + + $sql_where = $app->listform->getSearchSQL($sql_where); + $listTpl->setVar($app->listform->searchValues); + + // Generate SQL for paging + $limit_sql = $app->listform->getPagingSQL($sql_where); + $listTpl->setVar("paging", $app->listform->pagingHTML); + + $sql_order_by = ''; + if(isset($this->options["sql_order_by"])) { + $sql_order_by = $this->options["sql_order_by"]; + } //* Limit each page - $limits = array('5'=>'5','15'=>'15','25'=>'25','50'=>'50','100'=>'100','999999999' => 'all'); + $limits = array('5'=>'5', '15'=>'15', '25'=>'25', '50'=>'50', '100'=>'100', '999999999' => 'all'); //* create options and set selected, if default -> 15 is selected $options=''; foreach($limits as $key => $val){ - $options .= ''; + $options .= ''; } - $listTpl->setVar('search_limit',''); + $listTpl->setVar('search_limit', ''); //Sorting if(!isset($_SESSION['search'][$app->listform->listDef["name"]]['order'])){ - $_SESSION['search'][$app->listform->listDef["name"]]['order'] = ''; + $_SESSION['search'][$app->listform->listDef["name"]]['order'] = ''; } if(!empty($_GET['orderby'])){ - $order = str_replace('tbl_col_','',$_GET['orderby']); - //* Check the css class submited value - if (preg_match("/^[a-z\_]{1,}$/",$order)) { - if($_SESSION['search'][$app->listform->listDef["name"]]['order'] == $order){ - $_SESSION['search'][$app->listform->listDef["name"]]['order'] = $order.' DESC'; - } else { - $_SESSION['search'][$app->listform->listDef["name"]]['order'] = $order; - } - } + $order = str_replace('tbl_col_', '', $_GET['orderby']); + //* Check the css class submited value + if (preg_match("/^[a-z\_]{1,}$/", $order)) { + if($_SESSION['search'][$app->listform->listDef["name"]]['order'] == $order){ + $_SESSION['search'][$app->listform->listDef["name"]]['order'] = $order.' DESC'; + } else { + $_SESSION['search'][$app->listform->listDef["name"]]['order'] = $order; + } + } } // If a manuel oder by like customers isset the sorting will be infront if(!empty($_SESSION['search'][$app->listform->listDef["name"]]['order'])){ - if(empty($sql_order_by)){ - $sql_order_by = "ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"]]['order']; - } else { - $sql_order_by = str_replace("ORDER BY ","ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"]]['order'].', ',$sql_order_by); - } + if(empty($sql_order_by)){ + $sql_order_by = "ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"]]['order']; + } else { + $sql_order_by = str_replace("ORDER BY ", "ORDER BY ".$_SESSION['search'][$app->listform->listDef["name"]]['order'].', ', $sql_order_by); + } } - - // Loading language field - $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng"; - include($lng_file); - $listTpl->setVar($wb); - - - // Get the data - $records = $app->db->queryAllRecords("SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $sql_order_by $limit_sql"); - - $bgcolor = "#FFFFFF"; - if(is_array($records)) { - $idx_key = $app->listform->listDef["table_idx"]; - foreach($records as $rec) { - - $rec = $app->listform->decode($rec); - - // Change of color - $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF"; - $rec["bgcolor"] = $bgcolor; - - // substitute value for select fields - foreach($app->listform->listDef["item"] as $field) { - $key = $field["field"]; - if($field['formtype'] == "SELECT") { - if(strtolower($rec[$key]) == 'y' or strtolower($rec[$key]) == 'n') { - // Set a additional image variable for bolean fields - $rec['_'.$key.'_'] = (strtolower($rec[$key]) == 'y')?'x16/tick_circle.png':'x16/cross_circle.png'; - } - //* substitute value for select field - @$rec[$key] = $field['value'][$rec[$key]]; - } - // Create a lowercase version of every item - $rec[$key.'_lowercase'] = strtolower($rec[$key]); - } - - // The variable "id" contains always the index field - $rec["id"] = $rec[$idx_key]; - $rec["delete_confirmation"] = $wb['delete_confirmation']; - - $records_new[] = $rec; - } - } - - $listTpl->setLoop('records',@$records_new); - - // Setting Returnto information in the session - $list_name = $app->listform->listDef["name"]; - // $_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id; - $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id; - $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"]; - $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"]; - $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"]; - $_SESSION["s"]["form"]["return_to"] = $list_name; - //die(print_r($_SESSION["s"]["list"][$list_name])); - - return $listTpl->grab(); - - } + + // Loading language field + $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->listform->listDef['name']."_list.lng"; + include $lng_file; + $listTpl->setVar($wb); + + + // Get the data + $records = $app->db->queryAllRecords("SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $sql_order_by $limit_sql"); + + $bgcolor = "#FFFFFF"; + if(is_array($records)) { + $idx_key = $app->listform->listDef["table_idx"]; + foreach($records as $rec) { + + $rec = $app->listform->decode($rec); + + // Change of color + $bgcolor = ($bgcolor == "#FFFFFF")?"#EEEEEE":"#FFFFFF"; + $rec["bgcolor"] = $bgcolor; + + // substitute value for select fields + foreach($app->listform->listDef["item"] as $field) { + $key = $field["field"]; + if($field['formtype'] == "SELECT") { + if(strtolower($rec[$key]) == 'y' or strtolower($rec[$key]) == 'n') { + // Set a additional image variable for bolean fields + $rec['_'.$key.'_'] = (strtolower($rec[$key]) == 'y')?'x16/tick_circle.png':'x16/cross_circle.png'; + } + //* substitute value for select field + @$rec[$key] = $field['value'][$rec[$key]]; + } + // Create a lowercase version of every item + $rec[$key.'_lowercase'] = strtolower($rec[$key]); + } + + // The variable "id" contains always the index field + $rec["id"] = $rec[$idx_key]; + $rec["delete_confirmation"] = $wb['delete_confirmation']; + + $records_new[] = $rec; + } + } + + $listTpl->setLoop('records', @$records_new); + + // Setting Returnto information in the session + $list_name = $app->listform->listDef["name"]; + // $_SESSION["s"]["list"][$list_name]["parent_id"] = $app->tform_actions->id; + $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id; + $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"]; + $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"]; + $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"]; + $_SESSION["s"]["form"]["return_to"] = $list_name; + //die(print_r($_SESSION["s"]["list"][$list_name])); + + return $listTpl->grab(); + + } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remote.d/client.inc.php b/interface/lib/classes/remote.d/client.inc.php index ae5086b0f..e0dcad83f 100644 --- a/interface/lib/classes/remote.d/client.inc.php +++ b/interface/lib/classes/remote.d/client.inc.php @@ -39,19 +39,19 @@ by Marius Cramer */ class remoting_client extends remoting { -/* - * - * - * + /* + * + * + * * * Client functions - * - * + * + * */ //* Get client details public function client_get($session_id, $client_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'client_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -59,51 +59,51 @@ class remoting_client extends remoting { $app->uses('remoting_lib'); $app->remoting_lib->loadFormDef('../client/form/client.tform.php'); $data = $app->remoting_lib->getDataRecord($client_id); - - // we need to get the new-style templates for backwards-compatibility - maybe we remove this in a later version - if(is_array($data) && count($data) > 0) { - if(isset($data['client_id'])) { - // this is a single record - if($data['template_additional'] == '') { - $tpls = $app->db->queryAllRecords('SELECT CONCAT(`assigned_template_id`, \':\', `client_template_id`) as `item` FROM `client_template_assigned` WHERE `client_id` = ' . $data['client_id']); - $tpl_arr = array(); - if($tpls) { - foreach($tpls as $tpl) $tpl_arr[] = $tpl['item']; - } - $data['template_additional'] = implode('/', $tpl_arr); - unset($tpl_arr); - unset($tpls); - } - } elseif(isset($data[0]['client_id'])) { - // multiple client records - foreach($data as $index => $client) { - if($client['template_additional'] == '') { - $tpls = $app->db->queryAllRecords('SELECT CONCAT(`assigned_template_id`, \':\', `client_template_id`) as `item` FROM `client_template_assigned` WHERE `client_id` = ' . $client['client_id']); - $tpl_arr = array(); - if($tpls) { - foreach($tpls as $tpl) $tpl_arr[] = $tpl['item']; - } - $data[$index]['template_additional'] = implode('/', $tpl_arr); // dont use the $client array here - changes would not be returned to soap - } - unset($tpl_arr); - unset($tpls); - } - } - } - - return $data; + + // we need to get the new-style templates for backwards-compatibility - maybe we remove this in a later version + if(is_array($data) && count($data) > 0) { + if(isset($data['client_id'])) { + // this is a single record + if($data['template_additional'] == '') { + $tpls = $app->db->queryAllRecords('SELECT CONCAT(`assigned_template_id`, \':\', `client_template_id`) as `item` FROM `client_template_assigned` WHERE `client_id` = ' . $data['client_id']); + $tpl_arr = array(); + if($tpls) { + foreach($tpls as $tpl) $tpl_arr[] = $tpl['item']; + } + $data['template_additional'] = implode('/', $tpl_arr); + unset($tpl_arr); + unset($tpls); + } + } elseif(isset($data[0]['client_id'])) { + // multiple client records + foreach($data as $index => $client) { + if($client['template_additional'] == '') { + $tpls = $app->db->queryAllRecords('SELECT CONCAT(`assigned_template_id`, \':\', `client_template_id`) as `item` FROM `client_template_assigned` WHERE `client_id` = ' . $client['client_id']); + $tpl_arr = array(); + if($tpls) { + foreach($tpls as $tpl) $tpl_arr[] = $tpl['item']; + } + $data[$index]['template_additional'] = implode('/', $tpl_arr); // dont use the $client array here - changes would not be returned to soap + } + unset($tpl_arr); + unset($tpls); + } + } + } + + return $data; } - + public function client_get_id($session_id, $sys_userid) - { + { global $app; if(!$this->checkPerm($session_id, 'client_get_id')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + $sys_userid = $app->functions->intval($sys_userid); - + $rec = $app->db->queryOneRecord("SELECT client_id FROM sys_user WHERE userid = ".$sys_userid); if(isset($rec['client_id'])) { return $app->functions->intval($rec['client_id']); @@ -111,19 +111,19 @@ class remoting_client extends remoting { throw new SoapFault('no_client_found', 'There is no sysuser account for this client ID.'); return false; } - + } - + public function client_get_groupid($session_id, $client_id) - { + { global $app; if(!$this->checkPerm($session_id, 'client_get_id')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + $client_id = $app->functions->intval($client_id); - + $rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client_id); if(isset($rec['groupid'])) { return $app->functions->intval($rec['groupid']); @@ -131,228 +131,228 @@ class remoting_client extends remoting { throw new SoapFault('no_group_found', 'There is no group for this client ID.'); return false; } - + } - - + + public function client_add($session_id, $reseller_id, $params) { if (!$this->checkPerm($session_id, 'client_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - if(!isset($params['parent_client_id']) || $params['parent_client_id'] == 0) $params['parent_client_id'] = $reseller_id; - $affected_rows = $this->klientadd('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php',$reseller_id, $params); - return $affected_rows; - + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if(!isset($params['parent_client_id']) || $params['parent_client_id'] == 0) $params['parent_client_id'] = $reseller_id; + $affected_rows = $this->klientadd('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php', $reseller_id, $params); + return $affected_rows; + } - + public function client_update($session_id, $client_id, $reseller_id, $params) { - global $app; - - if (!$this->checkPerm($session_id, 'client_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; + global $app; + + if (!$this->checkPerm($session_id, 'client_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->uses('remoting_lib'); + $app->remoting_lib->loadFormDef('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php'); + $old_rec = $app->remoting_lib->getDataRecord($client_id); + + // we need the previuos templates assigned here + $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $client_id); + if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) { + // check previous type of storing templates + $tpls = explode('/', $old_rec['template_additional']); + $this->oldTemplatesAssigned = array(); + foreach($tpls as $item) { + $item = trim($item); + if(!$item) continue; + $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $client_id); } - - $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php'); - $old_rec = $app->remoting_lib->getDataRecord($client_id); - - // we need the previuos templates assigned here - $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $client_id); - if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) { - // check previous type of storing templates - $tpls = explode('/', $old_rec['template_additional']); - $this->oldTemplatesAssigned = array(); - foreach($tpls as $item) { - $item = trim($item); - if(!$item) continue; - $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $client_id); - } - unset($tpls); - } - if(isset($params['template_additional'])) { - $app->uses('client_templates'); - $templates = explode('/', $params['template_additional']); - $params['template_additional'] = ''; - $app->client_templates->update_client_templates($client_id, $templates); - unset($templates); - } - - - if(!isset($params['parent_client_id']) || $params['parent_client_id'] == 0) $params['parent_client_id'] = $reseller_id; - $affected_rows = $this->updateQuery('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php', $reseller_id, $client_id, $params, 'client:' . ($reseller_id ? 'reseller' : 'client') . ':on_after_update'); - - $app->remoting_lib->ispconfig_sysuser_update($params,$client_id); - - return $affected_rows; + unset($tpls); + } + if(isset($params['template_additional'])) { + $app->uses('client_templates'); + $templates = explode('/', $params['template_additional']); + $params['template_additional'] = ''; + $app->client_templates->update_client_templates($client_id, $templates); + unset($templates); + } + + + if(!isset($params['parent_client_id']) || $params['parent_client_id'] == 0) $params['parent_client_id'] = $reseller_id; + $affected_rows = $this->updateQuery('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php', $reseller_id, $client_id, $params, 'client:' . ($reseller_id ? 'reseller' : 'client') . ':on_after_update'); + + $app->remoting_lib->ispconfig_sysuser_update($params, $client_id); + + return $affected_rows; } - - public function client_template_additional_get($session_id, $client_id) { - global $app; + + public function client_template_additional_get($session_id, $client_id) { + global $app; if(!$this->checkPerm($session_id, 'client_get')) { $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - if(@is_numeric($client_id)) { - $sql = "SELECT * FROM `client_template_assigned` WHERE `client_id` = ".$client_id; - return $app->db->queryOneRecord($sql); - } else { - $this->server->fault('The ID must be an integer.'); - return array(); - } - } - - private function _set_client_formdata($client_id) { - global $app; - - $this->id = $client_id; - $this->dataRecord = $app->db->queryOneRecord('SELECT * FROM `client` WHERE `client_id` = ' . $client_id); - $this->oldDataRecord = $this->dataRecord; - - $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $client_id); - if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) { - // check previous type of storing templates - $tpls = explode('/', $this->oldDataRecord['template_additional']); - $this->oldTemplatesAssigned = array(); - foreach($tpls as $item) { - $item = trim($item); - if(!$item) continue; - $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $client_id); - } - unset($tpls); - } - } - - public function client_template_additional_add($session_id, $client_id, $template_id) { - global $app; - + + if(@is_numeric($client_id)) { + $sql = "SELECT * FROM `client_template_assigned` WHERE `client_id` = ".$client_id; + return $app->db->queryOneRecord($sql); + } else { + $this->server->fault('The ID must be an integer.'); + return array(); + } + } + + private function _set_client_formdata($client_id) { + global $app; + + $this->id = $client_id; + $this->dataRecord = $app->db->queryOneRecord('SELECT * FROM `client` WHERE `client_id` = ' . $client_id); + $this->oldDataRecord = $this->dataRecord; + + $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $client_id); + if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) { + // check previous type of storing templates + $tpls = explode('/', $this->oldDataRecord['template_additional']); + $this->oldTemplatesAssigned = array(); + foreach($tpls as $item) { + $item = trim($item); + if(!$item) continue; + $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $client_id); + } + unset($tpls); + } + } + + public function client_template_additional_add($session_id, $client_id, $template_id) { + global $app; + if(!$this->checkPerm($session_id, 'client_update')) { $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - if(@is_numeric($client_id) && @is_numeric($template_id)) { - // check if client exists - $check = $app->db->queryOneRecord('SELECT `client_id` FROM `client` WHERE `client_id` = ' . $client_id); - if(!$check) { - $this->server->fault('Invalid client'); - return false; - } - // check if template exists - $check = $app->db->queryOneRecord('SELECT `template_id` FROM `client_template` WHERE `template_id` = ' . $template_id); - if(!$check) { - $this->server->fault('Invalid template'); - return false; - } - - // for the update event we have to cheat a bit - $this->_set_client_formdata($client_id); - - $sql = "INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (" . $client_id . ", " . $template_id . ")"; - $app->db->query($sql); - $insert_id = $app->db->insertID(); - - $app->plugin->raiseEvent('client:client:on_after_update',$this); - - return $insert_id; - } else { - $this->server->fault('The IDs must be of type integer.'); - return false; - } - } - - public function client_template_additional_delete($session_id, $client_id, $assigned_template_id) { - global $app; - + + if(@is_numeric($client_id) && @is_numeric($template_id)) { + // check if client exists + $check = $app->db->queryOneRecord('SELECT `client_id` FROM `client` WHERE `client_id` = ' . $client_id); + if(!$check) { + $this->server->fault('Invalid client'); + return false; + } + // check if template exists + $check = $app->db->queryOneRecord('SELECT `template_id` FROM `client_template` WHERE `template_id` = ' . $template_id); + if(!$check) { + $this->server->fault('Invalid template'); + return false; + } + + // for the update event we have to cheat a bit + $this->_set_client_formdata($client_id); + + $sql = "INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (" . $client_id . ", " . $template_id . ")"; + $app->db->query($sql); + $insert_id = $app->db->insertID(); + + $app->plugin->raiseEvent('client:client:on_after_update', $this); + + return $insert_id; + } else { + $this->server->fault('The IDs must be of type integer.'); + return false; + } + } + + public function client_template_additional_delete($session_id, $client_id, $assigned_template_id) { + global $app; + if(!$this->checkPerm($session_id, 'client_update')) { $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - if(@is_numeric($client_id) && @is_numeric($template_id)) { - // check if client exists - $check = $app->db->queryOneRecord('SELECT `client_id` FROM `client` WHERE `client_id` = ' . $client_id); - if(!$check) { - $this->server->fault('Invalid client'); - return false; - } - // check if template exists - $check = $app->db->queryOneRecord('SELECT `assigned_template_id` FROM `client_template_assigned` WHERE `assigned_template_id` = ' . $assigned_template_id); - if(!$check) { - $this->server->fault('Invalid template'); - return false; - } - - // for the update event we have to cheat a bit - $this->_set_client_formdata($client_id); - - $sql = "DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = " . $template_id . " AND `client_id` = " . $client_id; - $app->db->query($sql); - $affected_rows = $app->db->affectedRows(); - - $app->plugin->raiseEvent('client:client:on_after_update',$this); - - return $affected_rows; - } else { - $this->server->fault('The IDs must be of type integer.'); - return false; - } - } - - public function client_delete($session_id,$client_id) - { - global $app; - - if (!$this->checkPerm($session_id, 'client_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; + + if(@is_numeric($client_id) && @is_numeric($template_id)) { + // check if client exists + $check = $app->db->queryOneRecord('SELECT `client_id` FROM `client` WHERE `client_id` = ' . $client_id); + if(!$check) { + $this->server->fault('Invalid client'); + return false; + } + // check if template exists + $check = $app->db->queryOneRecord('SELECT `assigned_template_id` FROM `client_template_assigned` WHERE `assigned_template_id` = ' . $assigned_template_id); + if(!$check) { + $this->server->fault('Invalid template'); + return false; } - $affected_rows = $this->deleteQuery('../client/form/client.tform.php',$client_id); - - $app->remoting_lib->ispconfig_sysuser_delete($client_id); - + + // for the update event we have to cheat a bit + $this->_set_client_formdata($client_id); + + $sql = "DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = " . $template_id . " AND `client_id` = " . $client_id; + $app->db->query($sql); + $affected_rows = $app->db->affectedRows(); + + $app->plugin->raiseEvent('client:client:on_after_update', $this); + return $affected_rows; + } else { + $this->server->fault('The IDs must be of type integer.'); + return false; + } } - + + public function client_delete($session_id, $client_id) + { + global $app; + + if (!$this->checkPerm($session_id, 'client_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../client/form/client.tform.php', $client_id); + + $app->remoting_lib->ispconfig_sysuser_delete($client_id); + + return $affected_rows; + } + // ----------------------------------------------------------------------------------------------- - + public function client_delete_everything($session_id, $client_id) - { - global $app, $conf; - + { + global $app, $conf; + if(!$this->checkPerm($session_id, 'client_delete_everything')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; } - + $client_id = $app->functions->intval($client_id); - if($client_id > 0) { + if($client_id > 0) { //* remove the group of the client from the resellers group $parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']); $parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id"); $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id"); - $app->auth->remove_group_from_user($parent_user['userid'],$client_group['groupid']); - + $app->auth->remove_group_from_user($parent_user['userid'], $client_group['groupid']); + //* delete the group of the client $app->db->query("DELETE FROM sys_group WHERE client_id = $client_id"); - + //* delete the sys user(s) of the client $app->db->query("DELETE FROM sys_user WHERE client_id = $client_id"); - + //* Delete all records (sub-clients, mail, web, etc....) of this client. $tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain,web_traffic'; - $tables_array = explode(',',$tables); + $tables_array = explode(',', $tables); $client_group_id = $app->functions->intval($client_group['groupid']); - + if($client_group_id > 1) { foreach($tables_array as $table) { if($table != '') { @@ -380,112 +380,116 @@ class remoting_client extends remoting { } } } - + } } } - + } - + if (!$this->checkPerm($session_id, 'client_delete')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../client/form/client.tform.php',$client_id); + $affected_rows = $this->deleteQuery('../client/form/client.tform.php', $client_id); - return $affected_rows; + return $affected_rows; } + /** * Get sys_user information by username - * @param int session id - * @param string user's name - * @return mixed false if error - * @author Julio Montoya BeezNest 2010 + * @param int session id + * @param string user's name + * @return mixed false if error + * @author Julio Montoya BeezNest 2010 */ + + public function client_get_by_username($session_id, $username) { - global $app; - if(!$this->checkPerm($session_id, 'client_get_by_username')) { + global $app; + if(!$this->checkPerm($session_id, 'client_get_by_username')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; - } - $username = $app->db->quote($username); - $rec = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE username = '".$username."'"); - if (isset($rec)) { + } + $username = $app->db->quote($username); + $rec = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE username = '".$username."'"); + if (isset($rec)) { return $rec; - } else { + } else { throw new SoapFault('no_client_found', 'There is no user account for this user name.'); return false; - } - } - /** - * Get All client_id's from database - * @param int session_id - * @return Array of all client_id's - */ + } + } + + /** + * Get All client_id's from database + * @param int session_id + * @return Array of all client_id's + */ public function client_get_all($session_id) { - global $app; - if(!$this->checkPerm($session_id, 'client_get_all')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $result = $app->db->queryAllRecords("SELECT client_id FROM client WHERE 1"); - if(!$result) { - return false; - } - foreach( $result as $record) { - $rarrary[] = $record['client_id']; - } - return $rarrary; + global $app; + if(!$this->checkPerm($session_id, 'client_get_all')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $result = $app->db->queryAllRecords("SELECT client_id FROM client WHERE 1"); + if(!$result) { + return false; + } + foreach( $result as $record) { + $rarrary[] = $record['client_id']; + } + return $rarrary; } - /** - * Changes client password - * - * @param int session id - * @param int client id - * @param string new password - * @return bool true if success - * @author Julio Montoya BeezNest 2010 - * - */ - public function client_change_password($session_id, $client_id, $new_password) { - global $app; - - if(!$this->checkPerm($session_id, 'client_change_password')) { + /** + * Changes client password + * + * @param int session id + * @param int client id + * @param string new password + * @return bool true if success + * @author Julio Montoya BeezNest 2010 + * + */ + public function client_change_password($session_id, $client_id, $new_password) { + global $app; + + if(!$this->checkPerm($session_id, 'client_change_password')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $client_id = $app->functions->intval($client_id); - $client = $app->db->queryOneRecord("SELECT client_id FROM client WHERE client_id = ".$client_id); - if($client['client_id'] > 0) { - $new_password = $app->db->quote($new_password); - $sql = "UPDATE client SET password = md5('".($new_password)."') WHERE client_id = ".$client_id; - $app->db->query($sql); - $sql = "UPDATE sys_user SET passwort = md5('".($new_password)."') WHERE client_id = ".$client_id; - $app->db->query($sql); - return true; - } else { + return false; + } + $client_id = $app->functions->intval($client_id); + $client = $app->db->queryOneRecord("SELECT client_id FROM client WHERE client_id = ".$client_id); + if($client['client_id'] > 0) { + $new_password = $app->db->quote($new_password); + $sql = "UPDATE client SET password = md5('".($new_password)."') WHERE client_id = ".$client_id; + $app->db->query($sql); + $sql = "UPDATE sys_user SET passwort = md5('".($new_password)."') WHERE client_id = ".$client_id; + $app->db->query($sql); + return true; + } else { throw new SoapFault('no_client_found', 'There is no user account for this client_id'); return false; - } - } + } + } /** - * Get all client templates - * @param int session id - * @author Julio Montoya BeezNest 2010 + * Get all client templates + * @param int session id + * @author Julio Montoya BeezNest 2010 */ public function client_templates_get_all($session_id) { global $app; if(!$this->checkPerm($session_id, 'client_templates_get_all')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; } - $sql = "SELECT * FROM client_template"; + $sql = "SELECT * FROM client_template"; $result = $app->db->queryAllRecords($sql); - return $result; - } + return $result; + } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remote.d/dns.inc.php b/interface/lib/classes/remote.d/dns.inc.php index 9e64ab8cb..1e9526a12 100644 --- a/interface/lib/classes/remote.d/dns.inc.php +++ b/interface/lib/classes/remote.d/dns.inc.php @@ -40,41 +40,41 @@ by Marius Cramer class remoting_dns extends remoting { // DNS Function -------------------------------------------------------------------------------------------------- - + //* Create Zone with Template public function dns_templatezone_add($session_id, $client_id, $template_id, $domain, $ip, $ns1, $ns2, $email) - { - global $app, $conf; + { + global $app, $conf; if(!$this->checkPerm($session_id, 'dns_templatezone_add')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; } $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM client WHERE client_id = ".$app->functions->intval($client_id)); $server_id = $client["default_dnsserver"]; $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = '$template_id'"); - $fields = explode(',',$template_record['fields']); + $fields = explode(',', $template_record['fields']); $tform_def_file = "../../web/dns/form/dns_soa.tform.php"; $app->uses('tform'); $app->tform->loadFormDef($tform_def_file); $app->uses('tpl,validate_dns'); - + //* replace template placeholders $tpl_content = $template_record['template']; - if($domain != '') $tpl_content = str_replace('{DOMAIN}',$domain,$tpl_content); - if($ip != '') $tpl_content = str_replace('{IP}',$ip,$tpl_content); - if($ns1 != '') $tpl_content = str_replace('{NS1}',$ns1,$tpl_content); - if($ns2 != '') $tpl_content = str_replace('{NS2}',$ns2,$tpl_content); - if($email != '') $tpl_content = str_replace('{EMAIL}',$email,$tpl_content); - + if($domain != '') $tpl_content = str_replace('{DOMAIN}', $domain, $tpl_content); + if($ip != '') $tpl_content = str_replace('{IP}', $ip, $tpl_content); + if($ns1 != '') $tpl_content = str_replace('{NS1}', $ns1, $tpl_content); + if($ns2 != '') $tpl_content = str_replace('{NS2}', $ns2, $tpl_content); + if($email != '') $tpl_content = str_replace('{EMAIL}', $email, $tpl_content); + //* Parse the template - $tpl_rows = explode("\n",$tpl_content); + $tpl_rows = explode("\n", $tpl_content); $section = ''; $vars = array(); $dns_rr = array(); foreach($tpl_rows as $row) { $row = trim($row); - if(substr($row,0,1) == '[') { + if(substr($row, 0, 1) == '[') { if($row == '[ZONE]') { $section = 'zone'; } elseif($row == '[DNS_RECORDS]') { @@ -86,14 +86,14 @@ class remoting_dns extends remoting { if($row != '') { //* Handle zone section if($section == 'zone') { - $parts = explode('=',$row); + $parts = explode('=', $row); $key = trim($parts[0]); $val = trim($parts[1]); if($key != '') $vars[$key] = $val; } //* Handle DNS Record rows if($section == 'dns_records') { - $parts = explode('|',$row); + $parts = explode('|', $row); $dns_rr[] = array( 'name' => $app->db->quote($parts[1]), 'type' => $app->db->quote($parts[0]), @@ -103,9 +103,9 @@ class remoting_dns extends remoting { ); } } - } + } } // end foreach - + if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'
'; if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'
'; if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'
'; @@ -113,8 +113,8 @@ class remoting_dns extends remoting { if($vars['retry'] == '') $error .= $app->lng('error_retry_empty').'
'; if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'
'; if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'
'; - if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'
'; - + if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'
'; + if($error == '') { // Insert the soa record $tmp = $app->db->queryOneRecord("SELECT userid,default_group FROM sys_user WHERE client_id = ".$app->functions->intval($client_id)); @@ -123,7 +123,7 @@ class remoting_dns extends remoting { unset($tmp); $origin = $app->db->quote($vars['origin']); $ns = $app->db->quote($vars['ns']); - $mbox = $app->db->quote(str_replace('@','.',$vars['mbox'])); + $mbox = $app->db->quote(str_replace('@', '.', $vars['mbox'])); $refresh = $app->db->quote($vars['refresh']); $retry = $app->db->quote($vars['retry']); $expire = $app->db->quote($vars['expire']); @@ -132,14 +132,14 @@ class remoting_dns extends remoting { $xfer = $app->db->quote($vars['xfer']); $also_notify = $app->db->quote($vars['also_notify']); $update_acl = $app->db->quote($vars['update_acl']); - $serial = $app->validate_dns->increase_serial(0); - $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `origin`, `ns`, `mbox`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `ttl`, `active`, `xfer`, `also_notify`, `update_acl`) VALUES + $serial = $app->validate_dns->increase_serial(0); + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `origin`, `ns`, `mbox`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `ttl`, `active`, `xfer`, `also_notify`, `update_acl`) VALUES ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$origin', '$ns', '$mbox', '$serial', '$refresh', '$retry', '$expire', '$minimum', '$ttl', 'Y', '$xfer', '$also_notify', '$update_acl')"; - $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); + $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); // Insert the dns_rr records if(is_array($dns_rr) && $dns_soa_id > 0) { foreach($dns_rr as $rr) { - $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$dns_soa_id', '$rr[name]', '$rr[type]', '$rr[data]', '$rr[aux]', '$rr[ttl]', 'Y')"; $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); } @@ -149,13 +149,13 @@ class remoting_dns extends remoting { throw new SoapFault('permission_denied', $error); } } - - + + //* Get record details public function dns_zone_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_zone_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -164,70 +164,70 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_soa.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - - //* Get record id by origin - public function dns_zone_get_id($session_id, $origin) - { - global $app; - - if(!$this->checkPerm($session_id, 'dns_zone_get_id')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - - if(!preg_match('/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i', $origin)){ - throw new SoapFault('no_domain_found', 'Invalid domain name.'); - return false; - } - - $rec = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin like '".$origin."%'"); - if(isset($rec['id'])) { - return $app->functions->intval($rec['id']); - } else { - throw new SoapFault('no_domain_found', 'There is no domain ID with informed domain name.'); - return false; - } - } - + + //* Get record id by origin + public function dns_zone_get_id($session_id, $origin) + { + global $app; + + if(!$this->checkPerm($session_id, 'dns_zone_get_id')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + if(!preg_match('/^[a-z0-9][a-z0-9\-]+[a-z0-9](\.[a-z]{2,4})+$/i', $origin)){ + throw new SoapFault('no_domain_found', 'Invalid domain name.'); + return false; + } + + $rec = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin like '".$origin."%'"); + if(isset($rec['id'])) { + return $app->functions->intval($rec['id']); + } else { + throw new SoapFault('no_domain_found', 'There is no domain ID with informed domain name.'); + return false; + } + } + //* Add a record public function dns_zone_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_zone_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_soa.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_soa.tform.php', $client_id, $params); } - + //* Update a record public function dns_zone_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_zone_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_soa.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_soa.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_zone_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_zone_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_soa.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_soa.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_aaaa_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_aaaa_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -236,46 +236,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_aaaa.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_aaaa_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_aaaa_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_aaaa.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_aaaa.tform.php', $client_id, $params); } - + //* Update a record public function dns_aaaa_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_aaaa_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_aaaa.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_aaaa.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_aaaa_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_aaaa_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_aaaa.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_aaaa.tform.php', $primary_id); return $affected_rows; } // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_a_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_a_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -284,46 +284,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_a.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_a_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_a_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_a.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_a.tform.php', $client_id, $params); } - + //* Update a record public function dns_a_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_a_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_a.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_a.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_a_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_a_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_a.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_a.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_alias_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_alias_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -332,46 +332,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_alias.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_alias_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_alias_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_alias.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_alias.tform.php', $client_id, $params); } - + //* Update a record public function dns_alias_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_alias_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_alias.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_alias.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_alias_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_alias_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_alias.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_alias.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_cname_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_cname_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -380,46 +380,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_cname.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_cname_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_cname_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_cname.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_cname.tform.php', $client_id, $params); } - + //* Update a record public function dns_cname_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_cname_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_cname.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_cname.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_cname_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_cname_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_cname.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_cname.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_hinfo_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_hinfo_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -428,46 +428,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_hinfo.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_hinfo_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_hinfo_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_hinfo.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_hinfo.tform.php', $client_id, $params); } - + //* Update a record public function dns_hinfo_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_hinfo_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_hinfo.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_hinfo.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_hinfo_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_hinfo_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_hinfo.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_hinfo.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_mx_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_mx_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -476,46 +476,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_mx.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_mx_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_mx_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_mx.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_mx.tform.php', $client_id, $params); } - + //* Update a record public function dns_mx_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_mx_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_mx.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_mx.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_mx_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_mx_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_mx.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_mx.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_ns_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_ns_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -524,46 +524,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_ns.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_ns_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_ns_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_ns.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_ns.tform.php', $client_id, $params); } - + //* Update a record public function dns_ns_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_ns_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_ns.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_ns.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_ns_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_ns_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_ns.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_ns.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_ptr_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_ptr_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -572,46 +572,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_ptr.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_ptr_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_ptr_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_ptr.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_ptr.tform.php', $client_id, $params); } - + //* Update a record public function dns_ptr_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_ptr_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_ptr.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_ptr.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_ptr_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_ptr_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_ptr.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_ptr.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_rp_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_rp_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -620,46 +620,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_rp.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_rp_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_rp_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_rp.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_rp.tform.php', $client_id, $params); } - + //* Update a record public function dns_rp_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_rp_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_rp.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_rp.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_rp_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_rp_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_rp.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_rp.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_srv_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_srv_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -668,46 +668,46 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_srv.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_srv_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_srv_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_srv.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_srv.tform.php', $client_id, $params); } - + //* Update a record public function dns_srv_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_srv_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_srv.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_srv.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_srv_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_srv_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_srv.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_srv.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------------- - + //* Get record details public function dns_txt_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'dns_txt_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -716,105 +716,109 @@ class remoting_dns extends remoting { $app->remoting_lib->loadFormDef('../dns/form/dns_txt.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function dns_txt_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_txt_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../dns/form/dns_txt.tform.php',$client_id,$params); + return $this->insertQuery('../dns/form/dns_txt.tform.php', $client_id, $params); } - + //* Update a record public function dns_txt_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'dns_txt_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../dns/form/dns_txt.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../dns/form/dns_txt.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function dns_txt_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'dns_txt_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../dns/form/dns_txt.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../dns/form/dns_txt.tform.php', $primary_id); return $affected_rows; } /** - * Get all DNS zone by user - *@author Julio Montoya BeezNest 2010 - */ - public function dns_zone_get_by_user($session_id, $client_id, $server_id) { - global $app; - if(!$this->checkPerm($session_id, 'dns_zone_get')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if (!empty($client_id) && !empty($server_id)) { - $server_id = $app->functions->intval($server_id); - $client_id = $app->functions->intval($client_id); - $sql = "SELECT id, origin FROM dns_soa d INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id AND server_id = $server_id"; - $result = $app->db->queryAllRecords($sql); - return $result; - } - return false; - } - + * Get all DNS zone by user + *@author Julio Montoya BeezNest 2010 + */ + + + public function dns_zone_get_by_user($session_id, $client_id, $server_id) { + global $app; + if(!$this->checkPerm($session_id, 'dns_zone_get')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if (!empty($client_id) && !empty($server_id)) { + $server_id = $app->functions->intval($server_id); + $client_id = $app->functions->intval($client_id); + $sql = "SELECT id, origin FROM dns_soa d INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id AND server_id = $server_id"; + $result = $app->db->queryAllRecords($sql); + return $result; + } + return false; + } + + + /** - * Get all dns records for a zone - * @param int session id - * @param int dns zone id - * @author Sebastian Mogilowski 2011 + * Get all dns records for a zone + * @param int session id + * @param int dns zone id + * @author Sebastian Mogilowski 2011 */ public function dns_rr_get_all_by_zone($session_id, $zone_id) { global $app; if(!$this->checkPerm($session_id, 'dns_zone_get')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; } - $sql = "SELECT * FROM dns_rr WHERE zone = ".$app->functions->intval($zone_id);; + $sql = "SELECT * FROM dns_rr WHERE zone = ".$app->functions->intval($zone_id);; $result = $app->db->queryAllRecords($sql); - return $result; - } + return $result; + } /** - * Changes DNS zone status - * @param int session id - * @param int dns soa id - * @param string status active or inactive string - * @author Julio Montoya BeezNest 2010 + * Changes DNS zone status + * @param int session id + * @param int dns soa id + * @param string status active or inactive string + * @author Julio Montoya BeezNest 2010 */ - - public function dns_zone_set_status($session_id, $primary_id, $status) { - global $app; - if(!$this->checkPerm($session_id, 'dns_zone_set_status')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if(in_array($status, array('active', 'inactive'))) { - if ($status == 'active') { - $status = 'Y'; - } else { - $status = 'N'; - } - $sql = "UPDATE dns_soa SET active = '$status' WHERE id = ".$app->functions->intval($primary_id); - $app->db->query($sql); - $result = $app->db->affectedRows(); - return $result; - } else { + public function dns_zone_set_status($session_id, $primary_id, $status) { + global $app; + if(!$this->checkPerm($session_id, 'dns_zone_set_status')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if(in_array($status, array('active', 'inactive'))) { + if ($status == 'active') { + $status = 'Y'; + } else { + $status = 'N'; + } + $sql = "UPDATE dns_soa SET active = '$status' WHERE id = ".$app->functions->intval($primary_id); + $app->db->query($sql); + $result = $app->db->affectedRows(); + return $result; + } else { throw new SoapFault('status_undefined', 'The status is not available'); return false; - } - } + } + } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remote.d/domains.inc.php b/interface/lib/classes/remote.d/domains.inc.php index 2afe8153d..9bba71002 100644 --- a/interface/lib/classes/remote.d/domains.inc.php +++ b/interface/lib/classes/remote.d/domains.inc.php @@ -40,12 +40,12 @@ by Marius Cramer class remoting_domains extends remoting { // ----------------------------------------------------------------------------------------------- - + //* Get record details public function domains_domain_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'domains_domain_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -57,40 +57,40 @@ class remoting_domains extends remoting { //* Add a record public function domains_domain_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'domains_domain_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../client/form/domain.tform.php',$client_id,$params); + return $this->insertQuery('../client/form/domain.tform.php', $client_id, $params); } //* Delete a record public function domains_domain_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'domains_domain_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../client/form/domain.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../client/form/domain.tform.php', $primary_id); return $affected_rows; } -// ----------------------------------------------------------------------------------------------- + // ----------------------------------------------------------------------------------------------- public function domains_get_all_by_user($session_id, $group_id) - { - global $app; + { + global $app; if(!$this->checkPerm($session_id, 'domains_get_all_by_user')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; } - $group_id = $app->functions->intval($group_id); - $sql = "SELECT domain_id, domain FROM domain WHERE sys_groupid = $group_id "; - $all = $app->db->queryAllRecords($sql); - return $all; + $group_id = $app->functions->intval($group_id); + $sql = "SELECT domain_id, domain FROM domain WHERE sys_groupid = $group_id "; + $all = $app->db->queryAllRecords($sql); + return $all; } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php index 5370c04a4..7adaf1fa7 100644 --- a/interface/lib/classes/remote.d/mail.inc.php +++ b/interface/lib/classes/remote.d/mail.inc.php @@ -41,9 +41,9 @@ by Marius Cramer class remoting_mail extends remoting { //* Get mail domain details public function mail_domain_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_domain_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -52,21 +52,21 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_domain.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a mail domain public function mail_domain_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'mail_domain_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $primary_id = $this->insertQuery('../mail/form/mail_domain.tform.php',$client_id,$params); + $primary_id = $this->insertQuery('../mail/form/mail_domain.tform.php', $client_id, $params); return $primary_id; } - + //* Update a mail domain public function mail_domain_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'mail_domain_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -74,10 +74,10 @@ class remoting_mail extends remoting { $affected_rows = $this->updateQuery('../mail/form/mail_domain.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a mail domain public function mail_domain_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'mail_domain_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -85,12 +85,12 @@ class remoting_mail extends remoting { $affected_rows = $this->deleteQuery('../mail/form/mail_domain.tform.php', $primary_id); return $affected_rows; } - + //* Get alias details public function mail_aliasdomain_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_aliasdomain_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -99,13 +99,13 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_aliasdomain.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* aliasy email public function mail_aliasdomain_add($session_id, $client_id, $params) { if (!$this->checkPerm($session_id, 'mail_aliasdomain_add')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } $affected_rows = $this->insertQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $params); @@ -115,31 +115,31 @@ class remoting_mail extends remoting { public function mail_aliasdomain_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_aliasdomain_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_aliasdomain_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_aliasdomain_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_aliasdomain_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_aliasdomain.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_aliasdomain_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_aliasdomain.tform.php', $primary_id); + return $affected_rows; } - + //* Get mail mailinglist details public function mail_mailinglist_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_mailinglist_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -148,21 +148,21 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_mailinglist.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a mail mailinglist public function mail_mailinglist_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'mail_mailinglist_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $primary_id = $this->insertQuery('../mail/form/mail_mailinglist.tform.php',$client_id,$params); + $primary_id = $this->insertQuery('../mail/form/mail_mailinglist.tform.php', $client_id, $params); return $primary_id; } - + //* Update a mail mailinglist public function mail_mailinglist_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'mail_mailinglist_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -170,10 +170,10 @@ class remoting_mail extends remoting { $affected_rows = $this->updateQuery('../mail/form/mail_mailinglist.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a mail mailinglist public function mail_mailinglist_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'mail_mailinglist_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -181,12 +181,12 @@ class remoting_mail extends remoting { $affected_rows = $this->deleteQuery('../mail/form/mail_mailinglist.tform.php', $primary_id); return $affected_rows; } - + //* Get mail user details public function mail_user_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_user_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -195,70 +195,70 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_user.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - - + + //* Add mail domain public function mail_user_add($session_id, $client_id, $params){ global $app; - + if (!$this->checkPerm($session_id, 'mail_user_add')){ - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + //* Check if mail domain exists - $email_parts = explode('@',$params['email']); + $email_parts = explode('@', $params['email']); $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'"); if($tmp['domain'] != $email_parts[1]) { - throw new SoapFault('mail_domain_does_not_exist','Mail domain - '.$email_parts[1].' - does not exist.'); + throw new SoapFault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.'); return false; } - + $affected_rows = $this->insertQuery('../mail/form/mail_user.tform.php', $client_id, $params); return $affected_rows; } - //* Update mail user + //* Update mail user public function mail_user_update($session_id, $client_id, $primary_id, $params) { global $app; - + if (!$this->checkPerm($session_id, 'mail_user_update')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + //* Check if mail domain exists - $email_parts = explode('@',$params['email']); + $email_parts = explode('@', $params['email']); $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'"); if($tmp['domain'] != $email_parts[1]) { - throw new SoapFault('mail_domain_does_not_exist','Mail domain - '.$email_parts[1].' - does not exist.'); + throw new SoapFault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.'); return false; } - + $affected_rows = $this->updateQuery('../mail/form/mail_user.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete mail user public function mail_user_delete($session_id, $primary_id) { if (!$this->checkPerm($session_id, 'mail_user_delete')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } $affected_rows = $this->deleteQuery('../mail/form/mail_user.tform.php', $primary_id); return $affected_rows; } - + //* Get mail user filter details public function mail_user_filter_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_user_filter_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -267,15 +267,15 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_user_filter.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + public function mail_user_filter_add($session_id, $client_id, $params) { global $app; if (!$this->checkPerm($session_id, 'mail_user_filter_add')){ - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->insertQuery('../mail/form/mail_user_filter.tform.php', $client_id, $params,'mail:mail_user_filter:on_after_insert'); + $affected_rows = $this->insertQuery('../mail/form/mail_user_filter.tform.php', $client_id, $params, 'mail:mail_user_filter:on_after_insert'); // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_insert',$this); return $affected_rows; } @@ -285,10 +285,10 @@ class remoting_mail extends remoting { global $app; if (!$this->checkPerm($session_id, 'mail_user_filter_update')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../mail/form/mail_user_filter.tform.php', $client_id, $primary_id, $params,'mail:mail_user_filter:on_after_update'); + $affected_rows = $this->updateQuery('../mail/form/mail_user_filter.tform.php', $client_id, $primary_id, $params, 'mail:mail_user_filter:on_after_update'); // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_update',$this); return $affected_rows; } @@ -298,19 +298,19 @@ class remoting_mail extends remoting { global $app; if (!$this->checkPerm($session_id, 'mail_user_filter_delete')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id,'mail:mail_user_filter:on_after_delete'); + $affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id, 'mail:mail_user_filter:on_after_delete'); // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this); return $affected_rows; } //* Get alias details public function mail_alias_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_alias_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -319,25 +319,25 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_alias.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* aliasy email public function mail_alias_add($session_id, $client_id, $params) { global $app; - + if (!$this->checkPerm($session_id, 'mail_alias_add')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + //* Check if there is no active mailbox with this address $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'"); if($tmp['number'] > 0) { - throw new SoapFault('duplicate','There is already a mailbox with this email address.'); + throw new SoapFault('duplicate', 'There is already a mailbox with this email address.'); } unset($tmp); - + $affected_rows = $this->insertQuery('../mail/form/mail_alias.tform.php', $client_id, $params); return $affected_rows; } @@ -346,40 +346,40 @@ class remoting_mail extends remoting { public function mail_alias_update($session_id, $client_id, $primary_id, $params) { global $app; - + if (!$this->checkPerm($session_id, 'mail_alias_update')) { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - //* Check if there is no active mailbox with this address + + //* Check if there is no active mailbox with this address $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'"); if($tmp['number'] > 0) { - throw new SoapFault('duplicate','There is already a mailbox with this email address.'); + throw new SoapFault('duplicate', 'There is already a mailbox with this email address.'); } unset($tmp); - + $affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params); return $affected_rows; } public function mail_alias_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_alias_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_alias.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_alias_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_alias.tform.php', $primary_id); + return $affected_rows; } - + //* Get mail forwarding details public function mail_forward_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_forward_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -388,48 +388,48 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_forward.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - - //* przekierowania email + + //* przekierowania email public function mail_forward_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_forward_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/mail_forward.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_forward_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/mail_forward.tform.php', $client_id, $params); + return $affected_rows; } public function mail_forward_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_forward_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_forward.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_forward_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_forward.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_forward_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_forward_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_forward.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_forward_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_forward.tform.php', $primary_id); + return $affected_rows; } - + //* Get catchall details public function mail_catchall_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_catchall_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -440,44 +440,44 @@ class remoting_mail extends remoting { } //* catchall e-mail - public function mail_catchall_add($session_id, $client_id, $params) + public function mail_catchall_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_catchall_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_catchall_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $params); + return $affected_rows; } public function mail_catchall_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_catchall_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_catchall_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_catchall_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_catchall_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_domain_catchall.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_catchall_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_domain_catchall.tform.php', $primary_id); + return $affected_rows; } - + //* Get transport details public function mail_transport_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_transport_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -486,48 +486,48 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_transport.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* przeniesienia e-mail public function mail_transport_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_transport_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/mail_transport.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_transport_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/mail_transport.tform.php', $client_id, $params); + return $affected_rows; } public function mail_transport_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_transport_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_transport.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_transport_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_transport.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_transport_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_transport_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_transport.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_transport_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_transport.tform.php', $primary_id); + return $affected_rows; } - + //* Get spamfilter whitelist details public function mail_spamfilter_whitelist_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -537,47 +537,47 @@ class remoting_mail extends remoting { return $app->remoting_lib->getDataRecord($primary_id); } - //* biała lista e-mail + //* biała lista e-mail public function mail_spamfilter_whitelist_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $params); + return $affected_rows; } public function mail_spamfilter_whitelist_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_spamfilter_whitelist_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/spamfilter_whitelist.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/spamfilter_whitelist.tform.php', $primary_id); + return $affected_rows; } - + //* Get spamfilter blacklist details public function mail_spamfilter_blacklist_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -586,48 +586,48 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/spamfilter_blacklist.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - - //* czarna lista e-mail + + //* czarna lista e-mail public function mail_spamfilter_blacklist_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $params); + return $affected_rows; } public function mail_spamfilter_blacklist_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_spamfilter_blacklist_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/spamfilter_blacklist.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/spamfilter_blacklist.tform.php', $primary_id); + return $affected_rows; } - + //* Get spamfilter user details public function mail_spamfilter_user_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_spamfilter_user_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -640,44 +640,44 @@ class remoting_mail extends remoting { //* filtr spamu użytkowników e-mail public function mail_spamfilter_user_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_user_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/spamfilter_users.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_user_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/spamfilter_users.tform.php', $client_id, $params); + return $affected_rows; } public function mail_spamfilter_user_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_user_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/spamfilter_users.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_user_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/spamfilter_users.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_spamfilter_user_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_spamfilter_user_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/spamfilter_users.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_spamfilter_user_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/spamfilter_users.tform.php', $primary_id); + return $affected_rows; } - + //* Get policy details public function mail_policy_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_policy_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -686,48 +686,48 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/spamfilter_policy.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - - //* polityki filtrów spamu e-mail + + //* polityki filtrów spamu e-mail public function mail_policy_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_policy_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_policy_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $params); + return $affected_rows; } public function mail_policy_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_policy_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_policy_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_policy_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_policy_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/spamfilter_policy.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_policy_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/spamfilter_policy.tform.php', $primary_id); + return $affected_rows; } - + //* Get fetchmail details public function mail_fetchmail_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_fetchmail_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -737,47 +737,47 @@ class remoting_mail extends remoting { return $app->remoting_lib->getDataRecord($primary_id); } - //* fetchmail + //* fetchmail public function mail_fetchmail_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_fetchmail_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/mail_get.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_fetchmail_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/mail_get.tform.php', $client_id, $params); + return $affected_rows; } public function mail_fetchmail_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_fetchmail_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_get.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_fetchmail_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_get.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_fetchmail_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_fetchmail_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_get.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_fetchmail_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_get.tform.php', $primary_id); + return $affected_rows; } - + //* Get whitelist details public function mail_whitelist_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_whitelist_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -786,48 +786,48 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_whitelist.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* wpisy białej listy public function mail_whitelist_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_whitelist_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/mail_whitelist.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_whitelist_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/mail_whitelist.tform.php', $client_id, $params); + return $affected_rows; } public function mail_whitelist_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_whitelist_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_whitelist.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_whitelist_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_whitelist.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_whitelist_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_whitelist_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_whitelist.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_whitelist_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_whitelist.tform.php', $primary_id); + return $affected_rows; } - + //* Get Blacklist details public function mail_blacklist_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_blacklist_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -836,48 +836,48 @@ class remoting_mail extends remoting { $app->remoting_lib->loadFormDef('../mail/form/mail_blacklist.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* wpisy białej listy public function mail_blacklist_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_blacklist_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/mail_blacklist.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_blacklist_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/mail_blacklist.tform.php', $client_id, $params); + return $affected_rows; } public function mail_blacklist_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_blacklist_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_blacklist.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_blacklist_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_blacklist.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_blacklist_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_blacklist_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_blacklist.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_blacklist_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_blacklist.tform.php', $primary_id); + return $affected_rows; } - + //* Get filter details public function mail_filter_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'mail_filter_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -890,84 +890,86 @@ class remoting_mail extends remoting { //* wpisy filtrow e-mail public function mail_filter_add($session_id, $client_id, $params) { - if (!$this->checkPerm($session_id, 'mail_filter_add')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->insertQuery('../mail/form/mail_content_filter.tform.php', $client_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_filter_add')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->insertQuery('../mail/form/mail_content_filter.tform.php', $client_id, $params); + return $affected_rows; } public function mail_filter_update($session_id, $client_id, $primary_id, $params) { - if (!$this->checkPerm($session_id, 'mail_filter_update')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->updateQuery('../mail/form/mail_content_filter.tform.php', $client_id, $primary_id, $params); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_filter_update')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->updateQuery('../mail/form/mail_content_filter.tform.php', $client_id, $primary_id, $params); + return $affected_rows; } public function mail_filter_delete($session_id, $primary_id) { - if (!$this->checkPerm($session_id, 'mail_filter_delete')) - { - throw new SoapFault('permission_denied','You do not have the permissions to access this function.'); - return false; - } - $affected_rows = $this->deleteQuery('../mail/form/mail_content_filter.tform.php', $primary_id); - return $affected_rows; + if (!$this->checkPerm($session_id, 'mail_filter_delete')) + { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $affected_rows = $this->deleteQuery('../mail/form/mail_content_filter.tform.php', $primary_id); + return $affected_rows; } - /** - * Fetch the mail_domain record for the provided domain. - * @param int session_id - * @param string the fully qualified domain (or subdomain) - * @return array array of arrays corresponding to the mail_domain table's records - * @author till, benlake - */ + /** + * Fetch the mail_domain record for the provided domain. + * @param int session_id + * @param string the fully qualified domain (or subdomain) + * @return array array of arrays corresponding to the mail_domain table's records + * @author till, benlake + */ + + public function mail_domain_get_by_domain($session_id, $domain) { - global $app; - if(!$this->checkPerm($session_id, 'mail_domain_get_by_domain')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if (!empty($domain)) { - $domain = $app->db->quote($domain); - $sql = "SELECT * FROM mail_domain WHERE domain = '$domain'"; - $result = $app->db->queryAllRecords($sql); - return $result; - } - return false; - } - - public function mail_domain_set_status($session_id, $primary_id, $status) { - global $app; - if(!$this->checkPerm($session_id, 'mail_domain_set_status')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if(in_array($status, array('active', 'inactive'))) { - if ($status == 'active') { - $status = 'y'; - } else { - $status = 'n'; - } - $sql = "UPDATE mail_domain SET active = '$status' WHERE domain_id = ".$app->functions->intval($primary_id); - $app->db->query($sql); - $result = $app->db->affectedRows(); - return $result; - } else { + global $app; + if(!$this->checkPerm($session_id, 'mail_domain_get_by_domain')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if (!empty($domain)) { + $domain = $app->db->quote($domain); + $sql = "SELECT * FROM mail_domain WHERE domain = '$domain'"; + $result = $app->db->queryAllRecords($sql); + return $result; + } + return false; + } + + public function mail_domain_set_status($session_id, $primary_id, $status) { + global $app; + if(!$this->checkPerm($session_id, 'mail_domain_set_status')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if(in_array($status, array('active', 'inactive'))) { + if ($status == 'active') { + $status = 'y'; + } else { + $status = 'n'; + } + $sql = "UPDATE mail_domain SET active = '$status' WHERE domain_id = ".$app->functions->intval($primary_id); + $app->db->query($sql); + $result = $app->db->affectedRows(); + return $result; + } else { throw new SoapFault('status_undefined', 'The status is not available'); return false; - } - } - + } + } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remote.d/openvz.inc.php b/interface/lib/classes/remote.d/openvz.inc.php index 1a1879183..4a087ccbc 100644 --- a/interface/lib/classes/remote.d/openvz.inc.php +++ b/interface/lib/classes/remote.d/openvz.inc.php @@ -40,12 +40,12 @@ by Marius Cramer class remoting_openvz extends remoting { //* Functions for virtual machine management - + //* Get OpenVZ OStemplate details public function openvz_ostemplate_get($session_id, $ostemplate_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -54,44 +54,44 @@ class remoting_openvz extends remoting { $app->remoting_lib->loadFormDef('../vm/form/openvz_ostemplate.tform.php'); return $app->remoting_lib->getDataRecord($ostemplate_id); } - + //* Add a openvz ostemplate record public function openvz_ostemplate_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../vm/form/openvz_ostemplate.tform.php',$client_id,$params); + return $this->insertQuery('../vm/form/openvz_ostemplate.tform.php', $client_id, $params); } - + //* Update openvz ostemplate record public function openvz_ostemplate_update($session_id, $client_id, $ostemplate_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../vm/form/openvz_ostemplate.tform.php',$client_id,$ostemplate_id,$params); + $affected_rows = $this->updateQuery('../vm/form/openvz_ostemplate.tform.php', $client_id, $ostemplate_id, $params); return $affected_rows; } - + //* Delete openvz ostemplate record public function openvz_ostemplate_delete($session_id, $ostemplate_id) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../vm/form/openvz_ostemplate.tform.php',$ostemplate_id); + $affected_rows = $this->deleteQuery('../vm/form/openvz_ostemplate.tform.php', $ostemplate_id); return $affected_rows; } - + //* Get OpenVZ template details public function openvz_template_get($session_id, $template_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -100,44 +100,44 @@ class remoting_openvz extends remoting { $app->remoting_lib->loadFormDef('../vm/form/openvz_template.tform.php'); return $app->remoting_lib->getDataRecord($template_id); } - + //* Add a openvz template record public function openvz_template_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../vm/form/openvz_template.tform.php',$client_id,$params); + return $this->insertQuery('../vm/form/openvz_template.tform.php', $client_id, $params); } - + //* Update openvz template record public function openvz_template_update($session_id, $client_id, $template_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../vm/form/openvz_template.tform.php',$client_id,$template_id,$params); + $affected_rows = $this->updateQuery('../vm/form/openvz_template.tform.php', $client_id, $template_id, $params); return $affected_rows; } - + //* Delete openvz template record public function openvz_template_delete($session_id, $template_id) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../vm/form/openvz_template.tform.php',$template_id); + $affected_rows = $this->deleteQuery('../vm/form/openvz_template.tform.php', $template_id); return $affected_rows; } - + //* Get OpenVZ ip details public function openvz_ip_get($session_id, $ip_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -146,68 +146,68 @@ class remoting_openvz extends remoting { $app->remoting_lib->loadFormDef('../vm/form/openvz_ip.tform.php'); return $app->remoting_lib->getDataRecord($ip_id); } - + //* Get OpenVZ a free IP address public function openvz_get_free_ip($session_id, $server_id = 0) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } $server_id = $app->functions->intval($server_id); - + if($server_id > 0) { $tmp = $app->db->queryOneRecord("SELECT ip_address_id, server_id, ip_address FROM openvz_ip WHERE reserved = 'n' AND vm_id = 0 AND server_id = $server_id LIMIT 0,1"); } else { $tmp = $app->db->queryOneRecord("SELECT ip_address_id, server_id, ip_address FROM openvz_ip WHERE reserved = 'n' AND vm_id = 0 LIMIT 0,1"); } - + if(count($tmp) > 0) { return $tmp; } else { throw new SoapFault('no_free_ip', 'There is no free IP available.'); } } - + //* Add a openvz ip record public function openvz_ip_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../vm/form/openvz_ip.tform.php',$client_id,$params); + return $this->insertQuery('../vm/form/openvz_ip.tform.php', $client_id, $params); } - + //* Update openvz ip record public function openvz_ip_update($session_id, $client_id, $ip_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../vm/form/openvz_ip.tform.php',$client_id,$ip_id,$params); + $affected_rows = $this->updateQuery('../vm/form/openvz_ip.tform.php', $client_id, $ip_id, $params); return $affected_rows; } - + //* Delete openvz ip record public function openvz_ip_delete($session_id, $ip_id) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../vm/form/openvz_ip.tform.php',$ip_id); + $affected_rows = $this->deleteQuery('../vm/form/openvz_ip.tform.php', $ip_id); return $affected_rows; } - + //* Get OpenVZ vm details public function openvz_vm_get($session_id, $vm_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -216,51 +216,51 @@ class remoting_openvz extends remoting { $app->remoting_lib->loadFormDef('../vm/form/openvz_vm.tform.php'); return $app->remoting_lib->getDataRecord($vm_id); } - + //* Get OpenVZ list public function openvz_vm_get_by_client($session_id, $client_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + if (!empty($client_id)) { - $client_id = $app->functions->intval($client_id); - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id"); - $sql = "SELECT * FROM openvz_vm WHERE sys_groupid = ".$app->functions->intval($tmp['groupid']); - $result = $app->db->queryAllRecords($sql); - return $result; - } - return false; + $client_id = $app->functions->intval($client_id); + $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id"); + $sql = "SELECT * FROM openvz_vm WHERE sys_groupid = ".$app->functions->intval($tmp['groupid']); + $result = $app->db->queryAllRecords($sql); + return $result; + } + return false; } - + //* Add a openvz vm record public function openvz_vm_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../vm/form/openvz_vm.tform.php',$client_id,$params); + return $this->insertQuery('../vm/form/openvz_vm.tform.php', $client_id, $params); } - + //* Add a openvz vm record from template public function openvz_vm_add_from_template($session_id, $client_id, $ostemplate_id, $template_id, $override_params = array()) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - + + $template_id = $app->functions->intval($template_id); $ostemplate_id = $app->functions->intval($ostemplate_id); - + //* Verify parameters if($template_id == 0) { throw new SoapFault('template_id_error', 'Template ID must be > 0.'); @@ -270,7 +270,7 @@ class remoting_openvz extends remoting { throw new SoapFault('ostemplate_id_error', 'OSTemplate ID must be > 0.'); return false; } - + // Verify if template and ostemplate exist $tmp = $app->db->queryOneRecord("SELECT template_id FROM openvz_template WHERE template_id = $template_id"); if(!is_array($tmp)) { @@ -282,10 +282,10 @@ class remoting_openvz extends remoting { throw new SoapFault('ostemplate_id_error', 'OSTemplate does not exist.'); return false; } - + //* Get the template $vtpl = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = $template_id"); - + //* Get the IP address and server_id if($override_params['server_id'] > 0) { $vmip = $app->db->queryOneRecord("SELECT ip_address_id, server_id, ip_address FROM openvz_ip WHERE reserved = 'n' AND vm_id = 0 AND server_id = ".$override_params['server_id']." LIMIT 0,1"); @@ -296,7 +296,7 @@ class remoting_openvz extends remoting { throw new SoapFault('vm_ip_error', 'Unable to get a free VM IP.'); return false; } - + //* Build the $params array $params = array(); $params['server_id'] = $vmip['server_id']; @@ -309,8 +309,8 @@ class remoting_openvz extends remoting { $params['active'] = (isset($override_params['active']))?$override_params['active']:'y'; $params['active_until_date'] = (isset($override_params['active_until_date']))?$override_params['active_until_date']:'0000-00-00'; $params['description'] = (isset($override_params['description']))?$override_params['description']:''; - - //* The next params get filled with pseudo values, as the get replaced + + //* The next params get filled with pseudo values, as the get replaced //* by the openvz event plugin anyway with values from the template $params['veid'] = 1; $params['diskspace'] = 1; @@ -323,178 +323,179 @@ class remoting_openvz extends remoting { $params['nameserver'] = '8.8.8.8 8.8.4.4'; $params['create_dns'] = 'n'; $params['capability'] = ''; - - return $this->insertQuery('../vm/form/openvz_vm.tform.php',$client_id,$params,'vm:openvz_vm:on_after_insert'); + + return $this->insertQuery('../vm/form/openvz_vm.tform.php', $client_id, $params, 'vm:openvz_vm:on_after_insert'); } - + //* Update openvz vm record public function openvz_vm_update($session_id, $client_id, $vm_id, $params) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../vm/form/openvz_vm.tform.php',$client_id,$vm_id,$params,'vm:openvz_vm:on_after_update'); + $affected_rows = $this->updateQuery('../vm/form/openvz_vm.tform.php', $client_id, $vm_id, $params, 'vm:openvz_vm:on_after_update'); return $affected_rows; } - + //* Delete openvz vm record public function openvz_vm_delete($session_id, $vm_id) - { + { if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../vm/form/openvz_vm.tform.php',$vm_id,'vm:openvz_vm:on_after_delete'); + $affected_rows = $this->deleteQuery('../vm/form/openvz_vm.tform.php', $vm_id, 'vm:openvz_vm:on_after_delete'); return $affected_rows; } - + //* Start VM public function openvz_vm_start($session_id, $vm_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + $app->uses('remoting_lib'); $app->remoting_lib->loadFormDef('../vm/form/openvz_vm.tform.php'); $vm = $app->remoting_lib->getDataRecord($vm_id); - + if(!is_array($vm)) { throw new SoapFault('action_pending', 'No VM with this ID available.'); return false; } - + if($vm['active'] == 'n') { throw new SoapFault('action_pending', 'VM is not in active state.'); return false; } - + $action = 'openvz_start_vm'; - - $tmp = $app->db->queryOneRecord("SELECT count(action_id) as actions FROM sys_remoteaction - WHERE server_id = '".$vm['server_id']."' + + $tmp = $app->db->queryOneRecord("SELECT count(action_id) as actions FROM sys_remoteaction + WHERE server_id = '".$vm['server_id']."' AND action_type = '$action' AND action_param = '".$vm['veid']."' AND action_state = 'pending'"); - + if($tmp['actions'] > 0) { throw new SoapFault('action_pending', 'There is already a action pending for this VM.'); return false; } else { $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$vm['server_id'] . ", ". - time() . ", ". - "'".$action."', ". - $vm['veid'].", ". - "'pending', ". - "''". - ")"; + "VALUES (". + (int)$vm['server_id'] . ", ". + time() . ", ". + "'".$action."', ". + $vm['veid'].", ". + "'pending', ". + "''". + ")"; $app->db->query($sql); } } - + //* Stop VM public function openvz_vm_stop($session_id, $vm_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + $app->uses('remoting_lib'); $app->remoting_lib->loadFormDef('../vm/form/openvz_vm.tform.php'); $vm = $app->remoting_lib->getDataRecord($vm_id); - + if(!is_array($vm)) { throw new SoapFault('action_pending', 'No VM with this ID available.'); return false; } - + if($vm['active'] == 'n') { throw new SoapFault('action_pending', 'VM is not in active state.'); return false; } - + $action = 'openvz_stop_vm'; - - $tmp = $app->db->queryOneRecord("SELECT count(action_id) as actions FROM sys_remoteaction - WHERE server_id = '".$vm['server_id']."' + + $tmp = $app->db->queryOneRecord("SELECT count(action_id) as actions FROM sys_remoteaction + WHERE server_id = '".$vm['server_id']."' AND action_type = '$action' AND action_param = '".$vm['veid']."' AND action_state = 'pending'"); - + if($tmp['actions'] > 0) { throw new SoapFault('action_pending', 'There is already a action pending for this VM.'); return false; } else { $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$vm['server_id'] . ", ". - time() . ", ". - "'".$action."', ". - $vm['veid'].", ". - "'pending', ". - "''". - ")"; + "VALUES (". + (int)$vm['server_id'] . ", ". + time() . ", ". + "'".$action."', ". + $vm['veid'].", ". + "'pending', ". + "''". + ")"; $app->db->query($sql); } } - + //* Restart VM public function openvz_vm_restart($session_id, $vm_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'vm_openvz')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + $app->uses('remoting_lib'); $app->remoting_lib->loadFormDef('../vm/form/openvz_vm.tform.php'); $vm = $app->remoting_lib->getDataRecord($vm_id); - + if(!is_array($vm)) { throw new SoapFault('action_pending', 'No VM with this ID available.'); return false; } - + if($vm['active'] == 'n') { throw new SoapFault('action_pending', 'VM is not in active state.'); return false; } - + $action = 'openvz_restart_vm'; - - $tmp = $app->db->queryOneRecord("SELECT count(action_id) as actions FROM sys_remoteaction - WHERE server_id = '".$vm['server_id']."' + + $tmp = $app->db->queryOneRecord("SELECT count(action_id) as actions FROM sys_remoteaction + WHERE server_id = '".$vm['server_id']."' AND action_type = '$action' AND action_param = '".$vm['veid']."' AND action_state = 'pending'"); - + if($tmp['actions'] > 0) { throw new SoapFault('action_pending', 'There is already a action pending for this VM.'); return false; } else { $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$vm['server_id'] . ", ". - time() . ", ". - "'".$action."', ". - $vm['veid'].", ". - "'pending', ". - "''". - ")"; + "VALUES (". + (int)$vm['server_id'] . ", ". + time() . ", ". + "'".$action."', ". + $vm['veid'].", ". + "'pending', ". + "''". + ")"; $app->db->query($sql); } } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remote.d/server.inc.php b/interface/lib/classes/remote.d/server.inc.php index 023d1a935..db21ac0f4 100644 --- a/interface/lib/classes/remote.d/server.inc.php +++ b/interface/lib/classes/remote.d/server.inc.php @@ -39,57 +39,59 @@ by Marius Cramer */ class remoting_server extends remoting { - /** - Gets the server configuration - @param int session id - @param int server id - @param string section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc - @author Julio Montoya BeezNest 2010 - */ - + /** + Gets the server configuration + @param int session id + @param int server id + @param string section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc + @author Julio Montoya BeezNest 2010 + */ + + public function server_get_serverid_by_ip($session_id, $ipaddress) - { - global $app; + { + global $app; if(!$this->checkPerm($session_id, 'server_get_serverid_by_ip')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; } - $sql = "SELECT server_id FROM server_ip WHERE ip_address = '$ipaddress' LIMIT 1 "; - $all = $app->db->queryAllRecords($sql); - return $all; + $sql = "SELECT server_id FROM server_ip WHERE ip_address = '$ipaddress' LIMIT 1 "; + $all = $app->db->queryAllRecords($sql); + return $all; } - + //* Add a IP address record public function server_ip_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'server_ip_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../admin/form/server_ip.tform.php',$client_id,$params); + return $this->insertQuery('../admin/form/server_ip.tform.php', $client_id, $params); } - + //* Update IP address record public function server_ip_update($session_id, $client_id, $ip_id, $params) - { + { if(!$this->checkPerm($session_id, 'server_ip_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../admin/form/server_ip.tform.php',$client_id,$ip_id,$params); + $affected_rows = $this->updateQuery('../admin/form/server_ip.tform.php', $client_id, $ip_id, $params); return $affected_rows; } - + //* Delete IP address record public function server_ip_delete($session_id, $ip_id) - { + { if(!$this->checkPerm($session_id, 'server_ip_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../admin/form/server_ip.tform.php',$ip_id); + $affected_rows = $this->deleteQuery('../admin/form/server_ip.tform.php', $ip_id); return $affected_rows; } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remote.d/sites.inc.php b/interface/lib/classes/remote.d/sites.inc.php index 37a79ba30..a043ce118 100644 --- a/interface/lib/classes/remote.d/sites.inc.php +++ b/interface/lib/classes/remote.d/sites.inc.php @@ -40,12 +40,12 @@ by Marius Cramer class remoting_sites extends remoting { // Website functions --------------------------------------------------------------------------------------- - + //* Get cron details public function sites_cron_get($session_id, $cron_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_cron_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -54,46 +54,46 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/cron.tform.php'); return $app->remoting_lib->getDataRecord($cron_id); } - + //* Add a cron record public function sites_cron_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_cron_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/cron.tform.php',$client_id,$params); + return $this->insertQuery('../sites/form/cron.tform.php', $client_id, $params); } - + //* Update cron record public function sites_cron_update($session_id, $client_id, $cron_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_cron_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../sites/form/cron.tform.php',$client_id,$cron_id,$params); + $affected_rows = $this->updateQuery('../sites/form/cron.tform.php', $client_id, $cron_id, $params); return $affected_rows; } - + //* Delete cron record public function sites_cron_delete($session_id, $cron_id) - { + { if(!$this->checkPerm($session_id, 'sites_cron_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/cron.tform.php',$cron_id); + $affected_rows = $this->deleteQuery('../sites/form/cron.tform.php', $cron_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_database_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_database_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -102,17 +102,17 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/database.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_database_add($session_id, $client_id, $params) - { - global $app; - + { + global $app; + if(!$this->checkPerm($session_id, 'sites_database_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + //* Check for duplicates $tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = '".$app->db->quote($params['database_name'])."' AND server_id = '".intval($params["server_id"])."'"); if($tmp['dbnum'] > 0) { @@ -120,66 +120,66 @@ class remoting_sites extends remoting { return false; } - $sql = $this->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params); - if($sql !== false) { - $app->uses('sites_database_plugin'); - - $this->id = 0; - $this->dataRecord = $params; - $app->sites_database_plugin->processDatabaseInsert($this); + $sql = $this->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params); + if($sql !== false) { + $app->uses('sites_database_plugin'); - return $this->insertQueryExecute($sql, $params); - } - - return false; + $this->id = 0; + $this->dataRecord = $params; + $app->sites_database_plugin->processDatabaseInsert($this); + + return $this->insertQueryExecute($sql, $params); + } + + return false; } - + //* Update a record public function sites_database_update($session_id, $client_id, $primary_id, $params) - { - global $app; - + { + global $app; + if(!$this->checkPerm($session_id, 'sites_database_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + $sql = $this->updateQueryPrepare('../sites/form/database.tform.php', $client_id, $primary_id, $params); - if($sql !== false) { - $app->uses('sites_database_plugin'); - - $this->id = $primary_id; - $this->dataRecord = $params; - $app->sites_database_plugin->processDatabaseUpdate($this); - return $this->updateQueryExecute($sql, $primary_id, $params); - } - - return false; - } - + if($sql !== false) { + $app->uses('sites_database_plugin'); + + $this->id = $primary_id; + $this->dataRecord = $params; + $app->sites_database_plugin->processDatabaseUpdate($this); + return $this->updateQueryExecute($sql, $primary_id, $params); + } + + return false; + } + //* Delete a record public function sites_database_delete($session_id, $primary_id) - { - global $app; + { + global $app; if(!$this->checkPerm($session_id, 'sites_database_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - $app->uses('sites_database_plugin'); - $app->sites_database_plugin->processDatabaseDelete($primary_id); - - $affected_rows = $this->deleteQuery('../sites/form/database.tform.php',$primary_id); + + $app->uses('sites_database_plugin'); + $app->sites_database_plugin->processDatabaseDelete($primary_id); + + $affected_rows = $this->deleteQuery('../sites/form/database.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_database_user_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_database_user_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -188,81 +188,81 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_database_user_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_database_user_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params); + return $this->insertQuery('../sites/form/database_user.tform.php', $client_id, $params); } - + //* Update a record public function sites_database_user_update($session_id, $client_id, $primary_id, $params) - { - global $app; - + { + global $app; + if(!$this->checkPerm($session_id, 'sites_database_user_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } $app->uses('remoting_lib'); $app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php'); - $old_rec = $app->remoting_lib->getDataRecord($primary_id); - + $old_rec = $app->remoting_lib->getDataRecord($primary_id); + $result = $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params); - - $new_rec = $app->remoting_lib->getDataRecord($primary_id); - - $records = $app->db->queryAllRecords("SELECT DISTINCT server_id FROM web_database WHERE database_user_id = '".$app->functions->intval($primary_id)."' UNION SELECT DISTINCT server_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($primary_id)."'"); - foreach($records as $rec) { - $tmp_rec = $new_rec; - $tmp_rec['server_id'] = $rec['server_id']; - $app->remoting_lib->datalogSave('UPDATE', $primary_id, $old_rec, $tmp_rec); - } - unset($new_rec); - unset($old_rec); - unset($records); - - return $result; - } - + + $new_rec = $app->remoting_lib->getDataRecord($primary_id); + + $records = $app->db->queryAllRecords("SELECT DISTINCT server_id FROM web_database WHERE database_user_id = '".$app->functions->intval($primary_id)."' UNION SELECT DISTINCT server_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($primary_id)."'"); + foreach($records as $rec) { + $tmp_rec = $new_rec; + $tmp_rec['server_id'] = $rec['server_id']; + $app->remoting_lib->datalogSave('UPDATE', $primary_id, $old_rec, $tmp_rec); + } + unset($new_rec); + unset($old_rec); + unset($records); + + return $result; + } + //* Delete a record public function sites_database_user_delete($session_id, $primary_id) - { - global $app; - + { + global $app; + if(!$this->checkPerm($session_id, 'sites_database_user_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - $app->db->datalogDelete('web_database_user', 'database_user_id', $primary_id); - $affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php',$primary_id); - - $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = '".$app->functions->intval($primary_id)."'"); - foreach($records as $rec) { - $app->db->datalogUpdate('web_database','database_user_id=NULL','database_id', $rec['database_id']); - - } - $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($primary_id)."'"); - foreach($records as $rec) { - $app->db->datalogUpdate('web_database','database_ro_user_id=NULL','database_id', $rec['database_id']); - } - + + $app->db->datalogDelete('web_database_user', 'database_user_id', $primary_id); + $affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php', $primary_id); + + $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = '".$app->functions->intval($primary_id)."'"); + foreach($records as $rec) { + $app->db->datalogUpdate('web_database', 'database_user_id=NULL', 'database_id', $rec['database_id']); + + } + $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($primary_id)."'"); + foreach($records as $rec) { + $app->db->datalogUpdate('web_database', 'database_ro_user_id=NULL', 'database_id', $rec['database_id']); + } + return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_ftp_user_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_ftp_user_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -271,66 +271,66 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/ftp_user.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_ftp_user_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_ftp_user_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/ftp_user.tform.php',$client_id,$params); + return $this->insertQuery('../sites/form/ftp_user.tform.php', $client_id, $params); } - + //* Update a record public function sites_ftp_user_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_ftp_user_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../sites/form/ftp_user.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../sites/form/ftp_user.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function sites_ftp_user_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'sites_ftp_user_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/ftp_user.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../sites/form/ftp_user.tform.php', $primary_id); return $affected_rows; } - + //* Get server for an ftp user public function sites_ftp_user_server_get($session_id, $ftp_user) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_ftp_user_server_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + $data = $app->db->queryOneRecord("SELECT server_id FROM ftp_user WHERE username = '".$app->db->quote($ftp_user)."'"); //file_put_contents('/tmp/test.txt', serialize($data)); - if(!isset($data['server_id'])) return false; - - $server = $this->server_get($session_id, $data['server_id'], 'server'); - //file_put_contents('/tmp/test2.txt', serialize($server)); - + if(!isset($data['server_id'])) return false; + + $server = $this->server_get($session_id, $data['server_id'], 'server'); + //file_put_contents('/tmp/test2.txt', serialize($server)); + return $server; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_shell_user_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_shell_user_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -339,46 +339,46 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/shell_user.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_shell_user_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_shell_user_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/shell_user.tform.php',$client_id,$params); + return $this->insertQuery('../sites/form/shell_user.tform.php', $client_id, $params); } - + //* Update a record public function sites_shell_user_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_shell_user_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../sites/form/shell_user.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../sites/form/shell_user.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function sites_shell_user_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'sites_shell_user_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/shell_user.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../sites/form/shell_user.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_web_domain_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_web_domain_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -387,7 +387,7 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/web_domain.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_web_domain_add($session_id, $client_id, $params, $readonly = false) { @@ -396,65 +396,65 @@ class remoting_sites extends remoting { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + if(!isset($params['client_group_id']) or (isset($params['client_group_id']) && empty($params['client_group_id']))) { $rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client_id)); $params['client_group_id'] = $rec['groupid']; } - + //* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin if($params['document_root'] == '') $params['document_root'] = '-'; if($params['system_user'] == '') $params['system_user'] = '-'; if($params['system_group'] == '') $params['system_group'] = '-'; - + //* Set a few defaults for nginx servers if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; - - $domain_id = $this->insertQuery('../sites/form/web_domain.tform.php',$client_id,$params, 'sites:web_domain:on_after_insert'); + + $domain_id = $this->insertQuery('../sites/form/web_domain.tform.php', $client_id, $params, 'sites:web_domain:on_after_insert'); if ($readonly === true) $app->db->query("UPDATE web_domain SET `sys_userid` = '1' WHERE domain_id = ".$domain_id); - return $domain_id; - } - + return $domain_id; + } + //* Update a record public function sites_web_domain_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_domain_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + //* Set a few defaults for nginx servers if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; - - $affected_rows = $this->updateQuery('../sites/form/web_domain.tform.php',$client_id,$primary_id,$params); + + $affected_rows = $this->updateQuery('../sites/form/web_domain.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function sites_web_domain_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'sites_web_domain_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/web_domain.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../sites/form/web_domain.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_web_vhost_subdomain_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_web_subdomain_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -463,7 +463,7 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/web_vhost_subdomain.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_web_vhost_subdomain_add($session_id, $client_id, $params) { @@ -472,58 +472,58 @@ class remoting_sites extends remoting { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + //* Set a few params to "not empty" values which get overwritten by the sites_web_domain_plugin if($params['document_root'] == '') $params['document_root'] = '-'; if($params['system_user'] == '') $params['system_user'] = '-'; if($params['system_group'] == '') $params['system_group'] = '-'; - + //* Set a few defaults for nginx servers if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; - - $domain_id = $this->insertQuery('../sites/form/web_vhost_subdomain.tform.php',$client_id,$params, 'sites:web_vhost_subdomain:on_after_insert'); - return $domain_id; - } - + + $domain_id = $this->insertQuery('../sites/form/web_vhost_subdomain.tform.php', $client_id, $params, 'sites:web_vhost_subdomain:on_after_insert'); + return $domain_id; + } + //* Update a record public function sites_web_vhost_subdomain_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_subdomain_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - + //* Set a few defaults for nginx servers if($params['pm_max_children'] == '') $params['pm_max_children'] = 1; if($params['pm_start_servers'] == '') $params['pm_start_servers'] = 1; if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; - - $affected_rows = $this->updateQuery('../sites/form/web_vhost_subdomain.tform.php',$client_id,$primary_id,$params, 'sites:web_vhost_subdomain:on_after_insert'); + + $affected_rows = $this->updateQuery('../sites/form/web_vhost_subdomain.tform.php', $client_id, $primary_id, $params, 'sites:web_vhost_subdomain:on_after_insert'); return $affected_rows; } - + //* Delete a record public function sites_web_vhost_subdomain_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'sites_web_subdomain_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/web_vhost_subdomain.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../sites/form/web_vhost_subdomain.tform.php', $primary_id); return $affected_rows; } - + // ----------------------------------------------------------------------------------------------- - + //* Get record details public function sites_web_aliasdomain_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -532,46 +532,46 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/web_aliasdomain.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_web_aliasdomain_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/web_aliasdomain.tform.php',$client_id,$params); + return $this->insertQuery('../sites/form/web_aliasdomain.tform.php', $client_id, $params); } - + //* Update a record public function sites_web_aliasdomain_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../sites/form/web_aliasdomain.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../sites/form/web_aliasdomain.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function sites_web_aliasdomain_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/web_aliasdomain.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../sites/form/web_aliasdomain.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_web_subdomain_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_web_subdomain_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -580,46 +580,46 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/web_subdomain.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_web_subdomain_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_subdomain_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/web_subdomain.tform.php',$client_id,$params); + return $this->insertQuery('../sites/form/web_subdomain.tform.php', $client_id, $params); } - + //* Update a record public function sites_web_subdomain_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_subdomain_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../sites/form/web_subdomain.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../sites/form/web_subdomain.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function sites_web_subdomain_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'sites_web_subdomain_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/web_subdomain.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../sites/form/web_subdomain.tform.php', $primary_id); return $affected_rows; } - + // ---------------------------------------------------------------------------------------------------------- - + //* Get record details public function sites_web_folder_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_web_folder_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -628,56 +628,56 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/web_folder.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_web_folder_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_folder_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/web_folder.tform.php',$client_id,$params); + return $this->insertQuery('../sites/form/web_folder.tform.php', $client_id, $params); } - + //* Update a record public function sites_web_folder_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_folder_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../sites/form/web_folder.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../sites/form/web_folder.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function sites_web_folder_delete($session_id, $primary_id) - { + { global $app; if(!$this->checkPerm($session_id, 'sites_web_folder_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - - // Delete all users that belong to this folder. - taken from web_folder_delete.php + + // Delete all users that belong to this folder. - taken from web_folder_delete.php $records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = '".$app->functions->intval($primary_id)."'"); foreach($records as $rec) { - $this->deleteQuery('../sites/form/web_folder_user.tform.php',$rec['web_folder_user_id']); + $this->deleteQuery('../sites/form/web_folder_user.tform.php', $rec['web_folder_user_id']); //$app->db->datalogDelete('web_folder_user','web_folder_user_id',$rec['web_folder_user_id']); } unset($records); - - $affected_rows = $this->deleteQuery('../sites/form/web_folder.tform.php',$primary_id); + + $affected_rows = $this->deleteQuery('../sites/form/web_folder.tform.php', $primary_id); return $affected_rows; } - + // ----------------------------------------------------------------------------------------------- - + //* Get record details public function sites_web_folder_user_get($session_id, $primary_id) - { + { global $app; - + if(!$this->checkPerm($session_id, 'sites_web_folder_user_get')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; @@ -686,118 +686,121 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/web_folder_user.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + //* Add a record public function sites_web_folder_user_add($session_id, $client_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_folder_user_add')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - return $this->insertQuery('../sites/form/web_folder_user.tform.php',$client_id,$params); + return $this->insertQuery('../sites/form/web_folder_user.tform.php', $client_id, $params); } - + //* Update a record public function sites_web_folder_user_update($session_id, $client_id, $primary_id, $params) - { + { if(!$this->checkPerm($session_id, 'sites_web_folder_user_update')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->updateQuery('../sites/form/web_folder_user.tform.php',$client_id,$primary_id,$params); + $affected_rows = $this->updateQuery('../sites/form/web_folder_user.tform.php', $client_id, $primary_id, $params); return $affected_rows; } - + //* Delete a record public function sites_web_folder_user_delete($session_id, $primary_id) - { + { if(!$this->checkPerm($session_id, 'sites_web_folder_user_delete')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; } - $affected_rows = $this->deleteQuery('../sites/form/web_folder_user.tform.php',$primary_id); + $affected_rows = $this->deleteQuery('../sites/form/web_folder_user.tform.php', $primary_id); return $affected_rows; } /** * Gets sites by $sys_userid & $sys_groupid - * @param int session id - * @param int user id - * @param array list of groups - * @return mixed array with sites by user - * @author Julio Montoya BeezNest 2010 + * @param int session id + * @param int user id + * @param array list of groups + * @return mixed array with sites by user + * @author Julio Montoya BeezNest 2010 */ + + public function client_get_sites_by_user($session_id, $sys_userid, $sys_groupid) { - global $app; - if(!$this->checkPerm($session_id, 'client_get_sites_by_user')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - $sys_userid = $app->functions->intval($sys_userid); - $sys_groupid = explode(',', $sys_groupid); - $new_group = array(); - foreach($sys_groupid as $group_id) { + global $app; + if(!$this->checkPerm($session_id, 'client_get_sites_by_user')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $sys_userid = $app->functions->intval($sys_userid); + $sys_groupid = explode(',', $sys_groupid); + $new_group = array(); + foreach($sys_groupid as $group_id) { $new_group[] = $app->functions->intval( $group_id); - } - $group_list = implode(',', $new_group); + } + $group_list = implode(',', $new_group); $sql ="SELECT domain, domain_id, document_root, active FROM web_domain WHERE ( (sys_userid = $sys_userid AND sys_perm_user LIKE '%r%') OR (sys_groupid IN ($group_list) AND sys_perm_group LIKE '%r%') OR sys_perm_other LIKE '%r%') AND type = 'vhost'"; - $result = $app->db->queryAllRecords($sql); - if(isset($result)) { + $result = $app->db->queryAllRecords($sql); + if(isset($result)) { return $result; - } else { + } else { throw new SoapFault('no_client_found', 'There is no site for this user'); return false; - } - } - - /** - * Change domains status - * @param int session id - * @param int site id - * @param string active or inactive string - * @return mixed false if error - * @author Julio Montoya BeezNest 2010 + } + } + + + + /** + * Change domains status + * @param int session id + * @param int site id + * @param string active or inactive string + * @return mixed false if error + * @author Julio Montoya BeezNest 2010 */ - - public function sites_web_domain_set_status($session_id, $primary_id, $status) { - global $app; - if(!$this->checkPerm($session_id, 'sites_web_domain_set_status')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if(in_array($status, array('active', 'inactive'))) { - if ($status == 'active') { - $status = 'y'; - } else { - $status = 'n'; - } - $sql = "UPDATE web_domain SET active = '$status' WHERE domain_id = ".$app->functions->intval($primary_id); - $app->db->query($sql); - $result = $app->db->affectedRows(); - return $result; - } else { + public function sites_web_domain_set_status($session_id, $primary_id, $status) { + global $app; + if(!$this->checkPerm($session_id, 'sites_web_domain_set_status')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if(in_array($status, array('active', 'inactive'))) { + if ($status == 'active') { + $status = 'y'; + } else { + $status = 'n'; + } + $sql = "UPDATE web_domain SET active = '$status' WHERE domain_id = ".$app->functions->intval($primary_id); + $app->db->query($sql); + $result = $app->db->affectedRows(); + return $result; + } else { throw new SoapFault('status_undefined', 'The status is not available'); return false; - } + } } - /** - * Get all databases by user - * @author Julio Montoya BeezNest 2010 - */ + /** + * Get all databases by user + * @author Julio Montoya BeezNest 2010 + */ public function sites_database_get_all_by_user($session_id, $client_id) - { - global $app; + { + global $app; if(!$this->checkPerm($session_id, 'sites_database_get')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; } - $client_id = $app->functions->intval($client_id); - $sql = "SELECT d.database_id, d.database_name, d.database_user_id, d.database_ro_user_id, du.database_user, du.database_password FROM web_database d LEFT JOIN web_database_user du ON (du.database_user_id = d.database_user_id) INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id"; + $client_id = $app->functions->intval($client_id); + $sql = "SELECT d.database_id, d.database_name, d.database_user_id, d.database_ro_user_id, du.database_user, du.database_password FROM web_database d LEFT JOIN web_database_user du ON (du.database_user_id = d.database_user_id) INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = $client_id"; $all = $app->db->queryAllRecords($sql); - return $all; + return $all; } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php index a6a6ddcdd..2dd717986 100644 --- a/interface/lib/classes/remoting.inc.php +++ b/interface/lib/classes/remoting.inc.php @@ -35,42 +35,42 @@ Copyright (c) Tri-Plex technology */ class remoting { - + //* remote session timeout in seconds private $session_timeout = 600; - + public $oldDataRecord; public $dataRecord; public $id; - - private $_methods = array(); - + + private $_methods = array(); + /* - These variables shall stay global. + These variables shall stay global. Please do not make them private variables. - + private $app; private $conf; */ - public function __construct($methods = array()) - { - global $app; - $app->uses('remoting_lib'); + public function __construct($methods = array()) + { + global $app; + $app->uses('remoting_lib'); + + $this->_methods = $methods; - $this->_methods = $methods; - - /* + /* $this->app = $app; $this->conf = $conf; */ - } - - //* remote login function + } + + //* remote login function public function login($username, $password, $client_login = false) - { + { global $app, $conf; - + // Maintenance mode $app->uses('ini_parser,getconf'); $server_config_array = $app->getconf->get_global_config('misc'); @@ -78,439 +78,442 @@ class remoting { throw new SoapFault('maintenance_mode', 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.'); return false; } - + if(empty($username)) { throw new SoapFault('login_username_empty', 'The login username is empty.'); return false; } - + if(empty($password)) { throw new SoapFault('login_password_empty', 'The login password is empty.'); return false; } - + //* Delete old remoting sessions $sql = "DELETE FROM remote_session WHERE tstamp < ".time(); $app->db->query($sql); - + $username = $app->db->quote($username); $password = $app->db->quote($password); - - if($client_login == true) { - $sql = "SELECT * FROM sys_user WHERE USERNAME = '$username'"; - $user = $app->db->queryOneRecord($sql); - if($user) { - $saved_password = stripslashes($user['passwort']); - - if(substr($saved_password,0,3) == '$1$') { - //* The password is crypt-md5 encrypted - $salt = '$1$'.substr($saved_password,3,8).'$'; - - if(crypt(stripslashes($password),$salt) != $saved_password) { - throw new SoapFault('client_login_failed', 'The login failed. Username or password wrong.'); - return false; - } - } else { - //* The password is md5 encrypted - if(md5($password) != $saved_password) { - throw new SoapFault('client_login_failed', 'The login failed. Username or password wrong.'); - return false; - } - } - } else { - throw new SoapFault('client_login_failed', 'The login failed. Username or password wrong.'); - return false; - } - if($user['active'] != 1) { - throw new SoapFault('client_login_failed', 'The login failed. User is blocked.'); - return false; - } - - // now we need the client data - $client = $app->db->queryOneRecord("SELECT client.can_use_api FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = " . $app->functions->intval($user['default_group'])); - if(!$client || $client['can_use_api'] != 'y') { - throw new SoapFault('client_login_failed', 'The login failed. Client may not use api.'); - return false; - } - - //* Create a remote user session - //srand ((double)microtime()*1000000); - $remote_session = md5(mt_rand().uniqid('ispco')); - $remote_userid = $user['userid']; - $remote_functions = ''; - $tstamp = time() + $this->session_timeout; - $sql = 'INSERT INTO remote_session (remote_session,remote_userid,remote_functions,client_login,tstamp' - .') VALUES (' - ." '$remote_session',$remote_userid,'$remote_functions',1,$tstamp)"; - $app->db->query($sql); - return $remote_session; + + if($client_login == true) { + $sql = "SELECT * FROM sys_user WHERE USERNAME = '$username'"; + $user = $app->db->queryOneRecord($sql); + if($user) { + $saved_password = stripslashes($user['passwort']); + + if(substr($saved_password, 0, 3) == '$1$') { + //* The password is crypt-md5 encrypted + $salt = '$1$'.substr($saved_password, 3, 8).'$'; + + if(crypt(stripslashes($password), $salt) != $saved_password) { + throw new SoapFault('client_login_failed', 'The login failed. Username or password wrong.'); + return false; + } + } else { + //* The password is md5 encrypted + if(md5($password) != $saved_password) { + throw new SoapFault('client_login_failed', 'The login failed. Username or password wrong.'); + return false; + } + } + } else { + throw new SoapFault('client_login_failed', 'The login failed. Username or password wrong.'); + return false; + } + if($user['active'] != 1) { + throw new SoapFault('client_login_failed', 'The login failed. User is blocked.'); + return false; + } + + // now we need the client data + $client = $app->db->queryOneRecord("SELECT client.can_use_api FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = " . $app->functions->intval($user['default_group'])); + if(!$client || $client['can_use_api'] != 'y') { + throw new SoapFault('client_login_failed', 'The login failed. Client may not use api.'); + return false; + } + + //* Create a remote user session + //srand ((double)microtime()*1000000); + $remote_session = md5(mt_rand().uniqid('ispco')); + $remote_userid = $user['userid']; + $remote_functions = ''; + $tstamp = time() + $this->session_timeout; + $sql = 'INSERT INTO remote_session (remote_session,remote_userid,remote_functions,client_login,tstamp' + .') VALUES (' + ." '$remote_session',$remote_userid,'$remote_functions',1,$tstamp)"; + $app->db->query($sql); + return $remote_session; } else { - $sql = "SELECT * FROM remote_user WHERE remote_username = '$username' and remote_password = md5('$password')"; - $remote_user = $app->db->queryOneRecord($sql); - if($remote_user['remote_userid'] > 0) { - //* Create a remote user session - //srand ((double)microtime()*1000000); - $remote_session = md5(mt_rand().uniqid('ispco')); - $remote_userid = $remote_user['remote_userid']; - $remote_functions = $remote_user['remote_functions']; - $tstamp = time() + $this->session_timeout; - $sql = 'INSERT INTO remote_session (remote_session,remote_userid,remote_functions,tstamp' - .') VALUES (' - ." '$remote_session',$remote_userid,'$remote_functions',$tstamp)"; - $app->db->query($sql); - return $remote_session; - } else { - throw new SoapFault('login_failed', 'The login failed. Username or password wrong.'); - return false; - } - } - + $sql = "SELECT * FROM remote_user WHERE remote_username = '$username' and remote_password = md5('$password')"; + $remote_user = $app->db->queryOneRecord($sql); + if($remote_user['remote_userid'] > 0) { + //* Create a remote user session + //srand ((double)microtime()*1000000); + $remote_session = md5(mt_rand().uniqid('ispco')); + $remote_userid = $remote_user['remote_userid']; + $remote_functions = $remote_user['remote_functions']; + $tstamp = time() + $this->session_timeout; + $sql = 'INSERT INTO remote_session (remote_session,remote_userid,remote_functions,tstamp' + .') VALUES (' + ." '$remote_session',$remote_userid,'$remote_functions',$tstamp)"; + $app->db->query($sql); + return $remote_session; + } else { + throw new SoapFault('login_failed', 'The login failed. Username or password wrong.'); + return false; + } + } + } - + //* remote logout function public function logout($session_id) - { + { global $app; - + if(empty($session_id)) { throw new SoapFault('session_id_empty', 'The SessionID is empty.'); return false; } - + $session_id = $app->db->quote($session_id); - + $sql = "DELETE FROM remote_session WHERE remote_session = '$session_id'"; $app->db->query($sql); - return ($app->db->affectedRows() == 1); + return $app->db->affectedRows() == 1; } - + //** protected functions ----------------------------------------------------------------------------------- - + protected function klientadd($formdef_file, $reseller_id, $params) - { + { global $app; - + //* Load the form definition $app->remoting_lib->loadFormDef($formdef_file); - + //* load the user profile of the client $app->remoting_lib->loadUserProfile($reseller_id); - + //* Get the SQL query - $sql = $app->remoting_lib->getSQL($params,'INSERT',0); - + $sql = $app->remoting_lib->getSQL($params, 'INSERT', 0); + //* Check if no system user with that username exists $username = $app->db->quote($params["username"]); $tmp = $app->db->queryOneRecord("SELECT count(userid) as number FROM sys_user WHERE username = '$username'"); if($tmp['number'] > 0) $app->remoting_lib->errorMessage .= "Duplicate username
"; - + //* Stop on error while preparing the sql query if($app->remoting_lib->errorMessage != '') { throw new SoapFault('data_processing_error', $app->remoting_lib->errorMessage); return false; } - + //* Execute the SQL query $app->db->query($sql); $insert_id = $app->db->insertID(); - - + + //* Stop on error while executing the sql query if($app->remoting_lib->errorMessage != '') { throw new SoapFault('data_processing_error', $app->remoting_lib->errorMessage); return false; } - + $this->id = $insert_id; $this->dataRecord = $params; - - $app->plugin->raiseEvent('client:' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . ':on_after_insert',$this); - + + $app->plugin->raiseEvent('client:' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . ':on_after_insert', $this); + /* if($app->db->errorMessage != '') { throw new SoapFault('database_error', $app->db->errorMessage . ' '.$sql); return false; } */ - - /* copied from the client_edit php */ + + /* copied from the client_edit php */ exec('ssh-keygen -t rsa -C '.$username.'-rsa-key-'.time().' -f /tmp/id_rsa -N ""'); $app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".$app->db->quote(@file_get_contents('/tmp/id_rsa'))."', ssh_rsa = '".$app->db->quote(@file_get_contents('/tmp/id_rsa.pub'))."' WHERE client_id = ".$this->id); exec('rm -f /tmp/id_rsa /tmp/id_rsa.pub'); - - - + + + //$app->uses('tform'); //* Save changes to Datalog if($app->remoting_lib->formDef["db_history"] == 'yes') { $new_rec = $app->remoting_lib->getDataRecord($insert_id); - $app->remoting_lib->datalogSave('INSERT',$primary_id,array(),$new_rec); - $app->remoting_lib->ispconfig_sysuser_add($params,$insert_id); + $app->remoting_lib->datalogSave('INSERT', $primary_id, array(), $new_rec); + $app->remoting_lib->ispconfig_sysuser_add($params, $insert_id); - if($reseller_id) { - $client_group = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = ".$insert_id); - $reseller_user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE client_id = ".$reseller_id); - $app->auth->add_group_to_user($reseller_user['userid'], $client_group['groupid']); - $app->db->query("UPDATE client SET parent_client_id = ".$reseller_id." WHERE client_id = ".$insert_id); - } + if($reseller_id) { + $client_group = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = ".$insert_id); + $reseller_user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE client_id = ".$reseller_id); + $app->auth->add_group_to_user($reseller_user['userid'], $client_group['groupid']); + $app->db->query("UPDATE client SET parent_client_id = ".$reseller_id." WHERE client_id = ".$insert_id); + } } return $insert_id; } - protected function insertQuery($formdef_file, $client_id, $params,$event_identifier = '') - { - $sql = $this->insertQueryPrepare($formdef_file, $client_id, $params); - if($sql !== false) return $this->insertQueryExecute($sql, $params,$event_identifier); - else return false; - } + protected function insertQuery($formdef_file, $client_id, $params, $event_identifier = '') + { + $sql = $this->insertQueryPrepare($formdef_file, $client_id, $params); + if($sql !== false) return $this->insertQueryExecute($sql, $params, $event_identifier); + else return false; + } protected function insertQueryPrepare($formdef_file, $client_id, $params) - { + { global $app; - + $app->uses('remoting_lib'); - + //* load the user profile of the client $app->remoting_lib->loadUserProfile($client_id); - + //* Load the form definition $app->remoting_lib->loadFormDef($formdef_file); - + //* Get the SQL query - $sql = $app->remoting_lib->getSQL($params,'INSERT',0); + $sql = $app->remoting_lib->getSQL($params, 'INSERT', 0); if($app->remoting_lib->errorMessage != '') { throw new SoapFault('data_processing_error', $app->remoting_lib->errorMessage); return false; } $app->log('Executed insertQueryPrepare', LOGLEVEL_DEBUG); - return $sql; + return $sql; } - - protected function insertQueryExecute($sql, $params,$event_identifier = '') - { + + protected function insertQueryExecute($sql, $params, $event_identifier = '') + { global $app; - + $app->uses('remoting_lib'); - + $app->db->query($sql); - + if($app->db->errorMessage != '') { throw new SoapFault('database_error', $app->db->errorMessage . ' '.$sql); return false; } - + $insert_id = $app->db->insertID(); - + // set a few values for compatibility with tform actions, mostly used by plugins $this->id = $insert_id; $this->dataRecord = $params; $app->log('Executed insertQueryExecute, raising events now if any: ' . $event_identifier, LOGLEVEL_DEBUG); - if($event_identifier != '') $app->plugin->raiseEvent($event_identifier,$this); - + if($event_identifier != '') $app->plugin->raiseEvent($event_identifier, $this); + //$app->uses('tform'); //* Save changes to Datalog if($app->remoting_lib->formDef["db_history"] == 'yes') { $new_rec = $app->remoting_lib->getDataRecord($insert_id); - $app->remoting_lib->datalogSave('INSERT',$primary_id,array(),$new_rec); - } + $app->remoting_lib->datalogSave('INSERT', $primary_id, array(), $new_rec); + } return $insert_id; } - + protected function updateQuery($formdef_file, $client_id, $primary_id, $params, $event_identifier = '') - { + { global $app; - + $sql = $this->updateQueryPrepare($formdef_file, $client_id, $primary_id, $params); - if($sql !== false) return $this->updateQueryExecute($sql, $primary_id, $params,$event_identifier); - else return false; + if($sql !== false) return $this->updateQueryExecute($sql, $primary_id, $params, $event_identifier); + else return false; } - + protected function updateQueryPrepare($formdef_file, $client_id, $primary_id, $params) - { + { global $app; - + $app->uses('remoting_lib'); - + //* load the user profile of the client $app->remoting_lib->loadUserProfile($client_id); - + //* Load the form definition $app->remoting_lib->loadFormDef($formdef_file); - + //* Get the SQL query - $sql = $app->remoting_lib->getSQL($params,'UPDATE',$primary_id); + $sql = $app->remoting_lib->getSQL($params, 'UPDATE', $primary_id); // throw new SoapFault('debug', $sql); if($app->remoting_lib->errorMessage != '') { throw new SoapFault('data_processing_error', $app->remoting_lib->errorMessage); return false; } - - return $sql; + + return $sql; } protected function updateQueryExecute($sql, $primary_id, $params, $event_identifier = '') - { + { global $app; - + $app->uses('remoting_lib'); - + $old_rec = $app->remoting_lib->getDataRecord($primary_id); - + // set a few values for compatibility with tform actions, mostly used by plugins $this->oldDataRecord = $old_rec; $this->id = $primary_id; $this->dataRecord = $params; - + $app->db->query($sql); - + if($app->db->errorMessage != '') { throw new SoapFault('database_error', $app->db->errorMessage . ' '.$sql); return false; } - + $affected_rows = $app->db->affectedRows(); $app->log('Executed updateQueryExecute, raising events now if any: ' . $event_identifier, LOGLEVEL_DEBUG); - - if($event_identifier != '') $app->plugin->raiseEvent($event_identifier,$this); - + + if($event_identifier != '') $app->plugin->raiseEvent($event_identifier, $this); + //* Save changes to Datalog if($app->remoting_lib->formDef["db_history"] == 'yes') { $new_rec = $app->remoting_lib->getDataRecord($primary_id); - $app->remoting_lib->datalogSave('UPDATE',$primary_id,$old_rec,$new_rec); + $app->remoting_lib->datalogSave('UPDATE', $primary_id, $old_rec, $new_rec); } - + return $affected_rows; } protected function deleteQuery($formdef_file, $primary_id, $event_identifier = '') - { + { global $app; - + $app->uses('remoting_lib'); - + //* load the user profile of the client $app->remoting_lib->loadUserProfile(0); - + //* Load the form definition $app->remoting_lib->loadFormDef($formdef_file); - + $old_rec = $app->remoting_lib->getDataRecord($primary_id); - + // set a few values for compatibility with tform actions, mostly used by plugins $this->oldDataRecord = $old_rec; $this->id = $primary_id; $this->dataRecord = $old_rec; $app->log('Executed deleteQuery, raising events now if any: ' . $event_identifier, LOGLEVEL_DEBUG); //$this->dataRecord = $params; - + //* Get the SQL query $sql = $app->remoting_lib->getDeleteSQL($primary_id); $app->db->errorMessage = ''; $app->db->query($sql); $affected_rows = $app->db->affectedRows(); - + if($app->db->errorMessage != '') { throw new SoapFault('database_error', $app->db->errorMessage . ' '.$sql); return false; } - + if($event_identifier != '') { - $app->plugin->raiseEvent($event_identifier,$this); + $app->plugin->raiseEvent($event_identifier, $this); } - + //* Save changes to Datalog if($app->remoting_lib->formDef["db_history"] == 'yes') { - $app->remoting_lib->datalogSave('DELETE',$primary_id,$old_rec,array()); + $app->remoting_lib->datalogSave('DELETE', $primary_id, $old_rec, array()); } - - + + return $affected_rows; } - - + + protected function checkPerm($session_id, $function_name) - { - global $app; - $dobre=array(); - $session = $this->getSession($session_id); - if(!$session){ - return false; - } - - $_SESSION['client_login'] = $session['client_login']; - if($session['client_login'] == 1) { - // permissions are checked at an other place - $_SESSION['client_sys_userid'] = $session['remote_userid']; - $app->remoting_lib->loadUserProfile(); // load the profile - we ALWAYS need this on client logins! - return true; - } else { - $_SESSION['client_sys_userid'] = 0; - } - - $dobre= str_replace(';',',',$session['remote_functions']); + { + global $app; + $dobre=array(); + $session = $this->getSession($session_id); + if(!$session){ + return false; + } + + $_SESSION['client_login'] = $session['client_login']; + if($session['client_login'] == 1) { + // permissions are checked at an other place + $_SESSION['client_sys_userid'] = $session['remote_userid']; + $app->remoting_lib->loadUserProfile(); // load the profile - we ALWAYS need this on client logins! + return true; + } else { + $_SESSION['client_sys_userid'] = 0; + } + + $dobre= str_replace(';', ',', $session['remote_functions']); $check = in_array($function_name, explode(',', $dobre) ); if(!$check) { - $app->log("REMOTE-LIB DENY: ".$session_id ." /". $function_name, LOGLEVEL_WARN); + $app->log("REMOTE-LIB DENY: ".$session_id ." /". $function_name, LOGLEVEL_WARN); } return $check; } - - + + protected function getSession($session_id) - { + { global $app; - + if(empty($session_id)) { - throw new SoapFault('session_id_empty','The SessionID is empty.'); + throw new SoapFault('session_id_empty', 'The SessionID is empty.'); return false; } - + $session_id = $app->db->quote($session_id); - + $now = time(); $sql = "SELECT * FROM remote_session WHERE remote_session = '$session_id' AND tstamp >= $now"; $session = $app->db->queryOneRecord($sql); if($session['remote_userid'] > 0) { return $session; } else { - throw new SoapFault('session_does_not_exist','The Session is expired or does not exist.'); + throw new SoapFault('session_does_not_exist', 'The Session is expired or does not exist.'); return false; } } - - // needed from inside the remoting plugins - public function server_get($session_id, $server_id, $section ='') { - global $app; - if(!$this->checkPerm($session_id, 'server_get')) { - throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); - return false; - } - if (!empty($session_id) && !empty($server_id)) { - $app->uses('remoting_lib , getconf'); - $section_config = $app->getconf->get_server_config($server_id,$section); - return $section_config; - } else { - return false; - } - } - + + // needed from inside the remoting plugins + public function server_get($session_id, $server_id, $section ='') { + global $app; + if(!$this->checkPerm($session_id, 'server_get')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if (!empty($session_id) && !empty($server_id)) { + $app->uses('remoting_lib , getconf'); + $section_config = $app->getconf->get_server_config($server_id, $section); + return $section_config; + } else { + return false; + } + } + /** - * Get a list of functions - * @param int session id - * @return mixed array of the available functions - * @author Julio Montoya BeezNest 2010 - */ - public function get_function_list($session_id) - { - if(!$this->checkPerm($session_id, 'get_function_list')) { + * Get a list of functions + * @param int session id + * @return mixed array of the available functions + * @author Julio Montoya BeezNest 2010 + */ + + + public function get_function_list($session_id) + { + if(!$this->checkPerm($session_id, 'get_function_list')) { throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); return false; - } - return $this->_methods; - } - + } + return $this->_methods; + } + } + ?> diff --git a/interface/lib/classes/remoting_lib.inc.php b/interface/lib/classes/remoting_lib.inc.php index f163a870b..5d1b23d24 100644 --- a/interface/lib/classes/remoting_lib.inc.php +++ b/interface/lib/classes/remoting_lib.inc.php @@ -35,285 +35,289 @@ Copyright (c) Tri-Plex technology */ /** -* Formularbehandlung -* -* Functions to validate, display and save form values -* -* Database table field definitions -* -* Datatypes: -* - INTEGER (Converts data to int automatically) -* - DOUBLE -* - CURRENCY (Formats digits in currency notation) -* - VARCHAR (No format check) -* - DATE (Date format, converts from and to UNIX timestamps automatically) -* -* Formtype: -* - TEXT (Normal text field) -* - PASSWORD (password field, the content will not be displayed again to the user) -* - SELECT (Option fiield) -* - MULTIPLE (Allows selection of multiple values) -* -* VALUE: -* - Value or array -* -* SEPARATOR -* - separator char used for fileds with multiple values -* -* Hint: The auto increment (ID) filed of the table has not be be definied separately. -* -*/ + * Formularbehandlung + * + * Functions to validate, display and save form values + * + * Database table field definitions + * + * Datatypes: + * - INTEGER (Converts data to int automatically) + * - DOUBLE + * - CURRENCY (Formats digits in currency notation) + * - VARCHAR (No format check) + * - DATE (Date format, converts from and to UNIX timestamps automatically) + * + * Formtype: + * - TEXT (Normal text field) + * - PASSWORD (password field, the content will not be displayed again to the user) + * - SELECT (Option fiield) + * - MULTIPLE (Allows selection of multiple values) + * + * VALUE: + * - Value or array + * + * SEPARATOR + * - separator char used for fileds with multiple values + * + * Hint: The auto increment (ID) filed of the table has not be be definied separately. + * + */ + + global $app; $app->load('tform_base'); class remoting_lib extends tform_base { - - - // additional class variables - var $sys_username; - var $sys_userid; - var $sys_default_group; - var $sys_groups; - var $client_id; - var $dataRecord; - - - //* Load the form definition from file. - special version for remoting - // module parameter is only for compatibility with base class - function loadFormDef($file, $module = '') { - global $app,$conf; - - include($file); - - $this->formDef = $form; - unset($this->formDef['tabs']); - - //* Copy all fields from all tabs into one form definition - foreach($form['tabs'] as $tab) { - foreach($tab['fields'] as $key => $value) { - $this->formDef['fields'][$key] = $value; - } + + + // additional class variables + var $sys_username; + var $sys_userid; + var $sys_default_group; + var $sys_groups; + var $client_id; + var $dataRecord; + + + //* Load the form definition from file. - special version for remoting + // module parameter is only for compatibility with base class + function loadFormDef($file, $module = '') { + global $app, $conf; + + include $file; + + $this->formDef = $form; + unset($this->formDef['tabs']); + + //* Copy all fields from all tabs into one form definition + foreach($form['tabs'] as $tab) { + foreach($tab['fields'] as $key => $value) { + $this->formDef['fields'][$key] = $value; } - unset($form); - - $this->dateformat = $app->lng('conf_format_dateshort'); - - return true; - } - - //* Load the user profile - function loadUserProfile($client_id_param = 0) { - global $app,$conf; - - $client_login = false; - if(isset($_SESSION['client_login']) && isset($_SESSION['client_sys_userid']) && $_SESSION['client_login'] == 1) { - $client_sys_userid = $app->functions->intval($_SESSION['client_sys_userid']); - - $client = $app->db->queryOneRecord("SELECT client.client_id FROM sys_user, client WHERE sys_user.client_id = client.client_id and sys_user.userid = " . $client_sys_userid); - - $this->client_id = $client['client_id']; - $client_login = true; - } else { - $this->client_id = $app->functions->intval($client_id_param); - } - - if($this->client_id == 0) { - $this->sys_username = 'admin'; - $this->sys_userid = 1; - $this->sys_default_group = 1; - $this->sys_groups = 1; - $_SESSION["s"]["user"]["typ"] = 'admin'; - } else { - //* load system user - try with sysuser and before with userid (workarrond) - /* + } + unset($form); + + $this->dateformat = $app->lng('conf_format_dateshort'); + + return true; + } + + //* Load the user profile + function loadUserProfile($client_id_param = 0) { + global $app, $conf; + + $client_login = false; + if(isset($_SESSION['client_login']) && isset($_SESSION['client_sys_userid']) && $_SESSION['client_login'] == 1) { + $client_sys_userid = $app->functions->intval($_SESSION['client_sys_userid']); + + $client = $app->db->queryOneRecord("SELECT client.client_id FROM sys_user, client WHERE sys_user.client_id = client.client_id and sys_user.userid = " . $client_sys_userid); + + $this->client_id = $client['client_id']; + $client_login = true; + } else { + $this->client_id = $app->functions->intval($client_id_param); + } + + if($this->client_id == 0) { + $this->sys_username = 'admin'; + $this->sys_userid = 1; + $this->sys_default_group = 1; + $this->sys_groups = 1; + $_SESSION["s"]["user"]["typ"] = 'admin'; + } else { + //* load system user - try with sysuser and before with userid (workarrond) + /* $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE sysuser_id = $client_id"); if(empty($user["userid"])) { - $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $client_id"); + $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $client_id"); if(empty($user["userid"])) { $this->errorMessage .= "No sysuser with the ID $client_id found."; return false; } }*/ - - $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE client_id = $this->client_id"); - $this->sys_username = $user['username']; - $this->sys_userid = $user['userid']; - $this->sys_default_group = $user['default_group']; - $this->sys_groups = $user['groups']; - // $_SESSION["s"]["user"]["typ"] = $user['typ']; - // we have to force admin priveliges for the remoting API as some function calls might fail otherwise. - if($client_login == false) $_SESSION["s"]["user"]["typ"] = 'admin'; - } - - $_SESSION["s"]["user"]["username"] = $this->sys_username; - $_SESSION["s"]["user"]["userid"] = $this->sys_userid; - $_SESSION["s"]["user"]["default_group"] = $this->sys_default_group; - $_SESSION["s"]["user"]["groups"] = $this->sys_groups; - $_SESSION["s"]["user"]["client_id"] = $this->client_id; - return true; - } - - - /** - * Converts the data in the array to human readable format - * Datatype conversion e.g. to show the data in lists - * tab parameter is only there for compatibility with params of base class - * - * @param record - * @return record - */ - function decode($record, $tab = '') { - return $this->_decode($record, '', true); - } - - /** - * Get the key => value array of a form filled from a datasource definitiom - * dummy parameter is only there for compatibility with params of base class - * - * @param field = array with field definition - * @param record = Dataset as array - * @return key => value array for the value field of a form - */ - - function getDatasourceData($field, $record, $dummy = '') { - return $this->_getDatasourceData($field, $record, true); - } - - /** - /** - * Rewrite the record data to be stored in the database - * and check values with regular expressions. - * dummy parameter is only there for compatibility with params of base class - * - * @param record = Datensatz als Array - * @return record - */ - function encode($record,$dbencode = true, $dummy = '') { - $new_record = $this->_encode($record, '', $dbencode, true); - if(isset($record['_ispconfig_pw_crypted'])) $new_record['_ispconfig_pw_crypted'] = $record['_ispconfig_pw_crypted']; // this one is not in form definitions! - - return $new_record; - } - - /** - * Create SQL statement - * dummy parameter is only there for compatibility with params of base class - * - * @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 = '', $dummy = '') { - - global $app; - - if(!is_array($this->formDef)) $app->error("Form definition not found."); - $this->dataRecord = $record; - - return $this->_getSQL($record, '', $action, $primary_id, $sql_ext_where, true); - } - - function getDeleteSQL($primary_id) { - - if(stristr($this->formDef['db_table'],'.')) { - $escape = ''; - } else { - $escape = '`'; - } - - $sql = "DELETE FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id. " AND " . $this->getAuthSQL('d', $this->formDef['db_table']); - return $sql; + $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE client_id = $this->client_id"); + $this->sys_username = $user['username']; + $this->sys_userid = $user['userid']; + $this->sys_default_group = $user['default_group']; + $this->sys_groups = $user['groups']; + // $_SESSION["s"]["user"]["typ"] = $user['typ']; + // we have to force admin priveliges for the remoting API as some function calls might fail otherwise. + if($client_login == false) $_SESSION["s"]["user"]["typ"] = 'admin'; } - function getDataRecord($primary_id) { - global $app; + $_SESSION["s"]["user"]["username"] = $this->sys_username; + $_SESSION["s"]["user"]["userid"] = $this->sys_userid; + $_SESSION["s"]["user"]["default_group"] = $this->sys_default_group; + $_SESSION["s"]["user"]["groups"] = $this->sys_groups; + $_SESSION["s"]["user"]["client_id"] = $this->client_id; + + return true; + } + + + /** + * Converts the data in the array to human readable format + * Datatype conversion e.g. to show the data in lists + * tab parameter is only there for compatibility with params of base class + * + * @param record + * @return record + */ + function decode($record, $tab = '') { + return $this->_decode($record, '', true); + } + + + /** + * Get the key => value array of a form filled from a datasource definitiom + * dummy parameter is only there for compatibility with params of base class + * + * @param field = array with field definition + * @param record = Dataset as array + * @return key => value array for the value field of a form + */ + function getDatasourceData($field, $record, $dummy = '') { + return $this->_getDatasourceData($field, $record, true); + } + + + /** + /** + * Rewrite the record data to be stored in the database + * and check values with regular expressions. + * dummy parameter is only there for compatibility with params of base class + * + * @param record = Datensatz als Array + * @return record + */ + function encode($record, $dbencode = true, $dummy = '') { + $new_record = $this->_encode($record, '', $dbencode, true); + if(isset($record['_ispconfig_pw_crypted'])) $new_record['_ispconfig_pw_crypted'] = $record['_ispconfig_pw_crypted']; // this one is not in form definitions! + + return $new_record; + } + + + /** + * Create SQL statement + * dummy parameter is only there for compatibility with params of base class + * + * @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 = '', $dummy = '') { + + global $app; + + if(!is_array($this->formDef)) $app->error("Form definition not found."); + $this->dataRecord = $record; + + return $this->_getSQL($record, '', $action, $primary_id, $sql_ext_where, true); + } + + function getDeleteSQL($primary_id) { + + if(stristr($this->formDef['db_table'], '.')) { + $escape = ''; + } else { $escape = '`'; - if(@is_numeric($primary_id)) { - return parent::getDataRecord($primary_id); - } elseif (@is_array($primary_id) || @is_object($primary_id)) { - if(@is_object($primary_id)) $primary_id = get_object_vars($primary_id); // do not use cast (array)xxx because it returns private and protected properties! - $sql_offset = 0; - $sql_limit = 0; - $sql_where = ''; - foreach($primary_id as $key => $val) { - $key = $app->db->quote($key); - $val = $app->db->quote($val); - if($key == '#OFFSET#') $sql_offset = $app->functions->intval($val); - elseif($key == '#LIMIT#') $sql_limit = $app->functions->intval($val); - elseif(stristr($val,'%')) { - $sql_where .= "$key like '$val' AND "; - } else { - $sql_where .= "$key = '$val' AND "; - } - } - $sql_where = substr($sql_where,0,-5); - if($sql_where == '') $sql_where = '1'; - $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$sql_where. " AND " . $this->getAuthSQL('r', $this->formDef['db_table']); - if($sql_offset >= 0 && $sql_limit > 0) $sql .= ' LIMIT ' . $sql_offset . ',' . $sql_limit; - return $app->db->queryAllRecords($sql); - } else { - $this->errorMessage = 'The ID must be either an integer or an array.'; - return array(); - } } - function ispconfig_sysuser_add($params,$insert_id){ - global $conf,$app,$sql1; - $username = $app->db->quote($params["username"]); - $password = $app->db->quote($params["password"]); - if(!isset($params['modules'])) { - $modules = $conf['interface_modules_enabled']; - } else { - $modules = $app->db->quote($params['modules']); - } - if(isset($params['limit_client']) && $params['limit_client'] > 0) { - $modules .= ',client'; - } - - if(!isset($params['startmodule'])) { - $startmodule = 'dashboard'; - } else { - $startmodule = $app->db->quote($params["startmodule"]); - if(!preg_match('/'.$startmodule.'/',$modules)) { - $_modules = explode(',',$modules); - $startmodule=$_modules[0]; + $sql = "DELETE FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id. " AND " . $this->getAuthSQL('d', $this->formDef['db_table']); + return $sql; + } + + function getDataRecord($primary_id) { + global $app; + $escape = '`'; + if(@is_numeric($primary_id)) { + return parent::getDataRecord($primary_id); + } elseif (@is_array($primary_id) || @is_object($primary_id)) { + if(@is_object($primary_id)) $primary_id = get_object_vars($primary_id); // do not use cast (array)xxx because it returns private and protected properties! + $sql_offset = 0; + $sql_limit = 0; + $sql_where = ''; + foreach($primary_id as $key => $val) { + $key = $app->db->quote($key); + $val = $app->db->quote($val); + if($key == '#OFFSET#') $sql_offset = $app->functions->intval($val); + elseif($key == '#LIMIT#') $sql_limit = $app->functions->intval($val); + elseif(stristr($val, '%')) { + $sql_where .= "$key like '$val' AND "; + } else { + $sql_where .= "$key = '$val' AND "; } } - $usertheme = $app->db->quote($params["usertheme"]); - $type = 'user'; - $active = 1; - $insert_id = $app->functions->intval($insert_id); - $language = $app->db->quote($params["language"]); - $groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('$username','','$insert_id')", 'groupid'); - $groups = $groupid; - if(!isset($params['_ispconfig_pw_crypted']) || $params['_ispconfig_pw_crypted'] != 1) $password = $app->auth->crypt_password(stripslashes($password)); - $sql1 = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id) - VALUES ('$username','$password','$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,$insert_id)"; - $app->db->query($sql1); + $sql_where = substr($sql_where, 0, -5); + if($sql_where == '') $sql_where = '1'; + $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$sql_where. " AND " . $this->getAuthSQL('r', $this->formDef['db_table']); + if($sql_offset >= 0 && $sql_limit > 0) $sql .= ' LIMIT ' . $sql_offset . ',' . $sql_limit; + return $app->db->queryAllRecords($sql); + } else { + $this->errorMessage = 'The ID must be either an integer or an array.'; + return array(); } - - function ispconfig_sysuser_update($params,$client_id){ - global $app; - $username = $app->db->quote($params["username"]); - $clear_password = $app->db->quote($params["password"]); - $client_id = $app->functions->intval($client_id); - if(!isset($params['_ispconfig_pw_crypted']) || $params['_ispconfig_pw_crypted'] != 1) $password = $app->auth->crypt_password(stripslashes($clear_password)); - else $password = $clear_password; - if ($clear_password) $pwstring = ", passwort = '$password'"; else $pwstring ="" ; - $sql = "UPDATE sys_user set username = '$username' $pwstring WHERE client_id = $client_id"; - $app->db->query($sql); + } + + function ispconfig_sysuser_add($params, $insert_id){ + global $conf, $app, $sql1; + $username = $app->db->quote($params["username"]); + $password = $app->db->quote($params["password"]); + if(!isset($params['modules'])) { + $modules = $conf['interface_modules_enabled']; + } else { + $modules = $app->db->quote($params['modules']); } - - function ispconfig_sysuser_delete($client_id){ - global $app; - $client_id = $app->functions->intval($client_id); - $sql = "DELETE FROM sys_user WHERE client_id = $client_id"; - $app->db->query($sql); - $sql = "DELETE FROM sys_group WHERE client_id = $client_id"; - $app->db->query($sql); + if(isset($params['limit_client']) && $params['limit_client'] > 0) { + $modules .= ',client'; } + if(!isset($params['startmodule'])) { + $startmodule = 'dashboard'; + } else { + $startmodule = $app->db->quote($params["startmodule"]); + if(!preg_match('/'.$startmodule.'/', $modules)) { + $_modules = explode(',', $modules); + $startmodule=$_modules[0]; + } + } + $usertheme = $app->db->quote($params["usertheme"]); + $type = 'user'; + $active = 1; + $insert_id = $app->functions->intval($insert_id); + $language = $app->db->quote($params["language"]); + $groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('$username','','$insert_id')", 'groupid'); + $groups = $groupid; + if(!isset($params['_ispconfig_pw_crypted']) || $params['_ispconfig_pw_crypted'] != 1) $password = $app->auth->crypt_password(stripslashes($password)); + $sql1 = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id) + VALUES ('$username','$password','$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,$insert_id)"; + $app->db->query($sql1); + } + + function ispconfig_sysuser_update($params, $client_id){ + global $app; + $username = $app->db->quote($params["username"]); + $clear_password = $app->db->quote($params["password"]); + $client_id = $app->functions->intval($client_id); + if(!isset($params['_ispconfig_pw_crypted']) || $params['_ispconfig_pw_crypted'] != 1) $password = $app->auth->crypt_password(stripslashes($clear_password)); + else $password = $clear_password; + if ($clear_password) $pwstring = ", passwort = '$password'"; else $pwstring ="" ; + $sql = "UPDATE sys_user set username = '$username' $pwstring WHERE client_id = $client_id"; + $app->db->query($sql); + } + + function ispconfig_sysuser_delete($client_id){ + global $app; + $client_id = $app->functions->intval($client_id); + $sql = "DELETE FROM sys_user WHERE client_id = $client_id"; + $app->db->query($sql); + $sql = "DELETE FROM sys_group WHERE client_id = $client_id"; + $app->db->query($sql); + } + } ?> diff --git a/interface/lib/classes/searchform.inc.php b/interface/lib/classes/searchform.inc.php index e87547a9d..cfa8f2836 100644 --- a/interface/lib/classes/searchform.inc.php +++ b/interface/lib/classes/searchform.inc.php @@ -30,224 +30,225 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class searchform { - public $debug = 0; - public $errorMessage; - public $listDef; - public $searchValues; - public $pagingHTML; - public $pagingValues; - public $searchChanged = 0; - public $module; - - public function loadListDef($file, $module = '') - { - global $app, $conf; - if(!is_file($file)){ - die("List-Definition: $file not found."); - } - include_once($file); - $this->listDef = $liste; - $this->module = $module; - + public $debug = 0; + public $errorMessage; + public $listDef; + public $searchValues; + public $pagingHTML; + public $pagingValues; + public $searchChanged = 0; + public $module; + + public function loadListDef($file, $module = '') + { + global $app, $conf; + if(!is_file($file)){ + die("List-Definition: $file not found."); + } + include_once $file; + $this->listDef = $liste; + $this->module = $module; + //* Fill datasources foreach($this->listDef['item'] as $key => $field) { if(is_array($field['datasource'])) { - $this->listDef['item'][$key]['value'] = $this->getDatasourceData($field); - } - } - return true; - } - + $this->listDef['item'][$key]['value'] = $this->getDatasourceData($field); + } + } + return true; + } + /** - * Get the key => value array of a form filed from a datasource definitiom - * - * @param field = array with field definition - * @param record = Dataset as array - * @return key => value array for the value field of a form - */ - - public function getDatasourceData($field) - { - global $app; - $values = array(); - - if($field['datasource']['type'] == 'SQL') { - //* Preparing SQL string. We will replace some common placeholders - $querystring = $field['datasource']['querystring']; - $querystring = str_replace('{USERID}', $_SESSION['s']['user']['userid'], $querystring); - $querystring = str_replace('{GROUPID}', $_SESSION['s']['user']['default_group'], $querystring); - $querystring = str_replace('{GROUPS}', $_SESSION['s']['user']['groups'], $querystring); - $table_idx = $this->formDef['db_table_idx']; - //$querystring = str_replace('{RECORDID}',$record[$table_idx],$querystring); - $app->uses('tform'); - $querystring = str_replace('{AUTHSQL}', $app->tform->getAuthSQL('r'), $querystring); - - //* Getting the records - $tmp_records = $app->db->queryAllRecords($querystring); - if($app->db->errorMessage != ''){ - die($app->db->errorMessage); - } - if(is_array($tmp_records)) { - $key_field = $field['datasource']['keyfield']; - $value_field = $field['datasource']['valuefield']; - foreach($tmp_records as $tmp_rec) { - $values[$tmp_rec[$key_field]] = $tmp_rec[$value_field]; - } - } - } - if($field['datasource']['type'] == 'CUSTOM') { - //* Calls a custom class to validate this record - if($field['datasource']['class'] != '' and $field['datasource']['function'] != '') { - $datasource_class = $field['datasource']['class']; - $datasource_function = $field['datasource']['function']; - $app->uses($datasource_class); - $record = array(); - $values = $app->$datasource_class->$datasource_function($field, $record); - }else{ - $this->errorMessage .= "Custom datasource class or function is empty
\r\n"; - } - } - return $values; - } - - public function getSearchSQL($sql_where = '') - { - global $db; - - //* Config vars - $list_name = $this->listDef['name']; - $search_prefix = $this->listDef['search_prefix']; - - //* store retrieval query - foreach($this->listDef['item'] as $i) { - $field = $i['field']; - - //* TODO ? hat sich die suche ge�ndert - has itself search ? - $ki = $search_prefix.$field; - if(isset($_REQUEST) and $_REQUEST[$ki] != $_SESSION['search'][$list_name][$ki]){ - $this->searchChanged = 1; - } - - //* suchfield in session store. - if(isset($_REQUEST[$ki])){ - $_SESSION['search'][$list_name][$ki] = $_REQUEST[$ki]; - } - - if($i['formtype'] == 'SELECT'){ - if(is_array($i['value'])) { - $out = ''; - foreach($i['value'] as $k => $v) { - $selected = ($k == $_SESSION['search'][$list_name][$ki] && $_SESSION['search'][$list_name][$ki] != '') ? ' SELECTED' : ''; - $out .= "\r\n"; - } - } - $this->searchValues[$ki] = $out; - }else{ - $this->searchValues[$ki] = $_SESSION['search'][$list_name][$ki]; - } - } - - //* store variables in object. $this->searchValues = $_SESSION["search"][$list_name]; - foreach($this->listDef['item'] as $i) { - $field = $i['field']; - //if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and"; + * Get the key => value array of a form filed from a datasource definitiom + * + * @param field = array with field definition + * @param record = Dataset as array + * @return key => value array for the value field of a form + */ + + + public function getDatasourceData($field) + { + global $app; + $values = array(); + + if($field['datasource']['type'] == 'SQL') { + //* Preparing SQL string. We will replace some common placeholders + $querystring = $field['datasource']['querystring']; + $querystring = str_replace('{USERID}', $_SESSION['s']['user']['userid'], $querystring); + $querystring = str_replace('{GROUPID}', $_SESSION['s']['user']['default_group'], $querystring); + $querystring = str_replace('{GROUPS}', $_SESSION['s']['user']['groups'], $querystring); + $table_idx = $this->formDef['db_table_idx']; + //$querystring = str_replace('{RECORDID}',$record[$table_idx],$querystring); + $app->uses('tform'); + $querystring = str_replace('{AUTHSQL}', $app->tform->getAuthSQL('r'), $querystring); + + //* Getting the records + $tmp_records = $app->db->queryAllRecords($querystring); + if($app->db->errorMessage != ''){ + die($app->db->errorMessage); + } + if(is_array($tmp_records)) { + $key_field = $field['datasource']['keyfield']; + $value_field = $field['datasource']['valuefield']; + foreach($tmp_records as $tmp_rec) { + $values[$tmp_rec[$key_field]] = $tmp_rec[$value_field]; + } + } + } + if($field['datasource']['type'] == 'CUSTOM') { + //* Calls a custom class to validate this record + if($field['datasource']['class'] != '' and $field['datasource']['function'] != '') { + $datasource_class = $field['datasource']['class']; + $datasource_function = $field['datasource']['function']; + $app->uses($datasource_class); + $record = array(); + $values = $app->$datasource_class->$datasource_function($field, $record); + }else{ + $this->errorMessage .= "Custom datasource class or function is empty
\r\n"; + } + } + return $values; + } + + public function getSearchSQL($sql_where = '') + { + global $db; + + //* Config vars + $list_name = $this->listDef['name']; + $search_prefix = $this->listDef['search_prefix']; + + //* store retrieval query + foreach($this->listDef['item'] as $i) { + $field = $i['field']; + + //* TODO ? hat sich die suche ge�ndert - has itself search ? + $ki = $search_prefix.$field; + if(isset($_REQUEST) and $_REQUEST[$ki] != $_SESSION['search'][$list_name][$ki]){ + $this->searchChanged = 1; + } + + //* suchfield in session store. + if(isset($_REQUEST[$ki])){ + $_SESSION['search'][$list_name][$ki] = $_REQUEST[$ki]; + } + + if($i['formtype'] == 'SELECT'){ + if(is_array($i['value'])) { + $out = ''; + foreach($i['value'] as $k => $v) { + $selected = ($k == $_SESSION['search'][$list_name][$ki] && $_SESSION['search'][$list_name][$ki] != '') ? ' SELECTED' : ''; + $out .= "\r\n"; + } + } + $this->searchValues[$ki] = $out; + }else{ + $this->searchValues[$ki] = $_SESSION['search'][$list_name][$ki]; + } + } + + //* store variables in object. $this->searchValues = $_SESSION["search"][$list_name]; + foreach($this->listDef['item'] as $i) { + $field = $i['field']; + //if($_REQUEST[$search_prefix.$field] != '') $sql_where .= " $field ".$i["op"]." '".$i["prefix"].$_REQUEST[$search_prefix.$field].$i["suffix"]."' and"; if($_SESSION['search'][$list_name][$ki] != ''){ - $sql_where .= " $field ".$i['op']." '".$i['prefix'].$_SESSION['search'][$list_name][$ki].$i['suffix']."' and"; - } - } - return ($sql_where != '') ? substr($sql_where, 0, -3) : '1'; - } - - public function getPagingSQL($sql_where = '1') { - global $app, $conf; - - $list_name = $this->listDef['name']; - $search_prefix = $this->listDef['search_prefix']; - $records_per_page = $this->listDef['records_per_page']; - $table = $this->listDef['table']; - - //* set page to seror id session not set - if($_SESSION['search'][$list_name]['page'] == '') $_SESSION['search'][$list_name]['page'] = 0; - - //* Set page size to request if set - if(isset($_REQUEST['page'])) $_SESSION['search'][$list_name]['page'] = $_REQUEST['page']; - - //* TODO PAGE to 0 set, if look for themselves ge?ndert. = page auf 0 setzen, wenn suche sich ge�ndert hat. - if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0; - - $sql_von = $_SESSION['search'][$list_name]['page'] * $records_per_page; - $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table WHERE $sql_where"); - $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); - - $vars['list_file'] = $this->listDef['file']; - $vars['page'] = $_SESSION['search'][$list_name]['page']; - $vars['last_page'] = $_SESSION['search'][$list_name]['page'] - 1; - $vars['next_page'] = $_SESSION['search'][$list_name]['page'] + 1; - $vars['pages'] = $pages; - $vars['max_pages'] = $pages + 1; - $vars['records_gesamt'] = $record_count['anzahl']; - $vars['page_params'] = $this->listDef['page_params']; - - if($_SESSION['search'][$list_name]['page'] > 0) $vars['show_page_back'] = 1; - if($_SESSION['search'][$list_name]['page'] <= $vars['pages'] - 1) $vars['show_page_next'] = 1; - - $this->pagingValues = $vars; - $this->pagingHTML = $this->getPagingHTML($vars); - - return "LIMIT $sql_von, $records_per_page"; - } - - public function getPagingHTML($vars) { - global $app; - $page_params = $vars['page_params']; - $list_file = $vars['list_file']; - $content = '   '; - if($vars['show_page_back'] == 1){ - $content .= ' '; - } - $content .= ' '.$app->lng('Page').' '.$vars['next_page'].' '.$app->lng('of').' '.$vars['max_pages'].' '; - if($vars['show_page_next'] == 1){ - $content .= '   '; - } else{ - $content .= ' '; - } - $content .= ' '; - return $content; - } - - public function getPagingHTMLasTXT($vars) - { - global $app; - $page_params = $vars['page_params']; - $list_file = $vars['list_file']; - $content = '[|<< ]'; - if($vars['show_page_back'] == 1){ - $content .= '[<< '.$app->lng('Back').'] '; - } - $content .= ' '.$app->lng('Page').' '.$vars['next_page'].' '.$app->lng('of').' '.$vars['max_pages'].' '; - if($vars['show_page_next'] == 1){ - $content .= '['.$app->lng('Next').' >>] '; - } - $content .= '[ >>|]'; - return $content; - } - - public function getSortSQL() - { - $sort_field = $this->listDef['sort_field']; - $sort_direction = $this->listDef['sort_direction']; - return ($sort_field != '' && $sort_direction != '') ? "ORDER BY $sort_field $sort_direction" : ''; - } - + $sql_where .= " $field ".$i['op']." '".$i['prefix'].$_SESSION['search'][$list_name][$ki].$i['suffix']."' and"; + } + } + return ($sql_where != '') ? substr($sql_where, 0, -3) : '1'; + } + + public function getPagingSQL($sql_where = '1') { + global $app, $conf; + + $list_name = $this->listDef['name']; + $search_prefix = $this->listDef['search_prefix']; + $records_per_page = $this->listDef['records_per_page']; + $table = $this->listDef['table']; + + //* set page to seror id session not set + if($_SESSION['search'][$list_name]['page'] == '') $_SESSION['search'][$list_name]['page'] = 0; + + //* Set page size to request if set + if(isset($_REQUEST['page'])) $_SESSION['search'][$list_name]['page'] = $_REQUEST['page']; + + //* TODO PAGE to 0 set, if look for themselves ge?ndert. = page auf 0 setzen, wenn suche sich ge�ndert hat. + if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0; + + $sql_von = $_SESSION['search'][$list_name]['page'] * $records_per_page; + $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM $table WHERE $sql_where"); + $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); + + $vars['list_file'] = $this->listDef['file']; + $vars['page'] = $_SESSION['search'][$list_name]['page']; + $vars['last_page'] = $_SESSION['search'][$list_name]['page'] - 1; + $vars['next_page'] = $_SESSION['search'][$list_name]['page'] + 1; + $vars['pages'] = $pages; + $vars['max_pages'] = $pages + 1; + $vars['records_gesamt'] = $record_count['anzahl']; + $vars['page_params'] = $this->listDef['page_params']; + + if($_SESSION['search'][$list_name]['page'] > 0) $vars['show_page_back'] = 1; + if($_SESSION['search'][$list_name]['page'] <= $vars['pages'] - 1) $vars['show_page_next'] = 1; + + $this->pagingValues = $vars; + $this->pagingHTML = $this->getPagingHTML($vars); + + return "LIMIT $sql_von, $records_per_page"; + } + + public function getPagingHTML($vars) { + global $app; + $page_params = $vars['page_params']; + $list_file = $vars['list_file']; + $content = '   '; + if($vars['show_page_back'] == 1){ + $content .= ' '; + } + $content .= ' '.$app->lng('Page').' '.$vars['next_page'].' '.$app->lng('of').' '.$vars['max_pages'].' '; + if($vars['show_page_next'] == 1){ + $content .= '   '; + } else{ + $content .= ' '; + } + $content .= ' '; + return $content; + } + + public function getPagingHTMLasTXT($vars) + { + global $app; + $page_params = $vars['page_params']; + $list_file = $vars['list_file']; + $content = '[|<< ]'; + if($vars['show_page_back'] == 1){ + $content .= '[<< '.$app->lng('Back').'] '; + } + $content .= ' '.$app->lng('Page').' '.$vars['next_page'].' '.$app->lng('of').' '.$vars['max_pages'].' '; + if($vars['show_page_next'] == 1){ + $content .= '['.$app->lng('Next').' >>] '; + } + $content .= '[ >>|]'; + return $content; + } + + public function getSortSQL() + { + $sort_field = $this->listDef['sort_field']; + $sort_direction = $this->listDef['sort_direction']; + return ($sort_field != '' && $sort_direction != '') ? "ORDER BY $sort_field $sort_direction" : ''; + } + public function saveSearchSettings($searchresult_name) - { + { global $app, $conf; - + $list_name = $this->listDef['name']; $settings = $_SESSION['search'][$list_name]; unset($settings['page']); $data = $app->db->quote(serialize($settings)); - + $userid = $_SESSION['s']['user']['userid']; $groupid = $_SESSION['s']['user']['default_group']; $sys_perm_user = 'riud'; @@ -256,92 +257,93 @@ class searchform { $module = $_SESSION['s']['module']['name']; $searchform = $this->listDef['name']; $title = $searchresult_name; - + $sql = 'INSERT INTO `searchform` ( ' - .'`sys_userid` , `sys_groupid` , `sys_perm_user` , `sys_perm_group` , `sys_perm_other` , `module` , `searchform` , `title` , `data` ' - .')VALUES (' - ."'$userid', '$groupid', '$sys_perm_user', '$sys_perm_group', '$sys_perm_other', '$module', '$searchform', '$title', '$data')"; + .'`sys_userid` , `sys_groupid` , `sys_perm_user` , `sys_perm_group` , `sys_perm_other` , `module` , `searchform` , `title` , `data` ' + .')VALUES (' + ."'$userid', '$groupid', '$sys_perm_user', '$sys_perm_group', '$sys_perm_other', '$module', '$searchform', '$title', '$data')"; $app->db->query($sql); } - public function decode($record) - { - global $app; - if(is_array($record)) { - foreach($this->listDef['item'] as $field) { - $key = $field['field']; - switch ($field['datatype']) - { - case 'DATE': - if($val > 0) { - $record[$key] = date($this->dateformat, $record[$key]); - } - break; - - case 'INTEGER': - $record[$key] = $app->functions->intval($record[$key]); - break; - - case 'DOUBLE': - $record[$key] = $record[$key]; - break; - - case 'CURRENCY': - $record[$key] = number_format($record[$key], 2, ',', ''); - break; - - - case 'VARCHAR': - case 'TEXT': - default: - $record[$key] = stripslashes($record[$key]); - break; - } - } - } - return $record; - } - - public function encode($record) - { - global $app; - if(is_array($record)) { - foreach($this->listDef['item'] as $field) { - $key = $field['field']; - switch ($field['datatype']) - { - case 'VARCHAR': - case 'TEXT': - if(!is_array($record[$key])) { - $record[$key] = $app->db->quote($record[$key]); - } else { - $record[$key] = implode($this->tableDef[$key]['separator'],$record[$key]); - } - break; - - case 'DATE': - if($record[$key] > 0) { - list($tag, $monat, $jahr) = explode('.', $record[$key]); - $record[$key] = mktime(0, 0, 0, $monat, $tag, $jahr); - } - break; - - case 'INTEGER': - $record[$key] = $app->functions->intval($record[$key]); - break; - - case 'DOUBLE': - $record[$key] = $app->db->quote($record[$key]); - break; - - case 'CURRENCY': - $record[$key] = str_replace(',', '.', $record[$key]); - break; - } - } - } - return $record; - } + public function decode($record) + { + global $app; + if(is_array($record)) { + foreach($this->listDef['item'] as $field) { + $key = $field['field']; + switch ($field['datatype']) + { + case 'DATE': + if($val > 0) { + $record[$key] = date($this->dateformat, $record[$key]); + } + break; + + case 'INTEGER': + $record[$key] = $app->functions->intval($record[$key]); + break; + + case 'DOUBLE': + $record[$key] = $record[$key]; + break; + + case 'CURRENCY': + $record[$key] = number_format($record[$key], 2, ',', ''); + break; + + + case 'VARCHAR': + case 'TEXT': + default: + $record[$key] = stripslashes($record[$key]); + break; + } + } + } + return $record; + } + + public function encode($record) + { + global $app; + if(is_array($record)) { + foreach($this->listDef['item'] as $field) { + $key = $field['field']; + switch ($field['datatype']) + { + case 'VARCHAR': + case 'TEXT': + if(!is_array($record[$key])) { + $record[$key] = $app->db->quote($record[$key]); + } else { + $record[$key] = implode($this->tableDef[$key]['separator'], $record[$key]); + } + break; + + case 'DATE': + if($record[$key] > 0) { + list($tag, $monat, $jahr) = explode('.', $record[$key]); + $record[$key] = mktime(0, 0, 0, $monat, $tag, $jahr); + } + break; + + case 'INTEGER': + $record[$key] = $app->functions->intval($record[$key]); + break; + + case 'DOUBLE': + $record[$key] = $app->db->quote($record[$key]); + break; + + case 'CURRENCY': + $record[$key] = str_replace(',', '.', $record[$key]); + break; + } + } + } + return $record; + } + } ?> diff --git a/interface/lib/classes/searchform_actions.inc.php b/interface/lib/classes/searchform_actions.inc.php index a451f4a85..e48eb8544 100644 --- a/interface/lib/classes/searchform_actions.inc.php +++ b/interface/lib/classes/searchform_actions.inc.php @@ -29,44 +29,44 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class searchform_actions { - + var $id; var $idx_key; var $DataRowColor; var $SQLExtWhere = ''; var $SQLOrderBy = ''; - + function onLoad() { global $app, $conf, $list_def_file; - + if(!is_object($app->tpl)) $app->uses('tpl'); if(!is_object($app->searchform)) $app->uses('searchform'); if(!is_object($app->tform)) $app->uses('tform'); - + // Load list definition $app->searchform->loadListDef($list_def_file); - + // Delete the search form contents, if requested if($_REQUEST["empty_searchfields"] == 'yes') { $list_name = $app->searchform->listDef["name"]; unset($_SESSION["search"][$list_name]); } - + // Save the search for later usage if($_REQUEST["btn_submit_search_save"] && $_REQUEST["search_save_as"] != '') { $app->searchform->saveSearchSettings($_REQUEST["search_save_as"]); } - + // Set th returnto value for forms $_SESSION["s"]["form"]["return_to_url"] = $app->searchform->listDef["file"]; - + if(!is_file('templates/'.$app->searchform->listDef["name"].'_search.htm')) { $app->uses('searchform_tpl_generator'); $app->searchform_tpl_generator->buildHTML($app->searchform->listDef); } - + $app->tpl->newTemplate("searchpage.tpl.htm"); - $app->tpl->setInclude('content_tpl','templates/'.$app->searchform->listDef["name"].'_search.htm'); + $app->tpl->setInclude('content_tpl', 'templates/'.$app->searchform->listDef["name"].'_search.htm'); // Getting Datasets from DB $records = $app->db->queryAllRecords($this->getQueryString()); @@ -74,30 +74,30 @@ class searchform_actions { $this->DataRowColor = "#FFFFFF"; if(is_array($records)) { - $this->idx_key = $app->searchform->listDef["table_idx"]; + $this->idx_key = $app->searchform->listDef["table_idx"]; foreach($records as $rec) { $records_new[] = $this->prepareDataRow($rec); } } - $app->tpl->setLoop('records',$records_new); - + $app->tpl->setLoop('records', $records_new); + //print_r($records_new); $this->onShow(); - - + + } - + function prepareDataRow($rec) { global $app; - + $rec = $app->searchform->decode($rec); // Alternating datarow colors $this->DataRowColor = ($this->DataRowColor == "#FFFFFF")?"#EEEEEE":"#FFFFFF"; $rec["bgcolor"] = $this->DataRowColor; - + // substitute value for select fields foreach($app->searchform->listDef["item"] as $field) { $key = $field["field"]; @@ -110,16 +110,16 @@ class searchform_actions { $rec[$key] = $field['value'][$rec[$key]]; } } - + // The variable "id" contains always the index variable $rec["id"] = $rec[$this->idx_key]; - + return $rec; } - + function getQueryString() { global $app; - + // Generate the search sql if($app->searchform->listDef["auth"] != 'no') { if($_SESSION["s"]["user"]["typ"] == "admin") { @@ -128,74 +128,75 @@ class searchform_actions { $sql_where = $app->tform->getAuthSQL('r')." and"; } } - + if($this->SQLExtWhere != '') { $sql_where .= " ".$this->SQLExtWhere." and"; } $sql_where = $app->searchform->getSearchSQL($sql_where); $app->tpl->setVar($app->searchform->searchValues); - + $order_by_sql = $this->SQLOrderBy; // Generate SQL for paging $limit_sql = $app->searchform->getPagingSQL($sql_where); - $app->tpl->setVar("paging",$app->searchform->pagingHTML); + $app->tpl->setVar("paging", $app->searchform->pagingHTML); return "SELECT * FROM ".$app->searchform->listDef["table"]." WHERE $sql_where $order_by_sql $limit_sql"; - + } - - + + function onShow() { global $app; - + // Language File setzen $lng_file = ISPC_WEB_PATH.'/lang/lib/lang/'.$_SESSION['s']['language'].'_list.lng'; if(!file_exists($lng_file)) $lng_file = ISPC_WEB_PATH.'/lang/lib/lang/en_'.'_list.lng'; - include($lng_file); + include $lng_file; $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$app->searchform->listDef['name']."_search.lng"; if(!file_exists($lng_file)) $lng_file = 'lib/lang/en_'.$app->searchform->listDef['name']."_search.lng"; - include($lng_file); + include $lng_file; $app->tpl->setVar($wb); - $app->tpl->setVar("form_action",$app->searchform->listDef["file"]); - + $app->tpl->setVar("form_action", $app->searchform->listDef["file"]); + // Parse the templates and send output to the browser $this->onShowEnd(); } - + function onShowEnd() { global $app; if(count($_REQUEST) > 0) { - $app->tpl->setVar('searchresult_visible',1); - if($_REQUEST['searchresult_visible'] == 'no') $app->tpl->setVar('searchresult_visible',0); - + $app->tpl->setVar('searchresult_visible', 1); + if($_REQUEST['searchresult_visible'] == 'no') $app->tpl->setVar('searchresult_visible', 0); + if($_REQUEST['searchform_visible'] == 'yes') { - $app->tpl->setVar('searchform_visible',1); + $app->tpl->setVar('searchform_visible', 1); } else { - $app->tpl->setVar('searchform_visible',0); + $app->tpl->setVar('searchform_visible', 0); } } else { - $app->tpl->setVar('searchform_visible',1); - if($_REQUEST['searchform_visible'] == 'no') $app->tpl->setVar('searchform_visible',0); - + $app->tpl->setVar('searchform_visible', 1); + if($_REQUEST['searchform_visible'] == 'no') $app->tpl->setVar('searchform_visible', 0); + if($_REQUEST['searchresult_visible'] == 'yes') { - $app->tpl->setVar('searchresult_visible',1); + $app->tpl->setVar('searchresult_visible', 1); } else { - $app->tpl->setVar('searchresult_visible',0); + $app->tpl->setVar('searchresult_visible', 0); } } - + // make columns visible - $visible_columns = explode(",",$app->searchform->listDef['default_columns']); + $visible_columns = explode(",", $app->searchform->listDef['default_columns']); foreach($visible_columns as $col) { - $app->tpl->setVar($col.'_visible',1); + $app->tpl->setVar($col.'_visible', 1); } - + $app->tpl_defaults(); $app->tpl->pparse(); } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/searchform_tpl_generator.inc.php b/interface/lib/classes/searchform_tpl_generator.inc.php index 4232e3b9d..81e2f4ef1 100644 --- a/interface/lib/classes/searchform_tpl_generator.inc.php +++ b/interface/lib/classes/searchform_tpl_generator.inc.php @@ -29,11 +29,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class searchform_tpl_generator { - - function buildHTML($listDef,$module = '') { - + + function buildHTML($listDef, $module = '') { + global $app; - + $lang = array(); $html = '

@@ -43,23 +43,23 @@ class searchform_tpl_generator { $lang["list_head_txt"] = $listDef["name"]; foreach($listDef["item"] as $field) { $key = $field["field"]; - + if($field["formtype"] == 'SELECT') { $html .= " : "; - } else { + } else { $html .= " : "; - } + } } -$html .= ' + $html .= ' @@ -67,14 +67,14 @@ $html .= '

-[Neue Suche] +[Neue Suche] [Suchkriterien ändern] -Suche speichern unter: +Suche speichern unter:

'; - + $lang["list_head_txt"] = $listDef["name"]; foreach($listDef["item"] as $field) { $key = $field["field"]; @@ -83,25 +83,25 @@ Suche speichern unter: "; $lang[$key."_txt"] = $key; } - + $html .= ' '; - + foreach($listDef["item"] as $field) { $key = $field["field"]; $html .= ""; $html .= " \r\n"; $html .= ""; } - + $html .= " "; - $html .= ' + $html .= '
 
{tmpl_var name=\"".$key."\"}[{tmpl_var name='delete_txt'}]
@@ -109,28 +109,28 @@ Suche speichern unter: \ No newline at end of file +?> diff --git a/interface/lib/classes/session.inc.php b/interface/lib/classes/session.inc.php index dc1280069..be0ca84ab 100644 --- a/interface/lib/classes/session.inc.php +++ b/interface/lib/classes/session.inc.php @@ -29,101 +29,101 @@ 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; - } - + $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)) { + 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(); - } - + $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'"); + $this->db->query("UPDATE sys_session SET last_updated = '$last_updated' WHERE session_id = '$session_id'"); return true; } - - if (@$this->session_array['session_id'] == '') { + + 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); + $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); + } 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'"; + $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; - } - + } + + 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; - } - + + 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); - + $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; - - } + + return true; + + } function __destruct () { - @session_write_close(); + @session_write_close(); - } + } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/simplepie.inc.php b/interface/lib/classes/simplepie.inc.php index 4fcb2c3a7..5d36c09d3 100644 --- a/interface/lib/classes/simplepie.inc.php +++ b/interface/lib/classes/simplepie.inc.php @@ -11,16 +11,16 @@ * 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 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. + * * 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 the SimplePie Team nor the names of its contributors may be used - * to endorse or promote products derived from this software without specific prior - * written permission. + * * Neither the name of the SimplePie Team 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 @@ -43,6 +43,7 @@ * @todo phpDoc comments */ + /** * SimplePie Name */ @@ -395,6 +396,7 @@ define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); */ class simplepie { + /** * @var array Raw data * @access private @@ -711,6 +713,7 @@ class simplepie */ var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); + /** * The SimplePie class contains feed level data and options * @@ -756,6 +759,7 @@ class simplepie } } + /** * Used for converting object to a string */ @@ -764,6 +768,7 @@ class simplepie return md5(serialize($this->data)); } + /** * Remove items that link back to this before destroying this object */ @@ -790,6 +795,7 @@ class simplepie } } + /** * Force the given data/URL to be treated as a feed no matter what it * appears like @@ -803,6 +809,7 @@ class simplepie $this->force_feed = (bool) $enable; } + /** * This is the URL of the feed you want to parse. * @@ -835,6 +842,7 @@ class simplepie } } + /** * Provides an instance of SimplePie_File to use as a feed * @@ -853,6 +861,7 @@ class simplepie return false; } + /** * Allows you to use a string of RSS/Atom data instead of a remote feed. * @@ -870,6 +879,7 @@ class simplepie $this->raw_data = $data; } + /** * Allows you to override the default timeout for fetching remote feeds. * @@ -885,6 +895,7 @@ class simplepie $this->timeout = (int) $timeout; } + /** * Forces SimplePie to use fsockopen() instead of the preferred cURL * functions. @@ -898,6 +909,7 @@ class simplepie $this->force_fsockopen = (bool) $enable; } + /** * Outputs the raw XML content of the feed, after it has gone through * SimplePie's filters. @@ -918,6 +930,7 @@ class simplepie $this->xml_dump = (bool) $enable; } + /** * Enables/disables caching in SimplePie. * @@ -933,6 +946,7 @@ class simplepie $this->cache = (bool) $enable; } + /** * Set the length of time (in seconds) that the contents of a feed * will be cached. @@ -945,6 +959,7 @@ class simplepie $this->cache_duration = (int) $seconds; } + /** * Set the length of time (in seconds) that the autodiscovered feed * URL will be cached. @@ -957,6 +972,7 @@ class simplepie $this->autodiscovery_cache_duration = (int) $seconds; } + /** * Set the file system location where the cached files should be stored. * @@ -968,6 +984,7 @@ class simplepie $this->cache_location = (string) $location; } + /** * Determines whether feed items should be sorted into reverse chronological order. * @@ -979,6 +996,7 @@ class simplepie $this->order_by_date = (bool) $enable; } + /** * Allows you to override the character encoding reported by the feed. * @@ -997,6 +1015,7 @@ class simplepie } } + /** * Set how much feed autodiscovery to do * @@ -1016,6 +1035,7 @@ class simplepie $this->autodiscovery = (int) $level; } + /** * Allows you to change which class SimplePie uses for caching. * Useful when you are overloading or extending SimplePie's default classes. @@ -1035,6 +1055,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for auto-discovery. * Useful when you are overloading or extending SimplePie's default classes. @@ -1054,6 +1075,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for XML parsing. * Useful when you are overloading or extending SimplePie's default classes. @@ -1073,6 +1095,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for remote file fetching. * Useful when you are overloading or extending SimplePie's default classes. @@ -1092,6 +1115,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for data sanitization. * Useful when you are overloading or extending SimplePie's default classes. @@ -1111,6 +1135,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for handling feed items. * Useful when you are overloading or extending SimplePie's default classes. @@ -1130,6 +1155,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for handling author data. * Useful when you are overloading or extending SimplePie's default classes. @@ -1149,6 +1175,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for handling category data. * Useful when you are overloading or extending SimplePie's default classes. @@ -1168,6 +1195,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for feed enclosures. * Useful when you are overloading or extending SimplePie's default classes. @@ -1187,6 +1215,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for captions * Useful when you are overloading or extending SimplePie's default classes. @@ -1206,6 +1235,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for * Useful when you are overloading or extending SimplePie's default classes. @@ -1225,6 +1255,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for * Useful when you are overloading or extending SimplePie's default classes. @@ -1244,6 +1275,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for * Useful when you are overloading or extending SimplePie's default classes. @@ -1263,6 +1295,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for * Useful when you are overloading or extending SimplePie's default classes. @@ -1282,6 +1315,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses for content-type sniffing. * Useful when you are overloading or extending SimplePie's default classes. @@ -1301,6 +1335,7 @@ class simplepie return false; } + /** * Allows you to change which class SimplePie uses item sources. * Useful when you are overloading or extending SimplePie's default classes. @@ -1320,6 +1355,7 @@ class simplepie return false; } + /** * Allows you to override the default user agent string. * @@ -1331,6 +1367,7 @@ class simplepie $this->useragent = (string) $ua; } + /** * Set callback function to create cache filename with * @@ -1345,6 +1382,7 @@ class simplepie } } + /** * Set javascript query string parameter * @@ -1363,6 +1401,7 @@ class simplepie } } + /** * Set options to make SP as fast as possible. Forgoes a * substantial amount of data sanitization in favor of speed. @@ -1383,6 +1422,7 @@ class simplepie } } + /** * Set maximum number of feeds to check with autodiscovery * @@ -1436,6 +1476,7 @@ class simplepie $this->sanitize->strip_comments($strip); } + /** * Set element/attribute key/value pairs of HTML attributes * containing URLs that need to be resolved relative to the feed @@ -1449,6 +1490,7 @@ class simplepie $this->sanitize->set_url_replacements($element_attribute); } + /** * Set the handler to enable the display of cached favicons. * @@ -1468,6 +1510,7 @@ class simplepie } } + /** * Set the handler to enable the display of cached images. * @@ -1487,6 +1530,7 @@ class simplepie } } + /** * Set the limit for items returned per-feed with multifeeds. * @@ -1830,6 +1874,7 @@ class simplepie } } + /** * Return the error message for the occured error * @@ -1879,16 +1924,16 @@ class simplepie elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) { if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) { $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10; } if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) { $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; } @@ -1900,38 +1945,38 @@ class simplepie { switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) { - case '0.91': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) + case '0.91': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) + { + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) { - switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) - { - case '0': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; - break; + case '0': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; + break; - case '24': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; - break; - } + case '24': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; + break; } - break; + } + break; - case '0.92': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; - break; + case '0.92': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; + break; - case '0.93': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; - break; + case '0.93': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; + break; - case '0.94': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; - break; + case '0.94': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; + break; - case '2.0': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; - break; + case '2.0': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; + break; } } } @@ -1943,6 +1988,7 @@ class simplepie return $this->data['type']; } + /** * Returns the URL for the favicon of the feed's website. * @@ -2004,6 +2050,7 @@ class simplepie return false; } + /** * @todo If we have a perm redirect we should return the new URL * @todo When we make the above change, let's support as well @@ -2069,6 +2116,7 @@ class simplepie } } + /** * Creates the subscribe_* methods' return data * @@ -2577,6 +2625,7 @@ class simplepie } } + /** * Added for parity between the parent-level and the item/entry-level. */ @@ -2774,7 +2823,7 @@ class simplepie function get_latitude() { - + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) { return (float) $return[0]['data']; @@ -3048,6 +3097,7 @@ class simplepie } } + /** * @static */ @@ -3056,6 +3106,7 @@ class simplepie return $a->get_date('U') <= $b->get_date('U'); } + /** * @static */ @@ -3106,6 +3157,7 @@ class simplepie return array(); } } + } class SimplePie_Item @@ -3124,6 +3176,7 @@ class SimplePie_Item return md5(serialize($this->data)); } + /** * Remove items that link back to this before destroying this object */ @@ -3621,14 +3674,14 @@ class SimplePie_Item $date_format = (string) $date_format; switch ($date_format) { - case '': - return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); + case '': + return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); - case 'U': - return $this->data['date']['parsed']; + case 'U': + return $this->data['date']['parsed']; - default: - return date($date_format, $this->data['date']['parsed']); + default: + return date($date_format, $this->data['date']['parsed']); } } else @@ -3758,6 +3811,7 @@ class SimplePie_Item } } + /** * @todo Add ability to prefer one type of content over another (in a media group). */ @@ -3774,6 +3828,7 @@ class SimplePie_Item } } + /** * Grabs all available enclosures (podcasts, etc.) * @@ -5626,6 +5681,7 @@ class SimplePie_Item } } + /** * Creates the add_to_* methods' return data * @@ -5725,6 +5781,7 @@ class SimplePie_Item { return $this->add_to_service('http://www.technorati.com/search/'); } + } class SimplePie_Source @@ -6043,6 +6100,7 @@ class SimplePie_Source } } + /** * Added for parity between the parent-level and the item/entry-level. */ @@ -6276,6 +6334,7 @@ class SimplePie_Source return null; } } + } class SimplePie_Author @@ -6333,6 +6392,7 @@ class SimplePie_Author return null; } } + } class SimplePie_Category @@ -6390,6 +6450,7 @@ class SimplePie_Category return $this->get_term(); } } + } class SimplePie_Enclosure @@ -6914,6 +6975,7 @@ class SimplePie_Enclosure return $this->embed($options, true); } + /** * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. */ @@ -6950,45 +7012,45 @@ class SimplePie_Enclosure $opt[1] = trim($opt[1]); switch ($opt[0]) { - case 'audio': - $audio = $opt[1]; - break; + case 'audio': + $audio = $opt[1]; + break; - case 'video': - $video = $opt[1]; - break; + case 'video': + $video = $opt[1]; + break; - case 'alt': - $alt = $opt[1]; - break; + case 'alt': + $alt = $opt[1]; + break; - case 'altclass': - $altclass = $opt[1]; - break; + case 'altclass': + $altclass = $opt[1]; + break; - case 'loop': - $loop = $opt[1]; - break; + case 'loop': + $loop = $opt[1]; + break; - case 'width': - $width = $opt[1]; - break; + case 'width': + $width = $opt[1]; + break; - case 'height': - $height = $opt[1]; - break; + case 'height': + $height = $opt[1]; + break; - case 'bgcolor': - $bgcolor = $opt[1]; - break; + case 'bgcolor': + $bgcolor = $opt[1]; + break; - case 'mediaplayer': - $mediaplayer = $opt[1]; - break; + case 'mediaplayer': + $mediaplayer = $opt[1]; + break; - case 'widescreen': - $widescreen = $opt[1]; - break; + case 'widescreen': + $widescreen = $opt[1]; + break; } } } @@ -7175,7 +7237,7 @@ class SimplePie_Enclosure // Mime-types by handler. $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash - $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player + $types_fmedia = array('video/flv', 'video/x-flv', 'flv-application/octet-stream'); // Flash Media Player $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 @@ -7195,121 +7257,121 @@ class SimplePie_Enclosure switch (strtolower($this->get_extension())) { // Audio mime-types - case 'aac': - case 'adts': - $type = 'audio/acc'; - break; + case 'aac': + case 'adts': + $type = 'audio/acc'; + break; - case 'aif': - case 'aifc': - case 'aiff': - case 'cdda': - $type = 'audio/aiff'; - break; + case 'aif': + case 'aifc': + case 'aiff': + case 'cdda': + $type = 'audio/aiff'; + break; - case 'bwf': - $type = 'audio/wav'; - break; + case 'bwf': + $type = 'audio/wav'; + break; - case 'kar': - case 'mid': - case 'midi': - case 'smf': - $type = 'audio/midi'; - break; + case 'kar': + case 'mid': + case 'midi': + case 'smf': + $type = 'audio/midi'; + break; - case 'm4a': - $type = 'audio/x-m4a'; - break; + case 'm4a': + $type = 'audio/x-m4a'; + break; - case 'mp3': - case 'swa': - $type = 'audio/mp3'; - break; + case 'mp3': + case 'swa': + $type = 'audio/mp3'; + break; - case 'wav': - $type = 'audio/wav'; - break; + case 'wav': + $type = 'audio/wav'; + break; - case 'wax': - $type = 'audio/x-ms-wax'; - break; + case 'wax': + $type = 'audio/x-ms-wax'; + break; - case 'wma': - $type = 'audio/x-ms-wma'; - break; + case 'wma': + $type = 'audio/x-ms-wma'; + break; // Video mime-types - case '3gp': - case '3gpp': - $type = 'video/3gpp'; - break; + case '3gp': + case '3gpp': + $type = 'video/3gpp'; + break; - case '3g2': - case '3gp2': - $type = 'video/3gpp2'; - break; + case '3g2': + case '3gp2': + $type = 'video/3gpp2'; + break; - case 'asf': - $type = 'video/x-ms-asf'; - break; + case 'asf': + $type = 'video/x-ms-asf'; + break; - case 'flv': - $type = 'video/x-flv'; - break; + case 'flv': + $type = 'video/x-flv'; + break; - case 'm1a': - case 'm1s': - case 'm1v': - case 'm15': - case 'm75': - case 'mp2': - case 'mpa': - case 'mpeg': - case 'mpg': - case 'mpm': - case 'mpv': - $type = 'video/mpeg'; - break; + case 'm1a': + case 'm1s': + case 'm1v': + case 'm15': + case 'm75': + case 'mp2': + case 'mpa': + case 'mpeg': + case 'mpg': + case 'mpm': + case 'mpv': + $type = 'video/mpeg'; + break; - case 'm4v': - $type = 'video/x-m4v'; - break; + case 'm4v': + $type = 'video/x-m4v'; + break; - case 'mov': - case 'qt': - $type = 'video/quicktime'; - break; + case 'mov': + case 'qt': + $type = 'video/quicktime'; + break; - case 'mp4': - case 'mpg4': - $type = 'video/mp4'; - break; + case 'mp4': + case 'mpg4': + $type = 'video/mp4'; + break; - case 'sdv': - $type = 'video/sd-video'; - break; + case 'sdv': + $type = 'video/sd-video'; + break; - case 'wm': - $type = 'video/x-ms-wm'; - break; + case 'wm': + $type = 'video/x-ms-wm'; + break; - case 'wmv': - $type = 'video/x-ms-wmv'; - break; + case 'wmv': + $type = 'video/x-ms-wmv'; + break; - case 'wvx': - $type = 'video/x-ms-wvx'; - break; + case 'wvx': + $type = 'video/x-ms-wvx'; + break; // Flash mime-types - case 'spl': - $type = 'application/futuresplash'; - break; + case 'spl': + $type = 'application/futuresplash'; + break; - case 'swf': - $type = 'application/x-shockwave-flash'; - break; + case 'swf': + $type = 'application/x-shockwave-flash'; + break; } } @@ -7345,6 +7407,7 @@ class SimplePie_Enclosure return $type; } } + } class SimplePie_Caption @@ -7430,6 +7493,7 @@ class SimplePie_Caption return null; } } + } class SimplePie_Credit @@ -7487,6 +7551,7 @@ class SimplePie_Credit return null; } } + } class SimplePie_Copyright @@ -7530,6 +7595,7 @@ class SimplePie_Copyright return null; } } + } class SimplePie_Rating @@ -7573,6 +7639,7 @@ class SimplePie_Rating return null; } } + } class SimplePie_Restriction @@ -7630,6 +7697,7 @@ class SimplePie_Restriction return null; } } + } /** @@ -7810,35 +7878,35 @@ class SimplePie_File // Hey, we act dumb elsewhere, so let's do that here too switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) { - case 'gzip': - case 'x-gzip': - $decoder = new SimplePie_gzdecode($this->body); - if (!$decoder->parse()) - { - $this->error = 'Unable to decode HTTP "gzip" stream'; - $this->success = false; - } - else - { - $this->body = $decoder->data; - } - break; + case 'gzip': + case 'x-gzip': + $decoder = new SimplePie_gzdecode($this->body); + if (!$decoder->parse()) + { + $this->error = 'Unable to decode HTTP "gzip" stream'; + $this->success = false; + } + else + { + $this->body = $decoder->data; + } + break; - case 'deflate': - if (($body = gzuncompress($this->body)) === false) + case 'deflate': + if (($body = gzuncompress($this->body)) === false) + { + if (($body = gzinflate($this->body)) === false) { - if (($body = gzinflate($this->body)) === false) - { - $this->error = 'Unable to decode HTTP "deflate" stream'; - $this->success = false; - } + $this->error = 'Unable to decode HTTP "deflate" stream'; + $this->success = false; } - $this->body = $body; - break; + } + $this->body = $body; + break; - default: - $this->error = 'Unknown content coding'; - $this->success = false; + default: + $this->error = 'Unknown content coding'; + $this->success = false; } } } @@ -7862,6 +7930,7 @@ class SimplePie_File } } } + } /** @@ -7871,6 +7940,7 @@ class SimplePie_File */ class SimplePie_HTTP_Parser { + /** * HTTP Version * @@ -7959,6 +8029,7 @@ class SimplePie_HTTP_Parser */ var $value = ''; + /** * Create an instance of the class with the input data * @@ -7971,6 +8042,7 @@ class SimplePie_HTTP_Parser $this->data_length = strlen($this->data); } + /** * Parse the input data * @@ -8000,6 +8072,7 @@ class SimplePie_HTTP_Parser } } + /** * Check whether there is data beyond the pointer * @@ -8011,6 +8084,7 @@ class SimplePie_HTTP_Parser return (bool) ($this->position < $this->data_length); } + /** * See if the next character is LWS * @@ -8026,6 +8100,7 @@ class SimplePie_HTTP_Parser && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20"))); } + /** * Parse the HTTP version * @@ -8055,6 +8130,7 @@ class SimplePie_HTTP_Parser } } + /** * Parse the status code * @@ -8074,6 +8150,7 @@ class SimplePie_HTTP_Parser } } + /** * Parse the reason phrase * @@ -8087,6 +8164,7 @@ class SimplePie_HTTP_Parser $this->state = 'new_line'; } + /** * Deal with a new line, shifting data around as needed * @@ -8125,6 +8203,7 @@ class SimplePie_HTTP_Parser } } + /** * Parse a header name * @@ -8153,6 +8232,7 @@ class SimplePie_HTTP_Parser } } + /** * Parse LWS, replacing consecutive LWS characters with a single space * @@ -8175,6 +8255,7 @@ class SimplePie_HTTP_Parser $this->value .= "\x20"; } + /** * See what state to move to while within non-quoted header values * @@ -8190,23 +8271,24 @@ class SimplePie_HTTP_Parser { switch ($this->data[$this->position]) { - case '"': - $this->position++; - $this->state = 'quote'; - break; + case '"': + $this->position++; + $this->state = 'quote'; + break; - case "\x0A": - $this->position++; - $this->state = 'new_line'; - break; + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; - default: - $this->state = 'value_char'; - break; + default: + $this->state = 'value_char'; + break; } } } + /** * Parse a header value while outside quotes * @@ -8220,6 +8302,7 @@ class SimplePie_HTTP_Parser $this->state = 'value'; } + /** * See what state to move to while within quoted header values * @@ -8235,28 +8318,29 @@ class SimplePie_HTTP_Parser { switch ($this->data[$this->position]) { - case '"': - $this->position++; - $this->state = 'value'; - break; + case '"': + $this->position++; + $this->state = 'value'; + break; - case "\x0A": - $this->position++; - $this->state = 'new_line'; - break; + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; - case '\\': - $this->position++; - $this->state = 'quote_escaped'; - break; + case '\\': + $this->position++; + $this->state = 'quote_escaped'; + break; - default: - $this->state = 'quote_char'; - break; + default: + $this->state = 'quote_char'; + break; } } } + /** * Parse a header value while within quotes * @@ -8270,6 +8354,7 @@ class SimplePie_HTTP_Parser $this->state = 'value'; } + /** * Parse an escaped character within quotes * @@ -8282,6 +8367,7 @@ class SimplePie_HTTP_Parser $this->state = 'quote'; } + /** * Parse the body * @@ -8292,6 +8378,7 @@ class SimplePie_HTTP_Parser $this->body = substr($this->data, $this->position); $this->state = 'emit'; } + } /** @@ -8301,6 +8388,7 @@ class SimplePie_HTTP_Parser */ class SimplePie_gzdecode { + /** * Compressed data * @@ -8407,6 +8495,7 @@ class SimplePie_gzdecode */ var $comment; + /** * Don't allow anything to be set * @@ -8417,6 +8506,7 @@ class SimplePie_gzdecode trigger_error("Cannot write property $name", E_USER_ERROR); } + /** * Set the compressed string and related properties * @@ -8428,6 +8518,7 @@ class SimplePie_gzdecode $this->compressed_size = strlen($data); } + /** * Decode the GZIP stream * @@ -8602,10 +8693,13 @@ class SimplePie_gzdecode return false; } } + } class SimplePie_Cache { + + /** * Don't call the constructor. Please. * @@ -8616,6 +8710,7 @@ class SimplePie_Cache trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR); } + /** * Create a new SimplePie_Cache object * @@ -8627,17 +8722,18 @@ class SimplePie_Cache $location_iri = new SimplePie_IRI($location); switch ($location_iri->get_scheme()) { - case 'mysql': - if (extension_loaded('mysql')) - { - return new SimplePie_Cache_MySQL($location_iri, $filename, $extension); - } - break; + case 'mysql': + if (extension_loaded('mysql')) + { + return new SimplePie_Cache_MySQL($location_iri, $filename, $extension); + } + break; - default: - return new SimplePie_Cache_File($location, $filename, $extension); + default: + return new SimplePie_Cache_File($location, $filename, $extension); } } + } class SimplePie_Cache_File @@ -8719,6 +8815,7 @@ class SimplePie_Cache_File } return false; } + } class SimplePie_Cache_DB @@ -8799,6 +8896,7 @@ class SimplePie_Cache_DB } return array(serialize($data->data), $items_by_id); } + } class SimplePie_Cache_MySQL extends SimplePie_Cache_DB @@ -9071,6 +9169,7 @@ class SimplePie_Cache_MySQL extends SimplePie_Cache_DB return false; } } + } class SimplePie_Misc @@ -9225,18 +9324,18 @@ class SimplePie_Misc { switch ($level) { - case E_USER_ERROR: - $note = 'PHP Error'; - break; - case E_USER_WARNING: - $note = 'PHP Warning'; - break; - case E_USER_NOTICE: - $note = 'PHP Notice'; - break; - default: - $note = 'Unknown Error'; - break; + case E_USER_ERROR: + $note = 'PHP Error'; + break; + case E_USER_WARNING: + $note = 'PHP Warning'; + break; + case E_USER_NOTICE: + $note = 'PHP Notice'; + break; + default: + $note = 'Unknown Error'; + break; } $log_error = true; @@ -9260,6 +9359,7 @@ class SimplePie_Misc return $message; } + /** * If a file has been cached, retrieve and display it. * @@ -9378,6 +9478,7 @@ class SimplePie_Misc } } + /** * Remove bad UTF-8 bytes * @@ -9413,6 +9514,7 @@ class SimplePie_Misc } } + /** * Converts a Windows-1252 encoded string to a UTF-8 encoded string * @@ -9474,1314 +9576,1314 @@ class SimplePie_Misc // Normalization from UTS #22 switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) { - case 'adobestandardencoding': - case 'csadobestandardencoding': - return 'Adobe-Standard-Encoding'; - - case 'adobesymbolencoding': - case 'cshppsmath': - return 'Adobe-Symbol-Encoding'; - - case 'ami1251': - case 'amiga1251': - return 'Amiga-1251'; - - case 'ansix31101983': - case 'csat5001983': - case 'csiso99naplps': - case 'isoir99': - case 'naplps': - return 'ANSI_X3.110-1983'; - - case 'arabic7': - case 'asmo449': - case 'csiso89asmo449': - case 'iso9036': - case 'isoir89': - return 'ASMO_449'; - - case 'big5': - case 'csbig5': - case 'xxbig5': - return 'Big5'; - - case 'big5hkscs': - return 'Big5-HKSCS'; - - case 'bocu1': - case 'csbocu1': - return 'BOCU-1'; - - case 'brf': - case 'csbrf': - return 'BRF'; - - case 'bs4730': - case 'csiso4unitedkingdom': - case 'gb': - case 'iso646gb': - case 'isoir4': - case 'uk': - return 'BS_4730'; - - case 'bsviewdata': - case 'csiso47bsviewdata': - case 'isoir47': - return 'BS_viewdata'; - - case 'cesu8': - case 'cscesu8': - return 'CESU-8'; - - case 'ca': - case 'csa71': - case 'csaz243419851': - case 'csiso121canadian1': - case 'iso646ca': - case 'isoir121': - return 'CSA_Z243.4-1985-1'; - - case 'csa72': - case 'csaz243419852': - case 'csiso122canadian2': - case 'iso646ca2': - case 'isoir122': - return 'CSA_Z243.4-1985-2'; - - case 'csaz24341985gr': - case 'csiso123csaz24341985gr': - case 'isoir123': - return 'CSA_Z243.4-1985-gr'; - - case 'csiso139csn369103': - case 'csn369103': - case 'isoir139': - return 'CSN_369103'; - - case 'csdecmcs': - case 'dec': - case 'decmcs': - return 'DEC-MCS'; - - case 'csiso21german': - case 'de': - case 'din66003': - case 'iso646de': - case 'isoir21': - return 'DIN_66003'; - - case 'csdkus': - case 'dkus': - return 'dk-us'; - - case 'csiso646danish': - case 'dk': - case 'ds2089': - case 'iso646dk': - return 'DS_2089'; - - case 'csibmebcdicatde': - case 'ebcdicatde': - return 'EBCDIC-AT-DE'; - - case 'csebcdicatdea': - case 'ebcdicatdea': - return 'EBCDIC-AT-DE-A'; - - case 'csebcdiccafr': - case 'ebcdiccafr': - return 'EBCDIC-CA-FR'; - - case 'csebcdicdkno': - case 'ebcdicdkno': - return 'EBCDIC-DK-NO'; - - case 'csebcdicdknoa': - case 'ebcdicdknoa': - return 'EBCDIC-DK-NO-A'; - - case 'csebcdices': - case 'ebcdices': - return 'EBCDIC-ES'; - - case 'csebcdicesa': - case 'ebcdicesa': - return 'EBCDIC-ES-A'; - - case 'csebcdicess': - case 'ebcdicess': - return 'EBCDIC-ES-S'; - - case 'csebcdicfise': - case 'ebcdicfise': - return 'EBCDIC-FI-SE'; - - case 'csebcdicfisea': - case 'ebcdicfisea': - return 'EBCDIC-FI-SE-A'; - - case 'csebcdicfr': - case 'ebcdicfr': - return 'EBCDIC-FR'; - - case 'csebcdicit': - case 'ebcdicit': - return 'EBCDIC-IT'; - - case 'csebcdicpt': - case 'ebcdicpt': - return 'EBCDIC-PT'; - - case 'csebcdicuk': - case 'ebcdicuk': - return 'EBCDIC-UK'; - - case 'csebcdicus': - case 'ebcdicus': - return 'EBCDIC-US'; - - case 'csiso111ecmacyrillic': - case 'ecmacyrillic': - case 'isoir111': - case 'koi8e': - return 'ECMA-cyrillic'; - - case 'csiso17spanish': - case 'es': - case 'iso646es': - case 'isoir17': - return 'ES'; - - case 'csiso85spanish2': - case 'es2': - case 'iso646es2': - case 'isoir85': - return 'ES2'; - - case 'cseucfixwidjapanese': - case 'extendedunixcodefixedwidthforjapanese': - return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; - - case 'cseucpkdfmtjapanese': - case 'eucjp': - case 'extendedunixcodepackedformatforjapanese': - return 'Extended_UNIX_Code_Packed_Format_for_Japanese'; - - case 'gb18030': - return 'GB18030'; - - case 'chinese': - case 'cp936': - case 'csgb2312': - case 'csiso58gb231280': - case 'gb2312': - case 'gb231280': - case 'gbk': - case 'isoir58': - case 'ms936': - case 'windows936': - return 'GBK'; - - case 'cn': - case 'csiso57gb1988': - case 'gb198880': - case 'iso646cn': - case 'isoir57': - return 'GB_1988-80'; - - case 'csiso153gost1976874': - case 'gost1976874': - case 'isoir153': - case 'stsev35888': - return 'GOST_19768-74'; - - case 'csiso150': - case 'csiso150greekccitt': - case 'greekccitt': - case 'isoir150': - return 'greek-ccitt'; - - case 'csiso88greek7': - case 'greek7': - case 'isoir88': - return 'greek7'; - - case 'csiso18greek7old': - case 'greek7old': - case 'isoir18': - return 'greek7-old'; - - case 'cshpdesktop': - case 'hpdesktop': - return 'HP-DeskTop'; - - case 'cshplegal': - case 'hplegal': - return 'HP-Legal'; - - case 'cshpmath8': - case 'hpmath8': - return 'HP-Math8'; - - case 'cshppifont': - case 'hppifont': - return 'HP-Pi-font'; - - case 'cshproman8': - case 'hproman8': - case 'r8': - case 'roman8': - return 'hp-roman8'; - - case 'hzgb2312': - return 'HZ-GB-2312'; - - case 'csibmsymbols': - case 'ibmsymbols': - return 'IBM-Symbols'; - - case 'csibmthai': - case 'ibmthai': - return 'IBM-Thai'; - - case 'ccsid858': - case 'cp858': - case 'ibm858': - case 'pcmultilingual850euro': - return 'IBM00858'; - - case 'ccsid924': - case 'cp924': - case 'ebcdiclatin9euro': - case 'ibm924': - return 'IBM00924'; - - case 'ccsid1140': - case 'cp1140': - case 'ebcdicus37euro': - case 'ibm1140': - return 'IBM01140'; - - case 'ccsid1141': - case 'cp1141': - case 'ebcdicde273euro': - case 'ibm1141': - return 'IBM01141'; - - case 'ccsid1142': - case 'cp1142': - case 'ebcdicdk277euro': - case 'ebcdicno277euro': - case 'ibm1142': - return 'IBM01142'; - - case 'ccsid1143': - case 'cp1143': - case 'ebcdicfi278euro': - case 'ebcdicse278euro': - case 'ibm1143': - return 'IBM01143'; - - case 'ccsid1144': - case 'cp1144': - case 'ebcdicit280euro': - case 'ibm1144': - return 'IBM01144'; - - case 'ccsid1145': - case 'cp1145': - case 'ebcdices284euro': - case 'ibm1145': - return 'IBM01145'; - - case 'ccsid1146': - case 'cp1146': - case 'ebcdicgb285euro': - case 'ibm1146': - return 'IBM01146'; - - case 'ccsid1147': - case 'cp1147': - case 'ebcdicfr297euro': - case 'ibm1147': - return 'IBM01147'; - - case 'ccsid1148': - case 'cp1148': - case 'ebcdicinternational500euro': - case 'ibm1148': - return 'IBM01148'; - - case 'ccsid1149': - case 'cp1149': - case 'ebcdicis871euro': - case 'ibm1149': - return 'IBM01149'; - - case 'cp37': - case 'csibm37': - case 'ebcdiccpca': - case 'ebcdiccpnl': - case 'ebcdiccpus': - case 'ebcdiccpwt': - case 'ibm37': - return 'IBM037'; - - case 'cp38': - case 'csibm38': - case 'ebcdicint': - case 'ibm38': - return 'IBM038'; - - case 'cp273': - case 'csibm273': - case 'ibm273': - return 'IBM273'; - - case 'cp274': - case 'csibm274': - case 'ebcdicbe': - case 'ibm274': - return 'IBM274'; - - case 'cp275': - case 'csibm275': - case 'ebcdicbr': - case 'ibm275': - return 'IBM275'; - - case 'csibm277': - case 'ebcdiccpdk': - case 'ebcdiccpno': - case 'ibm277': - return 'IBM277'; - - case 'cp278': - case 'csibm278': - case 'ebcdiccpfi': - case 'ebcdiccpse': - case 'ibm278': - return 'IBM278'; - - case 'cp280': - case 'csibm280': - case 'ebcdiccpit': - case 'ibm280': - return 'IBM280'; - - case 'cp281': - case 'csibm281': - case 'ebcdicjpe': - case 'ibm281': - return 'IBM281'; - - case 'cp284': - case 'csibm284': - case 'ebcdiccpes': - case 'ibm284': - return 'IBM284'; - - case 'cp285': - case 'csibm285': - case 'ebcdiccpgb': - case 'ibm285': - return 'IBM285'; - - case 'cp290': - case 'csibm290': - case 'ebcdicjpkana': - case 'ibm290': - return 'IBM290'; - - case 'cp297': - case 'csibm297': - case 'ebcdiccpfr': - case 'ibm297': - return 'IBM297'; - - case 'cp420': - case 'csibm420': - case 'ebcdiccpar1': - case 'ibm420': - return 'IBM420'; - - case 'cp423': - case 'csibm423': - case 'ebcdiccpgr': - case 'ibm423': - return 'IBM423'; - - case 'cp424': - case 'csibm424': - case 'ebcdiccphe': - case 'ibm424': - return 'IBM424'; - - case '437': - case 'cp437': - case 'cspc8codepage437': - case 'ibm437': - return 'IBM437'; - - case 'cp500': - case 'csibm500': - case 'ebcdiccpbe': - case 'ebcdiccpch': - case 'ibm500': - return 'IBM500'; - - case 'cp775': - case 'cspc775baltic': - case 'ibm775': - return 'IBM775'; - - case '850': - case 'cp850': - case 'cspc850multilingual': - case 'ibm850': - return 'IBM850'; - - case '851': - case 'cp851': - case 'csibm851': - case 'ibm851': - return 'IBM851'; - - case '852': - case 'cp852': - case 'cspcp852': - case 'ibm852': - return 'IBM852'; - - case '855': - case 'cp855': - case 'csibm855': - case 'ibm855': - return 'IBM855'; - - case '857': - case 'cp857': - case 'csibm857': - case 'ibm857': - return 'IBM857'; - - case '860': - case 'cp860': - case 'csibm860': - case 'ibm860': - return 'IBM860'; - - case '861': - case 'cp861': - case 'cpis': - case 'csibm861': - case 'ibm861': - return 'IBM861'; - - case '862': - case 'cp862': - case 'cspc862latinhebrew': - case 'ibm862': - return 'IBM862'; - - case '863': - case 'cp863': - case 'csibm863': - case 'ibm863': - return 'IBM863'; - - case 'cp864': - case 'csibm864': - case 'ibm864': - return 'IBM864'; - - case '865': - case 'cp865': - case 'csibm865': - case 'ibm865': - return 'IBM865'; - - case '866': - case 'cp866': - case 'csibm866': - case 'ibm866': - return 'IBM866'; - - case 'cp868': - case 'cpar': - case 'csibm868': - case 'ibm868': - return 'IBM868'; - - case '869': - case 'cp869': - case 'cpgr': - case 'csibm869': - case 'ibm869': - return 'IBM869'; - - case 'cp870': - case 'csibm870': - case 'ebcdiccproece': - case 'ebcdiccpyu': - case 'ibm870': - return 'IBM870'; - - case 'cp871': - case 'csibm871': - case 'ebcdiccpis': - case 'ibm871': - return 'IBM871'; - - case 'cp880': - case 'csibm880': - case 'ebcdiccyrillic': - case 'ibm880': - return 'IBM880'; - - case 'cp891': - case 'csibm891': - case 'ibm891': - return 'IBM891'; - - case 'cp903': - case 'csibm903': - case 'ibm903': - return 'IBM903'; - - case '904': - case 'cp904': - case 'csibbm904': - case 'ibm904': - return 'IBM904'; - - case 'cp905': - case 'csibm905': - case 'ebcdiccptr': - case 'ibm905': - return 'IBM905'; - - case 'cp918': - case 'csibm918': - case 'ebcdiccpar2': - case 'ibm918': - return 'IBM918'; - - case 'cp1026': - case 'csibm1026': - case 'ibm1026': - return 'IBM1026'; - - case 'ibm1047': - return 'IBM1047'; - - case 'csiso143iecp271': - case 'iecp271': - case 'isoir143': - return 'IEC_P27-1'; - - case 'csiso49inis': - case 'inis': - case 'isoir49': - return 'INIS'; - - case 'csiso50inis8': - case 'inis8': - case 'isoir50': - return 'INIS-8'; - - case 'csiso51iniscyrillic': - case 'iniscyrillic': - case 'isoir51': - return 'INIS-cyrillic'; - - case 'csinvariant': - case 'invariant': - return 'INVARIANT'; - - case 'iso2022cn': - return 'ISO-2022-CN'; - - case 'iso2022cnext': - return 'ISO-2022-CN-EXT'; - - case 'csiso2022jp': - case 'iso2022jp': - return 'ISO-2022-JP'; - - case 'csiso2022jp2': - case 'iso2022jp2': - return 'ISO-2022-JP-2'; - - case 'csiso2022kr': - case 'iso2022kr': - return 'ISO-2022-KR'; - - case 'cswindows30latin1': - case 'iso88591windows30latin1': - return 'ISO-8859-1-Windows-3.0-Latin-1'; - - case 'cswindows31latin1': - case 'iso88591windows31latin1': - return 'ISO-8859-1-Windows-3.1-Latin-1'; - - case 'csisolatin2': - case 'iso88592': - case 'iso885921987': - case 'isoir101': - case 'l2': - case 'latin2': - return 'ISO-8859-2'; - - case 'cswindows31latin2': - case 'iso88592windowslatin2': - return 'ISO-8859-2-Windows-Latin-2'; - - case 'csisolatin3': - case 'iso88593': - case 'iso885931988': - case 'isoir109': - case 'l3': - case 'latin3': - return 'ISO-8859-3'; - - case 'csisolatin4': - case 'iso88594': - case 'iso885941988': - case 'isoir110': - case 'l4': - case 'latin4': - return 'ISO-8859-4'; - - case 'csisolatincyrillic': - case 'cyrillic': - case 'iso88595': - case 'iso885951988': - case 'isoir144': - return 'ISO-8859-5'; - - case 'arabic': - case 'asmo708': - case 'csisolatinarabic': - case 'ecma114': - case 'iso88596': - case 'iso885961987': - case 'isoir127': - return 'ISO-8859-6'; - - case 'csiso88596e': - case 'iso88596e': - return 'ISO-8859-6-E'; - - case 'csiso88596i': - case 'iso88596i': - return 'ISO-8859-6-I'; - - case 'csisolatingreek': - case 'ecma118': - case 'elot928': - case 'greek': - case 'greek8': - case 'iso88597': - case 'iso885971987': - case 'isoir126': - return 'ISO-8859-7'; - - case 'csisolatinhebrew': - case 'hebrew': - case 'iso88598': - case 'iso885981988': - case 'isoir138': - return 'ISO-8859-8'; - - case 'csiso88598e': - case 'iso88598e': - return 'ISO-8859-8-E'; - - case 'csiso88598i': - case 'iso88598i': - return 'ISO-8859-8-I'; - - case 'cswindows31latin5': - case 'iso88599windowslatin5': - return 'ISO-8859-9-Windows-Latin-5'; - - case 'csisolatin6': - case 'iso885910': - case 'iso8859101992': - case 'isoir157': - case 'l6': - case 'latin6': - return 'ISO-8859-10'; - - case 'iso885913': - return 'ISO-8859-13'; - - case 'iso885914': - case 'iso8859141998': - case 'isoceltic': - case 'isoir199': - case 'l8': - case 'latin8': - return 'ISO-8859-14'; - - case 'iso885915': - case 'latin9': - return 'ISO-8859-15'; - - case 'iso885916': - case 'iso8859162001': - case 'isoir226': - case 'l10': - case 'latin10': - return 'ISO-8859-16'; - - case 'iso10646j1': - return 'ISO-10646-J-1'; - - case 'csunicode': - case 'iso10646ucs2': - return 'ISO-10646-UCS-2'; - - case 'csucs4': - case 'iso10646ucs4': - return 'ISO-10646-UCS-4'; - - case 'csunicodeascii': - case 'iso10646ucsbasic': - return 'ISO-10646-UCS-Basic'; - - case 'csunicodelatin1': - case 'iso10646': - case 'iso10646unicodelatin1': - return 'ISO-10646-Unicode-Latin1'; - - case 'csiso10646utf1': - case 'iso10646utf1': - return 'ISO-10646-UTF-1'; - - case 'csiso115481': - case 'iso115481': - case 'isotr115481': - return 'ISO-11548-1'; - - case 'csiso90': - case 'isoir90': - return 'iso-ir-90'; - - case 'csunicodeibm1261': - case 'isounicodeibm1261': - return 'ISO-Unicode-IBM-1261'; - - case 'csunicodeibm1264': - case 'isounicodeibm1264': - return 'ISO-Unicode-IBM-1264'; - - case 'csunicodeibm1265': - case 'isounicodeibm1265': - return 'ISO-Unicode-IBM-1265'; - - case 'csunicodeibm1268': - case 'isounicodeibm1268': - return 'ISO-Unicode-IBM-1268'; - - case 'csunicodeibm1276': - case 'isounicodeibm1276': - return 'ISO-Unicode-IBM-1276'; - - case 'csiso646basic1983': - case 'iso646basic1983': - case 'ref': - return 'ISO_646.basic:1983'; - - case 'csiso2intlrefversion': - case 'irv': - case 'iso646irv1983': - case 'isoir2': - return 'ISO_646.irv:1983'; - - case 'csiso2033': - case 'e13b': - case 'iso20331983': - case 'isoir98': - return 'ISO_2033-1983'; - - case 'csiso5427cyrillic': - case 'iso5427': - case 'isoir37': - return 'ISO_5427'; - - case 'iso5427cyrillic1981': - case 'iso54271981': - case 'isoir54': - return 'ISO_5427:1981'; - - case 'csiso5428greek': - case 'iso54281980': - case 'isoir55': - return 'ISO_5428:1980'; - - case 'csiso6937add': - case 'iso6937225': - case 'isoir152': - return 'ISO_6937-2-25'; - - case 'csisotextcomm': - case 'iso69372add': - case 'isoir142': - return 'ISO_6937-2-add'; - - case 'csiso8859supp': - case 'iso8859supp': - case 'isoir154': - case 'latin125': - return 'ISO_8859-supp'; - - case 'csiso10367box': - case 'iso10367box': - case 'isoir155': - return 'ISO_10367-box'; - - case 'csiso15italian': - case 'iso646it': - case 'isoir15': - case 'it': - return 'IT'; - - case 'csiso13jisc6220jp': - case 'isoir13': - case 'jisc62201969': - case 'jisc62201969jp': - case 'katakana': - case 'x2017': - return 'JIS_C6220-1969-jp'; - - case 'csiso14jisc6220ro': - case 'iso646jp': - case 'isoir14': - case 'jisc62201969ro': - case 'jp': - return 'JIS_C6220-1969-ro'; - - case 'csiso42jisc62261978': - case 'isoir42': - case 'jisc62261978': - return 'JIS_C6226-1978'; - - case 'csiso87jisx208': - case 'isoir87': - case 'jisc62261983': - case 'jisx2081983': - case 'x208': - return 'JIS_C6226-1983'; - - case 'csiso91jisc62291984a': - case 'isoir91': - case 'jisc62291984a': - case 'jpocra': - return 'JIS_C6229-1984-a'; - - case 'csiso92jisc62991984b': - case 'iso646jpocrb': - case 'isoir92': - case 'jisc62291984b': - case 'jpocrb': - return 'JIS_C6229-1984-b'; - - case 'csiso93jis62291984badd': - case 'isoir93': - case 'jisc62291984badd': - case 'jpocrbadd': - return 'JIS_C6229-1984-b-add'; - - case 'csiso94jis62291984hand': - case 'isoir94': - case 'jisc62291984hand': - case 'jpocrhand': - return 'JIS_C6229-1984-hand'; - - case 'csiso95jis62291984handadd': - case 'isoir95': - case 'jisc62291984handadd': - case 'jpocrhandadd': - return 'JIS_C6229-1984-hand-add'; - - case 'csiso96jisc62291984kana': - case 'isoir96': - case 'jisc62291984kana': - return 'JIS_C6229-1984-kana'; - - case 'csjisencoding': - case 'jisencoding': - return 'JIS_Encoding'; - - case 'cshalfwidthkatakana': - case 'jisx201': - case 'x201': - return 'JIS_X0201'; - - case 'csiso159jisx2121990': - case 'isoir159': - case 'jisx2121990': - case 'x212': - return 'JIS_X0212-1990'; - - case 'csiso141jusib1002': - case 'iso646yu': - case 'isoir141': - case 'js': - case 'jusib1002': - case 'yu': - return 'JUS_I.B1.002'; - - case 'csiso147macedonian': - case 'isoir147': - case 'jusib1003mac': - case 'macedonian': - return 'JUS_I.B1.003-mac'; - - case 'csiso146serbian': - case 'isoir146': - case 'jusib1003serb': - case 'serbian': - return 'JUS_I.B1.003-serb'; - - case 'koi7switched': - return 'KOI7-switched'; - - case 'cskoi8r': - case 'koi8r': - return 'KOI8-R'; - - case 'koi8u': - return 'KOI8-U'; - - case 'csksc5636': - case 'iso646kr': - case 'ksc5636': - return 'KSC5636'; - - case 'cskz1048': - case 'kz1048': - case 'rk1048': - case 'strk10482002': - return 'KZ-1048'; - - case 'csiso19latingreek': - case 'isoir19': - case 'latingreek': - return 'latin-greek'; - - case 'csiso27latingreek1': - case 'isoir27': - case 'latingreek1': - return 'Latin-greek-1'; - - case 'csiso158lap': - case 'isoir158': - case 'lap': - case 'latinlap': - return 'latin-lap'; - - case 'csmacintosh': - case 'mac': - case 'macintosh': - return 'macintosh'; - - case 'csmicrosoftpublishing': - case 'microsoftpublishing': - return 'Microsoft-Publishing'; - - case 'csmnem': - case 'mnem': - return 'MNEM'; - - case 'csmnemonic': - case 'mnemonic': - return 'MNEMONIC'; - - case 'csiso86hungarian': - case 'hu': - case 'iso646hu': - case 'isoir86': - case 'msz77953': - return 'MSZ_7795.3'; - - case 'csnatsdano': - case 'isoir91': - case 'natsdano': - return 'NATS-DANO'; - - case 'csnatsdanoadd': - case 'isoir92': - case 'natsdanoadd': - return 'NATS-DANO-ADD'; - - case 'csnatssefi': - case 'isoir81': - case 'natssefi': - return 'NATS-SEFI'; - - case 'csnatssefiadd': - case 'isoir82': - case 'natssefiadd': - return 'NATS-SEFI-ADD'; - - case 'csiso151cuba': - case 'cuba': - case 'iso646cu': - case 'isoir151': - case 'ncnc1081': - return 'NC_NC00-10:81'; - - case 'csiso69french': - case 'fr': - case 'iso646fr': - case 'isoir69': - case 'nfz62010': - return 'NF_Z_62-010'; - - case 'csiso25french': - case 'iso646fr1': - case 'isoir25': - case 'nfz620101973': - return 'NF_Z_62-010_(1973)'; - - case 'csiso60danishnorwegian': - case 'csiso60norwegian1': - case 'iso646no': - case 'isoir60': - case 'no': - case 'ns45511': - return 'NS_4551-1'; - - case 'csiso61norwegian2': - case 'iso646no2': - case 'isoir61': - case 'no2': - case 'ns45512': - return 'NS_4551-2'; - - case 'osdebcdicdf3irv': - return 'OSD_EBCDIC_DF03_IRV'; - - case 'osdebcdicdf41': - return 'OSD_EBCDIC_DF04_1'; - - case 'osdebcdicdf415': - return 'OSD_EBCDIC_DF04_15'; - - case 'cspc8danishnorwegian': - case 'pc8danishnorwegian': - return 'PC8-Danish-Norwegian'; - - case 'cspc8turkish': - case 'pc8turkish': - return 'PC8-Turkish'; - - case 'csiso16portuguese': - case 'iso646pt': - case 'isoir16': - case 'pt': - return 'PT'; - - case 'csiso84portuguese2': - case 'iso646pt2': - case 'isoir84': - case 'pt2': - return 'PT2'; - - case 'cp154': - case 'csptcp154': - case 'cyrillicasian': - case 'pt154': - case 'ptcp154': - return 'PTCP154'; - - case 'scsu': - return 'SCSU'; - - case 'csiso10swedish': - case 'fi': - case 'iso646fi': - case 'iso646se': - case 'isoir10': - case 'se': - case 'sen850200b': - return 'SEN_850200_B'; - - case 'csiso11swedishfornames': - case 'iso646se2': - case 'isoir11': - case 'se2': - case 'sen850200c': - return 'SEN_850200_C'; - - case 'csshiftjis': - case 'mskanji': - case 'shiftjis': - return 'Shift_JIS'; - - case 'csiso102t617bit': - case 'isoir102': - case 't617bit': - return 'T.61-7bit'; - - case 'csiso103t618bit': - case 'isoir103': - case 't61': - case 't618bit': - return 'T.61-8bit'; - - case 'csiso128t101g2': - case 'isoir128': - case 't101g2': - return 'T.101-G2'; - - case 'cstscii': - case 'tscii': - return 'TSCII'; - - case 'csunicode11': - case 'unicode11': - return 'UNICODE-1-1'; - - case 'csunicode11utf7': - case 'unicode11utf7': - return 'UNICODE-1-1-UTF-7'; - - case 'csunknown8bit': - case 'unknown8bit': - return 'UNKNOWN-8BIT'; - - case 'ansix341968': - case 'ansix341986': - case 'ascii': - case 'cp367': - case 'csascii': - case 'ibm367': - case 'iso646irv1991': - case 'iso646us': - case 'isoir6': - case 'us': - case 'usascii': - return 'US-ASCII'; - - case 'csusdk': - case 'usdk': - return 'us-dk'; - - case 'utf7': - return 'UTF-7'; - - case 'utf8': - return 'UTF-8'; - - case 'utf16': - return 'UTF-16'; - - case 'utf16be': - return 'UTF-16BE'; - - case 'utf16le': - return 'UTF-16LE'; - - case 'utf32': - return 'UTF-32'; - - case 'utf32be': - return 'UTF-32BE'; - - case 'utf32le': - return 'UTF-32LE'; - - case 'csventurainternational': - case 'venturainternational': - return 'Ventura-International'; - - case 'csventuramath': - case 'venturamath': - return 'Ventura-Math'; - - case 'csventuraus': - case 'venturaus': - return 'Ventura-US'; - - case 'csiso70videotexsupp1': - case 'isoir70': - case 'videotexsuppl': - return 'videotex-suppl'; - - case 'csviqr': - case 'viqr': - return 'VIQR'; - - case 'csviscii': - case 'viscii': - return 'VISCII'; - - case 'cswindows31j': - case 'windows31j': - return 'Windows-31J'; - - case 'iso885911': - case 'tis620': - return 'windows-874'; - - case 'cseuckr': - case 'csksc56011987': - case 'euckr': - case 'isoir149': - case 'korean': - case 'ksc5601': - case 'ksc56011987': - case 'ksc56011989': - case 'windows949': - return 'windows-949'; - - case 'windows1250': - return 'windows-1250'; - - case 'windows1251': - return 'windows-1251'; - - case 'cp819': - case 'csisolatin1': - case 'ibm819': - case 'iso88591': - case 'iso885911987': - case 'isoir100': - case 'l1': - case 'latin1': - case 'windows1252': - return 'windows-1252'; - - case 'windows1253': - return 'windows-1253'; - - case 'csisolatin5': - case 'iso88599': - case 'iso885991989': - case 'isoir148': - case 'l5': - case 'latin5': - case 'windows1254': - return 'windows-1254'; - - case 'windows1255': - return 'windows-1255'; + case 'adobestandardencoding': + case 'csadobestandardencoding': + return 'Adobe-Standard-Encoding'; + + case 'adobesymbolencoding': + case 'cshppsmath': + return 'Adobe-Symbol-Encoding'; + + case 'ami1251': + case 'amiga1251': + return 'Amiga-1251'; + + case 'ansix31101983': + case 'csat5001983': + case 'csiso99naplps': + case 'isoir99': + case 'naplps': + return 'ANSI_X3.110-1983'; + + case 'arabic7': + case 'asmo449': + case 'csiso89asmo449': + case 'iso9036': + case 'isoir89': + return 'ASMO_449'; + + case 'big5': + case 'csbig5': + case 'xxbig5': + return 'Big5'; + + case 'big5hkscs': + return 'Big5-HKSCS'; + + case 'bocu1': + case 'csbocu1': + return 'BOCU-1'; + + case 'brf': + case 'csbrf': + return 'BRF'; + + case 'bs4730': + case 'csiso4unitedkingdom': + case 'gb': + case 'iso646gb': + case 'isoir4': + case 'uk': + return 'BS_4730'; + + case 'bsviewdata': + case 'csiso47bsviewdata': + case 'isoir47': + return 'BS_viewdata'; + + case 'cesu8': + case 'cscesu8': + return 'CESU-8'; + + case 'ca': + case 'csa71': + case 'csaz243419851': + case 'csiso121canadian1': + case 'iso646ca': + case 'isoir121': + return 'CSA_Z243.4-1985-1'; + + case 'csa72': + case 'csaz243419852': + case 'csiso122canadian2': + case 'iso646ca2': + case 'isoir122': + return 'CSA_Z243.4-1985-2'; + + case 'csaz24341985gr': + case 'csiso123csaz24341985gr': + case 'isoir123': + return 'CSA_Z243.4-1985-gr'; + + case 'csiso139csn369103': + case 'csn369103': + case 'isoir139': + return 'CSN_369103'; + + case 'csdecmcs': + case 'dec': + case 'decmcs': + return 'DEC-MCS'; + + case 'csiso21german': + case 'de': + case 'din66003': + case 'iso646de': + case 'isoir21': + return 'DIN_66003'; + + case 'csdkus': + case 'dkus': + return 'dk-us'; + + case 'csiso646danish': + case 'dk': + case 'ds2089': + case 'iso646dk': + return 'DS_2089'; + + case 'csibmebcdicatde': + case 'ebcdicatde': + return 'EBCDIC-AT-DE'; + + case 'csebcdicatdea': + case 'ebcdicatdea': + return 'EBCDIC-AT-DE-A'; + + case 'csebcdiccafr': + case 'ebcdiccafr': + return 'EBCDIC-CA-FR'; + + case 'csebcdicdkno': + case 'ebcdicdkno': + return 'EBCDIC-DK-NO'; + + case 'csebcdicdknoa': + case 'ebcdicdknoa': + return 'EBCDIC-DK-NO-A'; + + case 'csebcdices': + case 'ebcdices': + return 'EBCDIC-ES'; + + case 'csebcdicesa': + case 'ebcdicesa': + return 'EBCDIC-ES-A'; + + case 'csebcdicess': + case 'ebcdicess': + return 'EBCDIC-ES-S'; + + case 'csebcdicfise': + case 'ebcdicfise': + return 'EBCDIC-FI-SE'; + + case 'csebcdicfisea': + case 'ebcdicfisea': + return 'EBCDIC-FI-SE-A'; + + case 'csebcdicfr': + case 'ebcdicfr': + return 'EBCDIC-FR'; + + case 'csebcdicit': + case 'ebcdicit': + return 'EBCDIC-IT'; + + case 'csebcdicpt': + case 'ebcdicpt': + return 'EBCDIC-PT'; + + case 'csebcdicuk': + case 'ebcdicuk': + return 'EBCDIC-UK'; + + case 'csebcdicus': + case 'ebcdicus': + return 'EBCDIC-US'; + + case 'csiso111ecmacyrillic': + case 'ecmacyrillic': + case 'isoir111': + case 'koi8e': + return 'ECMA-cyrillic'; + + case 'csiso17spanish': + case 'es': + case 'iso646es': + case 'isoir17': + return 'ES'; + + case 'csiso85spanish2': + case 'es2': + case 'iso646es2': + case 'isoir85': + return 'ES2'; + + case 'cseucfixwidjapanese': + case 'extendedunixcodefixedwidthforjapanese': + return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; + + case 'cseucpkdfmtjapanese': + case 'eucjp': + case 'extendedunixcodepackedformatforjapanese': + return 'Extended_UNIX_Code_Packed_Format_for_Japanese'; + + case 'gb18030': + return 'GB18030'; + + case 'chinese': + case 'cp936': + case 'csgb2312': + case 'csiso58gb231280': + case 'gb2312': + case 'gb231280': + case 'gbk': + case 'isoir58': + case 'ms936': + case 'windows936': + return 'GBK'; + + case 'cn': + case 'csiso57gb1988': + case 'gb198880': + case 'iso646cn': + case 'isoir57': + return 'GB_1988-80'; + + case 'csiso153gost1976874': + case 'gost1976874': + case 'isoir153': + case 'stsev35888': + return 'GOST_19768-74'; + + case 'csiso150': + case 'csiso150greekccitt': + case 'greekccitt': + case 'isoir150': + return 'greek-ccitt'; + + case 'csiso88greek7': + case 'greek7': + case 'isoir88': + return 'greek7'; + + case 'csiso18greek7old': + case 'greek7old': + case 'isoir18': + return 'greek7-old'; + + case 'cshpdesktop': + case 'hpdesktop': + return 'HP-DeskTop'; + + case 'cshplegal': + case 'hplegal': + return 'HP-Legal'; + + case 'cshpmath8': + case 'hpmath8': + return 'HP-Math8'; + + case 'cshppifont': + case 'hppifont': + return 'HP-Pi-font'; + + case 'cshproman8': + case 'hproman8': + case 'r8': + case 'roman8': + return 'hp-roman8'; + + case 'hzgb2312': + return 'HZ-GB-2312'; + + case 'csibmsymbols': + case 'ibmsymbols': + return 'IBM-Symbols'; + + case 'csibmthai': + case 'ibmthai': + return 'IBM-Thai'; + + case 'ccsid858': + case 'cp858': + case 'ibm858': + case 'pcmultilingual850euro': + return 'IBM00858'; + + case 'ccsid924': + case 'cp924': + case 'ebcdiclatin9euro': + case 'ibm924': + return 'IBM00924'; + + case 'ccsid1140': + case 'cp1140': + case 'ebcdicus37euro': + case 'ibm1140': + return 'IBM01140'; + + case 'ccsid1141': + case 'cp1141': + case 'ebcdicde273euro': + case 'ibm1141': + return 'IBM01141'; + + case 'ccsid1142': + case 'cp1142': + case 'ebcdicdk277euro': + case 'ebcdicno277euro': + case 'ibm1142': + return 'IBM01142'; + + case 'ccsid1143': + case 'cp1143': + case 'ebcdicfi278euro': + case 'ebcdicse278euro': + case 'ibm1143': + return 'IBM01143'; + + case 'ccsid1144': + case 'cp1144': + case 'ebcdicit280euro': + case 'ibm1144': + return 'IBM01144'; + + case 'ccsid1145': + case 'cp1145': + case 'ebcdices284euro': + case 'ibm1145': + return 'IBM01145'; + + case 'ccsid1146': + case 'cp1146': + case 'ebcdicgb285euro': + case 'ibm1146': + return 'IBM01146'; + + case 'ccsid1147': + case 'cp1147': + case 'ebcdicfr297euro': + case 'ibm1147': + return 'IBM01147'; + + case 'ccsid1148': + case 'cp1148': + case 'ebcdicinternational500euro': + case 'ibm1148': + return 'IBM01148'; + + case 'ccsid1149': + case 'cp1149': + case 'ebcdicis871euro': + case 'ibm1149': + return 'IBM01149'; + + case 'cp37': + case 'csibm37': + case 'ebcdiccpca': + case 'ebcdiccpnl': + case 'ebcdiccpus': + case 'ebcdiccpwt': + case 'ibm37': + return 'IBM037'; + + case 'cp38': + case 'csibm38': + case 'ebcdicint': + case 'ibm38': + return 'IBM038'; + + case 'cp273': + case 'csibm273': + case 'ibm273': + return 'IBM273'; + + case 'cp274': + case 'csibm274': + case 'ebcdicbe': + case 'ibm274': + return 'IBM274'; + + case 'cp275': + case 'csibm275': + case 'ebcdicbr': + case 'ibm275': + return 'IBM275'; + + case 'csibm277': + case 'ebcdiccpdk': + case 'ebcdiccpno': + case 'ibm277': + return 'IBM277'; + + case 'cp278': + case 'csibm278': + case 'ebcdiccpfi': + case 'ebcdiccpse': + case 'ibm278': + return 'IBM278'; + + case 'cp280': + case 'csibm280': + case 'ebcdiccpit': + case 'ibm280': + return 'IBM280'; + + case 'cp281': + case 'csibm281': + case 'ebcdicjpe': + case 'ibm281': + return 'IBM281'; + + case 'cp284': + case 'csibm284': + case 'ebcdiccpes': + case 'ibm284': + return 'IBM284'; + + case 'cp285': + case 'csibm285': + case 'ebcdiccpgb': + case 'ibm285': + return 'IBM285'; + + case 'cp290': + case 'csibm290': + case 'ebcdicjpkana': + case 'ibm290': + return 'IBM290'; + + case 'cp297': + case 'csibm297': + case 'ebcdiccpfr': + case 'ibm297': + return 'IBM297'; + + case 'cp420': + case 'csibm420': + case 'ebcdiccpar1': + case 'ibm420': + return 'IBM420'; + + case 'cp423': + case 'csibm423': + case 'ebcdiccpgr': + case 'ibm423': + return 'IBM423'; + + case 'cp424': + case 'csibm424': + case 'ebcdiccphe': + case 'ibm424': + return 'IBM424'; + + case '437': + case 'cp437': + case 'cspc8codepage437': + case 'ibm437': + return 'IBM437'; + + case 'cp500': + case 'csibm500': + case 'ebcdiccpbe': + case 'ebcdiccpch': + case 'ibm500': + return 'IBM500'; + + case 'cp775': + case 'cspc775baltic': + case 'ibm775': + return 'IBM775'; + + case '850': + case 'cp850': + case 'cspc850multilingual': + case 'ibm850': + return 'IBM850'; + + case '851': + case 'cp851': + case 'csibm851': + case 'ibm851': + return 'IBM851'; + + case '852': + case 'cp852': + case 'cspcp852': + case 'ibm852': + return 'IBM852'; + + case '855': + case 'cp855': + case 'csibm855': + case 'ibm855': + return 'IBM855'; + + case '857': + case 'cp857': + case 'csibm857': + case 'ibm857': + return 'IBM857'; + + case '860': + case 'cp860': + case 'csibm860': + case 'ibm860': + return 'IBM860'; + + case '861': + case 'cp861': + case 'cpis': + case 'csibm861': + case 'ibm861': + return 'IBM861'; + + case '862': + case 'cp862': + case 'cspc862latinhebrew': + case 'ibm862': + return 'IBM862'; + + case '863': + case 'cp863': + case 'csibm863': + case 'ibm863': + return 'IBM863'; + + case 'cp864': + case 'csibm864': + case 'ibm864': + return 'IBM864'; + + case '865': + case 'cp865': + case 'csibm865': + case 'ibm865': + return 'IBM865'; + + case '866': + case 'cp866': + case 'csibm866': + case 'ibm866': + return 'IBM866'; + + case 'cp868': + case 'cpar': + case 'csibm868': + case 'ibm868': + return 'IBM868'; + + case '869': + case 'cp869': + case 'cpgr': + case 'csibm869': + case 'ibm869': + return 'IBM869'; + + case 'cp870': + case 'csibm870': + case 'ebcdiccproece': + case 'ebcdiccpyu': + case 'ibm870': + return 'IBM870'; + + case 'cp871': + case 'csibm871': + case 'ebcdiccpis': + case 'ibm871': + return 'IBM871'; + + case 'cp880': + case 'csibm880': + case 'ebcdiccyrillic': + case 'ibm880': + return 'IBM880'; + + case 'cp891': + case 'csibm891': + case 'ibm891': + return 'IBM891'; + + case 'cp903': + case 'csibm903': + case 'ibm903': + return 'IBM903'; + + case '904': + case 'cp904': + case 'csibbm904': + case 'ibm904': + return 'IBM904'; + + case 'cp905': + case 'csibm905': + case 'ebcdiccptr': + case 'ibm905': + return 'IBM905'; + + case 'cp918': + case 'csibm918': + case 'ebcdiccpar2': + case 'ibm918': + return 'IBM918'; + + case 'cp1026': + case 'csibm1026': + case 'ibm1026': + return 'IBM1026'; + + case 'ibm1047': + return 'IBM1047'; + + case 'csiso143iecp271': + case 'iecp271': + case 'isoir143': + return 'IEC_P27-1'; + + case 'csiso49inis': + case 'inis': + case 'isoir49': + return 'INIS'; + + case 'csiso50inis8': + case 'inis8': + case 'isoir50': + return 'INIS-8'; + + case 'csiso51iniscyrillic': + case 'iniscyrillic': + case 'isoir51': + return 'INIS-cyrillic'; + + case 'csinvariant': + case 'invariant': + return 'INVARIANT'; + + case 'iso2022cn': + return 'ISO-2022-CN'; + + case 'iso2022cnext': + return 'ISO-2022-CN-EXT'; + + case 'csiso2022jp': + case 'iso2022jp': + return 'ISO-2022-JP'; + + case 'csiso2022jp2': + case 'iso2022jp2': + return 'ISO-2022-JP-2'; + + case 'csiso2022kr': + case 'iso2022kr': + return 'ISO-2022-KR'; + + case 'cswindows30latin1': + case 'iso88591windows30latin1': + return 'ISO-8859-1-Windows-3.0-Latin-1'; + + case 'cswindows31latin1': + case 'iso88591windows31latin1': + return 'ISO-8859-1-Windows-3.1-Latin-1'; + + case 'csisolatin2': + case 'iso88592': + case 'iso885921987': + case 'isoir101': + case 'l2': + case 'latin2': + return 'ISO-8859-2'; + + case 'cswindows31latin2': + case 'iso88592windowslatin2': + return 'ISO-8859-2-Windows-Latin-2'; + + case 'csisolatin3': + case 'iso88593': + case 'iso885931988': + case 'isoir109': + case 'l3': + case 'latin3': + return 'ISO-8859-3'; + + case 'csisolatin4': + case 'iso88594': + case 'iso885941988': + case 'isoir110': + case 'l4': + case 'latin4': + return 'ISO-8859-4'; + + case 'csisolatincyrillic': + case 'cyrillic': + case 'iso88595': + case 'iso885951988': + case 'isoir144': + return 'ISO-8859-5'; + + case 'arabic': + case 'asmo708': + case 'csisolatinarabic': + case 'ecma114': + case 'iso88596': + case 'iso885961987': + case 'isoir127': + return 'ISO-8859-6'; + + case 'csiso88596e': + case 'iso88596e': + return 'ISO-8859-6-E'; + + case 'csiso88596i': + case 'iso88596i': + return 'ISO-8859-6-I'; + + case 'csisolatingreek': + case 'ecma118': + case 'elot928': + case 'greek': + case 'greek8': + case 'iso88597': + case 'iso885971987': + case 'isoir126': + return 'ISO-8859-7'; + + case 'csisolatinhebrew': + case 'hebrew': + case 'iso88598': + case 'iso885981988': + case 'isoir138': + return 'ISO-8859-8'; + + case 'csiso88598e': + case 'iso88598e': + return 'ISO-8859-8-E'; + + case 'csiso88598i': + case 'iso88598i': + return 'ISO-8859-8-I'; + + case 'cswindows31latin5': + case 'iso88599windowslatin5': + return 'ISO-8859-9-Windows-Latin-5'; + + case 'csisolatin6': + case 'iso885910': + case 'iso8859101992': + case 'isoir157': + case 'l6': + case 'latin6': + return 'ISO-8859-10'; + + case 'iso885913': + return 'ISO-8859-13'; + + case 'iso885914': + case 'iso8859141998': + case 'isoceltic': + case 'isoir199': + case 'l8': + case 'latin8': + return 'ISO-8859-14'; + + case 'iso885915': + case 'latin9': + return 'ISO-8859-15'; + + case 'iso885916': + case 'iso8859162001': + case 'isoir226': + case 'l10': + case 'latin10': + return 'ISO-8859-16'; + + case 'iso10646j1': + return 'ISO-10646-J-1'; + + case 'csunicode': + case 'iso10646ucs2': + return 'ISO-10646-UCS-2'; + + case 'csucs4': + case 'iso10646ucs4': + return 'ISO-10646-UCS-4'; + + case 'csunicodeascii': + case 'iso10646ucsbasic': + return 'ISO-10646-UCS-Basic'; + + case 'csunicodelatin1': + case 'iso10646': + case 'iso10646unicodelatin1': + return 'ISO-10646-Unicode-Latin1'; + + case 'csiso10646utf1': + case 'iso10646utf1': + return 'ISO-10646-UTF-1'; + + case 'csiso115481': + case 'iso115481': + case 'isotr115481': + return 'ISO-11548-1'; + + case 'csiso90': + case 'isoir90': + return 'iso-ir-90'; + + case 'csunicodeibm1261': + case 'isounicodeibm1261': + return 'ISO-Unicode-IBM-1261'; + + case 'csunicodeibm1264': + case 'isounicodeibm1264': + return 'ISO-Unicode-IBM-1264'; + + case 'csunicodeibm1265': + case 'isounicodeibm1265': + return 'ISO-Unicode-IBM-1265'; + + case 'csunicodeibm1268': + case 'isounicodeibm1268': + return 'ISO-Unicode-IBM-1268'; + + case 'csunicodeibm1276': + case 'isounicodeibm1276': + return 'ISO-Unicode-IBM-1276'; + + case 'csiso646basic1983': + case 'iso646basic1983': + case 'ref': + return 'ISO_646.basic:1983'; + + case 'csiso2intlrefversion': + case 'irv': + case 'iso646irv1983': + case 'isoir2': + return 'ISO_646.irv:1983'; + + case 'csiso2033': + case 'e13b': + case 'iso20331983': + case 'isoir98': + return 'ISO_2033-1983'; + + case 'csiso5427cyrillic': + case 'iso5427': + case 'isoir37': + return 'ISO_5427'; + + case 'iso5427cyrillic1981': + case 'iso54271981': + case 'isoir54': + return 'ISO_5427:1981'; + + case 'csiso5428greek': + case 'iso54281980': + case 'isoir55': + return 'ISO_5428:1980'; + + case 'csiso6937add': + case 'iso6937225': + case 'isoir152': + return 'ISO_6937-2-25'; + + case 'csisotextcomm': + case 'iso69372add': + case 'isoir142': + return 'ISO_6937-2-add'; + + case 'csiso8859supp': + case 'iso8859supp': + case 'isoir154': + case 'latin125': + return 'ISO_8859-supp'; + + case 'csiso10367box': + case 'iso10367box': + case 'isoir155': + return 'ISO_10367-box'; + + case 'csiso15italian': + case 'iso646it': + case 'isoir15': + case 'it': + return 'IT'; + + case 'csiso13jisc6220jp': + case 'isoir13': + case 'jisc62201969': + case 'jisc62201969jp': + case 'katakana': + case 'x2017': + return 'JIS_C6220-1969-jp'; + + case 'csiso14jisc6220ro': + case 'iso646jp': + case 'isoir14': + case 'jisc62201969ro': + case 'jp': + return 'JIS_C6220-1969-ro'; + + case 'csiso42jisc62261978': + case 'isoir42': + case 'jisc62261978': + return 'JIS_C6226-1978'; + + case 'csiso87jisx208': + case 'isoir87': + case 'jisc62261983': + case 'jisx2081983': + case 'x208': + return 'JIS_C6226-1983'; + + case 'csiso91jisc62291984a': + case 'isoir91': + case 'jisc62291984a': + case 'jpocra': + return 'JIS_C6229-1984-a'; + + case 'csiso92jisc62991984b': + case 'iso646jpocrb': + case 'isoir92': + case 'jisc62291984b': + case 'jpocrb': + return 'JIS_C6229-1984-b'; + + case 'csiso93jis62291984badd': + case 'isoir93': + case 'jisc62291984badd': + case 'jpocrbadd': + return 'JIS_C6229-1984-b-add'; + + case 'csiso94jis62291984hand': + case 'isoir94': + case 'jisc62291984hand': + case 'jpocrhand': + return 'JIS_C6229-1984-hand'; + + case 'csiso95jis62291984handadd': + case 'isoir95': + case 'jisc62291984handadd': + case 'jpocrhandadd': + return 'JIS_C6229-1984-hand-add'; + + case 'csiso96jisc62291984kana': + case 'isoir96': + case 'jisc62291984kana': + return 'JIS_C6229-1984-kana'; + + case 'csjisencoding': + case 'jisencoding': + return 'JIS_Encoding'; + + case 'cshalfwidthkatakana': + case 'jisx201': + case 'x201': + return 'JIS_X0201'; + + case 'csiso159jisx2121990': + case 'isoir159': + case 'jisx2121990': + case 'x212': + return 'JIS_X0212-1990'; + + case 'csiso141jusib1002': + case 'iso646yu': + case 'isoir141': + case 'js': + case 'jusib1002': + case 'yu': + return 'JUS_I.B1.002'; + + case 'csiso147macedonian': + case 'isoir147': + case 'jusib1003mac': + case 'macedonian': + return 'JUS_I.B1.003-mac'; + + case 'csiso146serbian': + case 'isoir146': + case 'jusib1003serb': + case 'serbian': + return 'JUS_I.B1.003-serb'; + + case 'koi7switched': + return 'KOI7-switched'; + + case 'cskoi8r': + case 'koi8r': + return 'KOI8-R'; + + case 'koi8u': + return 'KOI8-U'; + + case 'csksc5636': + case 'iso646kr': + case 'ksc5636': + return 'KSC5636'; + + case 'cskz1048': + case 'kz1048': + case 'rk1048': + case 'strk10482002': + return 'KZ-1048'; + + case 'csiso19latingreek': + case 'isoir19': + case 'latingreek': + return 'latin-greek'; + + case 'csiso27latingreek1': + case 'isoir27': + case 'latingreek1': + return 'Latin-greek-1'; + + case 'csiso158lap': + case 'isoir158': + case 'lap': + case 'latinlap': + return 'latin-lap'; + + case 'csmacintosh': + case 'mac': + case 'macintosh': + return 'macintosh'; + + case 'csmicrosoftpublishing': + case 'microsoftpublishing': + return 'Microsoft-Publishing'; + + case 'csmnem': + case 'mnem': + return 'MNEM'; + + case 'csmnemonic': + case 'mnemonic': + return 'MNEMONIC'; + + case 'csiso86hungarian': + case 'hu': + case 'iso646hu': + case 'isoir86': + case 'msz77953': + return 'MSZ_7795.3'; + + case 'csnatsdano': + case 'isoir91': + case 'natsdano': + return 'NATS-DANO'; + + case 'csnatsdanoadd': + case 'isoir92': + case 'natsdanoadd': + return 'NATS-DANO-ADD'; + + case 'csnatssefi': + case 'isoir81': + case 'natssefi': + return 'NATS-SEFI'; + + case 'csnatssefiadd': + case 'isoir82': + case 'natssefiadd': + return 'NATS-SEFI-ADD'; + + case 'csiso151cuba': + case 'cuba': + case 'iso646cu': + case 'isoir151': + case 'ncnc1081': + return 'NC_NC00-10:81'; + + case 'csiso69french': + case 'fr': + case 'iso646fr': + case 'isoir69': + case 'nfz62010': + return 'NF_Z_62-010'; + + case 'csiso25french': + case 'iso646fr1': + case 'isoir25': + case 'nfz620101973': + return 'NF_Z_62-010_(1973)'; + + case 'csiso60danishnorwegian': + case 'csiso60norwegian1': + case 'iso646no': + case 'isoir60': + case 'no': + case 'ns45511': + return 'NS_4551-1'; + + case 'csiso61norwegian2': + case 'iso646no2': + case 'isoir61': + case 'no2': + case 'ns45512': + return 'NS_4551-2'; + + case 'osdebcdicdf3irv': + return 'OSD_EBCDIC_DF03_IRV'; + + case 'osdebcdicdf41': + return 'OSD_EBCDIC_DF04_1'; + + case 'osdebcdicdf415': + return 'OSD_EBCDIC_DF04_15'; + + case 'cspc8danishnorwegian': + case 'pc8danishnorwegian': + return 'PC8-Danish-Norwegian'; + + case 'cspc8turkish': + case 'pc8turkish': + return 'PC8-Turkish'; + + case 'csiso16portuguese': + case 'iso646pt': + case 'isoir16': + case 'pt': + return 'PT'; + + case 'csiso84portuguese2': + case 'iso646pt2': + case 'isoir84': + case 'pt2': + return 'PT2'; + + case 'cp154': + case 'csptcp154': + case 'cyrillicasian': + case 'pt154': + case 'ptcp154': + return 'PTCP154'; + + case 'scsu': + return 'SCSU'; + + case 'csiso10swedish': + case 'fi': + case 'iso646fi': + case 'iso646se': + case 'isoir10': + case 'se': + case 'sen850200b': + return 'SEN_850200_B'; + + case 'csiso11swedishfornames': + case 'iso646se2': + case 'isoir11': + case 'se2': + case 'sen850200c': + return 'SEN_850200_C'; + + case 'csshiftjis': + case 'mskanji': + case 'shiftjis': + return 'Shift_JIS'; + + case 'csiso102t617bit': + case 'isoir102': + case 't617bit': + return 'T.61-7bit'; + + case 'csiso103t618bit': + case 'isoir103': + case 't61': + case 't618bit': + return 'T.61-8bit'; + + case 'csiso128t101g2': + case 'isoir128': + case 't101g2': + return 'T.101-G2'; + + case 'cstscii': + case 'tscii': + return 'TSCII'; + + case 'csunicode11': + case 'unicode11': + return 'UNICODE-1-1'; + + case 'csunicode11utf7': + case 'unicode11utf7': + return 'UNICODE-1-1-UTF-7'; + + case 'csunknown8bit': + case 'unknown8bit': + return 'UNKNOWN-8BIT'; + + case 'ansix341968': + case 'ansix341986': + case 'ascii': + case 'cp367': + case 'csascii': + case 'ibm367': + case 'iso646irv1991': + case 'iso646us': + case 'isoir6': + case 'us': + case 'usascii': + return 'US-ASCII'; + + case 'csusdk': + case 'usdk': + return 'us-dk'; + + case 'utf7': + return 'UTF-7'; + + case 'utf8': + return 'UTF-8'; + + case 'utf16': + return 'UTF-16'; + + case 'utf16be': + return 'UTF-16BE'; + + case 'utf16le': + return 'UTF-16LE'; + + case 'utf32': + return 'UTF-32'; + + case 'utf32be': + return 'UTF-32BE'; + + case 'utf32le': + return 'UTF-32LE'; + + case 'csventurainternational': + case 'venturainternational': + return 'Ventura-International'; + + case 'csventuramath': + case 'venturamath': + return 'Ventura-Math'; + + case 'csventuraus': + case 'venturaus': + return 'Ventura-US'; + + case 'csiso70videotexsupp1': + case 'isoir70': + case 'videotexsuppl': + return 'videotex-suppl'; + + case 'csviqr': + case 'viqr': + return 'VIQR'; + + case 'csviscii': + case 'viscii': + return 'VISCII'; + + case 'cswindows31j': + case 'windows31j': + return 'Windows-31J'; + + case 'iso885911': + case 'tis620': + return 'windows-874'; + + case 'cseuckr': + case 'csksc56011987': + case 'euckr': + case 'isoir149': + case 'korean': + case 'ksc5601': + case 'ksc56011987': + case 'ksc56011989': + case 'windows949': + return 'windows-949'; + + case 'windows1250': + return 'windows-1250'; + + case 'windows1251': + return 'windows-1251'; + + case 'cp819': + case 'csisolatin1': + case 'ibm819': + case 'iso88591': + case 'iso885911987': + case 'isoir100': + case 'l1': + case 'latin1': + case 'windows1252': + return 'windows-1252'; + + case 'windows1253': + return 'windows-1253'; - case 'windows1256': - return 'windows-1256'; + case 'csisolatin5': + case 'iso88599': + case 'iso885991989': + case 'isoir148': + case 'l5': + case 'latin5': + case 'windows1254': + return 'windows-1254'; - case 'windows1257': - return 'windows-1257'; - - case 'windows1258': - return 'windows-1258'; + case 'windows1255': + return 'windows-1255'; - default: - return $charset; + case 'windows1256': + return 'windows-1256'; + + case 'windows1257': + return 'windows-1257'; + + case 'windows1258': + return 'windows-1258'; + + default: + return $charset; } } @@ -10840,6 +10942,7 @@ class SimplePie_Misc return false; } + /** * Strip HTML comments * @@ -10885,6 +10988,7 @@ class SimplePie_Misc return $decoder->parse(); } + /** * Remove RFC822 comments * @@ -10920,13 +11024,13 @@ class SimplePie_Misc { switch ($string[$position]) { - case '(': - $depth++; - break; + case '(': + $depth++; + break; - case ')': - $depth--; - break; + case ')': + $depth--; + break; } $position++; } @@ -10984,20 +11088,20 @@ class SimplePie_Misc { switch (strtolower(trim($attribs['']['type']))) { - case 'text': - case 'text/plain': - return SIMPLEPIE_CONSTRUCT_TEXT | $mode; + case 'text': + case 'text/plain': + return SIMPLEPIE_CONSTRUCT_TEXT | $mode; - case 'html': - case 'text/html': - return SIMPLEPIE_CONSTRUCT_HTML | $mode; + case 'html': + case 'text/html': + return SIMPLEPIE_CONSTRUCT_HTML | $mode; - case 'xhtml': - case 'application/xhtml+xml': - return SIMPLEPIE_CONSTRUCT_XHTML | $mode; + case 'xhtml': + case 'application/xhtml+xml': + return SIMPLEPIE_CONSTRUCT_XHTML | $mode; - default: - return SIMPLEPIE_CONSTRUCT_NONE | $mode; + default: + return SIMPLEPIE_CONSTRUCT_NONE | $mode; } } else @@ -11012,17 +11116,17 @@ class SimplePie_Misc { switch (strtolower(trim($attribs['']['type']))) { - case 'text': - return SIMPLEPIE_CONSTRUCT_TEXT; + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; - case 'html': - return SIMPLEPIE_CONSTRUCT_HTML; + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; - case 'xhtml': - return SIMPLEPIE_CONSTRUCT_XHTML; + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; - default: - return SIMPLEPIE_CONSTRUCT_NONE; + default: + return SIMPLEPIE_CONSTRUCT_NONE; } } return SIMPLEPIE_CONSTRUCT_TEXT; @@ -11035,14 +11139,14 @@ class SimplePie_Misc $type = strtolower(trim($attribs['']['type'])); switch ($type) { - case 'text': - return SIMPLEPIE_CONSTRUCT_TEXT; + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; - case 'html': - return SIMPLEPIE_CONSTRUCT_HTML; + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; - case 'xhtml': - return SIMPLEPIE_CONSTRUCT_XHTML; + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; } if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') { @@ -11125,6 +11229,7 @@ class SimplePie_Misc } } + /** * Converts a unicode codepoint to a UTF-8 character * @@ -11141,21 +11246,21 @@ class SimplePie_Misc return false; } else if ($codepoint <= 0x7f) - { - return chr($codepoint); - } + { + return chr($codepoint); + } else if ($codepoint <= 0x7ff) - { - return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); - } + { + return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); + } else if ($codepoint <= 0xffff) - { - return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); - } + { + return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + } else if ($codepoint <= 0x10ffff) - { - return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); - } + { + return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + } else { // U+FFFD REPLACEMENT CHARACTER @@ -11163,6 +11268,7 @@ class SimplePie_Misc } } + /** * Re-implementation of PHP 5's stripos() * @@ -11206,6 +11312,7 @@ class SimplePie_Misc } } + /** * Similar to parse_str() * @@ -11354,7 +11461,7 @@ class SimplePie_Misc header('Content-type: text/javascript; charset: UTF-8'); header('Cache-Control: must-revalidate'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days - ?> +?> function embed_odeo(link) { document.writeln(''); } @@ -11381,6 +11488,7 @@ function embed_wmedia(width, height, link) { } data = $data; } + /** * Parse the input data * @@ -11444,6 +11555,7 @@ class SimplePie_Decode_HTML_Entities return $this->data; } + /** * Consume the next byte * @@ -11463,6 +11575,7 @@ class SimplePie_Decode_HTML_Entities } } + /** * Consume a range of characters * @@ -11485,6 +11598,7 @@ class SimplePie_Decode_HTML_Entities } } + /** * Unconsume one byte * @@ -11496,6 +11610,7 @@ class SimplePie_Decode_HTML_Entities $this->position--; } + /** * Decode an entity * @@ -11505,86 +11620,87 @@ class SimplePie_Decode_HTML_Entities { switch ($this->consume()) { - case "\x09": - case "\x0A": - case "\x0B": - case "\x0B": - case "\x0C": - case "\x20": - case "\x3C": - case "\x26": - case false: + case "\x09": + case "\x0A": + case "\x0B": + case "\x0B": + case "\x0C": + case "\x20": + case "\x3C": + case "\x26": + case false: + break; + + case "\x23": + switch ($this->consume()) + { + case "\x78": + case "\x58": + $range = '0123456789ABCDEFabcdef'; + $hex = true; break; - case "\x23": - switch ($this->consume()) - { - case "\x78": - case "\x58": - $range = '0123456789ABCDEFabcdef'; - $hex = true; - break; + default: + $range = '0123456789'; + $hex = false; + $this->unconsume(); + break; + } - default: - $range = '0123456789'; - $hex = false; - $this->unconsume(); - break; - } + if ($codepoint = $this->consume_range($range)) + { + static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); - if ($codepoint = $this->consume_range($range)) + if ($hex) { - static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); - - if ($hex) - { - $codepoint = hexdec($codepoint); - } - else - { - $codepoint = intval($codepoint); - } - - if (isset($windows_1252_specials[$codepoint])) - { - $replacement = $windows_1252_specials[$codepoint]; - } - else - { - $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); - } - - if (!in_array($this->consume(), array(';', false), true)) - { - $this->unconsume(); - } - - $consumed_length = strlen($this->consumed); - $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); - $this->position += strlen($replacement) - $consumed_length; + $codepoint = hexdec($codepoint); + } + else + { + $codepoint = intval($codepoint); } - break; - default: - static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C"); + if (isset($windows_1252_specials[$codepoint])) + { + $replacement = $windows_1252_specials[$codepoint]; + } + else + { + $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); + } - for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) + if (!in_array($this->consume(), array(';', false), true)) { - $consumed = substr($this->consumed, 1); - if (isset($entities[$consumed])) - { - $match = $consumed; - } + $this->unconsume(); } - if ($match !== null) + $consumed_length = strlen($this->consumed); + $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); + $this->position += strlen($replacement) - $consumed_length; + } + break; + + default: + static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C"); + + for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) + { + $consumed = substr($this->consumed, 1); + if (isset($entities[$consumed])) { - $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); - $this->position += strlen($entities[$match]) - strlen($consumed) - 1; + $match = $consumed; } - break; + } + + if ($match !== null) + { + $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); + $this->position += strlen($entities[$match]) - strlen($consumed) - 1; + } + break; } } + } /** @@ -11594,6 +11710,7 @@ class SimplePie_Decode_HTML_Entities */ class SimplePie_IRI { + /** * Scheme * @@ -11658,6 +11775,7 @@ class SimplePie_IRI */ var $valid = array(); + /** * Return the entire IRI when you try and read the object as a string * @@ -11669,6 +11787,7 @@ class SimplePie_IRI return $this->get_iri(); } + /** * Create a new IRI object, from a specified string * @@ -11771,6 +11890,7 @@ class SimplePie_IRI return $target; } + /** * Parse an IRI into scheme/authority/path/query/fragment segments * @@ -11788,6 +11908,7 @@ class SimplePie_IRI return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]); } + /** * Remove dot segments from a path * @@ -11849,6 +11970,7 @@ class SimplePie_IRI return $output . $input; } + /** * Replace invalid character with percent encoding * @@ -11928,6 +12050,7 @@ class SimplePie_IRI return $string; } + /** * Check if the object represents a valid IRI * @@ -11939,6 +12062,7 @@ class SimplePie_IRI return array_sum($this->valid) === count($this->valid); } + /** * Set the scheme. Returns true on success, false on failure (if there are * any invalid characters). @@ -11958,21 +12082,21 @@ class SimplePie_IRI $len = strlen($scheme); switch (true) { - case $len > 1: - if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1)) - { - $this->scheme = null; - $this->valid[__FUNCTION__] = false; - return false; - } + case $len > 1: + if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1)) + { + $this->scheme = null; + $this->valid[__FUNCTION__] = false; + return false; + } - case $len > 0: - if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1)) - { - $this->scheme = null; - $this->valid[__FUNCTION__] = false; - return false; - } + case $len > 0: + if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1)) + { + $this->scheme = null; + $this->valid[__FUNCTION__] = false; + return false; + } } $this->scheme = strtolower($scheme); } @@ -11980,6 +12104,7 @@ class SimplePie_IRI return true; } + /** * Set the authority. Returns true on success, false on failure (if there are * any invalid characters). @@ -12013,6 +12138,7 @@ class SimplePie_IRI return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port); } + /** * Set the userinfo. * @@ -12034,6 +12160,7 @@ class SimplePie_IRI return true; } + /** * Set the host. Returns true on success, false on failure (if there are * any invalid characters). @@ -12073,6 +12200,7 @@ class SimplePie_IRI } } + /** * Set the port. Returns true on success, false on failure (if there are * any invalid characters). @@ -12103,6 +12231,7 @@ class SimplePie_IRI } } + /** * Set the path. * @@ -12136,6 +12265,7 @@ class SimplePie_IRI } } + /** * Set the query. * @@ -12157,6 +12287,7 @@ class SimplePie_IRI return true; } + /** * Set the fragment. * @@ -12178,6 +12309,7 @@ class SimplePie_IRI return true; } + /** * Get the complete IRI * @@ -12218,6 +12350,7 @@ class SimplePie_IRI } } + /** * Get the scheme * @@ -12229,6 +12362,7 @@ class SimplePie_IRI return $this->scheme; } + /** * Get the complete authority * @@ -12261,6 +12395,7 @@ class SimplePie_IRI } } + /** * Get the user information * @@ -12272,6 +12407,7 @@ class SimplePie_IRI return $this->userinfo; } + /** * Get the host * @@ -12283,6 +12419,7 @@ class SimplePie_IRI return $this->host; } + /** * Get the port * @@ -12294,6 +12431,7 @@ class SimplePie_IRI return $this->port; } + /** * Get the path * @@ -12305,6 +12443,7 @@ class SimplePie_IRI return $this->path; } + /** * Get the query * @@ -12316,6 +12455,7 @@ class SimplePie_IRI return $this->query; } + /** * Get the fragment * @@ -12326,6 +12466,7 @@ class SimplePie_IRI { return $this->fragment; } + } /** @@ -12342,6 +12483,8 @@ class SimplePie_IRI */ class SimplePie_Net_IPv6 { + + /** * Removes a possible existing netmask specification of an IP address. * @@ -12364,6 +12507,7 @@ class SimplePie_Net_IPv6 return $addr; } + /** * Uncompresses an IPv6 address * @@ -12371,8 +12515,8 @@ class SimplePie_Net_IPv6 * function expects an valid IPv6 address and expands the '::' to * the required zeros. * - * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 - * ::1 -> 0:0:0:0:0:0:0:1 + * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 + * ::1 -> 0:0:0:0:0:0:0:1 * * @access public * @static @@ -12430,35 +12574,36 @@ class SimplePie_Net_IPv6 } // ::xxx else if ($c1 === -1) - { - $fill = str_repeat('0:', 7 - $c2); - $uip = str_replace('::', $fill, $uip); - } + { + $fill = str_repeat('0:', 7 - $c2); + $uip = str_replace('::', $fill, $uip); + } // xxx:: else if ($c2 === -1) - { - $fill = str_repeat(':0', 7 - $c1); - $uip = str_replace('::', $fill, $uip); - } + { + $fill = str_repeat(':0', 7 - $c1); + $uip = str_replace('::', $fill, $uip); + } // xxx::xxx else { $fill = str_repeat(':0:', 6 - $c2 - $c1); - $uip = str_replace('::', $fill, $uip); - $uip = str_replace('::', ':', $uip); + $uip = str_replace('::', $fill, $uip); + $uip = str_replace('::', ':', $uip); } } return $uip; } + /** * Splits an IPv6 address into the IPv6 and a possible IPv4 part * * RFC 2373 allows you to note the last two parts of an IPv6 address as * an IPv4 compatible address * - * Example: 0:0:0:0:0:0:13.1.68.3 - * 0:0:0:0:0:FFFF:129.144.52.38 + * Example: 0:0:0:0:0:0:13.1.68.3 + * 0:0:0:0:0:FFFF:129.144.52.38 * * @access public * @static @@ -12481,6 +12626,7 @@ class SimplePie_Net_IPv6 } } + /** * Checks an IPv6 address * @@ -12538,6 +12684,7 @@ class SimplePie_Net_IPv6 return false; } } + } /** @@ -12547,6 +12694,7 @@ class SimplePie_Net_IPv6 */ class SimplePie_Parse_Date { + /** * Input data * @@ -13029,6 +13177,7 @@ class SimplePie_Parse_Date */ var $user = array(); + /** * Create new SimplePie_Parse_Date object, and set self::day_pcre, * self::month_pcre, and self::built_in @@ -13075,6 +13224,7 @@ class SimplePie_Parse_Date return $object; } + /** * Parse a date * @@ -13104,6 +13254,7 @@ class SimplePie_Parse_Date return false; } + /** * Add a callback method to parse a date * @@ -13123,6 +13274,7 @@ class SimplePie_Parse_Date } } + /** * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as * well as allowing any of upper or lower case "T", horizontal tabs, or @@ -13196,6 +13348,7 @@ class SimplePie_Parse_Date } } + /** * Remove RFC822 comments * @@ -13231,13 +13384,13 @@ class SimplePie_Parse_Date { switch ($string[$position]) { - case '(': - $depth++; - break; + case '(': + $depth++; + break; - case ')': - $depth--; - break; + case ')': + $depth--; + break; } $position++; } @@ -13257,6 +13410,7 @@ class SimplePie_Parse_Date return $output; } + /** * Parse RFC2822's date format * @@ -13350,6 +13504,7 @@ class SimplePie_Parse_Date } } + /** * Parse RFC850's date format * @@ -13415,6 +13570,7 @@ class SimplePie_Parse_Date } } + /** * Parse C99's asctime()'s date format * @@ -13457,6 +13613,7 @@ class SimplePie_Parse_Date } } + /** * Parse dates using strtotime() * @@ -13475,6 +13632,7 @@ class SimplePie_Parse_Date return $strtotime; } } + } /** @@ -13484,6 +13642,7 @@ class SimplePie_Parse_Date */ class SimplePie_Content_Type_Sniffer { + /** * File object * @@ -13492,6 +13651,7 @@ class SimplePie_Content_Type_Sniffer */ var $file; + /** * Create an instance of the class with the input file * @@ -13503,6 +13663,7 @@ class SimplePie_Content_Type_Sniffer $this->file = $file; } + /** * Get the Content-Type of the specified file * @@ -13568,6 +13729,7 @@ class SimplePie_Content_Type_Sniffer } } + /** * Sniff text or binary * @@ -13593,6 +13755,7 @@ class SimplePie_Content_Type_Sniffer } } + /** * Sniff unknown * @@ -13639,6 +13802,7 @@ class SimplePie_Content_Type_Sniffer } } + /** * Sniff images * @@ -13670,6 +13834,7 @@ class SimplePie_Content_Type_Sniffer } } + /** * Sniff HTML * @@ -13685,19 +13850,19 @@ class SimplePie_Content_Type_Sniffer { switch ($this->file->body[$pos]) { - case "\x09": - case "\x0A": - case "\x0D": - case "\x20": - $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); - continue 2; + case "\x09": + case "\x0A": + case "\x0D": + case "\x20": + $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); + continue 2; - case '<': - $pos++; - break; + case '<': + $pos++; + break; - default: - return 'text/html'; + default: + return 'text/html'; } if (substr($this->file->body, $pos, 3) === '!--') @@ -13751,6 +13916,7 @@ class SimplePie_Content_Type_Sniffer return 'text/html'; } + } /** @@ -13760,6 +13926,7 @@ class SimplePie_Content_Type_Sniffer */ class SimplePie_XML_Declaration_Parser { + /** * XML Version * @@ -13816,6 +13983,7 @@ class SimplePie_XML_Declaration_Parser */ var $position = 0; + /** * Create an instance of the class with the input data * @@ -13828,6 +13996,7 @@ class SimplePie_XML_Declaration_Parser $this->data_length = strlen($this->data); } + /** * Parse the input data * @@ -13855,6 +14024,7 @@ class SimplePie_XML_Declaration_Parser } } + /** * Check whether there is data beyond the pointer * @@ -13866,6 +14036,7 @@ class SimplePie_XML_Declaration_Parser return (bool) ($this->position < $this->data_length); } + /** * Advance past any whitespace * @@ -13878,6 +14049,7 @@ class SimplePie_XML_Declaration_Parser return $whitespace; } + /** * Read value */ @@ -14040,17 +14212,17 @@ class SimplePie_XML_Declaration_Parser { switch ($standalone) { - case 'yes': - $this->standalone = true; - break; + case 'yes': + $this->standalone = true; + break; - case 'no': - $this->standalone = false; - break; + case 'no': + $this->standalone = false; + break; - default: - $this->state = false; - return; + default: + $this->state = false; + return; } $this->skip_whitespace(); @@ -14068,6 +14240,7 @@ class SimplePie_XML_Declaration_Parser $this->state = false; } } + } class SimplePie_Locator @@ -14325,6 +14498,7 @@ class SimplePie_Locator } return null; } + } class SimplePie_Parser @@ -14443,51 +14617,51 @@ class SimplePie_Parser switch ($xml->nodeType) { - case constant('XMLReader::END_ELEMENT'): + case constant('XMLReader::END_ELEMENT'): + if ($xml->namespaceURI !== '') + { + $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $tagName = $xml->localName; + } + $this->tag_close(null, $tagName); + break; + case constant('XMLReader::ELEMENT'): + $empty = $xml->isEmptyElement; + if ($xml->namespaceURI !== '') + { + $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $tagName = $xml->localName; + } + $attributes = array(); + while ($xml->moveToNextAttribute()) + { if ($xml->namespaceURI !== '') { - $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; } else { - $tagName = $xml->localName; + $attrName = $xml->localName; } + $attributes[$attrName] = $xml->value; + } + $this->tag_open(null, $tagName, $attributes); + if ($empty) + { $this->tag_close(null, $tagName); - break; - case constant('XMLReader::ELEMENT'): - $empty = $xml->isEmptyElement; - if ($xml->namespaceURI !== '') - { - $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; - } - else - { - $tagName = $xml->localName; - } - $attributes = array(); - while ($xml->moveToNextAttribute()) - { - if ($xml->namespaceURI !== '') - { - $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; - } - else - { - $attrName = $xml->localName; - } - $attributes[$attrName] = $xml->value; - } - $this->tag_open(null, $tagName, $attributes); - if ($empty) - { - $this->tag_close(null, $tagName); - } - break; - case constant('XMLReader::TEXT'): + } + break; + case constant('XMLReader::TEXT'): - case constant('XMLReader::CDATA'): - $this->cdata(null, $xml->value); - break; + case constant('XMLReader::CDATA'): + $this->cdata(null, $xml->value); + break; } } if ($error = libxml_get_last_error()) @@ -14588,7 +14762,7 @@ class SimplePie_Parser $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') - || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')) + || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')) { $this->current_xhtml_construct = 0; } @@ -14663,6 +14837,7 @@ class SimplePie_Parser } return $cache[$string]; } + } /** @@ -14818,6 +14993,7 @@ class SimplePie_Sanitize $this->output_encoding = (string) $encoding; } + /** * Set element/attribute key/value pairs of HTML attributes * containing URLs that need to be resolved relative to the feed @@ -15018,6 +15194,7 @@ class SimplePie_Sanitize return ''; } } + } ?> diff --git a/interface/lib/classes/sites_database_plugin.inc.php b/interface/lib/classes/sites_database_plugin.inc.php index 37cc546b1..d255fdca8 100644 --- a/interface/lib/classes/sites_database_plugin.inc.php +++ b/interface/lib/classes/sites_database_plugin.inc.php @@ -31,22 +31,22 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class sites_database_plugin { public function processDatabaseInsert($form_page) { - global $app; - + global $app; + /*if($form_page->dataRecord["parent_domain_id"] > 0) { $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($form_page->dataRecord["parent_domain_id"])); - + //* The Database user shall be owned by the same group then the website $sys_groupid = $web['sys_groupid']; } else { $sys_groupid = $form_page->dataRecord['sys_groupid']; } - - + + if($form_page->dataRecord['database_user_id']) { // check if there has already been a database on this server with that user $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "')"); - + if($check && $check['cnt'] < 1) { // we need to make a datalog insert for the database users that are connected to this database $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "'"); @@ -60,7 +60,7 @@ class sites_database_plugin { if($form_page->dataRecord['database_ro_user_id']) { // check if there has already been a database on this server with that user $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "')"); - + if($check && $check['cnt'] < 1) { // we need to make a datalog insert for the database users that are connected to this database $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "'"); @@ -70,22 +70,22 @@ class sites_database_plugin { } } }*/ - } - - public function processDatabaseUpdate($form_page) { - global $app; - - /*$old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . $app->functions->intval($form_page->id)); - + } + + public function processDatabaseUpdate($form_page) { + global $app; + + /*$old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . $app->functions->intval($form_page->id)); + if($form_page->dataRecord["parent_domain_id"] > 0) { $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($form_page->dataRecord["parent_domain_id"])); - + //* The Database user shall be owned by the same group then the website $sys_groupid = $web['sys_groupid']; } else { $sys_groupid = $form_page->dataRecord['sys_groupid']; } - + // check if database user has changed if($old_record['database_user_id'] && $old_record['database_user_id'] != $form_page->dataRecord['database_user_id'] && $old_record['database_user_id'] != $form_page->dataRecord['database_ro_user_id']) { // check if any database on the server still uses this one @@ -112,11 +112,11 @@ class sites_database_plugin { } } }*/ - - /*if($form_page->dataRecord['database_user_id']) { + + /*if($form_page->dataRecord['database_user_id']) { // check if there has already been a database on this server with that user $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "')"); - + if($check && $check['cnt'] < 1) { // we need to make a datalog insert for the database users that are connected to this database $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_user_id']) . "'"); @@ -130,7 +130,7 @@ class sites_database_plugin { if($form_page->dataRecord['database_ro_user_id']) { // check if there has already been a database on this server with that user $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($form_page->dataRecord['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "')"); - + if($check && $check['cnt'] < 1) { // we need to make a datalog insert for the database users that are connected to this database $db_user = $app->db->queryOneRecord("SELECT * FROM `web_database_user` WHERE `database_user_id` = '" . $app->functions->intval($form_page->dataRecord['database_ro_user_id']) . "'"); @@ -140,13 +140,13 @@ class sites_database_plugin { } } }*/ - - } - - public function processDatabaseDelete($primary_id) { - global $app; - - /*$old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . $app->functions->intval($primary_id)); + + } + + public function processDatabaseDelete($primary_id) { + global $app; + + /*$old_record = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_id` = ' . $app->functions->intval($primary_id)); if($old_record['database_user_id']) { // check if any database on the server still uses this one $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_database` WHERE `server_id` = '" . $app->functions->intval($old_record['server_id']) . "' AND (`database_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "' OR `database_ro_user_id` = '" . $app->functions->intval($old_record['database_user_id']) . "') AND `database_id` != '" . $app->functions->intval($primary_id) . "'"); @@ -171,8 +171,9 @@ class sites_database_plugin { } } }*/ - - } + + } + } ?> diff --git a/interface/lib/classes/soap_handler.inc.php b/interface/lib/classes/soap_handler.inc.php index e998d21fe..c2bf64376 100644 --- a/interface/lib/classes/soap_handler.inc.php +++ b/interface/lib/classes/soap_handler.inc.php @@ -31,64 +31,65 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class ISPConfigSoapHandler { - private $methods = array(); - private $classes = array(); - - public function __construct() { - global $app; - - // load main remoting file - $app->load('remoting'); - - // load all remote classes and get their methods - $dir = dirname(realpath(__FILE__)) . '/remote.d'; - $d = opendir($dir); - while($f = readdir($d)) { - if($f == '.' || $f == '..') continue; - if(!is_file($dir . '/' . $f) || substr($f, strrpos($f, '.')) != '.php') continue; - - $name = substr($f, 0, strpos($f, '.')); - - include($dir . '/' . $f); - $class_name = 'remoting_' . $name; - if(class_exists($class_name, false)) { - $this->classes[$class_name] = new $class_name(); - foreach(get_class_methods($this->classes[$class_name]) as $method) { - $this->methods[$method] = $class_name; - } - } - } - closedir($d); - - // add main methods - $this->methods['login'] = 'remoting'; - $this->methods['logout'] = 'remoting'; - $this->methods['get_function_list'] = 'remoting'; - - // create main class - $this->classes['remoting'] = new remoting(array_keys($this->methods)); - } - - public function __call($method, $params) { - if(array_key_exists($method, $this->methods) == false) { - throw new SoapFault('invalid_method', 'Method ' . $method . ' does not exist'); - } - - $class_name = $this->methods[$method]; - if(array_key_exists($class_name, $this->classes) == false) { - throw new SoapFault('invalid_class', 'Class ' . $class_name . ' does not exist'); - } - - if(method_exists($this->classes[$class_name], $method) == false) { - throw new SoapFault('invalid_method', 'Method ' . $method . ' does not exist in the class it was expected (' . $class_name . ')'); - } - - try { - return call_user_func_array(array($this->classes[$class_name], $method), $params); - } catch(SoapFault $e) { - throw $e; - } - } + private $methods = array(); + private $classes = array(); + + public function __construct() { + global $app; + + // load main remoting file + $app->load('remoting'); + + // load all remote classes and get their methods + $dir = dirname(realpath(__FILE__)) . '/remote.d'; + $d = opendir($dir); + while($f = readdir($d)) { + if($f == '.' || $f == '..') continue; + if(!is_file($dir . '/' . $f) || substr($f, strrpos($f, '.')) != '.php') continue; + + $name = substr($f, 0, strpos($f, '.')); + + include $dir . '/' . $f; + $class_name = 'remoting_' . $name; + if(class_exists($class_name, false)) { + $this->classes[$class_name] = new $class_name(); + foreach(get_class_methods($this->classes[$class_name]) as $method) { + $this->methods[$method] = $class_name; + } + } + } + closedir($d); + + // add main methods + $this->methods['login'] = 'remoting'; + $this->methods['logout'] = 'remoting'; + $this->methods['get_function_list'] = 'remoting'; + + // create main class + $this->classes['remoting'] = new remoting(array_keys($this->methods)); + } + + public function __call($method, $params) { + if(array_key_exists($method, $this->methods) == false) { + throw new SoapFault('invalid_method', 'Method ' . $method . ' does not exist'); + } + + $class_name = $this->methods[$method]; + if(array_key_exists($class_name, $this->classes) == false) { + throw new SoapFault('invalid_class', 'Class ' . $class_name . ' does not exist'); + } + + if(method_exists($this->classes[$class_name], $method) == false) { + throw new SoapFault('invalid_method', 'Method ' . $method . ' does not exist in the class it was expected (' . $class_name . ')'); + } + + try { + return call_user_func_array(array($this->classes[$class_name], $method), $params); + } catch(SoapFault $e) { + throw $e; + } + } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php index 806d6b247..f33450881 100644 --- a/interface/lib/classes/tform.inc.php +++ b/interface/lib/classes/tform.inc.php @@ -29,313 +29,317 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** -* Formularbehandlung -* -* Functions to validate, display and save form values -* -* Database table field definitions -* -* Datatypes: -* - INTEGER (Converts data to int automatically) -* - DOUBLE -* - CURRENCY (Formats digits in currency notation) -* - VARCHAR (No format check) -* - DATE (Date format, converts from and to UNIX timestamps automatically) -* -* Formtype: -* - TEXT (Normal text field) -* - PASSWORD (password field, the content will not be displayed again to the user) -* - SELECT (Option fiield) -* - MULTIPLE (Allows selection of multiple values) -* -* VALUE: -* - Value or array -* -* SEPARATOR -* - separator char used for fileds with multiple values -* -* Hint: The auto increment (ID) filed of the table has not be be definied separately. -* -*/ + * Formularbehandlung + * + * Functions to validate, display and save form values + * + * Database table field definitions + * + * Datatypes: + * - INTEGER (Converts data to int automatically) + * - DOUBLE + * - CURRENCY (Formats digits in currency notation) + * - VARCHAR (No format check) + * - DATE (Date format, converts from and to UNIX timestamps automatically) + * + * Formtype: + * - TEXT (Normal text field) + * - PASSWORD (password field, the content will not be displayed again to the user) + * - SELECT (Option fiield) + * - MULTIPLE (Allows selection of multiple values) + * + * VALUE: + * - Value or array + * + * SEPARATOR + * - separator char used for fileds with multiple values + * + * Hint: The auto increment (ID) filed of the table has not be be definied separately. + * + */ + + global $app; $app->load('tform_base'); class tform extends tform_base { - /* + /* This function checks if a user has the parmissions $perm for the data record with the ID $record_id If record_id = 0, the the permissions are tested against the defaults of the form file. */ - function checkPerm($record_id,$perm) { - global $app; - - if($record_id > 0) { - // Add backticks for incomplete table names. - if(stristr($this->formDef['db_table'],'.')) { - $escape = ''; - } else { - $escape = '`'; - } - - $sql = "SELECT ".$this->formDef['db_table_idx']." FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$record_id." AND ".$this->getAuthSQL($perm); - if($record = $app->db->queryOneRecord($sql)) { - return true; - } else { - return false; - } - } else { - $result = false; - if(@$this->formDef["auth_preset"]["userid"] == $_SESSION["s"]["user"]["userid"] && stristr($perm,$this->formDef["auth_preset"]["perm_user"])) $result = true; - if(@$this->formDef["auth_preset"]["groupid"] == $_SESSION["s"]["user"]["groupid"] && stristr($perm,$this->formDef["auth_preset"]["perm_group"])) $result = true; - if(@stristr($this->formDef["auth_preset"]["perm_other"],$perm)) $result = true; + function checkPerm($record_id, $perm) { + global $app; - // if preset == 0, everyone can insert a record of this type - if($this->formDef["auth_preset"]["userid"] == 0 AND $this->formDef["auth_preset"]["groupid"] == 0 AND (@stristr($this->formDef["auth_preset"]["perm_user"],$perm) OR @stristr($this->formDef["auth_preset"]["perm_group"],$perm))) $result = true; + if($record_id > 0) { + // Add backticks for incomplete table names. + if(stristr($this->formDef['db_table'], '.')) { + $escape = ''; + } else { + $escape = '`'; + } - return $result; + $sql = "SELECT ".$this->formDef['db_table_idx']." FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$record_id." AND ".$this->getAuthSQL($perm); + if($record = $app->db->queryOneRecord($sql)) { + return true; + } else { + return false; + } + } else { + $result = false; + if(@$this->formDef["auth_preset"]["userid"] == $_SESSION["s"]["user"]["userid"] && stristr($perm, $this->formDef["auth_preset"]["perm_user"])) $result = true; + if(@$this->formDef["auth_preset"]["groupid"] == $_SESSION["s"]["user"]["groupid"] && stristr($perm, $this->formDef["auth_preset"]["perm_group"])) $result = true; + if(@stristr($this->formDef["auth_preset"]["perm_other"], $perm)) $result = true; - } + // if preset == 0, everyone can insert a record of this type + if($this->formDef["auth_preset"]["userid"] == 0 and $this->formDef["auth_preset"]["groupid"] == 0 and (@stristr($this->formDef["auth_preset"]["perm_user"], $perm) or @stristr($this->formDef["auth_preset"]["perm_group"], $perm))) $result = true; + + return $result; } - function getNextTab() { - // Which tab is shown - if($this->errorMessage == '') { - // If there is no error - if(isset($_REQUEST["next_tab"]) && $_REQUEST["next_tab"] != '') { - // If the next tab is known - $active_tab = $_REQUEST["next_tab"]; - } else { - // else use the default tab - $active_tab = $this->formDef['tab_default']; - } - } else { - // Show the same tab again in case of an error - $active_tab = $_SESSION["s"]["form"]["tab"]; - } + } - return $active_tab; + function getNextTab() { + // Which tab is shown + if($this->errorMessage == '') { + // If there is no error + if(isset($_REQUEST["next_tab"]) && $_REQUEST["next_tab"] != '') { + // If the next tab is known + $active_tab = $_REQUEST["next_tab"]; + } else { + // else use the default tab + $active_tab = $this->formDef['tab_default']; + } + } else { + // Show the same tab again in case of an error + $active_tab = $_SESSION["s"]["form"]["tab"]; } - function getCurrentTab() { - return $_SESSION["s"]["form"]["tab"]; + return $active_tab; + } + + function getCurrentTab() { + return $_SESSION["s"]["form"]["tab"]; + } + + function isReadonlyTab($tab, $primary_id) { + global $app, $conf; + + // Add backticks for incomplete table names. + if(stristr($this->formDef['db_table'], '.')) { + $escape = ''; + } else { + $escape = '`'; } - function isReadonlyTab($tab, $primary_id) { - global $app, $conf; + $sql = "SELECT sys_userid FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id; + $record = $app->db->queryOneRecord($sql); - // Add backticks for incomplete table names. - if(stristr($this->formDef['db_table'],'.')) { - $escape = ''; - } else { - $escape = '`'; - } + // return true if the readonly flag of the form is set and the current loggedin user is not the owner of the record. + if(isset($this->formDef['tabs'][$tab]['readonly']) && $this->formDef['tabs'][$tab]['readonly'] == true && $record['sys_userid'] != $_SESSION["s"]["user"]["userid"]) { + return true; + } else { + return false; + } + } - $sql = "SELECT sys_userid FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id; - $record = $app->db->queryOneRecord($sql); - // return true if the readonly flag of the form is set and the current loggedin user is not the owner of the record. - if(isset($this->formDef['tabs'][$tab]['readonly']) && $this->formDef['tabs'][$tab]['readonly'] == true && $record['sys_userid'] != $_SESSION["s"]["user"]["userid"]) { - return true; - } else { - return false; - } + // translation function for forms, tries the form wordbook first and if this fails, it tries the global wordbook + function lng($msg) { + global $app, $conf; + + if(isset($this->wordbook[$msg])) { + return $this->wordbook[$msg]; + } else { + return $app->lng($msg); } + } - // translation function for forms, tries the form wordbook first and if this fails, it tries the global wordbook - function lng($msg) { - global $app,$conf; + function checkClientLimit($limit_name, $sql_where = '') { + global $app; - if(isset($this->wordbook[$msg])) { - return $this->wordbook[$msg]; - } else { - return $app->lng($msg); - } + $check_passed = true; + $limit_name = $app->db->quote($limit_name); + if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.'); + + // Get the limits of the client that is currently logged in + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT $limit_name as number, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + // Check if the user may add another item + if($client["number"] >= 0) { + $sql = "SELECT count(".$this->formDef['db_table_idx'].") as number FROM ".$this->formDef['db_table']." WHERE ".$this->getAuthSQL('u'); + if($sql_where != '') $sql .= ' and '.$sql_where; + $tmp = $app->db->queryOneRecord($sql); + if($tmp["number"] >= $client["number"]) $check_passed = false; } - function checkClientLimit($limit_name,$sql_where = '') { - global $app; + return $check_passed; + } - $check_passed = true; - $limit_name = $app->db->quote($limit_name); - if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.'); + function checkResellerLimit($limit_name, $sql_where = '') { + global $app; - // Get the limits of the client that is currently logged in + $check_passed = true; + $limit_name = $app->db->quote($limit_name); + if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.'); + + // Get the limits of the client that is currently logged in + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + //* If the client belongs to a reseller, we will check against the reseller Limit too + if($client['parent_client_id'] != 0) { + + //* first we need to know the groups of this reseller + $tmp = $app->db->queryOneRecord("SELECT userid, groups FROM sys_user WHERE client_id = ".$client['parent_client_id']); + $reseller_groups = $tmp["groups"]; + $reseller_userid = $tmp["userid"]; + + // Get the limits of the reseller of the logged in client $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT $limit_name as number, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $reseller = $app->db->queryOneRecord("SELECT $limit_name as number FROM client WHERE client_id = ".$client['parent_client_id']); // Check if the user may add another item - if($client["number"] >= 0) { - $sql = "SELECT count(".$this->formDef['db_table_idx'].") as number FROM ".$this->formDef['db_table']." WHERE ".$this->getAuthSQL('u'); + if($reseller["number"] >= 0) { + $sql = "SELECT count(".$this->formDef['db_table_idx'].") as number FROM ".$this->formDef['db_table']." WHERE (sys_groupid IN (".$reseller_groups.") or sys_userid = ".$reseller_userid.")"; if($sql_where != '') $sql .= ' and '.$sql_where; $tmp = $app->db->queryOneRecord($sql); - if($tmp["number"] >= $client["number"]) $check_passed = false; + if($tmp["number"] >= $reseller["number"]) $check_passed = false; } - - return $check_passed; } - function checkResellerLimit($limit_name,$sql_where = '') { - global $app; + return $check_passed; + } - $check_passed = true; - $limit_name = $app->db->quote($limit_name); - if($limit_name == '') $app->error('Limit name missing in function checkClientLimit.'); + //* get the difference record of two arrays + function getDiffRecord($record_old, $record_new) { - // Get the limits of the client that is currently logged in - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - - //* If the client belongs to a reseller, we will check against the reseller Limit too - if($client['parent_client_id'] != 0) { - - //* first we need to know the groups of this reseller - $tmp = $app->db->queryOneRecord("SELECT userid, groups FROM sys_user WHERE client_id = ".$client['parent_client_id']); - $reseller_groups = $tmp["groups"]; - $reseller_userid = $tmp["userid"]; - - // Get the limits of the reseller of the logged in client - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $reseller = $app->db->queryOneRecord("SELECT $limit_name as number FROM client WHERE client_id = ".$client['parent_client_id']); - - // Check if the user may add another item - if($reseller["number"] >= 0) { - $sql = "SELECT count(".$this->formDef['db_table_idx'].") as number FROM ".$this->formDef['db_table']." WHERE (sys_groupid IN (".$reseller_groups.") or sys_userid = ".$reseller_userid.")"; - if($sql_where != '') $sql .= ' and '.$sql_where; - $tmp = $app->db->queryOneRecord($sql); - if($tmp["number"] >= $reseller["number"]) $check_passed = false; - } - } - - return $check_passed; - } - - //* get the difference record of two arrays - function getDiffRecord($record_old,$record_new) { - - if(is_array($record_new) && count($record_new) > 0) { + if(is_array($record_new) && count($record_new) > 0) { foreach($record_new as $key => $val) { if(@$record_old[$key] != $val) { // Record has changed - $diffrec[$key] = array( 'old' => @$record_old[$key], - 'new' => $val); - } + $diffrec[$key] = array( 'old' => @$record_old[$key], + 'new' => $val); } - } elseif(is_array($record_old)) { - foreach($record_old as $key => $val) { - if($record_new[$key] != $val) { - // Record has changed - $diffrec[$key] = array( 'new' => $record_new[$key], - 'old' => $val); - } - } + } + } elseif(is_array($record_old)) { + foreach($record_old as $key => $val) { + if($record_new[$key] != $val) { + // Record has changed + $diffrec[$key] = array( 'new' => $record_new[$key], + 'old' => $val); } - return $diffrec; - + } + } + return $diffrec; + + } + + + /** + * Generate HTML for DATETIME fields. + * + * @access private + * @param string $form_element Name of the form element. + * @param string $default_value Selected value for fields. + * @param bool $display_secons Include seconds selection. + * @return string HTML + */ + function _getDateTimeHTML($form_element, $default_value, $display_seconds=false) + { + $_datetime = strtotime($default_value); + $_showdate = ($_datetime === false) ? false : true; + + $dselect = array('day', 'month', 'year', 'hour', 'minute'); + if ($display_seconds === true) { + $dselect[] = 'second'; } - /** - * Generate HTML for DATETIME fields. - * - * @access private - * @param string $form_element Name of the form element. - * @param string $default_value Selected value for fields. - * @param bool $display_secons Include seconds selection. - * @return string HTML - */ - function _getDateTimeHTML($form_element, $default_value, $display_seconds=false) - { - $_datetime = strtotime($default_value); - $_showdate = ($_datetime === false) ? false : true; + $out = ''; - $dselect = array('day','month','year','hour','minute'); - if ($display_seconds === true) { - $dselect[] = 'second'; - } + foreach ($dselect as $dt_element) + { + $dt_options = array(); + $dt_space = 1; + + switch ($dt_element) { + case 'day': + for ($i = 1; $i <= 31; $i++) { + $dt_options[] = array('name' => sprintf('%02d', $i), + 'value' => sprintf('%d', $i)); + } + $selected_value = date('d', $_datetime); + break; - $out = ''; - - foreach ($dselect as $dt_element) - { - $dt_options = array(); - $dt_space = 1; - - switch ($dt_element) { - case 'day': - for ($i = 1; $i <= 31; $i++) { - $dt_options[] = array('name' => sprintf('%02d', $i), - 'value' => sprintf('%d', $i)); - } - $selected_value = date('d', $_datetime); - break; - - case 'month': - for ($i = 1; $i <= 12; $i++) { - $dt_options[] = array('name' => strftime('%b', mktime(0, 0, 0, $i, 1, 2000)), - 'value' => strftime('%m', mktime(0, 0, 0, $i, 1, 2000))); - } - $selected_value = date('n', $_datetime); - break; - - case 'year': - $start_year = strftime("%Y"); - $years = range((int)$start_year, (int)($start_year+3)); - - foreach ($years as $year) { - $dt_options[] = array('name' => $year, - 'value' => $year); - } - $selected_value = date('Y', $_datetime); - $dt_space = 2; - break; - - case 'hour': - foreach(range(0, 23) as $hour) { - $dt_options[] = array('name' => sprintf('%02d', $hour), - 'value' => sprintf('%d', $hour)); - } - $selected_value = date('G', $_datetime); - break; - - case 'minute': - foreach(range(0, 59) as $minute) { - if (($minute % 5) == 0) { - $dt_options[] = array('name' => sprintf('%02d', $minute), - 'value' => sprintf('%d', $minute)); - } - } - $selected_value = (int)floor(date('i', $_datetime)); - break; - - case 'second': - foreach(range(0, 59) as $second) { - $dt_options[] = array('name' => sprintf('%02d', $second), - 'value' => sprintf('%d', $second)); - } - $selected_value = (int)floor(date('s', $_datetime)); - break; - } - - $out .= "' . str_repeat(' ', $dt_space); + $out .= "' . str_repeat(' ', $dt_space); } + + return $out; + } + } ?> diff --git a/interface/lib/classes/tform_actions.inc.php b/interface/lib/classes/tform_actions.inc.php index 4db3157e5..336d2fb5d 100644 --- a/interface/lib/classes/tform_actions.inc.php +++ b/interface/lib/classes/tform_actions.inc.php @@ -30,570 +30,578 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class tform_actions { - public $id; - public $activeTab; - public $dataRecord; - public $plugins = array(); - public $oldDataRecord; // This array is only filled during updates and when db_history is enabled. - - function onLoad() { - global $app, $conf, $tform_def_file; - - // Loading template classes and initialize template - if(!is_object($app->tpl)) $app->uses('tpl'); - if(!is_object($app->tform)) $app->uses('tform'); - - $app->tpl->newTemplate("tabbed_form.tpl.htm"); - - // Load table definition from file - $app->tform->loadFormDef($tform_def_file); - - // Importing ID - $this->id = (isset($_REQUEST["id"]))?$app->functions->intval($_REQUEST["id"]):0; - - // show print version of the form - if(isset($_GET["print_form"]) && $_GET["print_form"] == 1) { - die('Function disabled.'); - $this->onPrintForm(); - } - - // send this form by email - if(isset($_GET["send_form_by_mail"]) && $_GET["send_form_by_mail"] == 1) { - die('Function disabled.'); - $this->onMailSendForm(); - } + public $id; + public $activeTab; + public $dataRecord; + public $plugins = array(); + public $oldDataRecord; // This array is only filled during updates and when db_history is enabled. + + function onLoad() { + global $app, $conf, $tform_def_file; + + // Loading template classes and initialize template + if(!is_object($app->tpl)) $app->uses('tpl'); + if(!is_object($app->tform)) $app->uses('tform'); + + $app->tpl->newTemplate("tabbed_form.tpl.htm"); + + // Load table definition from file + $app->tform->loadFormDef($tform_def_file); + + // Importing ID + $this->id = (isset($_REQUEST["id"]))?$app->functions->intval($_REQUEST["id"]):0; + + // show print version of the form + if(isset($_GET["print_form"]) && $_GET["print_form"] == 1) { + die('Function disabled.'); + $this->onPrintForm(); + } + + // send this form by email + if(isset($_GET["send_form_by_mail"]) && $_GET["send_form_by_mail"] == 1) { + die('Function disabled.'); + $this->onMailSendForm(); + } + + if(count($_POST) > 1) { + $this->dataRecord = $_POST; + $this->onSubmit(); + } else { + $this->onShow(); + } + } + + /** + * Function called on page submit + */ + + + function onSubmit() { + global $app, $conf; + + // check if the client is locked - he may not change anything, then. + if(!$app->auth->is_admin()) { + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT client.locked FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$app->functions->intval($client_group_id)); + if(is_array($client) && $client['locked'] == 'y') { + $app->tform->errorMessage .= $app->lng("client_you_are_locked")."
"; + } + } + + // Calling the action functions + if($this->id > 0) { + $app->tform->action == 'EDIT'; + $this->onUpdate(); + } else { + $app->tform->action == 'NEW'; + $this->onInsert(); + } + } + - if(count($_POST) > 1) { - $this->dataRecord = $_POST; - $this->onSubmit(); - } else { - $this->onShow(); - } - } - - /** - * Function called on page submit - */ - - function onSubmit() { - global $app, $conf; - - // check if the client is locked - he may not change anything, then. - if(!$app->auth->is_admin()) { - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.locked FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ".$app->functions->intval($client_group_id)); - if(is_array($client) && $client['locked'] == 'y') { - $app->tform->errorMessage .= $app->lng("client_you_are_locked")."
"; - } + /** + * Function called on data update + */ + function onUpdate() { + global $app, $conf; + + $this->onBeforeUpdate(); + + $ext_where = ''; + $sql = $app->tform->getSQL($this->dataRecord, $app->tform->getCurrentTab(), 'UPDATE', $this->id, $ext_where); + if($app->tform->errorMessage == '') { + + if($app->tform->formDef['db_history'] == 'yes') { + $this->oldDataRecord = $app->tform->getDataRecord($this->id); + } + + // Save record in database + $this->onUpdateSave($sql); + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_update_save', array('page_form'=>$this, 'sql'=>$sql)); + + // loading plugins + $next_tab = $app->tform->getCurrentTab(); + $this->loadPlugins($next_tab); + + // Call plugin + foreach($this->plugins as $plugin) { + $plugin->onUpdate(); + } + + $this->onAfterUpdate(); + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_update', $this); + + // Write data history (sys_datalog) + if($app->tform->formDef['db_history'] == 'yes') { + $new_data_record = $app->tform->getDataRecord($this->id); + $app->tform->datalogSave('UPDATE', $this->id, $this->oldDataRecord, $new_data_record); + unset($new_data_record); + unset($old_data_record); + } + + if($_REQUEST["next_tab"] == '') { + $list_name = $_SESSION["s"]["form"]["return_to"]; + // When a list is embedded inside of a form + + //if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { + if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { + $redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; + $_SESSION["s"]["form"]["return_to"] = ''; + session_write_close(); + header($redirect); + // When a returnto variable is set + } elseif (isset($_SESSION["s"]["form"]["return_to_url"]) && $_SESSION["s"]["form"]["return_to_url"] != '') { + $redirect = $_SESSION["s"]["form"]["return_to_url"]; + $_SESSION["s"]["form"]["return_to_url"] = ''; + session_write_close(); + header("Location: ".$redirect); + exit; + // Use the default list of the form + } else { + header("Location: ".$app->tform->formDef['list_default']); } - - // Calling the action functions - if($this->id > 0) { - $app->tform->action == 'EDIT'; - $this->onUpdate(); - } else { - $app->tform->action == 'NEW'; - $this->onInsert(); - } - } - - /** - * Function called on data update - */ - - function onUpdate() { - global $app, $conf; - - $this->onBeforeUpdate(); - - $ext_where = ''; - $sql = $app->tform->getSQL($this->dataRecord,$app->tform->getCurrentTab(),'UPDATE',$this->id,$ext_where); - if($app->tform->errorMessage == '') { - - if($app->tform->formDef['db_history'] == 'yes') { - $this->oldDataRecord = $app->tform->getDataRecord($this->id); - } - - // Save record in database - $this->onUpdateSave($sql); - $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_update_save',array('page_form'=>$this, 'sql'=>$sql)); - - // loading plugins - $next_tab = $app->tform->getCurrentTab(); - $this->loadPlugins($next_tab); - - // Call plugin - foreach($this->plugins as $plugin) { - $plugin->onUpdate(); - } - - $this->onAfterUpdate(); - $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_update',$this); - - // Write data history (sys_datalog) - if($app->tform->formDef['db_history'] == 'yes') { - $new_data_record = $app->tform->getDataRecord($this->id); - $app->tform->datalogSave('UPDATE',$this->id,$this->oldDataRecord,$new_data_record); - unset($new_data_record); - unset($old_data_record); - } - - if($_REQUEST["next_tab"] == '') { - $list_name = $_SESSION["s"]["form"]["return_to"]; - // When a list is embedded inside of a form - - //if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { - if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { - $redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; - $_SESSION["s"]["form"]["return_to"] = ''; - session_write_close(); - header($redirect); - // When a returnto variable is set - } elseif (isset($_SESSION["s"]["form"]["return_to_url"]) && $_SESSION["s"]["form"]["return_to_url"] != '') { - $redirect = $_SESSION["s"]["form"]["return_to_url"]; - $_SESSION["s"]["form"]["return_to_url"] = ''; - session_write_close(); - header("Location: ".$redirect); - exit; - // Use the default list of the form - } else { - header("Location: ".$app->tform->formDef['list_default']); - } - exit; - } else { - $this->onShow(); - } - } else { - $this->onError(); - } - } - - /* + exit; + } else { + $this->onShow(); + } + } else { + $this->onError(); + } + } + + /* Save record in database */ - - function onUpdateSave($sql) { - global $app; - if(!empty($sql) && !$app->tform->isReadonlyTab($app->tform->getCurrentTab(),$this->id)) { - $app->db->query($sql); - if($app->db->errorMessage != '') die($app->db->errorMessage); + + function onUpdateSave($sql) { + global $app; + if(!empty($sql) && !$app->tform->isReadonlyTab($app->tform->getCurrentTab(), $this->id)) { + $app->db->query($sql); + if($app->db->errorMessage != '') die($app->db->errorMessage); + } + } + + + + + + /** + * Function called on data insert + */ + function onInsert() { + global $app, $conf; + + $this->onBeforeInsert(); + + $ext_where = ''; + $sql = $app->tform->getSQL($this->dataRecord, $app->tform->getCurrentTab(), 'INSERT', $this->id, $ext_where); + if($app->tform->errorMessage == '') { + + $this->id = $this->onInsertSave($sql); + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_insert_save', array('page_form'=>$this, 'sql'=>$sql)); + + // loading plugins + $next_tab = $app->tform->getCurrentTab(); + $this->loadPlugins($next_tab); + + // Call plugin + foreach($this->plugins as $plugin) { + $plugin->onInsert(); } + + $this->onAfterInsert(); + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_insert', $this); + + // Write data history (sys_datalog) + if($app->tform->formDef['db_history'] == 'yes') { + $new_data_record = $app->tform->getDataRecord($this->id); + $app->tform->datalogSave('INSERT', $this->id, array(), $new_data_record); + unset($new_data_record); + } + + + if($_REQUEST["next_tab"] == '') { + $list_name = $_SESSION["s"]["form"]["return_to"]; + // if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { + if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { + $redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; + $_SESSION["s"]["form"]["return_to"] = ''; + session_write_close(); + header($redirect); + exit; + } elseif ($_SESSION["s"]["form"]["return_to_url"] != '') { + $redirect = $_SESSION["s"]["form"]["return_to_url"]; + $_SESSION["s"]["form"]["return_to_url"] = ''; + session_write_close(); + header("Location: ".$redirect); + exit; + } else { + header("Location: ".$app->tform->formDef['list_default']); + } + exit; + } else { + $this->onShow(); + } + } else { + $this->onError(); } - - - /** - * Function called on data insert - */ - - function onInsert() { - global $app, $conf; - - $this->onBeforeInsert(); - - $ext_where = ''; - $sql = $app->tform->getSQL($this->dataRecord,$app->tform->getCurrentTab(),'INSERT',$this->id,$ext_where); - if($app->tform->errorMessage == '') { - - $this->id = $this->onInsertSave($sql); - $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_insert_save',array('page_form'=>$this, 'sql'=>$sql)); - - // loading plugins - $next_tab = $app->tform->getCurrentTab(); - $this->loadPlugins($next_tab); - - // Call plugin - foreach($this->plugins as $plugin) { - $plugin->onInsert(); - } - - $this->onAfterInsert(); - $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_insert',$this); - - // Write data history (sys_datalog) - if($app->tform->formDef['db_history'] == 'yes') { - $new_data_record = $app->tform->getDataRecord($this->id); - $app->tform->datalogSave('INSERT',$this->id,array(),$new_data_record); - unset($new_data_record); - } - - - if($_REQUEST["next_tab"] == '') { - $list_name = $_SESSION["s"]["form"]["return_to"]; - // if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { - if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { - $redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; - $_SESSION["s"]["form"]["return_to"] = ''; - session_write_close(); - header($redirect); - exit; - } elseif ($_SESSION["s"]["form"]["return_to_url"] != '') { - $redirect = $_SESSION["s"]["form"]["return_to_url"]; - $_SESSION["s"]["form"]["return_to_url"] = ''; - session_write_close(); - header("Location: ".$redirect); - exit; - } else { - header("Location: ".$app->tform->formDef['list_default']); - } - exit; - } else { - $this->onShow(); - } - } else { - $this->onError(); - } - } - - /* + } + + /* Save record in database */ - - function onInsertSave($sql) { - global $app, $conf; - $app->db->query($sql); - if($app->db->errorMessage != '') die($app->db->errorMessage); - return $app->db->insertID(); + + function onInsertSave($sql) { + global $app, $conf; + $app->db->query($sql); + if($app->db->errorMessage != '') die($app->db->errorMessage); + return $app->db->insertID(); + } + + function onBeforeUpdate() { + global $app, $conf; + } + + function onBeforeInsert() { + global $app, $conf; + } + + function onAfterUpdate() { + global $app, $conf; + } + + function onAfterInsert() { + global $app, $conf; + } + + + /** + * Function called on data insert or update error + */ + function onError() { + global $app, $conf; + + $app->tpl->setVar("error", "
  • ".$app->tform->errorMessage."
  • "); + $app->tpl->setVar($this->dataRecord); + $this->onShow(); + } + + + /** + * Function called on data delete + */ + function onDelete() { + global $app, $conf, $list_def_file, $tform_def_file; + + include_once $list_def_file; + + // Loading tform framework + if(!is_object($app->tform)) $app->uses('tform'); + + // Load table definition from file + $app->tform->loadFormDef($tform_def_file); + + // importing ID + $this->id = $app->functions->intval($_REQUEST["id"]); + + if($this->id > 0) { + + // checking permissions + if($app->tform->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { + if($app->tform->checkPerm($this->id, 'd') == false) $app->error($app->lng('error_no_delete_permission')); + } + + //$this->dataRecord = $app->db->queryOneRecord("SELECT * FROM ".$liste["table"]." WHERE ".$liste["table_idx"]." = ".$this->id); + $this->dataRecord = $app->tform->getDataRecord($this->id); + + $this->onBeforeDelete(); + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_before_delete', $this); + + // Saving record to datalog when db_history enabled + if($app->tform->formDef["db_history"] == 'yes') { + //$old_data_record = $app->tform->getDataRecord($this->id); + $app->tform->datalogSave('DELETE', $this->id, $this->dataRecord, array()); + } + + $app->db->query("DELETE FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." LIMIT 1"); + + + // loading plugins + $next_tab = $app->tform->getCurrentTab(); + $this->loadPlugins($next_tab); + + + // Call plugin + foreach($this->plugins as $plugin) { + $plugin->onDelete(); + } + + $this->onAfterDelete(); + $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_delete', $this); } - function onBeforeUpdate() { - global $app, $conf; - } - - function onBeforeInsert() { - global $app, $conf; - } - - function onAfterUpdate() { - global $app, $conf; - } - - function onAfterInsert() { - global $app, $conf; - } - - - /** - * Function called on data insert or update error - */ - - function onError() { - global $app, $conf; - - $app->tpl->setVar("error","
  • ".$app->tform->errorMessage."
  • "); - $app->tpl->setVar($this->dataRecord); - $this->onShow(); - } - - /** - * Function called on data delete - */ - - function onDelete() { - global $app, $conf,$list_def_file,$tform_def_file; - - include_once($list_def_file); - - // Loading tform framework - if(!is_object($app->tform)) $app->uses('tform'); - - // Load table definition from file - $app->tform->loadFormDef($tform_def_file); - - // importing ID - $this->id = $app->functions->intval($_REQUEST["id"]); - - if($this->id > 0) { - - // checking permissions - if($app->tform->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { - if($app->tform->checkPerm($this->id,'d') == false) $app->error($app->lng('error_no_delete_permission')); - } - - //$this->dataRecord = $app->db->queryOneRecord("SELECT * FROM ".$liste["table"]." WHERE ".$liste["table_idx"]." = ".$this->id); - $this->dataRecord = $app->tform->getDataRecord($this->id); - - $this->onBeforeDelete(); - $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_before_delete',$this); - - // Saving record to datalog when db_history enabled - if($app->tform->formDef["db_history"] == 'yes') { - //$old_data_record = $app->tform->getDataRecord($this->id); - $app->tform->datalogSave('DELETE',$this->id,$this->dataRecord,array()); - } - - $app->db->query("DELETE FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." LIMIT 1"); - - - // loading plugins - $next_tab = $app->tform->getCurrentTab(); - $this->loadPlugins($next_tab); - - - // Call plugin - foreach($this->plugins as $plugin) { - $plugin->onDelete(); - } - - $this->onAfterDelete(); - $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_after_delete',$this); - } - - //header("Location: ".$liste["file"]."?PHPSESSID=".$_SESSION["s"]["id"]); - $list_name = $_SESSION["s"]["form"]["return_to"]; - if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { - $redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; - $_SESSION["s"]["form"]["return_to"] = ''; - session_write_close(); - header($redirect); - } else { - header("Location: ".$liste["file"]); - } - exit; - - } - - function onBeforeDelete() { - global $app, $conf; - } - - function onAfterDelete() { - global $app, $conf; - } - - /** - * Function to print the form content - */ - - function onPrintForm() { - global $app, $conf; - - if($app->tform->formDef['template_print'] == '') die('No print template available.'); - - $app->tpl->newTemplate("print.tpl.htm"); - $app->tpl->setInclude("content_tpl",$app->tform->formDef['template_print']); + //header("Location: ".$liste["file"]."?PHPSESSID=".$_SESSION["s"]["id"]); + $list_name = $_SESSION["s"]["form"]["return_to"]; + if($list_name != '' && $_SESSION["s"]["list"][$list_name]["parent_id"] != $this->id && $_SESSION["s"]["list"][$list_name]["parent_name"] != $app->tform->formDef["name"]) { + $redirect = "Location: ".$_SESSION["s"]["list"][$list_name]["parent_script"]."?id=".$_SESSION["s"]["list"][$list_name]["parent_id"]."&next_tab=".$_SESSION["s"]["list"][$list_name]["parent_tab"]; + $_SESSION["s"]["form"]["return_to"] = ''; + session_write_close(); + header($redirect); + } else { + header("Location: ".$liste["file"]); + } + exit; - if($app->tform->formDef['auth'] == 'no') { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; - } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); - } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); - - $record["datum"] = date("d.m.Y"); - - $app->tpl->setVar($app->tform->wordbook); + } - $app->tpl->setVar($record); + function onBeforeDelete() { + global $app, $conf; + } + + function onAfterDelete() { + global $app, $conf; + } + + + + + + /** + * Function to print the form content + */ + function onPrintForm() { + global $app, $conf; + + if($app->tform->formDef['template_print'] == '') die('No print template available.'); + + $app->tpl->newTemplate("print.tpl.htm"); + $app->tpl->setInclude("content_tpl", $app->tform->formDef['template_print']); + + if($app->tform->formDef['auth'] == 'no') { + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; + } else { + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); + } + if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); + + $record["datum"] = date("d.m.Y"); + + $app->tpl->setVar($app->tform->wordbook); + + $app->tpl->setVar($record); + $app->tpl_defaults(); + $app->tpl->pparse(); + exit; + + } + + + + + + /** + * Function to print the form content + */ + function onMailSendForm() { + global $app, $conf; + + if($app->tform->formDef['template_mailsend'] == '') die('No print template available.'); + + if($_POST["email"] == '' && $_POST["sender"] == '') { + // Zeige Formular zum versenden an. + $app->tpl->newTemplate("form.tpl.htm"); + $app->tpl->setInclude("content_tpl", $app->tform->formDef['template_mailsend']); + $app->tpl->setVar('show_form', 1); + $app->tpl->setVar("form_action", $app->tform->formDef['action'].'?send_form_by_mail=1'); + $app->tpl->setVar("id", $this->id); $app->tpl_defaults(); $app->tpl->pparse(); exit; - - } - - /** - * Function to print the form content - */ - - function onMailSendForm() { - global $app, $conf; - - if($app->tform->formDef['template_mailsend'] == '') die('No print template available.'); - - if($_POST["email"] == '' && $_POST["sender"] == '') { - // Zeige Formular zum versenden an. - $app->tpl->newTemplate("form.tpl.htm"); - $app->tpl->setInclude("content_tpl",$app->tform->formDef['template_mailsend']); - $app->tpl->setVar('show_form',1); - $app->tpl->setVar("form_action",$app->tform->formDef['action'].'?send_form_by_mail=1'); - $app->tpl->setVar("id",$this->id); - $app->tpl_defaults(); - $app->tpl->pparse(); - exit; + } else { + $app->tpl->newTemplate("mail.tpl.htm"); + $app->tpl->setInclude("content_tpl", $app->tform->formDef['template_mailsend']); + $app->tpl->setVar('show_mail', 1); + if($app->tform->formDef['auth'] == 'no') { + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; } else { - $app->tpl->newTemplate("mail.tpl.htm"); - $app->tpl->setInclude("content_tpl",$app->tform->formDef['template_mailsend']); - $app->tpl->setVar('show_mail',1); - if($app->tform->formDef['auth'] == 'no') { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; - } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); - } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); - - $record["datum"] = date("d.m.Y"); - $record["mailmessage"] = $_POST["message"]; - - $app->tpl->setVar($app->tform->wordbook); - - $app->tpl->setVar($record); - $app->tpl_defaults(); - - $email_message = $app->tpl->grab(); - $email = $_POST["email"]; - $sender = $_POST["sender"]; - - $headers = "MIME-Version: 1.0\n"; - $headers .= "Content-type: text/html; charset=iso-8859-1\n"; - $headers .= "From: $sender\n"; - - if (!preg_match('/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '([-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.)+' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/', $sender)) { - $sender = 'noreply@iprguard.de'; - } - - if (preg_match('/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '([-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.)+' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/', $email)) { - mail($email, 'Domainrecherche Statement '.$record["domain"], $email_message, $headers); - } - echo "

     

    Email wurde versand.

    "; - exit; + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); } - - + if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); - if($app->tform->formDef['auth'] == 'no') { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; - } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); - } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); - $record["datum"] = date("d.m.Y"); - + $record["mailmessage"] = $_POST["message"]; + $app->tpl->setVar($app->tform->wordbook); $app->tpl->setVar($record); $app->tpl_defaults(); - $app->tpl->pparse(); + + $email_message = $app->tpl->grab(); + $email = $_POST["email"]; + $sender = $_POST["sender"]; + + $headers = "MIME-Version: 1.0\n"; + $headers .= "Content-type: text/html; charset=iso-8859-1\n"; + $headers .= "From: $sender\n"; + + if (!preg_match('/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '([-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.)+' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/', $sender)) { + $sender = 'noreply@iprguard.de'; + } + + if (preg_match('/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+' . '@' . '([-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.)+' . '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/', $email)) { + mail($email, 'Domainrecherche Statement '.$record["domain"], $email_message, $headers); + } + echo "

     

    Email wurde versand.

    "; exit; - } - /** - * Function called on page show - */ - - function onShow() { - global $app, $conf; - - // Which tab do we render - $this->active_tab = $app->tform->getNextTab(); - - if($this->id > 0) { - $this->onShowEdit(); - } else { - $this->onShowNew(); - } - - // make Form and Tabs - $app->tform->showForm(); - - // Setting default values - $app->tpl_defaults(); - - // Show the navigation bar of the form - if(isset($app->tform->formDef['navibar']) && $app->tform->formDef['navibar'] == 'yes') { - $navibar = ''; - if($app->tform->formDef['template_print'] != '') { - $navibar .= 'Drucken  '; - } - if($app->tform->formDef['template_mailsend'] != '') { - $navibar .= "tform->formDef['action'].'?id='.$this->id."&send_form_by_mail=1','send','width=370,height=240')\">\"Als"; - } - $app->tpl->setVar('form_navibar',$navibar); - } - - if(isset($_SESSION['show_info_msg'])) { - $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); - unset($_SESSION['show_info_msg']); - } - if(isset($_SESSION['show_error_msg'])) { - $app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']); - unset($_SESSION['show_error_msg']); - } - - // loading plugins - $this->loadPlugins($this->active_tab); - - // Calling the Plugin onShow Events and set the data in the - // plugins placeholder in the template - foreach($this->plugins as $plugin_name => $plugin) { - $app->tpl->setVar($plugin_name,$plugin->onShow()); - } - - // Parse the templates and send output to the browser - $this->onShowEnd(); - - } - - /** - * Function called on new record - */ - - function onShowNew() { - global $app, $conf; - - if($app->tform->errorMessage == '') { - $record = array(); - $record = $app->tform->getHTML($record, $app->tform->formDef['tab_default'],'NEW'); - } else { - $record = $app->tform->getHTML($app->tform->encode($_POST,$this->active_tab),$this->active_tab,'EDIT'); - } - - $app->tpl->setVar($record); - } - - /** - * Function called on edit record - */ - - function onShowEdit() { - global $app, $conf; - - // bestehenden Datensatz anzeigen - if($app->tform->errorMessage == '') { - if($app->tform->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); - } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; - } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); - } else { - // $record = $app->tform->encode($_POST,$this->active_tab); - $record = $app->tform->encode($this->dataRecord,$this->active_tab,false); - } - - $this->dataRecord = $record; - - // Userdaten umwandeln - $record = $app->tform->getHTML($record, $this->active_tab,'EDIT'); - $record['id'] = $this->id; - - $app->tpl->setVar($record); - } - - function onShowEnd() { - global $app, $conf; - - // Template parsen - $app->tpl->pparse(); - } - - function loadPlugins($next_tab) { - global $app; - if(@is_array($app->tform->formDef["tabs"][$next_tab]["plugins"])) { - $app->load('plugin_base'); - foreach($app->tform->formDef["tabs"][$next_tab]["plugins"] as $plugin_name => $plugin_settings) { - $plugin_class = $plugin_settings["class"]; - $app->load($plugin_class); - $this->plugins[$plugin_name] = new $plugin_class; - $this->plugins[$plugin_name]->setOptions($plugin_name,$plugin_settings['options']); - // Make the data of the form easily accessible for the plugib - $this->plugins[$plugin_name]->form = $this; - $this->plugins[$plugin_name]->onLoad(); - } - } + + + if($app->tform->formDef['auth'] == 'no') { + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; + } else { + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); + } + if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); + + $record["datum"] = date("d.m.Y"); + + $app->tpl->setVar($app->tform->wordbook); + + $app->tpl->setVar($record); + $app->tpl_defaults(); + $app->tpl->pparse(); + exit; + + } + + + /** + * Function called on page show + */ + function onShow() { + global $app, $conf; + + // Which tab do we render + $this->active_tab = $app->tform->getNextTab(); + + if($this->id > 0) { + $this->onShowEdit(); + } else { + $this->onShowNew(); + } + + // make Form and Tabs + $app->tform->showForm(); + + // Setting default values + $app->tpl_defaults(); + + // Show the navigation bar of the form + if(isset($app->tform->formDef['navibar']) && $app->tform->formDef['navibar'] == 'yes') { + $navibar = ''; + if($app->tform->formDef['template_print'] != '') { + $navibar .= 'Drucken  '; + } + if($app->tform->formDef['template_mailsend'] != '') { + $navibar .= "tform->formDef['action'].'?id='.$this->id."&send_form_by_mail=1','send','width=370,height=240')\">\"Als"; + } + $app->tpl->setVar('form_navibar', $navibar); + } + + if(isset($_SESSION['show_info_msg'])) { + $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); + unset($_SESSION['show_info_msg']); + } + if(isset($_SESSION['show_error_msg'])) { + $app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']); + unset($_SESSION['show_error_msg']); + } + + // loading plugins + $this->loadPlugins($this->active_tab); + + // Calling the Plugin onShow Events and set the data in the + // plugins placeholder in the template + foreach($this->plugins as $plugin_name => $plugin) { + $app->tpl->setVar($plugin_name, $plugin->onShow()); + } + + // Parse the templates and send output to the browser + $this->onShowEnd(); + + } + + + /** + * Function called on new record + */ + function onShowNew() { + global $app, $conf; + + if($app->tform->errorMessage == '') { + $record = array(); + $record = $app->tform->getHTML($record, $app->tform->formDef['tab_default'], 'NEW'); + } else { + $record = $app->tform->getHTML($app->tform->encode($_POST, $this->active_tab), $this->active_tab, 'EDIT'); + } + + $app->tpl->setVar($record); + } + + + /** + * Function called on edit record + */ + function onShowEdit() { + global $app, $conf; + + // bestehenden Datensatz anzeigen + if($app->tform->errorMessage == '') { + if($app->tform->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); + } else { + $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; + } + if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); + } else { + // $record = $app->tform->encode($_POST,$this->active_tab); + $record = $app->tform->encode($this->dataRecord, $this->active_tab, false); + } + + $this->dataRecord = $record; + + // Userdaten umwandeln + $record = $app->tform->getHTML($record, $this->active_tab, 'EDIT'); + $record['id'] = $this->id; + + $app->tpl->setVar($record); + } + + function onShowEnd() { + global $app, $conf; + + // Template parsen + $app->tpl->pparse(); + } + + function loadPlugins($next_tab) { + global $app; + if(@is_array($app->tform->formDef["tabs"][$next_tab]["plugins"])) { + $app->load('plugin_base'); + foreach($app->tform->formDef["tabs"][$next_tab]["plugins"] as $plugin_name => $plugin_settings) { + $plugin_class = $plugin_settings["class"]; + $app->load($plugin_class); + $this->plugins[$plugin_name] = new $plugin_class; + $this->plugins[$plugin_name]->setOptions($plugin_name, $plugin_settings['options']); + // Make the data of the form easily accessible for the plugib + $this->plugins[$plugin_name]->form = $this; + $this->plugins[$plugin_name]->onLoad(); + } } + } } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index b80aa72f5..856cdc498 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -29,87 +29,88 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** -* Formularbehandlung -* -* Functions to validate, display and save form values -* -* Database table field definitions -* -* Datatypes: -* - INTEGER (Converts data to int automatically) -* - DOUBLE -* - CURRENCY (Formats digits in currency notation) -* - VARCHAR (No format check) -* - DATE (Date format, converts from and to UNIX timestamps automatically) -* -* Formtype: -* - TEXT (Normal text field) -* - PASSWORD (password field, the content will not be displayed again to the user) -* - SELECT (Option fiield) -* - MULTIPLE (Allows selection of multiple values) -* -* VALUE: -* - Value or array -* -* SEPARATOR -* - separator char used for fileds with multiple values -* -* Hint: The auto increment (ID) filed of the table has not be be definied separately. -* -*/ - -class tform_base { + * Formularbehandlung + * + * Functions to validate, display and save form values + * + * Database table field definitions + * + * Datatypes: + * - INTEGER (Converts data to int automatically) + * - DOUBLE + * - CURRENCY (Formats digits in currency notation) + * - VARCHAR (No format check) + * - DATE (Date format, converts from and to UNIX timestamps automatically) + * + * Formtype: + * - TEXT (Normal text field) + * - PASSWORD (password field, the content will not be displayed again to the user) + * - SELECT (Option fiield) + * - MULTIPLE (Allows selection of multiple values) + * + * VALUE: + * - Value or array + * + * SEPARATOR + * - separator char used for fileds with multiple values + * + * Hint: The auto increment (ID) filed of the table has not be be definied separately. + * + */ - /** - * Definition of the database table (array) - * @var tableDef - */ - var $tableDef; - - /** - * Private - * @var action - */ - var $action; - /** - * Table name (String) - * @var table_name - */ - var $table_name; - - /** - * Debug Variable - * @var debug - */ - var $debug = 0; - - /** - * name of the primary field of the database table (string) - * @var table_index - */ - var $table_index; - - /** - * contains the error messages - * @var errorMessage - */ - var $errorMessage = ''; - - var $dateformat = "d.m.Y"; - var $formDef = array(); - var $wordbook; - var $module; - var $primary_id; - var $diffrec = array(); +class tform_base { - /** - * Loading of the table definition - * - * @param file: path to the form definition file - * @return true - */ - /* + /** + * Definition of the database table (array) + * @var tableDef + */ + var $tableDef; + + /** + * Private + * @var action + */ + var $action; + + /** + * Table name (String) + * @var table_name + */ + var $table_name; + + /** + * Debug Variable + * @var debug + */ + var $debug = 0; + + /** + * name of the primary field of the database table (string) + * @var table_index + */ + var $table_index; + + /** + * contains the error messages + * @var errorMessage + */ + var $errorMessage = ''; + + var $dateformat = "d.m.Y"; + var $formDef = array(); + var $wordbook; + var $module; + var $primary_id; + var $diffrec = array(); + + /** + * Loading of the table definition + * + * @param file: path to the form definition file + * @return true + */ + /* function loadTableDef($file) { global $app,$conf; @@ -121,42 +122,42 @@ class tform_base { } */ - function loadFormDef($file,$module = '') { - global $app,$conf; + function loadFormDef($file, $module = '') { + global $app, $conf; - include($file); - $this->formDef = $form; + include $file; + $this->formDef = $form; - $this->module = $module; - $wb = array(); + $this->module = $module; + $wb = array(); - include_once(ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng'); + include_once ISPC_ROOT_PATH.'/lib/lang/'.$_SESSION['s']['language'].'.lng'; - if(is_array($wb)) $wb_global = $wb; + if(is_array($wb)) $wb_global = $wb; - if($module == '') { - $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$this->formDef["name"].".lng"; - if(!file_exists($lng_file)) $lng_file = "lib/lang/en_".$this->formDef["name"].".lng"; - include($lng_file); - } else { - $lng_file = "../$module/lib/lang/".$_SESSION["s"]["language"]."_".$this->formDef["name"].".lng"; - if(!file_exists($lng_file)) $lng_file = "../$module/lib/lang/en_".$this->formDef["name"].".lng"; - include($lng_file); - } + if($module == '') { + $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_".$this->formDef["name"].".lng"; + if(!file_exists($lng_file)) $lng_file = "lib/lang/en_".$this->formDef["name"].".lng"; + include $lng_file; + } else { + $lng_file = "../$module/lib/lang/".$_SESSION["s"]["language"]."_".$this->formDef["name"].".lng"; + if(!file_exists($lng_file)) $lng_file = "../$module/lib/lang/en_".$this->formDef["name"].".lng"; + include $lng_file; + } - if(is_array($wb_global)) { - $wb = $app->functions->array_merge($wb_global,$wb); - } - if(isset($wb_global)) unset($wb_global); + if(is_array($wb_global)) { + $wb = $app->functions->array_merge($wb_global, $wb); + } + if(isset($wb_global)) unset($wb_global); - $this->wordbook = $wb; + $this->wordbook = $wb; - $this->dateformat = $app->lng('conf_format_dateshort'); + $this->dateformat = $app->lng('conf_format_dateshort'); - return true; - } + return true; + } - /* + /* * Converts the data in the array to human readable format * Datatype conversion e.g. to show the data in lists * @@ -165,1108 +166,1111 @@ class tform_base { * @param apply_filters * @return record */ - protected function _decode($record, $tab = '', $api = false) { - global $app; - $new_record = ''; - if($api == false) { - $table_idx = $this->formDef['db_table_idx']; - if(isset($record[$table_idx])) $new_record[$table_idx] = $app->functions->intval($record[$table_idx ]); - $fields = &$this->formDef['tabs'][$tab]['fields']; - } else { - $fields = &$this->formDef['fields']; + protected function _decode($record, $tab = '', $api = false) { + global $app; + $new_record = ''; + if($api == false) { + $table_idx = $this->formDef['db_table_idx']; + if(isset($record[$table_idx])) $new_record[$table_idx] = $app->functions->intval($record[$table_idx ]); + $fields = &$this->formDef['tabs'][$tab]['fields']; + } else { + $fields = &$this->formDef['fields']; + } + + if(is_array($record)) { + foreach($fields as $key => $field) { + + //* Apply filter to record value. + if($api == false && isset($field['filters']) && is_array($field['filters'])) { + $record[$key] = $this->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SHOW'); } - if(is_array($record)) { - foreach($fields as $key => $field) { + switch ($field['datatype']) { + case 'VARCHAR': + $new_record[$key] = ($api == true ? stripslashes($record[$key]) : $record[$key]); + break; - //* Apply filter to record value. - if($api == false && isset($field['filters']) && is_array($field['filters'])) { - $record[$key] = $this->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SHOW'); - } + case 'TEXT': + $new_record[$key] = ($api == true ? stripslashes($record[$key]) : $record[$key]); + break; - switch ($field['datatype']) { - case 'VARCHAR': - $new_record[$key] = ($api == true ? stripslashes($record[$key]) : $record[$key]); - break; - - case 'TEXT': - $new_record[$key] = ($api == true ? stripslashes($record[$key]) : $record[$key]); - break; - - case 'DATETSTAMP': - if($record[$key] > 0) { - $new_record[$key] = date($this->dateformat,$record[$key]); - } - break; - - case 'DATE': - if($record[$key] != '' && $record[$key] != '0000-00-00') { - $tmp = explode('-',$record[$key]); - $new_record[$key] = date($this->dateformat,mktime(0, 0, 0, $tmp[1] , $tmp[2], $tmp[0])); - } - break; - - case 'INTEGER': - $new_record[$key] = $app->functions->intval($record[$key]); - break; - - case 'DOUBLE': - $new_record[$key] = $record[$key]; - break; - - case 'CURRENCY': - $new_record[$key] = $app->functions->currency_format($record[$key]); - break; - - default: - $new_record[$key] = ($api == true ? stripslashes($record[$key]) : $record[$key]); - } - } + case 'DATETSTAMP': + if($record[$key] > 0) { + $new_record[$key] = date($this->dateformat, $record[$key]); + } + break; + + case 'DATE': + if($record[$key] != '' && $record[$key] != '0000-00-00') { + $tmp = explode('-', $record[$key]); + $new_record[$key] = date($this->dateformat, mktime(0, 0, 0, $tmp[1] , $tmp[2], $tmp[0])); + } + break; + + case 'INTEGER': + $new_record[$key] = $app->functions->intval($record[$key]); + break; + case 'DOUBLE': + $new_record[$key] = $record[$key]; + break; + + case 'CURRENCY': + $new_record[$key] = $app->functions->currency_format($record[$key]); + break; + + default: + $new_record[$key] = ($api == true ? stripslashes($record[$key]) : $record[$key]); } + } + + } return $new_record; + } + + + /** + * Converts the data in the array to human readable format + * Datatype conversion e.g. to show the data in lists + * + * @param record + * @return record + */ + function decode($record, $tab) { + global $conf, $app; + if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab does not exist or the tab is empty (TAB: $tab)."); + return $this->_decode($record, $tab, false); + } + + /** + * Get the key => value array of a form filled from a datasource definitiom + * + * @param field = array with field definition + * @param record = Dataset as array + * @return key => value array for the value field of a form + */ + protected function _getDatasourceData($field, $record, $api = false) { + global $app; + + $values = array(); + + if($field["datasource"]["type"] == 'SQL') { + + // Preparing SQL string. We will replace some + // common placeholders + $querystring = $field["datasource"]["querystring"]; + $querystring = str_replace("{USERID}", $_SESSION["s"]["user"]["userid"], $querystring); + $querystring = str_replace("{GROUPID}", $_SESSION["s"]["user"]["default_group"], $querystring); + $querystring = str_replace("{GROUPS}", $_SESSION["s"]["user"]["groups"], $querystring); + $table_idx = $this->formDef['db_table_idx']; + + $tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0; + $querystring = str_replace("{RECORDID}", $tmp_recordid, $querystring); + unset($tmp_recordid); + + $querystring = str_replace("{AUTHSQL}", $this->getAuthSQL('r'), $querystring); + + // Getting the records + $tmp_records = $app->db->queryAllRecords($querystring); + if($app->db->errorMessage != '') die($app->db->errorMessage); + if(is_array($tmp_records)) { + $key_field = $field["datasource"]["keyfield"]; + $value_field = $field["datasource"]["valuefield"]; + foreach($tmp_records as $tmp_rec) { + $tmp_id = $tmp_rec[$key_field]; + $values[$tmp_id] = $tmp_rec[$value_field]; + } + } } - /** - * Converts the data in the array to human readable format - * Datatype conversion e.g. to show the data in lists - * - * @param record - * @return record - */ - function decode($record,$tab) { - global $conf, $app; - if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab does not exist or the tab is empty (TAB: $tab)."); - return $this->_decode($record, $tab, false); + if($field["datasource"]["type"] == 'CUSTOM') { + // Calls a custom class to validate this record + if($field["datasource"]['class'] != '' and $field["datasource"]['function'] != '') { + $datasource_class = $field["datasource"]['class']; + $datasource_function = $field["datasource"]['function']; + $app->uses($datasource_class); + $values = $app->$datasource_class->$datasource_function($field, $record); + } else { + $this->errorMessage .= "Custom datasource class or function is empty
    \r\n"; + } } - /** - * Get the key => value array of a form filled from a datasource definitiom - * - * @param field = array with field definition - * @param record = Dataset as array - * @return key => value array for the value field of a form - */ + if($api == false && isset($field['filters']) && is_array($field['filters'])) { + $new_values = array(); + foreach($values as $index => $value) { + $new_index = $this->filterField($index, $index, $field['filters'], 'SHOW'); + $new_values[$new_index] = $this->filterField($index, (isset($values[$index]))?$values[$index]:'', $field['filters'], 'SHOW'); + } + $values = $new_values; + unset($new_values); + unset($new_index); + } - protected function _getDatasourceData($field, $record, $api = false) { - global $app; + return $values; - $values = array(); + } - if($field["datasource"]["type"] == 'SQL') { - // Preparing SQL string. We will replace some - // common placeholders - $querystring = $field["datasource"]["querystring"]; - $querystring = str_replace("{USERID}",$_SESSION["s"]["user"]["userid"],$querystring); - $querystring = str_replace("{GROUPID}",$_SESSION["s"]["user"]["default_group"],$querystring); - $querystring = str_replace("{GROUPS}",$_SESSION["s"]["user"]["groups"],$querystring); - $table_idx = $this->formDef['db_table_idx']; + /** + * Get the key => value array of a form filled from a datasource definitiom + * + * @param field = array with field definition + * @param record = Dataset as array + * @return key => value array for the value field of a form + */ + function getDatasourceData($field, $record) { + return $this->_getDatasourceData($field, $record, false); + } - $tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0; - $querystring = str_replace("{RECORDID}",$tmp_recordid,$querystring); - unset($tmp_recordid); + //* If the parameter 'valuelimit' is set + function applyValueLimit($limit, $values) { - $querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring); + global $app; - // Getting the records - $tmp_records = $app->db->queryAllRecords($querystring); - if($app->db->errorMessage != '') die($app->db->errorMessage); - if(is_array($tmp_records)) { - $key_field = $field["datasource"]["keyfield"]; - $value_field = $field["datasource"]["valuefield"]; - foreach($tmp_records as $tmp_rec) { - $tmp_id = $tmp_rec[$key_field]; - $values[$tmp_id] = $tmp_rec[$value_field]; - } - } - } + $limit_parts = explode(':', $limit); - if($field["datasource"]["type"] == 'CUSTOM') { - // Calls a custom class to validate this record - if($field["datasource"]['class'] != '' and $field["datasource"]['function'] != '') { - $datasource_class = $field["datasource"]['class']; - $datasource_function = $field["datasource"]['function']; - $app->uses($datasource_class); - $values = $app->$datasource_class->$datasource_function($field, $record); - } else { - $this->errorMessage .= "Custom datasource class or function is empty
    \r\n"; - } - } + //* values are limited to a comma separated list + if($limit_parts[0] == 'list') { + $allowed = explode(',', $limit_parts[1]); + } - if($api == false && isset($field['filters']) && is_array($field['filters'])) { - $new_values = array(); - foreach($values as $index => $value) { - $new_index = $this->filterField($index, $index, $field['filters'], 'SHOW'); - $new_values[$new_index] = $this->filterField($index, (isset($values[$index]))?$values[$index]:'', $field['filters'], 'SHOW'); - } - $values = $new_values; - unset($new_values); - unset($new_index); - } + //* values are limited to a field in the client settings + if($limit_parts[0] == 'client') { + if($_SESSION["s"]["user"]["typ"] == 'admin') { + return $values; + } else { + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT ".$limit_parts[1]." as lm FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $allowed = explode(',', $client['lm']); + } + } + //* values are limited to a field in the reseller settings + if($limit_parts[0] == 'reseller') { + if($_SESSION["s"]["user"]["typ"] == 'admin') { return $values; + } else { + //* Get the limits of the client that is currently logged in + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + //echo "SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"; + //* If the client belongs to a reseller, we will check against the reseller Limit too + if($client['parent_client_id'] != 0) { + + //* first we need to know the groups of this reseller + $tmp = $app->db->queryOneRecord("SELECT userid, groups FROM sys_user WHERE client_id = ".$client['parent_client_id']); + $reseller_groups = $tmp["groups"]; + $reseller_userid = $tmp["userid"]; + + // Get the limits of the reseller of the logged in client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $reseller = $app->db->queryOneRecord("SELECT ".$limit_parts[1]." as lm FROM client WHERE client_id = ".$client['parent_client_id']); + $allowed = explode(',', $reseller['lm']); + } else { + return $values; + } + } // end if admin + } // end if reseller + + //* values are limited to a field in the system settings + if($limit_parts[0] == 'system') { + $app->uses('getconf'); + $tmp_conf = $app->getconf->get_global_config($limit_parts[1]); + $tmp_key = $limit_parts[2]; + $allowed = $tmp_conf[$tmp_key]; + } + $values_new = array(); + foreach($values as $key => $val) { + if(in_array($key, $allowed)) $values_new[$key] = $val; } - /** - * Get the key => value array of a form filled from a datasource definitiom - * - * @param field = array with field definition - * @param record = Dataset as array - * @return key => value array for the value field of a form - */ + return $values_new; + } - function getDatasourceData($field, $record) { - return $this->_getDatasourceData($field, $record, false); - } - //* If the parameter 'valuelimit' is set - function applyValueLimit($limit,$values) { + /** + * Prepare the data record to show the data in a form. + * + * @param record = Datensatz als Array + * @param action = NEW oder EDIT + * @return record + */ + function getHTML($record, $tab, $action = 'NEW') { - global $app; + global $app; - $limit_parts = explode(':',$limit); + $this->action = $action; - //* values are limited to a comma separated list - if($limit_parts[0] == 'list') { - $allowed = explode(',',$limit_parts[1]); - } + if(!is_array($this->formDef)) $app->error("No form definition found."); + if(!is_array($this->formDef['tabs'][$tab])) $app->error("The tab is empty or does not exist (TAB: $tab)."); - //* values are limited to a field in the client settings - if($limit_parts[0] == 'client') { - if($_SESSION["s"]["user"]["typ"] == 'admin') { - return $values; - } else { - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT ".$limit_parts[1]." as lm FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - $allowed = explode(',',$client['lm']); - } - } + $new_record = array(); + if($action == 'EDIT') { + $record = $this->decode($record, $tab); + if(is_array($record)) { + foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) { - //* values are limited to a field in the reseller settings - if($limit_parts[0] == 'reseller') { - if($_SESSION["s"]["user"]["typ"] == 'admin') { - return $values; - } else { - //* Get the limits of the client that is currently logged in - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - //echo "SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"; - //* If the client belongs to a reseller, we will check against the reseller Limit too - if($client['parent_client_id'] != 0) { - - //* first we need to know the groups of this reseller - $tmp = $app->db->queryOneRecord("SELECT userid, groups FROM sys_user WHERE client_id = ".$client['parent_client_id']); - $reseller_groups = $tmp["groups"]; - $reseller_userid = $tmp["userid"]; - - // Get the limits of the reseller of the logged in client - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $reseller = $app->db->queryOneRecord("SELECT ".$limit_parts[1]." as lm FROM client WHERE client_id = ".$client['parent_client_id']); - $allowed = explode(',',$reseller['lm']); + if(isset($record[$key])) { + $val = $record[$key]; } else { - return $values; + $val = ''; } - } // end if admin - } // end if reseller - - //* values are limited to a field in the system settings - if($limit_parts[0] == 'system') { - $app->uses('getconf'); - $tmp_conf = $app->getconf->get_global_config($limit_parts[1]); - $tmp_key = $limit_parts[2]; - $allowed = $tmp_conf[$tmp_key]; - } - $values_new = array(); - foreach($values as $key => $val) { - if(in_array($key,$allowed)) $values_new[$key] = $val; - } - - return $values_new; - } + // If Datasource is set, get the data from there + if(isset($field['datasource']) && is_array($field['datasource'])) { + if(is_array($field["value"])) { + //$field["value"] = array_merge($field["value"],$this->getDatasourceData($field, $record)); + $field["value"] = $app->functions->array_merge($field["value"], $this->getDatasourceData($field, $record)); + } else { + $field["value"] = $this->getDatasourceData($field, $record); + } + } + // If a limitation for the values is set + if(isset($field['valuelimit']) && is_array($field["value"])) { + $field["value"] = $this->applyValueLimit($field['valuelimit'], $field["value"]); + } - /** - * Prepare the data record to show the data in a form. - * - * @param record = Datensatz als Array - * @param action = NEW oder EDIT - * @return record - */ - function getHTML($record, $tab, $action = 'NEW') { - - global $app; - - $this->action = $action; - - if(!is_array($this->formDef)) $app->error("No form definition found."); - if(!is_array($this->formDef['tabs'][$tab])) $app->error("The tab is empty or does not exist (TAB: $tab)."); - - $new_record = array(); - if($action == 'EDIT') { - $record = $this->decode($record,$tab); - if(is_array($record)) { - foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) { - - if(isset($record[$key])) { - $val = $record[$key]; - } else { - $val = ''; - } - - // If Datasource is set, get the data from there - if(isset($field['datasource']) && is_array($field['datasource'])) { - if(is_array($field["value"])) { - //$field["value"] = array_merge($field["value"],$this->getDatasourceData($field, $record)); - $field["value"] = $app->functions->array_merge($field["value"],$this->getDatasourceData($field, $record)); - } else { - $field["value"] = $this->getDatasourceData($field, $record); - } - } - - // If a limitation for the values is set - if(isset($field['valuelimit']) && is_array($field["value"])) { - $field["value"] = $this->applyValueLimit($field['valuelimit'],$field["value"]); - } - - switch ($field['formtype']) { - case 'SELECT': - $out = ''; - if(is_array($field['value'])) { - foreach($field['value'] as $k => $v) { - $selected = ($k == $val)?' SELECTED':''; - if(!empty($this->wordbook[$v])) - $v = $this->wordbook[$v]; - $out .= "\r\n"; - } - } - $new_record[$key] = $out; - break; - case 'MULTIPLE': - if(is_array($field['value'])) { - - // Split - $vals = explode($field['separator'],$val); - - // write HTML - $out = ''; - foreach($field['value'] as $k => $v) { - - $selected = ''; - foreach($vals as $tvl) { - if(trim($tvl) == trim($k)) $selected = ' SELECTED'; - } - - $out .= "\r\n"; - } - } - $new_record[$key] = $out; - break; - - case 'PASSWORD': - $new_record[$key] = ''; - break; - - case 'CHECKBOX': - $checked = ($val == $field['value'][1])?' CHECKED':''; - $new_record[$key] = "\r\n"; - break; - - case 'CHECKBOXARRAY': - if(is_array($field['value'])) { - - // aufsplitten ergebnisse - $vals = explode($field['separator'],$val); - - // HTML schreiben - $out = ''; - $elementNo = 0; - foreach($field['value'] as $k => $v) { - - $checked = ''; - foreach($vals as $tvl) { - if(trim($tvl) == trim($k)) $checked = ' CHECKED'; - } - // $out .= "\r\n"; - $out .= "
    \r\n"; - $elementNo++; - } - } - $new_record[$key] = $out; - break; - - case 'RADIO': - if(is_array($field['value'])) { - - // HTML schreiben - $out = ''; - $elementNo = 0; - foreach($field['value'] as $k => $v) { - $checked = ($k == $val)?' CHECKED':''; - //$out .= "\r\n"; - $out .= "\r\n"; - $elementNo++; - } - } - $new_record[$key] = $out; - break; - - case 'DATETIME': - if (strtotime($val) !== false) { - $dt_value = $val; - } elseif ( isset($field['default']) && (strtotime($field['default']) !== false) ) { - $dt_value = $field['default']; - } else { - $dt_value = 0; - } - - $display_seconds = (isset($field['display_seconds']) && $field['display_seconds'] == true) ? true : false; - - $new_record[$key] = $this->_getDateTimeHTML($key, $dt_value, $display_seconds); - break; - - default: - if(isset($record[$key])) { - $new_record[$key] = htmlspecialchars($record[$key]); - } else { - $new_record[$key] = ''; - } - } - } + switch ($field['formtype']) { + case 'SELECT': + $out = ''; + if(is_array($field['value'])) { + foreach($field['value'] as $k => $v) { + $selected = ($k == $val)?' SELECTED':''; + if(!empty($this->wordbook[$v])) + $v = $this->wordbook[$v]; + $out .= "\r\n"; + } } - } else { - // Action: NEW - foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) { - - // If Datasource is set, get the data from there - if(@is_array($field['datasource'])) { - if(is_array($field["value"])) { - $field["value"] = $app->functions->array_merge($field["value"],$this->getDatasourceData($field, $record)); - } else { - $field["value"] = $this->getDatasourceData($field, $record); - } - } + $new_record[$key] = $out; + break; + case 'MULTIPLE': + if(is_array($field['value'])) { - // If a limitation for the values is set - if(isset($field['valuelimit']) && is_array($field["value"])) { - $field["value"] = $this->applyValueLimit($field['valuelimit'],$field["value"]); - } + // Split + $vals = explode($field['separator'], $val); - switch ($field['formtype']) { - case 'SELECT': - if(is_array($field['value'])) { - $out = ''; - foreach($field['value'] as $k => $v) { - $selected = ($k == $field["default"])?' SELECTED':''; - $out .= "\r\n"; - } - } - if(isset($out)) $new_record[$key] = $out; - break; - case 'MULTIPLE': - if(is_array($field['value'])) { - - // aufsplitten ergebnisse - $vals = explode($field['separator'],$val); - - // HTML schreiben - $out = ''; - foreach($field['value'] as $k => $v) { - - $out .= "\r\n"; - } - } - $new_record[$key] = $out; - break; - - case 'PASSWORD': - //$new_record[$key] = ''; - $new_record[$key] = htmlspecialchars($field['default']); - break; - - case 'CHECKBOX': - // $checked = (empty($field["default"]))?'':' CHECKED'; - $checked = ($field["default"] == $field['value'][1])?' CHECKED':''; - $new_record[$key] = "\r\n"; - break; - - case 'CHECKBOXARRAY': - if(is_array($field['value'])) { - - // aufsplitten ergebnisse - $vals = explode($field['separator'],$field["default"]); - - // HTML schreiben - $out = ''; - $elementNo = 0; - foreach($field['value'] as $k => $v) { - - $checked = ''; - foreach($vals as $tvl) { - if(trim($tvl) == trim($k)) $checked = ' CHECKED'; - } - // $out .= "\r\n"; - $out .= "  \r\n"; - $elementNo++; - } - } - $new_record[$key] = $out; - break; - - case 'RADIO': - if(is_array($field['value'])) { - - // HTML schreiben - $out = ''; - $elementNo = 0; - foreach($field['value'] as $k => $v) { - $checked = ($k == $field["default"])?' CHECKED':''; - //$out .= "\r\n"; - $out .= "\r\n"; - $elementNo++; - } - } - $new_record[$key] = $out; - break; - - case 'DATETIME': - $dt_value = (isset($field['default'])) ? $field['default'] : 0; - $display_seconds = (isset($field['display_seconds']) && $field['display_seconds'] == true) ? true : false; - - $new_record[$key] = $this->_getDateTimeHTML($key, $dt_value, $display_seconds); - break; - - default: - $new_record[$key] = htmlspecialchars($field['default']); + // write HTML + $out = ''; + foreach($field['value'] as $k => $v) { + + $selected = ''; + foreach($vals as $tvl) { + if(trim($tvl) == trim($k)) $selected = ' SELECTED'; } + + $out .= "\r\n"; + } } + $new_record[$key] = $out; + break; - } + case 'PASSWORD': + $new_record[$key] = ''; + break; - if($this->debug == 1) $this->dbg($new_record); + case 'CHECKBOX': + $checked = ($val == $field['value'][1])?' CHECKED':''; + $new_record[$key] = "\r\n"; + break; - return $new_record; - } + case 'CHECKBOXARRAY': + if(is_array($field['value'])) { - /** - * Rewrite the record data to be stored in the database - * and check values with regular expressions. - * - * @param record = Datensatz als Array - * @return record - */ - protected function _encode($record,$tab,$dbencode = true,$api = false) { - global $app; - if($api == true) $fields = &$this->formDef['fields']; - else $fields = &$this->formDef['tabs'][$tab]['fields']; - if(is_array($record)) { - foreach($fields as $key => $field) { - - //* Apply filter to record value - if(isset($field['filters']) && is_array($field['filters'])) { - $record[$key] = $this->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SAVE'); - } - //* Validate record value - if(isset($field['validators']) && is_array($field['validators'])) { - $this->validateField($key, (isset($record[$key]))?$record[$key]:'', $field['validators']); - } + // aufsplitten ergebnisse + $vals = explode($field['separator'], $val); - switch ($field['datatype']) { - case 'VARCHAR': - if(!@is_array($record[$key])) { - $new_record[$key] = (isset($record[$key]))?$record[$key]:''; - } else { - $new_record[$key] = implode($field['separator'],$record[$key]); - } - break; - case 'TEXT': - if(!is_array($record[$key])) { - $new_record[$key] = $record[$key]; - } else { - $new_record[$key] = implode($field['separator'],$record[$key]); - } - break; - case 'DATETSTAMP': - if($record[$key] > 0) { - list($tag,$monat,$jahr) = explode('.',$record[$key]); - $new_record[$key] = mktime(0,0,0,$monat,$tag,$jahr); - } else { - $new_record[$key] = 0; - } - break; - case 'DATE': - if($record[$key] != '' && $record[$key] != '0000-00-00') { - if(function_exists('date_parse_from_format')) { - $date_parts = date_parse_from_format($this->dateformat,$record[$key]); - //list($tag,$monat,$jahr) = explode('.',$record[$key]); - $new_record[$key] = $date_parts['year'].'-'.$date_parts['month'].'-'.$date_parts['day']; - //$tmp = strptime($record[$key],$this->dateformat); - //$new_record[$key] = ($tmp['tm_year']+1900).'-'.($tmp['tm_mon']+1).'-'.$tmp['tm_mday']; - } else { - //$tmp = strptime($record[$key],$this->dateformat); - //$new_record[$key] = ($tmp['tm_year']+1900).'-'.($tmp['tm_mon']+1).'-'.$tmp['tm_mday']; - $tmp = strtotime($record[$key]); - $new_record[$key] = date('Y-m-d',$tmp); - } - } else { - $new_record[$key] = '0000-00-00'; - } - break; - case 'INTEGER': - $new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0; - //if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default']; - //if($key == 'refresh') die($record[$key]); - break; - case 'DOUBLE': - $new_record[$key] = $record[$key]; - break; - case 'CURRENCY': - $new_record[$key] = str_replace(",",".",$record[$key]); - break; - - case 'DATETIME': - if (is_array($record[$key])) - { - $filtered_values = array_map(create_function('$item','return (int)$item;'), $record[$key]); - extract($filtered_values, EXTR_PREFIX_ALL, '_dt'); - - if ($_dt_day != 0 && $_dt_month != 0 && $_dt_year != 0) { - $new_record[$key] = date( 'Y-m-d H:i:s', mktime($_dt_hour, $_dt_minute, $_dt_second, $_dt_month, $_dt_day, $_dt_year) ); - } - } - break; - } + // HTML schreiben + $out = ''; + $elementNo = 0; + foreach($field['value'] as $k => $v) { - // The use of the field value is deprecated, use validators instead - if(isset($field['regex']) && $field['regex'] != '') { - // Enable that "." matches also newlines - $field['regex'] .= 's'; - if(!preg_match($field['regex'], $record[$key])) { - $errmsg = $field['errmsg']; - $this->errorMessage .= ($api == true ? $errmsg : $this->wordbook[$errmsg]."
    ") . "\r\n"; - } + $checked = ''; + foreach($vals as $tvl) { + if(trim($tvl) == trim($k)) $checked = ' CHECKED'; } + // $out .= "\r\n"; + $out .= "
    \r\n"; + $elementNo++; + } + } + $new_record[$key] = $out; + break; - //* Add slashes to all records, when we encode data which shall be inserted into mysql. - if($dbencode == true) $new_record[$key] = $app->db->quote($new_record[$key]); + case 'RADIO': + if(is_array($field['value'])) { + + // HTML schreiben + $out = ''; + $elementNo = 0; + foreach($field['value'] as $k => $v) { + $checked = ($k == $val)?' CHECKED':''; + //$out .= "\r\n"; + $out .= "\r\n"; + $elementNo++; + } } - } - return $new_record; - } + $new_record[$key] = $out; + break; - /** - * Rewrite the record data to be stored in the database - * and check values with regular expressions. - * - * @param record = Datensatz als Array - * @return record - */ - function encode($record,$tab,$dbencode = true) { - global $app; + case 'DATETIME': + if (strtotime($val) !== false) { + $dt_value = $val; + } elseif ( isset($field['default']) && (strtotime($field['default']) !== false) ) { + $dt_value = $field['default']; + } else { + $dt_value = 0; + } - if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab is empty or does not exist (TAB: $tab)."); - return $this->_encode($record, $tab, $dbencode, false); - } + $display_seconds = (isset($field['display_seconds']) && $field['display_seconds'] == true) ? true : false; - /** - * process the filters for a given field. - * - * @param field_name = Name of the field - * @param field_value = value of the field - * @param filters = Array of filters - * @param filter_event = 'SAVE'or 'SHOW' - * @return record - */ + $new_record[$key] = $this->_getDateTimeHTML($key, $dt_value, $display_seconds); + break; - function filterField($field_name, $field_value, $filters, $filter_event) { + default: + if(isset($record[$key])) { + $new_record[$key] = htmlspecialchars($record[$key]); + } else { + $new_record[$key] = ''; + } + } + } + } + } else { + // Action: NEW + foreach($this->formDef['tabs'][$tab]['fields'] as $key => $field) { + + // If Datasource is set, get the data from there + if(@is_array($field['datasource'])) { + if(is_array($field["value"])) { + $field["value"] = $app->functions->array_merge($field["value"], $this->getDatasourceData($field, $record)); + } else { + $field["value"] = $this->getDatasourceData($field, $record); + } + } - global $app; - $returnval = $field_value; + // If a limitation for the values is set + if(isset($field['valuelimit']) && is_array($field["value"])) { + $field["value"] = $this->applyValueLimit($field['valuelimit'], $field["value"]); + } - //* Loop trough all filters - foreach($filters as $filter) { - if($filter['event'] == $filter_event) { - switch ($filter['type']) { - case 'TOLOWER': - $returnval = strtolower($returnval); - break; - case 'TOUPPER': - $returnval = strtoupper($returnval); - break; - case 'IDNTOASCII': - $returnval = $app->functions->idn_encode($returnval); - break; - case 'IDNTOUTF8': - $returnval = $app->functions->idn_decode($returnval); - break; - default: - $this->errorMessage .= "Unknown Filter: ".$filter['type']; - break; + switch ($field['formtype']) { + case 'SELECT': + if(is_array($field['value'])) { + $out = ''; + foreach($field['value'] as $k => $v) { + $selected = ($k == $field["default"])?' SELECTED':''; + $out .= "\r\n"; + } + } + if(isset($out)) $new_record[$key] = $out; + break; + case 'MULTIPLE': + if(is_array($field['value'])) { + + // aufsplitten ergebnisse + $vals = explode($field['separator'], $val); + + // HTML schreiben + $out = ''; + foreach($field['value'] as $k => $v) { + + $out .= "\r\n"; + } + } + $new_record[$key] = $out; + break; + + case 'PASSWORD': + //$new_record[$key] = ''; + $new_record[$key] = htmlspecialchars($field['default']); + break; + + case 'CHECKBOX': + // $checked = (empty($field["default"]))?'':' CHECKED'; + $checked = ($field["default"] == $field['value'][1])?' CHECKED':''; + $new_record[$key] = "\r\n"; + break; + + case 'CHECKBOXARRAY': + if(is_array($field['value'])) { + + // aufsplitten ergebnisse + $vals = explode($field['separator'], $field["default"]); + + // HTML schreiben + $out = ''; + $elementNo = 0; + foreach($field['value'] as $k => $v) { + + $checked = ''; + foreach($vals as $tvl) { + if(trim($tvl) == trim($k)) $checked = ' CHECKED'; + } + // $out .= "\r\n"; + $out .= "  \r\n"; + $elementNo++; + } + } + $new_record[$key] = $out; + break; + + case 'RADIO': + if(is_array($field['value'])) { + + // HTML schreiben + $out = ''; + $elementNo = 0; + foreach($field['value'] as $k => $v) { + $checked = ($k == $field["default"])?' CHECKED':''; + //$out .= "\r\n"; + $out .= "\r\n"; + $elementNo++; + } } + $new_record[$key] = $out; + break; + + case 'DATETIME': + $dt_value = (isset($field['default'])) ? $field['default'] : 0; + $display_seconds = (isset($field['display_seconds']) && $field['display_seconds'] == true) ? true : false; + + $new_record[$key] = $this->_getDateTimeHTML($key, $dt_value, $display_seconds); + break; + + default: + $new_record[$key] = htmlspecialchars($field['default']); } } - return $returnval; + } - /** - * process the validators for a given field. - * - * @param field_name = Name of the field - * @param field_value = value of the field - * @param validatoors = Array of validators - * @return record - */ + if($this->debug == 1) $this->dbg($new_record); - function validateField($field_name, $field_value, $validators) { - - global $app; - - $escape = '`'; - - // loop trough the validators - foreach($validators as $validator) { - - switch ($validator['type']) { - case 'REGEX': - $validator['regex'] .= 's'; - if(!preg_match($validator['regex'], $field_value)) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - break; - case 'UNIQUE': - if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n'; - if($validator['allowempty'] == 'n' || ($validator['allowempty'] == 'y' && $field_value != '')){ - if($this->action == 'NEW') { - $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."'"); - if($num_rec["number"] > 0) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } else { - $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."' AND ".$this->formDef['db_table_idx']." != ".$this->primary_id); - if($num_rec["number"] > 0) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } - } - break; - case 'NOTEMPTY': - if(empty($field_value)) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - break; - case 'ISEMAIL': - if(function_exists('filter_var')) { - if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } else { - if(!preg_match("/^\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-zA-Z0-9\-]{2,30}$/i", $field_value)) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } - break; - case 'ISINT': - if(function_exists('filter_var') && $field_value < 2147483647) { - if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT) === false) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } else { - $tmpval = $app->functions->intval($field_value); - if($tmpval === 0 and !empty($field_value)) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } - break; - case 'ISPOSITIVE': - if(!is_numeric($field_value) || $field_value <= 0){ - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - break; - case 'ISV6PREFIX': - $v6_prefix_ok = 0; - $explode_field_value = explode(':',$field_value); - if ($explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]=='' ){ - if ( count($explode_field_value) <= 9 ) { - if(filter_var(substr($field_value,0,strlen($field_value)-2),FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).'::0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) or filter_var(substr($field_value,0,strlen($field_value)-2).':0',FILTER_VALIDATE_IP,FILTER_FLAG_IPV6) ) { - $v6_prefix_ok = 1; - } + return $new_record; + } + + /** + * Rewrite the record data to be stored in the database + * and check values with regular expressions. + * + * @param record = Datensatz als Array + * @return record + */ + protected function _encode($record, $tab, $dbencode = true, $api = false) { + global $app; + if($api == true) $fields = &$this->formDef['fields']; + else $fields = &$this->formDef['tabs'][$tab]['fields']; + if(is_array($record)) { + foreach($fields as $key => $field) { + + //* Apply filter to record value + if(isset($field['filters']) && is_array($field['filters'])) { + $record[$key] = $this->filterField($key, (isset($record[$key]))?$record[$key]:'', $field['filters'], 'SAVE'); + } + //* Validate record value + if(isset($field['validators']) && is_array($field['validators'])) { + $this->validateField($key, (isset($record[$key]))?$record[$key]:'', $field['validators']); + } + + switch ($field['datatype']) { + case 'VARCHAR': + if(!@is_array($record[$key])) { + $new_record[$key] = (isset($record[$key]))?$record[$key]:''; + } else { + $new_record[$key] = implode($field['separator'], $record[$key]); + } + break; + case 'TEXT': + if(!is_array($record[$key])) { + $new_record[$key] = $record[$key]; + } else { + $new_record[$key] = implode($field['separator'], $record[$key]); + } + break; + case 'DATETSTAMP': + if($record[$key] > 0) { + list($tag, $monat, $jahr) = explode('.', $record[$key]); + $new_record[$key] = mktime(0, 0, 0, $monat, $tag, $jahr); + } else { + $new_record[$key] = 0; + } + break; + case 'DATE': + if($record[$key] != '' && $record[$key] != '0000-00-00') { + if(function_exists('date_parse_from_format')) { + $date_parts = date_parse_from_format($this->dateformat, $record[$key]); + //list($tag,$monat,$jahr) = explode('.',$record[$key]); + $new_record[$key] = $date_parts['year'].'-'.$date_parts['month'].'-'.$date_parts['day']; + //$tmp = strptime($record[$key],$this->dateformat); + //$new_record[$key] = ($tmp['tm_year']+1900).'-'.($tmp['tm_mon']+1).'-'.$tmp['tm_mday']; + } else { + //$tmp = strptime($record[$key],$this->dateformat); + //$new_record[$key] = ($tmp['tm_year']+1900).'-'.($tmp['tm_mon']+1).'-'.$tmp['tm_mday']; + $tmp = strtotime($record[$key]); + $new_record[$key] = date('Y-m-d', $tmp); + } + } else { + $new_record[$key] = '0000-00-00'; + } + break; + case 'INTEGER': + $new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0; + //if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default']; + //if($key == 'refresh') die($record[$key]); + break; + case 'DOUBLE': + $new_record[$key] = $record[$key]; + break; + case 'CURRENCY': + $new_record[$key] = str_replace(",", ".", $record[$key]); + break; + + case 'DATETIME': + if (is_array($record[$key])) + { + $filtered_values = array_map(create_function('$item', 'return (int)$item;'), $record[$key]); + extract($filtered_values, EXTR_PREFIX_ALL, '_dt'); + + if ($_dt_day != 0 && $_dt_month != 0 && $_dt_year != 0) { + $new_record[$key] = date( 'Y-m-d H:i:s', mktime($_dt_hour, $_dt_minute, $_dt_second, $_dt_month, $_dt_day, $_dt_year) ); + } + } + break; + } + + // The use of the field value is deprecated, use validators instead + if(isset($field['regex']) && $field['regex'] != '') { + // Enable that "." matches also newlines + $field['regex'] .= 's'; + if(!preg_match($field['regex'], $record[$key])) { + $errmsg = $field['errmsg']; + $this->errorMessage .= ($api == true ? $errmsg : $this->wordbook[$errmsg]."
    ") . "\r\n"; + } + } + + //* Add slashes to all records, when we encode data which shall be inserted into mysql. + if($dbencode == true) $new_record[$key] = $app->db->quote($new_record[$key]); + } + } + return $new_record; + } + + + /** + * Rewrite the record data to be stored in the database + * and check values with regular expressions. + * + * @param record = Datensatz als Array + * @return record + */ + function encode($record, $tab, $dbencode = true) { + global $app; + + if(!is_array($this->formDef['tabs'][$tab])) $app->error("Tab is empty or does not exist (TAB: $tab)."); + return $this->_encode($record, $tab, $dbencode, false); + } + + + /** + * process the filters for a given field. + * + * @param field_name = Name of the field + * @param field_value = value of the field + * @param filters = Array of filters + * @param filter_event = 'SAVE'or 'SHOW' + * @return record + */ + function filterField($field_name, $field_value, $filters, $filter_event) { + + global $app; + $returnval = $field_value; + + //* Loop trough all filters + foreach($filters as $filter) { + if($filter['event'] == $filter_event) { + switch ($filter['type']) { + case 'TOLOWER': + $returnval = strtolower($returnval); + break; + case 'TOUPPER': + $returnval = strtoupper($returnval); + break; + case 'IDNTOASCII': + $returnval = $app->functions->idn_encode($returnval); + break; + case 'IDNTOUTF8': + $returnval = $app->functions->idn_decode($returnval); + break; + default: + $this->errorMessage .= "Unknown Filter: ".$filter['type']; + break; + } + } + } + return $returnval; + } + + + /** + * process the validators for a given field. + * + * @param field_name = Name of the field + * @param field_value = value of the field + * @param validatoors = Array of validators + * @return record + */ + function validateField($field_name, $field_value, $validators) { + + global $app; + + $escape = '`'; + + // loop trough the validators + foreach($validators as $validator) { + + switch ($validator['type']) { + case 'REGEX': + $validator['regex'] .= 's'; + if(!preg_match($validator['regex'], $field_value)) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } + } + break; + case 'UNIQUE': + if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n'; + if($validator['allowempty'] == 'n' || ($validator['allowempty'] == 'y' && $field_value != '')){ + if($this->action == 'NEW') { + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."'"); + if($num_rec["number"] > 0) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; } + } } else { - $v6_prefix_ok = 2; + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."' AND ".$this->formDef['db_table_idx']." != ".$this->primary_id); + if($num_rec["number"] > 0) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } + } } - // check subnet against defined server-ipv6 - $sql_v6 = $app->db->queryOneRecord("SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND virtualhost = 'y' LIMIT 0,1"); - $sql_v6_explode=explode(':',$sql_v6['ip_address']); - if ( count($sql_v6_explode) < count($explode_field_value) && isset($sql_v6['ip_address']) ) { - $v6_prefix_ok = 3; + } + break; + case 'NOTEMPTY': + if(empty($field_value)) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; } - if($v6_prefix_ok == 0) { + } + break; + case 'ISEMAIL': + if(function_exists('filter_var')) { + if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) { $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } } - if($v6_prefix_ok == 2) { - $errmsg = 'IPv6 Prefix must end with ::'; + } else { + if(!preg_match("/^\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-zA-Z0-9\-]{2,30}$/i", $field_value)) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } } - if($v6_prefix_ok == 3) { - $errmsg = 'IPv6 Prefix too long (according to Server IP Addresses)'; + } + break; + case 'ISINT': + if(function_exists('filter_var') && $field_value < 2147483647) { + if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT) === false) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } } - if($v6_prefix_ok <> 1){ + } else { + $tmpval = $app->functions->intval($field_value); + if($tmpval === 0 and !empty($field_value)) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } + } + } + break; + case 'ISPOSITIVE': + if(!is_numeric($field_value) || $field_value <= 0){ + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { $this->errorMessage .= $errmsg."
    \r\n"; } + } break; - case 'ISIPV4': - $vip=1; - if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){ - $groups=explode(".",$field_value); - foreach($groups as $group){ - if($group<0 OR $group>255) - $vip=0; - } - }else{$vip=0;} - if($vip==0) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - break; - case 'ISIP': - if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n'; - if($validator['allowempty'] == 'y' && $field_value == '') { - //* Do nothing - } else { - //* Check if its a IPv4 or IPv6 address - if(isset($validator['separator']) && $validator['separator'] != '') { - //* When the field may contain several IP addresses, split them by the char defined as separator - $field_value_array = explode($validator['separator'],$field_value); - } else { - $field_value_array[] = $field_value; - } - foreach($field_value_array as $field_value) { - $field_value = trim($field_value); - if(function_exists('filter_var')) { - if(!filter_var($field_value,FILTER_VALIDATE_IP)) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } else { - //* Check content with regex, if we use php < 5.2 - $ip_ok = 0; - if(preg_match("/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i", $field_value)){ - $ip_ok = 1; - } - if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){ - $ip_ok = 1; - } - if($ip_ok == 0) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - } - } - } - break; - case 'RANGE': - //* Checks if the value is within the given range or above / below a value - //* Range examples: < 10 = ":10", between 2 and 10 = "2:10", above 5 = "5:". - $range_parts = explode(':',trim($validator['range'])); - $ok = true; - if($range_parts[0] != '' && $field_value < $range_parts[0]) { - $ok = false; - } - if($range_parts[1] != '' && $field_value > $range_parts[1]) { - $ok = false; - } - if($ok != true) { - $errmsg = $validator['errmsg']; - if(isset($this->wordbook[$errmsg])) { - $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; - } else { - $this->errorMessage .= $errmsg."
    \r\n"; - } - } - unset($range_parts); - break; - case 'CUSTOM': - // Calls a custom class to validate this record - if($validator['class'] != '' and $validator['function'] != '') { - $validator_class = $validator['class']; - $validator_function = $validator['function']; - $app->uses($validator_class); - $this->errorMessage .= $app->$validator_class->$validator_function($field_name, $field_value, $validator); - } else { - $this->errorMessage .= "Custom validator class or function is empty
    \r\n"; - } - break; - default: - $this->errorMessage .= "Unknown Validator: ".$validator['type']; - break; + case 'ISV6PREFIX': + $v6_prefix_ok = 0; + $explode_field_value = explode(':', $field_value); + if ($explode_field_value[count($explode_field_value)-1]=='' && $explode_field_value[count($explode_field_value)-2]=='' ){ + if ( count($explode_field_value) <= 9 ) { + if(filter_var(substr($field_value, 0, strlen($field_value)-2), FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) or filter_var(substr($field_value, 0, strlen($field_value)-2).'::0', FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) or filter_var(substr($field_value, 0, strlen($field_value)-2).':0', FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) ) { + $v6_prefix_ok = 1; } - - + } + } else { + $v6_prefix_ok = 2; } - - return true; - } - - /** - * Create SQL statement - * - * @param record = Datensatz als Array - * @param action = INSERT oder UPDATE - * @param primary_id - * @return record - */ - protected function _getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '', $api = false) { - - global $app; - - $this->action = $action; - $this->primary_id = $primary_id; - - - $record = $this->encode($record,$tab,true); - $sql_insert_key = ''; - $sql_insert_val = ''; - $sql_update = ''; - - if($api == true) $fields = &$this->formDef['fields']; - else $fields = &$this->formDef['tabs'][$tab]['fields']; - - // go trough all fields of the tab - if(is_array($record)) { - foreach($fields as $key => $field) { - // Wenn es kein leeres Passwortfeld ist - if (!($field['formtype'] == 'PASSWORD' and $record[$key] == '')) { - // Erzeuge Insert oder Update Quelltext - if($action == "INSERT") { - if($field['formtype'] == 'PASSWORD') { - $sql_insert_key .= "`$key`, "; - if ((isset($field['encryption']) && $field['encryption'] == 'CLEARTEXT') || (isset($record['_ispconfig_pw_crypted']) && $record['_ispconfig_pw_crypted'] == 1)) { - $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; - } elseif(isset($field['encryption']) && $field['encryption'] == 'CRYPT') { - $record[$key] = $app->auth->crypt_password(stripslashes($record[$key])); - $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; - } elseif (isset($field['encryption']) && $field['encryption'] == 'MYSQL') { - $tmp = $app->db->queryOneRecord("SELECT PASSWORD('".$app->db->quote(stripslashes($record[$key]))."') as `crypted`"); - $record[$key] = $tmp['crypted']; - $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; - } else { - $record[$key] = md5(stripslashes($record[$key])); - $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; - } - } elseif ($field['formtype'] == 'CHECKBOX') { - $sql_insert_key .= "`$key`, "; - if($record[$key] == '') { - // if a checkbox is not set, we set it to the unchecked value - $sql_insert_val .= "'".$field['value'][0]."', "; - $record[$key] = $field['value'][0]; - } else { - $sql_insert_val .= "'".$record[$key]."', "; - } - } else { - $sql_insert_key .= "`$key`, "; - $sql_insert_val .= "'".$record[$key]."', "; - } - } else { - if($field['formtype'] == 'PASSWORD') { - if ((isset($field['encryption']) && $field['encryption'] == 'CLEARTEXT') || (isset($record['_ispconfig_pw_crypted']) && $record['_ispconfig_pw_crypted'] == 1)) { - $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; - } elseif(isset($field['encryption']) && $field['encryption'] == 'CRYPT') { - $record[$key] = $app->auth->crypt_password(stripslashes($record[$key])); - $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; - } elseif (isset($field['encryption']) && $field['encryption'] == 'MYSQL') { - $tmp = $app->db->queryOneRecord("SELECT PASSWORD('".$app->db->quote(stripslashes($record[$key]))."') as `crypted`"); - $record[$key] = $tmp['crypted']; - $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; - } else { - $record[$key] = md5(stripslashes($record[$key])); - $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; - } - - } elseif ($field['formtype'] == 'CHECKBOX') { - if($record[$key] == '') { - // if a checkbox is not set, we set it to the unchecked value - $sql_update .= "`$key` = '".$field['value'][0]."', "; - $record[$key] = $field['value'][0]; - } else { - $sql_update .= "`$key` = '".$record[$key]."', "; - } - } else { - $sql_update .= "`$key` = '".$record[$key]."', "; - } - } + // check subnet against defined server-ipv6 + $sql_v6 = $app->db->queryOneRecord("SELECT ip_address FROM server_ip WHERE ip_type = 'IPv6' AND virtualhost = 'y' LIMIT 0,1"); + $sql_v6_explode=explode(':', $sql_v6['ip_address']); + if ( count($sql_v6_explode) < count($explode_field_value) && isset($sql_v6['ip_address']) ) { + $v6_prefix_ok = 3; + } + if($v6_prefix_ok == 0) { + $errmsg = $validator['errmsg']; + } + if($v6_prefix_ok == 2) { + $errmsg = 'IPv6 Prefix must end with ::'; + } + if($v6_prefix_ok == 3) { + $errmsg = 'IPv6 Prefix too long (according to Server IP Addresses)'; + } + if($v6_prefix_ok <> 1){ + $this->errorMessage .= $errmsg."
    \r\n"; + } + break; + case 'ISIPV4': + $vip=1; + if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){ + $groups=explode(".", $field_value); + foreach($groups as $group){ + if($group<0 or $group>255) + $vip=0; + } + }else{$vip=0;} + if($vip==0) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } + } + break; + case 'ISIP': + if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n'; + if($validator['allowempty'] == 'y' && $field_value == '') { + //* Do nothing + } else { + //* Check if its a IPv4 or IPv6 address + if(isset($validator['separator']) && $validator['separator'] != '') { + //* When the field may contain several IP addresses, split them by the char defined as separator + $field_value_array = explode($validator['separator'], $field_value); + } else { + $field_value_array[] = $field_value; + } + foreach($field_value_array as $field_value) { + $field_value = trim($field_value); + if(function_exists('filter_var')) { + if(!filter_var($field_value, FILTER_VALIDATE_IP)) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; } else { - // we unset the password filed, if empty to tell the datalog function - // that the password has not been changed - unset($record[$key]); + $this->errorMessage .= $errmsg."
    \r\n"; } + } + } else { + //* Check content with regex, if we use php < 5.2 + $ip_ok = 0; + if(preg_match("/^(\:\:([a-f0-9]{1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3})?$/i", $field_value)){ + $ip_ok = 1; + } + if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){ + $ip_ok = 1; + } + if($ip_ok == 0) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } + } } - } - - - // Add backticks for incomplete table names - if(stristr($this->formDef['db_table'],'.')) { - $escape = ''; + } + } + break; + case 'RANGE': + //* Checks if the value is within the given range or above / below a value + //* Range examples: < 10 = ":10", between 2 and 10 = "2:10", above 5 = "5:". + $range_parts = explode(':', trim($validator['range'])); + $ok = true; + if($range_parts[0] != '' && $field_value < $range_parts[0]) { + $ok = false; + } + if($range_parts[1] != '' && $field_value > $range_parts[1]) { + $ok = false; + } + if($ok != true) { + $errmsg = $validator['errmsg']; + if(isset($this->wordbook[$errmsg])) { + $this->errorMessage .= $this->wordbook[$errmsg]."
    \r\n"; + } else { + $this->errorMessage .= $errmsg."
    \r\n"; + } + } + unset($range_parts); + break; + case 'CUSTOM': + // Calls a custom class to validate this record + if($validator['class'] != '' and $validator['function'] != '') { + $validator_class = $validator['class']; + $validator_function = $validator['function']; + $app->uses($validator_class); + $this->errorMessage .= $app->$validator_class->$validator_function($field_name, $field_value, $validator); } else { - $escape = '`'; + $this->errorMessage .= "Custom validator class or function is empty
    \r\n"; } + break; + default: + $this->errorMessage .= "Unknown Validator: ".$validator['type']; + break; + } - if($action == "INSERT") { - if($this->formDef['auth'] == 'yes') { - // Set user and group - $sql_insert_key .= "`sys_userid`, "; - $sql_insert_val .= ($this->formDef["auth_preset"]["userid"] > 0)?"'".$this->formDef["auth_preset"]["userid"]."', ":"'".$_SESSION["s"]["user"]["userid"]."', "; - $sql_insert_key .= "`sys_groupid`, "; - $sql_insert_val .= ($this->formDef["auth_preset"]["groupid"] > 0)?"'".$this->formDef["auth_preset"]["groupid"]."', ":"'".$_SESSION["s"]["user"]["default_group"]."', "; - $sql_insert_key .= "`sys_perm_user`, "; - $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_user"]."', "; - $sql_insert_key .= "`sys_perm_group`, "; - $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_group"]."', "; - $sql_insert_key .= "`sys_perm_other`, "; - $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_other"]."', "; - } - $sql_insert_key = substr($sql_insert_key,0,-2); - $sql_insert_val = substr($sql_insert_val,0,-2); - $sql = "INSERT INTO ".$escape.$this->formDef['db_table'].$escape." ($sql_insert_key) VALUES ($sql_insert_val)"; - } else { - if($this->formDef['auth'] == 'yes') { - if($primary_id != 0) { - if($api == true && $_SESSION["s"]["user"]["client_id"] > 0 && $_SESSION["s"]["user"]["iserid"] > 0 && $_SESSION["s"]["user"]["default_group"] > 0) { - $sql_update .= '`sys_userid` = '.$this->sys_userid.', '; - $sql_update .= '`sys_groupid` = '.$this->sys_default_group.', '; - } - - $sql_update = substr($sql_update,0,-2); - $sql = "UPDATE ".$escape.$this->formDef['db_table'].$escape." SET ".$sql_update." WHERE ".$this->getAuthSQL('u')." AND ".$this->formDef['db_table_idx']." = ".$primary_id; - if($sql_ext_where != '') $sql .= " and ".$sql_ext_where; + } + + return true; + } + + /** + * Create SQL statement + * + * @param record = Datensatz als Array + * @param action = INSERT oder UPDATE + * @param primary_id + * @return record + */ + protected function _getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '', $api = false) { + + global $app; + + $this->action = $action; + $this->primary_id = $primary_id; + + + $record = $this->encode($record, $tab, true); + $sql_insert_key = ''; + $sql_insert_val = ''; + $sql_update = ''; + + if($api == true) $fields = &$this->formDef['fields']; + else $fields = &$this->formDef['tabs'][$tab]['fields']; + + // go trough all fields of the tab + if(is_array($record)) { + foreach($fields as $key => $field) { + // Wenn es kein leeres Passwortfeld ist + if (!($field['formtype'] == 'PASSWORD' and $record[$key] == '')) { + // Erzeuge Insert oder Update Quelltext + if($action == "INSERT") { + if($field['formtype'] == 'PASSWORD') { + $sql_insert_key .= "`$key`, "; + if ((isset($field['encryption']) && $field['encryption'] == 'CLEARTEXT') || (isset($record['_ispconfig_pw_crypted']) && $record['_ispconfig_pw_crypted'] == 1)) { + $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; + } elseif(isset($field['encryption']) && $field['encryption'] == 'CRYPT') { + $record[$key] = $app->auth->crypt_password(stripslashes($record[$key])); + $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; + } elseif (isset($field['encryption']) && $field['encryption'] == 'MYSQL') { + $tmp = $app->db->queryOneRecord("SELECT PASSWORD('".$app->db->quote(stripslashes($record[$key]))."') as `crypted`"); + $record[$key] = $tmp['crypted']; + $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; + } else { + $record[$key] = md5(stripslashes($record[$key])); + $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; + } + } elseif ($field['formtype'] == 'CHECKBOX') { + $sql_insert_key .= "`$key`, "; + if($record[$key] == '') { + // if a checkbox is not set, we set it to the unchecked value + $sql_insert_val .= "'".$field['value'][0]."', "; + $record[$key] = $field['value'][0]; + } else { + $sql_insert_val .= "'".$record[$key]."', "; + } } else { - $app->error("Primary ID fehlt!"); + $sql_insert_key .= "`$key`, "; + $sql_insert_val .= "'".$record[$key]."', "; } } else { - if($primary_id != 0) { - $sql_update = substr($sql_update,0,-2); - $sql = "UPDATE ".$escape.$this->formDef['db_table'].$escape." SET ".$sql_update." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id; - if($sql_ext_where != '') $sql .= " and ".$sql_ext_where; + if($field['formtype'] == 'PASSWORD') { + if ((isset($field['encryption']) && $field['encryption'] == 'CLEARTEXT') || (isset($record['_ispconfig_pw_crypted']) && $record['_ispconfig_pw_crypted'] == 1)) { + $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; + } elseif(isset($field['encryption']) && $field['encryption'] == 'CRYPT') { + $record[$key] = $app->auth->crypt_password(stripslashes($record[$key])); + $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; + } elseif (isset($field['encryption']) && $field['encryption'] == 'MYSQL') { + $tmp = $app->db->queryOneRecord("SELECT PASSWORD('".$app->db->quote(stripslashes($record[$key]))."') as `crypted`"); + $record[$key] = $tmp['crypted']; + $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; + } else { + $record[$key] = md5(stripslashes($record[$key])); + $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; + } + + } elseif ($field['formtype'] == 'CHECKBOX') { + if($record[$key] == '') { + // if a checkbox is not set, we set it to the unchecked value + $sql_update .= "`$key` = '".$field['value'][0]."', "; + $record[$key] = $field['value'][0]; + } else { + $sql_update .= "`$key` = '".$record[$key]."', "; + } } else { - $app->error("Primary ID fehlt!"); + $sql_update .= "`$key` = '".$record[$key]."', "; } } - //* return a empty string if there is nothing to update - if(trim($sql_update) == '') $sql = ''; + } else { + // we unset the password filed, if empty to tell the datalog function + // that the password has not been changed + unset($record[$key]); } - - return $sql; + } } - /** - * Create SQL statement - * - * @param record = Datensatz als Array - * @param action = INSERT oder UPDATE - * @param primary_id - * @return record - */ - function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '') { - global $app; + // Add backticks for incomplete table names + if(stristr($this->formDef['db_table'], '.')) { + $escape = ''; + } else { + $escape = '`'; + } - // If there are no data records on the tab, return empty sql string - if(count($this->formDef['tabs'][$tab]['fields']) == 0) return ''; - // checking permissions - if($this->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { - if($action == "INSERT") { - if(!$this->checkPerm($primary_id,'i')) $this->errorMessage .= "Insert denied.
    \r\n"; - } else { - if(!$this->checkPerm($primary_id,'u')) $this->errorMessage .= "Update denied.
    \r\n"; - } - } - - if(!is_array($this->formDef)) $app->error("Form definition not found."); - if(!is_array($this->formDef['tabs'][$tab])) $app->error("The tab is empty or does not exist (TAB: $tab)."); + if($action == "INSERT") { + if($this->formDef['auth'] == 'yes') { + // Set user and group + $sql_insert_key .= "`sys_userid`, "; + $sql_insert_val .= ($this->formDef["auth_preset"]["userid"] > 0)?"'".$this->formDef["auth_preset"]["userid"]."', ":"'".$_SESSION["s"]["user"]["userid"]."', "; + $sql_insert_key .= "`sys_groupid`, "; + $sql_insert_val .= ($this->formDef["auth_preset"]["groupid"] > 0)?"'".$this->formDef["auth_preset"]["groupid"]."', ":"'".$_SESSION["s"]["user"]["default_group"]."', "; + $sql_insert_key .= "`sys_perm_user`, "; + $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_user"]."', "; + $sql_insert_key .= "`sys_perm_group`, "; + $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_group"]."', "; + $sql_insert_key .= "`sys_perm_other`, "; + $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_other"]."', "; + } + $sql_insert_key = substr($sql_insert_key, 0, -2); + $sql_insert_val = substr($sql_insert_val, 0, -2); + $sql = "INSERT INTO ".$escape.$this->formDef['db_table'].$escape." ($sql_insert_key) VALUES ($sql_insert_val)"; + } else { + if($this->formDef['auth'] == 'yes') { + if($primary_id != 0) { + if($api == true && $_SESSION["s"]["user"]["client_id"] > 0 && $_SESSION["s"]["user"]["iserid"] > 0 && $_SESSION["s"]["user"]["default_group"] > 0) { + $sql_update .= '`sys_userid` = '.$this->sys_userid.', '; + $sql_update .= '`sys_groupid` = '.$this->sys_default_group.', '; + } - return $this->_getSQL($record, $tab, $action, $primary_id, $sql_ext_where, false); + $sql_update = substr($sql_update, 0, -2); + $sql = "UPDATE ".$escape.$this->formDef['db_table'].$escape." SET ".$sql_update." WHERE ".$this->getAuthSQL('u')." AND ".$this->formDef['db_table_idx']." = ".$primary_id; + if($sql_ext_where != '') $sql .= " and ".$sql_ext_where; + } else { + $app->error("Primary ID fehlt!"); + } + } else { + if($primary_id != 0) { + $sql_update = substr($sql_update, 0, -2); + $sql = "UPDATE ".$escape.$this->formDef['db_table'].$escape." SET ".$sql_update." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id; + if($sql_ext_where != '') $sql .= " and ".$sql_ext_where; + } else { + $app->error("Primary ID fehlt!"); + } + } + //* return a empty string if there is nothing to update + if(trim($sql_update) == '') $sql = ''; } - /** - * Debugging arrays. - * - * @param array_data - */ - function dbg($array_data) { + return $sql; + } + - echo "
    ";
    -				print_r($array_data);
    -				echo "
    "; + /** + * Create SQL statement + * + * @param record = Datensatz als Array + * @param action = INSERT oder UPDATE + * @param primary_id + * @return record + */ + function getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '') { + global $app; + + // If there are no data records on the tab, return empty sql string + if(count($this->formDef['tabs'][$tab]['fields']) == 0) return ''; + + // checking permissions + if($this->formDef['auth'] == 'yes' && $_SESSION["s"]["user"]["typ"] != 'admin') { + if($action == "INSERT") { + if(!$this->checkPerm($primary_id, 'i')) $this->errorMessage .= "Insert denied.
    \r\n"; + } else { + if(!$this->checkPerm($primary_id, 'u')) $this->errorMessage .= "Update denied.
    \r\n"; + } } + if(!is_array($this->formDef)) $app->error("Form definition not found."); + if(!is_array($this->formDef['tabs'][$tab])) $app->error("The tab is empty or does not exist (TAB: $tab)."); + + return $this->_getSQL($record, $tab, $action, $primary_id, $sql_ext_where, false); + } + + + /** + * Debugging arrays. + * + * @param array_data + */ + function dbg($array_data) { + + echo "
    ";
    +		print_r($array_data);
    +		echo "
    "; + + } + function showForm() { - global $app,$conf; + global $app, $conf; if(!is_array($this->formDef)) die("Form Definition wurde nicht geladen."); - $active_tab = $this->getNextTab(); + $active_tab = $this->getNextTab(); // go trough the tabs foreach( $this->formDef["tabs"] as $key => $tab) { @@ -1285,20 +1289,20 @@ class tform_base { if(!is_file($tab["template"])) { - $app->uses('tform_tpl_generator'); - $app->tform_tpl_generator->buildHTML($this->formDef,$tab['name']); + $app->uses('tform_tpl_generator'); + $app->tform_tpl_generator->buildHTML($this->formDef, $tab['name']); } $app->tpl->setVar('readonly_tab', (isset($tab['readonly']) && $tab['readonly'] == true)); - $app->tpl->setInclude('content_tpl',$tab["template"]); + $app->tpl->setInclude('content_tpl', $tab["template"]); $tab["active"] = 1; $_SESSION["s"]["form"]["tab"] = $tab['name']; } else { - $tab["active"] = 0; + $tab["active"] = 0; } - // Unset unused variables. - unset($tab["fields"]); - unset($tab["plugins"]); + // Unset unused variables. + unset($tab["fields"]); + unset($tab["plugins"]); $frmTab[] = $tab; } @@ -1306,52 +1310,53 @@ class tform_base { // setting form tabs $app->tpl->setLoop("formTab", $frmTab); - // Set form action - $app->tpl->setVar('form_action',$this->formDef["action"]); - $app->tpl->setVar('form_active_tab',$active_tab); + // Set form action + $app->tpl->setVar('form_action', $this->formDef["action"]); + $app->tpl->setVar('form_active_tab', $active_tab); - // Set form title - $form_hint = $this->lng($this->formDef["title"]); - if($this->formDef["description"] != '') $form_hint .= '
    '.$this->lng($this->formDef["description"]).'
    '; - $app->tpl->setVar('form_hint',$form_hint); + // Set form title + $form_hint = $this->lng($this->formDef["title"]); + if($this->formDef["description"] != '') $form_hint .= '
    '.$this->lng($this->formDef["description"]).'
    '; + $app->tpl->setVar('form_hint', $form_hint); - // Set Wordbook for this form + // Set Wordbook for this form - $app->tpl->setVar($this->wordbook); - } + $app->tpl->setVar($this->wordbook); + } - function getDataRecord($primary_id) { - global $app; - $escape = '`'; - $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id." AND ".$this->getAuthSQL('r',$this->formDef['db_table']); - return $app->db->queryOneRecord($sql); - } + function getDataRecord($primary_id) { + global $app; + $escape = '`'; + $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id." AND ".$this->getAuthSQL('r', $this->formDef['db_table']); + return $app->db->queryOneRecord($sql); + } - function datalogSave($action,$primary_id, $record_old, $record_new) { - global $app,$conf; + function datalogSave($action, $primary_id, $record_old, $record_new) { + global $app, $conf; - $app->db->datalogSave($this->formDef['db_table'], $action, $this->formDef['db_table_idx'], $primary_id, $record_old, $record_new); - return true; - } + $app->db->datalogSave($this->formDef['db_table'], $action, $this->formDef['db_table_idx'], $primary_id, $record_old, $record_new); + return true; + } - function getAuthSQL($perm, $table = '') { - if($_SESSION["s"]["user"]["typ"] == 'admin') { - return '1'; - } else { - if ($table != ''){ - $table = ' ' . $table . '.'; - } - $groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0; - $sql = '('; - $sql .= "(" . $table . "sys_userid = ".$_SESSION["s"]["user"]["userid"]." AND " . $table . "sys_perm_user like '%$perm%') OR "; - $sql .= "(" . $table . "sys_groupid IN (".$groups.") AND " . $table ."sys_perm_group like '%$perm%') OR "; - $sql .= $table . "sys_perm_other like '%$perm%'"; - $sql .= ')'; - - return $sql; - } + function getAuthSQL($perm, $table = '') { + if($_SESSION["s"]["user"]["typ"] == 'admin') { + return '1'; + } else { + if ($table != ''){ + $table = ' ' . $table . '.'; + } + $groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0; + $sql = '('; + $sql .= "(" . $table . "sys_userid = ".$_SESSION["s"]["user"]["userid"]." AND " . $table . "sys_perm_user like '%$perm%') OR "; + $sql .= "(" . $table . "sys_groupid IN (".$groups.") AND " . $table ."sys_perm_group like '%$perm%') OR "; + $sql .= $table . "sys_perm_other like '%$perm%'"; + $sql .= ')'; + + return $sql; } + } + } ?> diff --git a/interface/lib/classes/tform_tpl_generator.inc.php b/interface/lib/classes/tform_tpl_generator.inc.php index bfc932f84..635aa0467 100644 --- a/interface/lib/classes/tform_tpl_generator.inc.php +++ b/interface/lib/classes/tform_tpl_generator.inc.php @@ -29,13 +29,13 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class tform_tpl_generator { - - function buildHTML($formDef,$tab) { - + + function buildHTML($formDef, $tab) { + global $app; - + $module = $_SESSION["s"]["module"]["name"]; - + $html = '

    @@ -51,22 +51,22 @@ class tform_tpl_generator { if ($field['required'] == true ) { $html_reqcode = $html_reqestedelement; } else { $html_reqcode = ''; } switch ($field['formtype']) { - case 'TEXT': - $html .= " + case 'TEXT': + $html .= "
    "; break; - case 'TEXTAREA': - $html .= " + case 'TEXTAREA': + $html .= "
    "; break; - case 'SELECT': - $html .= " + case 'SELECT': + $html .= "
    "; break; - case 'MULTIPLE': - $html .= " + case 'MULTIPLE': + $html .= "
    "; break; - case 'PASSWORD': - $html .= " + case 'PASSWORD': + $html .= "
    "; break; - case 'CHECKBOX': - $html .= " + case 'CHECKBOX': + $html .= "

    ".$html_reqcode."{tmpl_var name='".$key."_txt'}

    @@ -99,8 +99,8 @@ class tform_tpl_generator {
    "; break; - case 'CHECKBOXARRAY': - $html .= " + case 'CHECKBOXARRAY': + $html .= "

    ".$html_reqcode."{tmpl_var name='".$key."_txt'}

    @@ -108,8 +108,8 @@ class tform_tpl_generator {
    "; break; - case 'RADIO': - $html .= " + case 'RADIO': + $html .= "

    ".$html_reqcode."{tmpl_var name='".$key."_txt'}

    @@ -118,18 +118,18 @@ class tform_tpl_generator {
    "; break; } - + // Language File Eintrag für "Feld-Titel" anlegen $lang[$key."_txt"] = $key; - + // language File Eintrag, für error-Text anlegen if(isset($field["errmsg"]) && $field["errmsg"] != '') { $errmsg = $field["errmsg"]; $lang[$errmsg] = $errmsg; } - + } - + $html .= " @@ -140,94 +140,94 @@ class tform_tpl_generator {
    - + "; - + // speichere Template - if (!$handle = fopen($formDef['tabs'][$tab]['template'], 'w')) { - print "Cannot open file (".$formDef['tabs'][$tab]['template'].")"; - exit; - } - - if (!fwrite($handle, $html)) { - print "Cannot write to file ($filename)"; - exit; + if (!$handle = fopen($formDef['tabs'][$tab]['template'], 'w')) { + print "Cannot open file (".$formDef['tabs'][$tab]['template'].")"; + exit; + } + + if (!fwrite($handle, $html)) { + print "Cannot write to file ($filename)"; + exit; } fclose($handle); - - $this->lng_add($lang,$formDef); - + + $this->lng_add($lang, $formDef); + // überprüfe, ob es die Tabelle schon gibt, // ansonsten wird sie angelegt $tables = $app->db->getTables(); - - if(!@in_array($formDef['db_table'],$tables)) { + + if(!@in_array($formDef['db_table'], $tables)) { // Datenbank noch nicht vorhanden - + $columns = array(); - + // füge ID Feld hinzu - $col = array( 'action' => 'add', - 'name' => $formDef["db_table_idx"], - 'type' => 'int64', - 'typeValue' => '', - 'defaultValue' => false, - 'notNull' => true, - 'autoInc' => true, - 'option' => 'primary' - ); - + $col = array( 'action' => 'add', + 'name' => $formDef["db_table_idx"], + 'type' => 'int64', + 'typeValue' => '', + 'defaultValue' => false, + 'notNull' => true, + 'autoInc' => true, + 'option' => 'primary' + ); + $columns[] = $col; $app->db->show_error_messages = true; - + if($formDef["auth"] == 'yes') { - - $col = array( 'action' => 'add', - 'name' => 'sys_userid', - 'type' => 'int32', - 'typeValue' => '', - 'defaultValue' => '0', - 'notNull' => true - ); + + $col = array( 'action' => 'add', + 'name' => 'sys_userid', + 'type' => 'int32', + 'typeValue' => '', + 'defaultValue' => '0', + 'notNull' => true + ); $columns[] = $col; - $col = array( 'action' => 'add', - 'name' => 'sys_groupid', - 'type' => 'int32', - 'typeValue' => '', - 'defaultValue' => '0', - 'notNull' => true - ); + $col = array( 'action' => 'add', + 'name' => 'sys_groupid', + 'type' => 'int32', + 'typeValue' => '', + 'defaultValue' => '0', + 'notNull' => true + ); $columns[] = $col; - $col = array( 'action' => 'add', - 'name' => 'sys_perm_user', - 'type' => 'varchar', - 'typeValue' => '5', - 'defaultValue' => 'NULL', - 'notNull' => true - ); + $col = array( 'action' => 'add', + 'name' => 'sys_perm_user', + 'type' => 'varchar', + 'typeValue' => '5', + 'defaultValue' => 'NULL', + 'notNull' => true + ); $columns[] = $col; - $col = array( 'action' => 'add', - 'name' => 'sys_perm_group', - 'type' => 'varchar', - 'typeValue' => '5', - 'defaultValue' => 'NULL', - 'notNull' => true - ); + $col = array( 'action' => 'add', + 'name' => 'sys_perm_group', + 'type' => 'varchar', + 'typeValue' => '5', + 'defaultValue' => 'NULL', + 'notNull' => true + ); $columns[] = $col; - $col = array( 'action' => 'add', - 'name' => 'sys_perm_other', - 'type' => 'varchar', - 'typeValue' => '5', - 'defaultValue' => 'NULL', - 'notNull' => true - ); + $col = array( 'action' => 'add', + 'name' => 'sys_perm_other', + 'type' => 'varchar', + 'typeValue' => '5', + 'defaultValue' => 'NULL', + 'notNull' => true + ); $columns[] = $col; - + } - - + + foreach($formDef['tabs'] as $tab) { foreach($tab["fields"] as $name => $field) { /* @@ -240,85 +240,86 @@ class tform_tpl_generator { notNull => true | false autoInc => true | false option => unique | primary | index) - - + + */ switch ($field["datatype"]) { - case 'INTEGER': - $type = 'int32'; - $typevalue = ''; - $defaultValue = ($field["default"] != '')?$field["default"]:'0'; + case 'INTEGER': + $type = 'int32'; + $typevalue = ''; + $defaultValue = ($field["default"] != '')?$field["default"]:'0'; break; - case 'DOUBLE': - $type = 'double'; - $typevalue = ''; - $defaultValue = ($field["default"] != '')?$field["default"]:'0'; + case 'DOUBLE': + $type = 'double'; + $typevalue = ''; + $defaultValue = ($field["default"] != '')?$field["default"]:'0'; break; - case 'CURRENCY': - $type = 'double'; - $typevalue = ''; - $defaultValue = ($field["default"] != '')?$field["default"]:'0'; + case 'CURRENCY': + $type = 'double'; + $typevalue = ''; + $defaultValue = ($field["default"] != '')?$field["default"]:'0'; break; - case 'VARCHAR': - $type = 'varchar'; - $typeValue = ($field["maxlength"] > 0 and $field["maxlength"] <= 256)?$field["maxlength"]:255; - // $defaultValue = ($field["default"] != '')?$field["default"]:'NOT NULL'; - $defaultValue = ($field["default"] != '')?$field["default"]:'NULL'; + case 'VARCHAR': + $type = 'varchar'; + $typeValue = ($field["maxlength"] > 0 and $field["maxlength"] <= 256)?$field["maxlength"]:255; + // $defaultValue = ($field["default"] != '')?$field["default"]:'NOT NULL'; + $defaultValue = ($field["default"] != '')?$field["default"]:'NULL'; break; - case 'TEXT': - $type = 'text'; - $typevalue = ''; - $defaultValue = 'NULL'; + case 'TEXT': + $type = 'text'; + $typevalue = ''; + $defaultValue = 'NULL'; break; - case 'DATE': - $type = 'int64'; - $typevalue = ''; - $defaultValue = ($field["default"] != '')?$field["default"]:'0'; + case 'DATE': + $type = 'int64'; + $typevalue = ''; + $defaultValue = ($field["default"] != '')?$field["default"]:'0'; break; } - - - $col = array( 'action' => 'add', - 'name' => $name, - 'type' => $type, - 'typeValue' => $typeValue, - 'defaultValue' => $defaultValue, - 'notNull' => true - ); - + + + $col = array( 'action' => 'add', + 'name' => $name, + 'type' => $type, + 'typeValue' => $typeValue, + 'defaultValue' => $defaultValue, + 'notNull' => true + ); + $columns[] = $col; } } - - $app->db->createTable($formDef["db_table"],$columns); - + + $app->db->createTable($formDef["db_table"], $columns); + } } - - function lng_add($lang,$formDef) { - global $go_api, $go_info,$conf; - + + function lng_add($lang, $formDef) { + global $go_api, $go_info, $conf; + $lng_file = "lib/lang/".$conf["language"]."_".$formDef['name'].".lng"; if(is_file($lng_file)) { - include($lng_file); + include $lng_file; } else { $wb = array(); } - - $wb_out = array_merge($lang,$wb); - + + $wb_out = array_merge($lang, $wb); + if(is_array($wb_out)) { - $fp = fopen ($lng_file, "w"); - fwrite($fp," $val) { $new_line = '$wb["'.$key.'"] = '."'$val';\n"; - fwrite($fp,$new_line); - + fwrite($fp, $new_line); + } - fwrite($fp,"?>"); + fwrite($fp, "?>"); fclose($fp); } } + } -?> \ No newline at end of file +?> diff --git a/interface/lib/classes/tools_monitor.inc.php b/interface/lib/classes/tools_monitor.inc.php index cb389c8d4..19f2ccd5a 100644 --- a/interface/lib/classes/tools_monitor.inc.php +++ b/interface/lib/classes/tools_monitor.inc.php @@ -29,21 +29,21 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class tools_monitor { - function showServerLoad() { - global $app; + function showServerLoad() { + global $app; - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'server_load' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'server_load' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - if(isset($record['data'])) { - $data = unserialize($record['data']); + if(isset($record['data'])) { + $data = unserialize($record['data']); - /* + /* Format the data */ - if (strlen($data['up_minutes']) == "1") $data['up_minutes'] = "0".$data['up_minutes']; - $html = - '
    + if (strlen($data['up_minutes']) == "1") $data['up_minutes'] = "0".$data['up_minutes']; + $html = + '
    @@ -54,7 +54,7 @@ class tools_monitor { ' . - ' + ' @@ -69,27 +69,27 @@ class tools_monitor {
    ' . $app->lng("Users online").': ' . $data['user_online'] . '
    ' . $app->lng("System load 1 minute") . ': ' . $data['load_1'] . '
    '; - } else { - $html = '

    '.$app->lng("no_data_serverload_txt").'

    '; - } + } else { + $html = '

    '.$app->lng("no_data_serverload_txt").'

    '; + } - return $html; - } + return $html; + } - function showDiskUsage () { - global $app; + function showDiskUsage () { + global $app; - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'disk_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'disk_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - if(isset($record['data'])) { - $data = unserialize($record['data']); + if(isset($record['data'])) { + $data = unserialize($record['data']); - /* + /* Format the data */ - $html = - '
    + $html = + '
    @@ -101,34 +101,34 @@ class tools_monitor { '; - foreach($data as $line) { - $html .= ''; - foreach ($line as $item) { - $html .= ''; - } - $html .= ''; - } - $html .= '
    '.$app->lng("monitor_diskusage_usage_txt").' '.$app->lng("monitor_diskusage_mounted_txt").'
    ' . $item . '
    '; - $html .= '
    '; - } else { - $html = '

    '.$app->lng("no_data_diskusage_txt").'

    '; - } - - - return $html; - } - - function showDatabaseSize () { - global $app; - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'database_size' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - if(isset($record['data'])) { - $data = unserialize($record['data']); - /* + foreach($data as $line) { + $html .= ''; + foreach ($line as $item) { + $html .= '' . $item . ''; + } + $html .= ''; + } + $html .= ''; + $html .= '
    '; + } else { + $html = '

    '.$app->lng("no_data_diskusage_txt").'

    '; + } + + + return $html; + } + + function showDatabaseSize () { + global $app; + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'database_size' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + if(isset($record['data'])) { + $data = unserialize($record['data']); + /* Format the data */ - $html = - '
    + $html = + '
    @@ -137,448 +137,450 @@ class tools_monitor { '; - foreach($data as $line) { - $html .= ''; - if ($line['size'] > 0) $line['size'] = $app->functions->formatBytes($line['size']); - $t=$app->db->queryOneRecord("SELECT username FROM client WHERE sys_groupid = ".$line['client_id']); - $line['client_id']=$t['username']; - unset($t); - foreach ($line as $item) { - $html .= ''; - } - $html .= ''; - } - $html .= '
    '.$app->lng("monitor_database_size_txt").' '.$app->lng("monitor_database_client_txt").'
    ' . $item . '
    '; - $html .= '
    '; - } else { - $html = '

    '.$app->lng("no_data_database_size_txt").'

    '; - } - return $html; - } - - function showMemUsage () { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mem_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - if(isset($record['data'])) { - $data = unserialize($record['data']); - - /* + foreach($data as $line) { + $html .= ''; + if ($line['size'] > 0) $line['size'] = $app->functions->formatBytes($line['size']); + $t=$app->db->queryOneRecord("SELECT username FROM client WHERE sys_groupid = ".$line['client_id']); + $line['client_id']=$t['username']; + unset($t); + foreach ($line as $item) { + $html .= '' . $item . ''; + } + $html .= ''; + } + $html .= ''; + $html .= '
    '; + } else { + $html = '

    '.$app->lng("no_data_database_size_txt").'

    '; + } + return $html; + } + + function showMemUsage () { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mem_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + if(isset($record['data'])) { + $data = unserialize($record['data']); + + /* Format the data */ - $html = - '
    + $html = + '
    '; - foreach($data as $key => $value) { - if ($key != '') { - $html .= ' + foreach($data as $key => $value) { + if ($key != '') { + $html .= ''; - } - } - $html .= '
    ' . $key . ': ' . $value . '
    '; - $html .= '
    '; + } + } + $html .= ''; + $html .= '
    '; - } else { - $html = '

    '.$app->lng("no_data_memusage_txt").'

    '; - } + } else { + $html = '

    '.$app->lng("no_data_memusage_txt").'

    '; + } - return $html; - } + return $html; + } - function showCpuInfo () { - global $app; + function showCpuInfo () { + global $app; - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'cpu_info' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'cpu_info' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - if(isset($record['data'])) { - $data = unserialize($record['data']); + if(isset($record['data'])) { + $data = unserialize($record['data']); - /* + /* Format the data */ - $html = - '
    + $html = + '
    '; - foreach($data as $key => $value) { - if ($key != '') { - $html .= ' + foreach($data as $key => $value) { + if ($key != '') { + $html .= ''; - } - } - $html .= '
    ' . $key . ': ' . $value . '
    '; - $html .= '
    '; - } else { - $html = '

    '.$app->lng("no_data_cpuinfo_txt").'

    '; - } + } + } + $html .= ''; + $html .= '
    '; + } else { + $html = '

    '.$app->lng("no_data_cpuinfo_txt").'

    '; + } - return $html; - } + return $html; + } - function showServices () { - global $app; + function showServices () { + global $app; - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'services' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'services' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - if(isset($record['data'])) { - $data = unserialize($record['data']); + if(isset($record['data'])) { + $data = unserialize($record['data']); - /* + /* Format the data */ - $html = - '
    + $html = + '
    '; - if($data['webserver'] != -1) { - if($data['webserver'] == 1) { - $status = ''.$app->lng("monitor_services_online_txt").''; - } else { - $status = ''.$app->lng("monitor_services_offline_txt").''; - } - $html .= ' + if($data['webserver'] != -1) { + if($data['webserver'] == 1) { + $status = ''.$app->lng("monitor_services_online_txt").''; + } else { + $status = ''.$app->lng("monitor_services_offline_txt").''; + } + $html .= ''; - } + } - if($data['ftpserver'] != -1) { - if($data['ftpserver'] == 1) { - $status = ''.$app->lng("monitor_services_online_txt").''; - } else { - $status = ''.$app->lng("monitor_services_offline_txt").''; - } - $html .= ' + if($data['ftpserver'] != -1) { + if($data['ftpserver'] == 1) { + $status = ''.$app->lng("monitor_services_online_txt").''; + } else { + $status = ''.$app->lng("monitor_services_offline_txt").''; + } + $html .= ''; - } - - if($data['smtpserver'] != -1) { - if($data['smtpserver'] == 1) { - $status = ''.$app->lng("monitor_services_online_txt").''; - } else { - $status = ''.$app->lng("monitor_services_offline_txt").''; - } - $html .= ' + } + + if($data['smtpserver'] != -1) { + if($data['smtpserver'] == 1) { + $status = ''.$app->lng("monitor_services_online_txt").''; + } else { + $status = ''.$app->lng("monitor_services_offline_txt").''; + } + $html .= ''; - } - - if($data['pop3server'] != -1) { - if($data['pop3server'] == 1) { - $status = ''.$app->lng("monitor_services_online_txt").''; - } else { - $status = ''.$app->lng("monitor_services_offline_txt").''; - } - $html .= ' + } + + if($data['pop3server'] != -1) { + if($data['pop3server'] == 1) { + $status = ''.$app->lng("monitor_services_online_txt").''; + } else { + $status = ''.$app->lng("monitor_services_offline_txt").''; + } + $html .= ''; - } - - if($data['imapserver'] != -1) { - if($data['imapserver'] == 1) { - $status = ''.$app->lng("monitor_services_online_txt").''; - } else { - $status = ''.$app->lng("monitor_services_offline_txt").''; - } - $html .= ' + } + + if($data['imapserver'] != -1) { + if($data['imapserver'] == 1) { + $status = ''.$app->lng("monitor_services_online_txt").''; + } else { + $status = ''.$app->lng("monitor_services_offline_txt").''; + } + $html .= ''; - } - - if($data['bindserver'] != -1) { - if($data['bindserver'] == 1) { - $status = ''.$app->lng("monitor_services_online_txt").''; - } else { - $status = ''.$app->lng("monitor_services_offline_txt").''; - } - $html .= ' + } + + if($data['bindserver'] != -1) { + if($data['bindserver'] == 1) { + $status = ''.$app->lng("monitor_services_online_txt").''; + } else { + $status = ''.$app->lng("monitor_services_offline_txt").''; + } + $html .= ''; - } - - if($data['mysqlserver'] != -1) { - if($data['mysqlserver'] == 1) { - $status = ''.$app->lng("monitor_services_online_txt").''; - } else { - $status = ''.$app->lng("monitor_services_offline_txt").''; - } - $html .= ' + } + + if($data['mysqlserver'] != -1) { + if($data['mysqlserver'] == 1) { + $status = ''.$app->lng("monitor_services_online_txt").''; + } else { + $status = ''.$app->lng("monitor_services_offline_txt").''; + } + $html .= ''; - } + } - $html .= '
    '.$app->lng("monitor_services_web_txt").' '.$status.'
    '.$app->lng("monitor_services_ftp_txt").' '.$status.'
    '.$app->lng("monitor_services_smtp_txt").' '.$status.'
    '.$app->lng("monitor_services_pop_txt").' '.$status.'
    '.$app->lng("monitor_services_imap_txt").' '.$status.'
    '.$app->lng("monitor_services_mydns_txt").' '.$status.'
    '.$app->lng("monitor_services_mysql_txt").' '.$status.'
    '; - } else { - $html = '

    '.$app->lng("no_data_services_txt").'

    '; - } + $html .= '
    '; + } else { + $html = '

    '.$app->lng("no_data_services_txt").'

    '; + } - return $html; - } + return $html; + } - function showSystemUpdate() { - global $app; + function showSystemUpdate() { + global $app; - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'system_update' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'system_update' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - if(isset($record['data'])) { - $html = - '
    + if(isset($record['data'])) { + $html = + '
    '; - /* + /* * First, we have to detect, if there is any monitoring-data. * If not (because the destribution is not supported) show this. */ - if ($record['state'] == 'no_state') { - $html .= '

    '.$app->lng("monitor_updates_nosupport_txt").'

    '; - } - else { - $data = unserialize($record['data']); - $html .= nl2br(html_entity_decode($data['output'])); - } - $html .= '
    '; - } else { - $html = '

    '.$app->lng("no_data_updates_txt").'

    '; - } - - return $html; - } - - - function showOpenVzBeancounter() { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'openvz_beancounter' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - if(isset($record['data'])) { - $html = - '
    + if ($record['state'] == 'no_state') { + $html .= '

    '.$app->lng("monitor_updates_nosupport_txt").'

    '; + } + else { + $data = unserialize($record['data']); + $html .= nl2br(html_entity_decode($data['output'])); + } + $html .= '
    '; + } else { + $html = '

    '.$app->lng("no_data_updates_txt").'

    '; + } + + return $html; + } + + + function showOpenVzBeancounter() { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'openvz_beancounter' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + if(isset($record['data'])) { + $html = + '
    '; - /* + /* * First, we have to detect, if there is any monitoring-data. * If not (because the server is not a VE) show this. */ - $data = unserialize($record['data']); - if ((!isset($data)) || ($data == '')) { - $html .= '

    '.$app->lng("monitor_beancounter_nosupport_txt").'

    '; - } - else { - $html .= '
    ' . nl2br($data) . '
    '; - } - $html .= '
    '; - } else { - $html = '

    '.$app->lng("no_data_updates_txt").'

    '; - } - - return $html; - } - - function showRaidState() { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'raid_state' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - if(isset($record['data'])) { - $html = - '
    + $data = unserialize($record['data']); + if ((!isset($data)) || ($data == '')) { + $html .= '

    '.$app->lng("monitor_beancounter_nosupport_txt").'

    '; + } + else { + $html .= '
    ' . nl2br($data) . '
    '; + } + $html .= '
    '; + } else { + $html = '

    '.$app->lng("no_data_updates_txt").'

    '; + } + + return $html; + } + + function showRaidState() { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'raid_state' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + if(isset($record['data'])) { + $html = + '
    '; - /* + /* * First, we have to detect, if there is any monitoring-data. * If not (because the RAID-Controler is not supported yet) show this. */ - if ($record['state'] == 'no_state') { - $html .= '

    '.$app->lng("monitor_nosupportedraid1_txt").'

    '; - } - else { - $data = unserialize($record['data']); - $html .= nl2br($data['output']); - } - $html .= '
    '; - - } else { - $html = '

    '.$app->lng("no_data_raid_txt").'

    '; - } - - return $html; - } - - function showRKHunter() { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'rkhunter' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - if(isset($record['data'])) { - $html = - '
    + if ($record['state'] == 'no_state') { + $html .= '

    '.$app->lng("monitor_nosupportedraid1_txt").'

    '; + } + else { + $data = unserialize($record['data']); + $html .= nl2br($data['output']); + } + $html .= '
    '; + + } else { + $html = '

    '.$app->lng("no_data_raid_txt").'

    '; + } + + return $html; + } + + function showRKHunter() { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'rkhunter' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + if(isset($record['data'])) { + $html = + '
    '; - /* + /* * First, we have to detect, if there is any monitoring-data. * If not (because rkhunter is not installed) show this. */ - $data = unserialize($record['data']); - if ($data['output'] == '') { - $html .= '

    '.$app->lng("monitor_norkhunter_txt").'

    '; - } - else { - $html .= nl2br($data['output']); - } - $html .= '
    '; - - } else { - $html = '

    '.$app->lng("no_data_rkhunter_txt").'

    '; - } - - return $html; - } - - function showFail2ban() { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_fail2ban' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - if(isset($record['data'])) { - $html = - '
    + $data = unserialize($record['data']); + if ($data['output'] == '') { + $html .= '

    '.$app->lng("monitor_norkhunter_txt").'

    '; + } + else { + $html .= nl2br($data['output']); + } + $html .= '
    '; + + } else { + $html = '

    '.$app->lng("no_data_rkhunter_txt").'

    '; + } + + return $html; + } + + function showFail2ban() { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_fail2ban' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + if(isset($record['data'])) { + $html = + '
    '; - /* + /* * First, we have to detect, if there is any monitoring-data. * If not (because fail2ban is not installed) show this. */ - $data = unserialize($record['data']); - if ($data == '') { - $html .= '

    '. - 'fail2ban is not installed at this server.
    ' . - 'See more (for debian) here...'. - '

    '; - } - else { - $html .= nl2br($data); - } - $html .= '
    '; - - } else { - $html = '

    There is no data available at the moment.

    '; - } - - return $html; - } - - function showMongoDB() { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_mongodb' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - if(isset($record['data'])) { - $html = - '
    + $data = unserialize($record['data']); + if ($data == '') { + $html .= '

    '. + 'fail2ban is not installed at this server.
    ' . + 'See more (for debian) here...'. + '

    '; + } + else { + $html .= nl2br($data); + } + $html .= '
    '; + + } else { + $html = '

    There is no data available at the moment.

    '; + } + + return $html; + } + + function showMongoDB() { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_mongodb' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + if(isset($record['data'])) { + $html = + '
    '; - /* + /* * First, we have to detect, if there is any monitoring-data. * If not (because mongodb is not installed) show this. */ - $data = unserialize($record['data']); - if ($data == '') { - $html .= '

    '. - 'MongoDB is not installed at this server.
    ' . - 'See more (for debian) here...'. - '

    '; - } - else { - $html .= nl2br($data); - } - $html .= '
    '; - - } else { - $html = '

    There is no data available at the moment.

    '; - } - - return $html; - } - - function showIPTables() { - global $app; - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'iptables_rules' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - if(isset($record['data'])) { - $html = - '
    + $data = unserialize($record['data']); + if ($data == '') { + $html .= '

    '. + 'MongoDB is not installed at this server.
    ' . + 'See more (for debian) here...'. + '

    '; + } + else { + $html .= nl2br($data); + } + $html .= '
    '; + + } else { + $html = '

    There is no data available at the moment.

    '; + } + + return $html; + } + + function showIPTables() { + global $app; + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'iptables_rules' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + if(isset($record['data'])) { + $html = + '
    '; - $data = unserialize($record['data']); - if ($data == '') { - $html .= '

    Problem, there are no rules listed for the server

    '; - } - else { - $html .= nl2br($data['output']); - } - $html .= '
    '; - } else { - $html = '

    There is no data available at the moment.

    '; - } - return $html; - } - - - function showMailq() { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mailq' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - if(isset($record['data'])) { - $data = unserialize($record['data']); - $html = nl2br($data['output']); - } else { - $html = '

    '.$app->lng("no_data_mailq_txt").'

    '; - } - - return $html; - } - - function getDataTime($type) { - global $app; - - /* fetch the Data from the DB */ - $record = $app->db->queryOneRecord("SELECT created FROM monitor_data WHERE type = '" . $type . "' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); - - /* TODO: datetimeformat should be set somewhat other way */ - $dateTimeFormat = $app->lng("monitor_settings_datetimeformat_txt"); - - if(isset($record['created'])) { - // $res = date('Y-m-d H:i', $record['created']); - $res = date($dateTimeFormat, $record['created']); - } else { - $res = '????-??-?? ??:??'; - } - return $res; - } + $data = unserialize($record['data']); + if ($data == '') { + $html .= '

    Problem, there are no rules listed for the server

    '; + } + else { + $html .= nl2br($data['output']); + } + $html .= ''; + } else { + $html = '

    There is no data available at the moment.

    '; + } + return $html; + } + + + function showMailq() { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mailq' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + if(isset($record['data'])) { + $data = unserialize($record['data']); + $html = nl2br($data['output']); + } else { + $html = '

    '.$app->lng("no_data_mailq_txt").'

    '; + } + + return $html; + } + + function getDataTime($type) { + global $app; + + /* fetch the Data from the DB */ + $record = $app->db->queryOneRecord("SELECT created FROM monitor_data WHERE type = '" . $type . "' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc"); + + /* TODO: datetimeformat should be set somewhat other way */ + $dateTimeFormat = $app->lng("monitor_settings_datetimeformat_txt"); + + if(isset($record['created'])) { + // $res = date('Y-m-d H:i', $record['created']); + $res = date($dateTimeFormat, $record['created']); + } else { + $res = '????-??-?? ??:??'; + } + return $res; + } + } + ?> diff --git a/interface/lib/classes/tools_sites.inc.php b/interface/lib/classes/tools_sites.inc.php index deb57f5e3..c636bbc61 100644 --- a/interface/lib/classes/tools_sites.inc.php +++ b/interface/lib/classes/tools_sites.inc.php @@ -29,147 +29,148 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. class tools_sites { - function replacePrefix($name, $dataRecord) { - // No input -> no possible output -> go out! - if ($name=="") return ""; - - // Array containing keys to search - $keywordlist=array('CLIENTNAME','CLIENTID','DOMAINID'); - - // Try to match the key within the string - foreach ($keywordlist as $keyword) { - if (substr_count($name, '['.$keyword.']') > 0) { - switch ($keyword) { - case 'CLIENTNAME': - $name=str_replace('['.$keyword.']', $this->getClientName($dataRecord),$name); - break; - case 'CLIENTID': - $name=str_replace('['.$keyword.']', $this->getClientID($dataRecord),$name); - break; - case 'DOMAINID': - $name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'],$name); - break; - } - } - } - return $name; - } - - function removePrefix($name, $currentPrefix, $globalPrefix) { - if($name == "") return ""; - - if($currentPrefix === '') return $name; // empty prefix, do not change name - if($currentPrefix === '#') $currentPrefix = $globalPrefix; // entry has no prefix set, maybe it was created before this function was introduced - - if($currentPrefix === '') return $name; // no current prefix and global prefix is empty -> nothing to remove here. - - return preg_replace('/^' . preg_quote($currentPrefix, '/') . '/', '', $name); // return name without prefix - } - - function getPrefix($currentPrefix, $userPrefix, $adminPrefix = false) { - global $app; - - if($currentPrefix !== '#') return $currentPrefix; // return the currently set prefix for this entry (# = no prefix set yet) - - if($adminPrefix === false) $adminPrefix = $userPrefix; - - if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) return $adminPrefix; - else return $userPrefix; - } - - function getClientName($dataRecord) { - global $app, $conf; - if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { - // Get the group-id of the user if the logged in user is neither admin nor reseller - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - } else { - // Get the group-id from the data itself - if(isset($dataRecord['client_group_id'])) { - $client_group_id = $dataRecord['client_group_id']; - } elseif (isset($dataRecord['parent_domain_id'])) { - $tmp = $app->db->queryOneRecord("SELECT sys_groupid FROM web_domain WHERE domain_id = " . $dataRecord['parent_domain_id']); - $client_group_id = $tmp['sys_groupid']; - } elseif(isset($dataRecord['sys_groupid'])) { - $client_group_id = $dataRecord['sys_groupid']; - } else { - $client_group_id = 0; - } - } - - $tmp = $app->db->queryOneRecord("SELECT name FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id)); - $clientName = $tmp['name']; - if ($clientName == "") $clientName = 'default'; - $clientName = $this->convertClientName($clientName); - return $clientName; - } - - function getClientID($dataRecord) { - global $app, $conf; - - if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { - // Get the group-id of the user - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - } else { - // Get the group-id from the data itself - if(isset($dataRecord['client_group_id'])) { - $client_group_id = $dataRecord['client_group_id']; - } elseif (isset($dataRecord['parent_domain_id']) && $dataRecord['parent_domain_id'] != 0) { - $tmp = $app->db->queryOneRecord("SELECT sys_groupid FROM web_domain WHERE domain_id = " . $dataRecord['parent_domain_id']); - $client_group_id = $tmp['sys_groupid']; - } elseif(isset($dataRecord['sys_groupid'])) { - $client_group_id = $dataRecord['sys_groupid']; - } else { - $client_group_id = 0; - } - } - $tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id)); - $clientID = $tmp['client_id']; - if ($clientID == '') $clientID = '0'; - return $clientID; - } - - function convertClientName($name){ - $allowed = 'abcdefghijklmnopqrstuvwxyz0123456789_'; - $res = ''; - $name = strtolower(trim($name)); - for ($i=0; $i < strlen($name); $i++){ - if ($name[$i] == ' ') continue; - if (strpos($allowed, $name[$i]) !== false){ - $res .= $name[$i]; - } - else { - $res .= '_'; - } - } - return $res; - } - - function getDomainModuleDomains() { - global $app; - - $sql = "SELECT domain_id, domain FROM domain WHERE"; - if ($_SESSION["s"]["user"]["typ"] == 'admin') { - $sql .= " 1"; - } else { - $groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0; - $sql .= " sys_groupid IN (".$groups.")"; - } - $sql .= " ORDER BY domain"; - return $app->db->queryAllRecords($sql); - } - - function checkDomainModuleDomain($domain_id) { - global $app; - - $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($domain_id); - if ($_SESSION["s"]["user"]["typ"] != 'admin') { - $groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0; - $sql .= " AND sys_groupid IN (".$groups.")"; - } - $domain = $app->db->queryOneRecord($sql); - if(!$domain || !$domain['domain_id']) return false; - return $domain['domain']; - } + function replacePrefix($name, $dataRecord) { + // No input -> no possible output -> go out! + if ($name=="") return ""; + + // Array containing keys to search + $keywordlist=array('CLIENTNAME', 'CLIENTID', 'DOMAINID'); + + // Try to match the key within the string + foreach ($keywordlist as $keyword) { + if (substr_count($name, '['.$keyword.']') > 0) { + switch ($keyword) { + case 'CLIENTNAME': + $name=str_replace('['.$keyword.']', $this->getClientName($dataRecord), $name); + break; + case 'CLIENTID': + $name=str_replace('['.$keyword.']', $this->getClientID($dataRecord), $name); + break; + case 'DOMAINID': + $name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'], $name); + break; + } + } + } + return $name; + } + + function removePrefix($name, $currentPrefix, $globalPrefix) { + if($name == "") return ""; + + if($currentPrefix === '') return $name; // empty prefix, do not change name + if($currentPrefix === '#') $currentPrefix = $globalPrefix; // entry has no prefix set, maybe it was created before this function was introduced + + if($currentPrefix === '') return $name; // no current prefix and global prefix is empty -> nothing to remove here. + + return preg_replace('/^' . preg_quote($currentPrefix, '/') . '/', '', $name); // return name without prefix + } + + function getPrefix($currentPrefix, $userPrefix, $adminPrefix = false) { + global $app; + + if($currentPrefix !== '#') return $currentPrefix; // return the currently set prefix for this entry (# = no prefix set yet) + + if($adminPrefix === false) $adminPrefix = $userPrefix; + + if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) return $adminPrefix; + else return $userPrefix; + } + + function getClientName($dataRecord) { + global $app, $conf; + if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { + // Get the group-id of the user if the logged in user is neither admin nor reseller + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + } else { + // Get the group-id from the data itself + if(isset($dataRecord['client_group_id'])) { + $client_group_id = $dataRecord['client_group_id']; + } elseif (isset($dataRecord['parent_domain_id'])) { + $tmp = $app->db->queryOneRecord("SELECT sys_groupid FROM web_domain WHERE domain_id = " . $dataRecord['parent_domain_id']); + $client_group_id = $tmp['sys_groupid']; + } elseif(isset($dataRecord['sys_groupid'])) { + $client_group_id = $dataRecord['sys_groupid']; + } else { + $client_group_id = 0; + } + } + + $tmp = $app->db->queryOneRecord("SELECT name FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id)); + $clientName = $tmp['name']; + if ($clientName == "") $clientName = 'default'; + $clientName = $this->convertClientName($clientName); + return $clientName; + } + + function getClientID($dataRecord) { + global $app, $conf; + + if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { + // Get the group-id of the user + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + } else { + // Get the group-id from the data itself + if(isset($dataRecord['client_group_id'])) { + $client_group_id = $dataRecord['client_group_id']; + } elseif (isset($dataRecord['parent_domain_id']) && $dataRecord['parent_domain_id'] != 0) { + $tmp = $app->db->queryOneRecord("SELECT sys_groupid FROM web_domain WHERE domain_id = " . $dataRecord['parent_domain_id']); + $client_group_id = $tmp['sys_groupid']; + } elseif(isset($dataRecord['sys_groupid'])) { + $client_group_id = $dataRecord['sys_groupid']; + } else { + $client_group_id = 0; + } + } + $tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id)); + $clientID = $tmp['client_id']; + if ($clientID == '') $clientID = '0'; + return $clientID; + } + + function convertClientName($name){ + $allowed = 'abcdefghijklmnopqrstuvwxyz0123456789_'; + $res = ''; + $name = strtolower(trim($name)); + for ($i=0; $i < strlen($name); $i++){ + if ($name[$i] == ' ') continue; + if (strpos($allowed, $name[$i]) !== false){ + $res .= $name[$i]; + } + else { + $res .= '_'; + } + } + return $res; + } + + function getDomainModuleDomains() { + global $app; + + $sql = "SELECT domain_id, domain FROM domain WHERE"; + if ($_SESSION["s"]["user"]["typ"] == 'admin') { + $sql .= " 1"; + } else { + $groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0; + $sql .= " sys_groupid IN (".$groups.")"; + } + $sql .= " ORDER BY domain"; + return $app->db->queryAllRecords($sql); + } + + function checkDomainModuleDomain($domain_id) { + global $app; + + $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($domain_id); + if ($_SESSION["s"]["user"]["typ"] != 'admin') { + $groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0; + $sql .= " AND sys_groupid IN (".$groups.")"; + } + $domain = $app->db->queryOneRecord($sql); + if(!$domain || !$domain['domain_id']) return false; + return $domain['domain']; + } + } ?> diff --git a/interface/lib/classes/tpl.inc.php b/interface/lib/classes/tpl.inc.php index 070e34919..4b411e2c3 100644 --- a/interface/lib/classes/tpl.inc.php +++ b/interface/lib/classes/tpl.inc.php @@ -1,15 +1,16 @@ -* @package vLIB -* @access public -* @see vlibTemplate.html -*/ + * vlibTemplate is a class used to seperate PHP and HTML. + * For instructions on how to use vlibTemplate, see the + * vlibTemplate.html file, located in the 'docs' directory. + * + * @since 07/03/2002 + * @author Kelvin Jones + * @package vLIB + * @access public + * @see vlibTemplate.html + */ + /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ @@ -25,200 +26,243 @@ //** check and avoid multiple loading of class if (!defined('vlibTemplateClassLoaded')) { - define('vlibTemplateClassLoaded', 1); - include_once (ISPC_CLASS_PATH.'/tpl_error.inc.php'); - include_once (ISPC_CLASS_PATH.'/tpl_ini.inc.php'); + define('vlibTemplateClassLoaded', 1); + include_once ISPC_CLASS_PATH.'/tpl_error.inc.php'; + include_once ISPC_CLASS_PATH.'/tpl_ini.inc.php'; + + class tpl{ - class tpl{ - - /*-----------------------------------------------------------------------------\ + /*-----------------------------------------------------------------------------\ | ATTENTION | | Do not touch the following variables. vlibTemplate will not work otherwise. | \-----------------------------------------------------------------------------*/ - private $OPTIONS = array( - 'MAX_INCLUDES' => 10, - 'TEMPLATE_DIR' => null, - 'GLOBAL_VARS' => null, - 'GLOBAL_CONTEXT_VARS' => null, - 'LOOP_CONTEXT_VARS' => null, - 'SET_LOOP_VAR' => null, - 'DEFAULT_ESCAPE' => null, - 'STRICT' => null, - 'CASELESS' => null, - 'UNKNOWNS' => null, - 'TIME_PARSE' => null, - 'ENABLE_PHPINCLUDE' => null, - 'INCLUDE_PATHS' => array(), - 'CACHE_DIRECTORY' => null, - 'CACHE_LIFETIME' => null, - 'CACHE_EXTENSION' => null - ); - - /** open and close tags used for escaping */ - private $ESCAPE_TAGS = array( - 'html' => array('open' => 'htmlspecialchars(' ,'close'=> ', ENT_QUOTES)'), - 'url' => array('open' => 'urlencode(' ,'close'=> ')'), - 'rawurl' => array('open' => 'rawurlencode(' ,'close'=> ')'), - 'sq' => array('open' => 'addcslashes(' ,'close'=> ", \"'\")"), - 'dq' => array('open' => 'addcslashes(' ,'close'=> ", '\"')"), - '1' => array('open' => 'htmlspecialchars(' ,'close'=> ', ENT_QUOTES)'), - '0' => array('open' => '' ,'close'=> ''), - 'none' => array('open' => '' ,'close'=> ''), - 'hex' => array('open' => '$this->_escape_hex(' ,'close'=> ', false)'), - 'hexentity' => array('open' => '$this->_escape_hex(' ,'close'=> ', true)') - ); - - /** open and close tags used for formatting */ - private $FORMAT_TAGS = array( - 'strtoupper' => array('open' => 'strtoupper(', 'close'=> ')'), - 'uc' => array('open' => 'strtoupper(', 'close'=> ')'), - 'strtolower' => array('open' => 'strtolower(', 'close'=> ')'), - 'lc' => array('open' => 'strtolower(', 'close'=> ')'), - 'ucfirst' => array('open' => 'ucfirst(', 'close'=> ')'), - 'lcucfirst' => array('open' => 'ucfirst(strtolower(', 'close'=> '))'), - 'ucwords' => array('open' => 'ucwords(', 'close'=> ')'), - 'lcucwords' => array('open' => 'ucwords(strtolower(', 'close'=> '))') - ); - - /** operators allowed when using extended TMPL_IF syntax */ - private $allowed_if_ops = array('==','!=','<>','<','>','<=','>='); - - /** dbs allowed by vlibTemplate::setDbLoop(). */ - private $allowed_loop_dbs = array('MYSQL','POSTGRESQL','INFORMIX','INTERBASE','INGRES', - 'MSSQL','MSQL','OCI8','ORACLE','OVRIMOS','SYBASE'); - - /** root directory of vlibTemplate automagically filled in */ - private $VLIBTEMPLATE_ROOT = null; - - /** contains current directory used when doing recursive include */ - private $_currentincludedir = array(); - - /** current depth of includes */ - private $_includedepth = 0; - - /** full path to tmpl file */ - private $_tmplfilename = null; - - /** file data before it's parsed */ - private $_tmplfile = null; - - /** parsed version of file, ready for eval()ing */ - private $_tmplfilep = null; - - /** eval()ed version ready for printing or whatever */ - private $_tmploutput = null; - - /** array for variables to be kept */ - private $_vars = array(); - - /** array where loop variables are kept */ - private $_arrvars = array(); - - /** array which holds the current namespace during parse */ - private $_namespace = array(); - - /** variable is set to true once the template is parsed, to save re-parsing everything */ - private $_parsed = false; - - /** array holds all unknowns vars */ - private $_unknowns = array(); - - /** microtime when template parsing began */ - private $_firstparsetime = null; - - /** total time taken to parse template */ - private $_totalparsetime = null; - - /** name of current loop being passed in */ - private $_currloopname = null; - - /** rows with the above loop */ - private $_currloop = array(); - - /** define vars to avoid warnings */ - private $_debug = null; - private $_cache = null; - - /** array which holds the dynamic Includes */ - private $_dyninclude = array(); - - /*-----------------------------------------------------------------------------\ + private $OPTIONS = array( + 'MAX_INCLUDES' => 10, + 'TEMPLATE_DIR' => null, + 'GLOBAL_VARS' => null, + 'GLOBAL_CONTEXT_VARS' => null, + 'LOOP_CONTEXT_VARS' => null, + 'SET_LOOP_VAR' => null, + 'DEFAULT_ESCAPE' => null, + 'STRICT' => null, + 'CASELESS' => null, + 'UNKNOWNS' => null, + 'TIME_PARSE' => null, + 'ENABLE_PHPINCLUDE' => null, + 'INCLUDE_PATHS' => array(), + 'CACHE_DIRECTORY' => null, + 'CACHE_LIFETIME' => null, + 'CACHE_EXTENSION' => null + ); + + /** open and close tags used for escaping */ + private $ESCAPE_TAGS = array( + 'html' => array('open' => 'htmlspecialchars(' , 'close'=> ', ENT_QUOTES)'), + 'url' => array('open' => 'urlencode(' , 'close'=> ')'), + 'rawurl' => array('open' => 'rawurlencode(' , 'close'=> ')'), + 'sq' => array('open' => 'addcslashes(' , 'close'=> ", \"'\")"), + 'dq' => array('open' => 'addcslashes(' , 'close'=> ", '\"')"), + '1' => array('open' => 'htmlspecialchars(' , 'close'=> ', ENT_QUOTES)'), + '0' => array('open' => '' , 'close'=> ''), + 'none' => array('open' => '' , 'close'=> ''), + 'hex' => array('open' => '$this->_escape_hex(' , 'close'=> ', false)'), + 'hexentity' => array('open' => '$this->_escape_hex(' , 'close'=> ', true)') + ); + + + + /** open and close tags used for formatting */ + private $FORMAT_TAGS = array( + 'strtoupper' => array('open' => 'strtoupper(', 'close'=> ')'), + 'uc' => array('open' => 'strtoupper(', 'close'=> ')'), + 'strtolower' => array('open' => 'strtolower(', 'close'=> ')'), + 'lc' => array('open' => 'strtolower(', 'close'=> ')'), + 'ucfirst' => array('open' => 'ucfirst(', 'close'=> ')'), + 'lcucfirst' => array('open' => 'ucfirst(strtolower(', 'close'=> '))'), + 'ucwords' => array('open' => 'ucwords(', 'close'=> ')'), + 'lcucwords' => array('open' => 'ucwords(strtolower(', 'close'=> '))') + ); + + /** operators allowed when using extended TMPL_IF syntax */ + private $allowed_if_ops = array('==', '!=', '<>', '<', '>', '<=', '>='); + + + + /** dbs allowed by vlibTemplate::setDbLoop(). */ + private $allowed_loop_dbs = array('MYSQL', 'POSTGRESQL', 'INFORMIX', 'INTERBASE', 'INGRES', + 'MSSQL', 'MSQL', 'OCI8', 'ORACLE', 'OVRIMOS', 'SYBASE'); + + + + /** root directory of vlibTemplate automagically filled in */ + private $VLIBTEMPLATE_ROOT = null; + + + + /** contains current directory used when doing recursive include */ + private $_currentincludedir = array(); + + + + /** current depth of includes */ + private $_includedepth = 0; + + + + /** full path to tmpl file */ + private $_tmplfilename = null; + + + + /** file data before it's parsed */ + private $_tmplfile = null; + + + + /** parsed version of file, ready for eval()ing */ + private $_tmplfilep = null; + + + + /** eval()ed version ready for printing or whatever */ + private $_tmploutput = null; + + + + /** array for variables to be kept */ + private $_vars = array(); + + + + /** array where loop variables are kept */ + private $_arrvars = array(); + + /** array which holds the current namespace during parse */ + private $_namespace = array(); + + + + /** variable is set to true once the template is parsed, to save re-parsing everything */ + private $_parsed = false; + + + + /** array holds all unknowns vars */ + private $_unknowns = array(); + + + + /** microtime when template parsing began */ + private $_firstparsetime = null; + + + + /** total time taken to parse template */ + private $_totalparsetime = null; + + + + /** name of current loop being passed in */ + private $_currloopname = null; + + + + /** rows with the above loop */ + private $_currloop = array(); + + + + /** define vars to avoid warnings */ + private $_debug = null; + private $_cache = null; + + + + /** array which holds the dynamic Includes */ + private $_dyninclude = array(); + + /*-----------------------------------------------------------------------------\ | public functions | \-----------------------------------------------------------------------------*/ - - - /** - * Usually called by the class constructor. - * Stores the filename in $this->_tmplfilename. - * Raises an error if the template file is not found. - * @param string $tmplfile full path to template file - * @return boolean true - * @access public - */ - public function newTemplate($tmplfile) - { - if (!$tfile = $this->_fileSearch($tmplfile)){ - vlibTemplateError::raiseError('VT_ERROR_NOFILE', KILL, $tmplfile); - } - //* make sure that any parsing vars are cleared for the new template - $this->_tmplfile = null; - $this->_tmplfilep = null; - $this->_tmploutput = null; - $this->_parsed = false; - $this->_unknowns = array(); - $this->_firstparsetime = null; - $this->_totalparsetime = null; - - //* reset debug module - if ($this->_debug){ - $this->_debugReset(); - } - $this->_tmplfilename = $tfile; - return true; - } - - /** - * Sets variables to be used by the template - * If $k is an array, then it will treat it as an associative array - * using the keys as variable names and the values as variable values. - * @param mixed $k key to define variable name - * @param mixed $v variable to assign to $k - * @return boolean true/false - * @access public - */ - public function setVar($k, $v = null) - { - if (is_array($k)) { - foreach($k as $key => $value){ - $key = ($this->OPTIONS['CASELESS']) ? strtolower(trim($key)) : trim($key); - if (preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $key) && $value !== null ) { - $this->_vars[$key] = $value; - } - } - } else { - if (preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $k) && $v !== null) { - if ($this->OPTIONS['CASELESS']) $k = strtolower($k); - $this->_vars[trim($k)] = $v; - } else { - return false; - } - } - return true; - } - - /** - * Sets dynamic includes to be used by the template - * If $k is an array, then it will treat it as an associative array - * using the keys as variable names and the values as variable values. - * @param mixed $k key to define variable name - * @param mixed $v variable to assign to $k - * @return boolean true/false - * @access public - */ - public function setInclude($k, $v = null) - { - if(is_array($k)) { + + + + + /** + * Usually called by the class constructor. + * Stores the filename in $this->_tmplfilename. + * Raises an error if the template file is not found. + * @param string $tmplfile full path to template file + * @return boolean true + * @access public + */ + public function newTemplate($tmplfile) + { + if (!$tfile = $this->_fileSearch($tmplfile)){ + vlibTemplateError::raiseError('VT_ERROR_NOFILE', KILL, $tmplfile); + } + + //* make sure that any parsing vars are cleared for the new template + $this->_tmplfile = null; + $this->_tmplfilep = null; + $this->_tmploutput = null; + $this->_parsed = false; + $this->_unknowns = array(); + $this->_firstparsetime = null; + $this->_totalparsetime = null; + + //* reset debug module + if ($this->_debug){ + $this->_debugReset(); + } + $this->_tmplfilename = $tfile; + return true; + } + + /** + * Sets variables to be used by the template + * If $k is an array, then it will treat it as an associative array + * using the keys as variable names and the values as variable values. + * @param mixed $k key to define variable name + * @param mixed $v variable to assign to $k + * @return boolean true/false + * @access public + */ + public function setVar($k, $v = null) + { + if (is_array($k)) { + foreach($k as $key => $value){ + $key = ($this->OPTIONS['CASELESS']) ? strtolower(trim($key)) : trim($key); + if (preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $key) && $value !== null ) { + $this->_vars[$key] = $value; + } + } + } else { + if (preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $k) && $v !== null) { + if ($this->OPTIONS['CASELESS']) $k = strtolower($k); + $this->_vars[trim($k)] = $v; + } else { + return false; + } + } + return true; + } + + + + /** + * Sets dynamic includes to be used by the template + * If $k is an array, then it will treat it as an associative array + * using the keys as variable names and the values as variable values. + * @param mixed $k key to define variable name + * @param mixed $v variable to assign to $k + * @return boolean true/false + * @access public + */ + public function setInclude($k, $v = null) + { + if(is_array($k)) { foreach($k as $key => $val) { $this->_dyninclude[$key] = $val; } @@ -228,103 +272,103 @@ if (!defined('vlibTemplateClassLoaded')) { return true; } - /** - * Unsets a variable which has already been set - * Parse in all vars wanted for deletion in seperate parametres - * @param string var name to remove use: vlibTemplate::unsetVar(var[, var..]) - * @return boolean true/false returns true unless called with 0 params - * @access public - */ - public function unsetVar() - { - $num_args = func_num_args(); - if ($num_args < 1) return false; - - for ($i = 0; $i < $num_args; $i++) { - $var = func_get_arg($i); - if ($this->OPTIONS['CASELESS']) $var = strtolower($var); - if (!preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $var)) continue; - unset($this->_vars[$var]); - } - return true; - } - - /** - * Gets all vars currently set in global namespace. - * @return array - * @access public - */ - public function getVars() - { - return empty($this->_vars) ? false : $this->_vars; - } - - /** - * Gets a single var from the global namespace - * @return var - * @access public - */ - public function getVar($var) - { - if ($this->OPTIONS['CASELESS']) $var = strtolower($var); - return (empty($var) || !isset($this->_vars[$var])) ? false : $this->_vars[$var]; - } - - /** - * sets the GLOBAL_CONTEXT_VARS - * @return true - * @access public - */ - public function setContextVars() - { - $_phpself = @$GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']; - $_pathinfo = @$GLOBALS['HTTP_SERVER_VARS']['PATH_INFO']; - $_request_uri = @$GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']; - $_qs = @$GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']; - - //* the following fixes bug of $PHP_SELF on Win32 CGI and IIS. - $_self = (!empty($_pathinfo)) ? $_pathinfo : $_phpself; - $_uri = (!empty($_request_uri)) ? $_request_uri : $_self.'?'.$_qs; - - $this->setvar('__SELF__', $_self); - $this->setvar('__REQUEST_URI__', $_uri); - return true; - } - - /** - * Builds the loop construct for use with . - * @param string $k string to define loop name - * @param array $v array to assign to $k - * @return boolean true/false - * @access public - */ - public function setLoop($k, $v) - { - if (is_array($v) && preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $k)) { - $k = ($this->OPTIONS['CASELESS']) ? strtolower(trim($k)) : trim($k); - $this->_arrvars[$k] = array(); - if ($this->OPTIONS['SET_LOOP_VAR'] && !empty($v)) $this->setvar($k, 1); - if (($this->_arrvars[$k] = $this->_arrayBuild($v)) == false) { - vlibTemplateError::raiseError('VT_WARNING_INVALID_ARR', WARNING, $k); - } else { - $this->vars['_'.$k.'_num'] = count($v); - } - } - return true; - } - - /** - * [** EXPERIMENTAL **] - * Function to create a loop from a Db result resource link. - * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() - * @param string $result link to a Db result resource - * @param string $db_type, type of db that the result resource belongs to. - * @return boolean true/false - * @access public - */ - public function setDbLoop($loopname, $result, $db_type = 'MYSQL') - { - /* + /** + * Unsets a variable which has already been set + * Parse in all vars wanted for deletion in seperate parametres + * @param string var name to remove use: vlibTemplate::unsetVar(var[, var..]) + * @return boolean true/false returns true unless called with 0 params + * @access public + */ + public function unsetVar() + { + $num_args = func_num_args(); + if ($num_args < 1) return false; + + for ($i = 0; $i < $num_args; $i++) { + $var = func_get_arg($i); + if ($this->OPTIONS['CASELESS']) $var = strtolower($var); + if (!preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $var)) continue; + unset($this->_vars[$var]); + } + return true; + } + + /** + * Gets all vars currently set in global namespace. + * @return array + * @access public + */ + public function getVars() + { + return empty($this->_vars) ? false : $this->_vars; + } + + /** + * Gets a single var from the global namespace + * @return var + * @access public + */ + public function getVar($var) + { + if ($this->OPTIONS['CASELESS']) $var = strtolower($var); + return (empty($var) || !isset($this->_vars[$var])) ? false : $this->_vars[$var]; + } + + /** + * sets the GLOBAL_CONTEXT_VARS + * @return true + * @access public + */ + public function setContextVars() + { + $_phpself = @$GLOBALS['HTTP_SERVER_VARS']['PHP_SELF']; + $_pathinfo = @$GLOBALS['HTTP_SERVER_VARS']['PATH_INFO']; + $_request_uri = @$GLOBALS['HTTP_SERVER_VARS']['REQUEST_URI']; + $_qs = @$GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']; + + //* the following fixes bug of $PHP_SELF on Win32 CGI and IIS. + $_self = (!empty($_pathinfo)) ? $_pathinfo : $_phpself; + $_uri = (!empty($_request_uri)) ? $_request_uri : $_self.'?'.$_qs; + + $this->setvar('__SELF__', $_self); + $this->setvar('__REQUEST_URI__', $_uri); + return true; + } + + /** + * Builds the loop construct for use with . + * @param string $k string to define loop name + * @param array $v array to assign to $k + * @return boolean true/false + * @access public + */ + public function setLoop($k, $v) + { + if (is_array($v) && preg_match('/^[A-Za-z]+[A-Za-z0-9_]*$/', $k)) { + $k = ($this->OPTIONS['CASELESS']) ? strtolower(trim($k)) : trim($k); + $this->_arrvars[$k] = array(); + if ($this->OPTIONS['SET_LOOP_VAR'] && !empty($v)) $this->setvar($k, 1); + if (($this->_arrvars[$k] = $this->_arrayBuild($v)) == false) { + vlibTemplateError::raiseError('VT_WARNING_INVALID_ARR', WARNING, $k); + } else { + $this->vars['_'.$k.'_num'] = count($v); + } + } + return true; + } + + /** + * [** EXPERIMENTAL **] + * Function to create a loop from a Db result resource link. + * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() + * @param string $result link to a Db result resource + * @param string $db_type, type of db that the result resource belongs to. + * @return boolean true/false + * @access public + */ + public function setDbLoop($loopname, $result, $db_type = 'MYSQL') + { + /* $db_type = strtoupper($db_type); if (!in_array($db_type, $this->allowed_loop_dbs)) { vlibTemplateError::raiseError('VT_WARNING_INVALID_LOOP_DB', WARNING, $db_type); @@ -452,932 +496,936 @@ if (!defined('vlibTemplateClassLoaded')) { $this->setLoop($loopname, $loop_arr); return true; */ - } - - /** - * Sets the name for the curent loop in the 3 step loop process. - * @param string $name string to define loop name - * @return boolean true/false - * @access public - */ - public function newLoop($loopname) - { - if (preg_match('/^[a-z_]+[a-z0-9_]*$/i', $loopname)) { - $this->_currloopname[$loopname] = $loopname; - $this->_currloop[$loopname] = array(); - return true; - } else { - return false; - } - } - - /** - * Adds a row to the current loop in the 3 step loop process. - * @param array $row loop row to add to current loop - * @param string $loopname loop to which you want to add row, if not set will use last loop set using newLoop(). - * @return boolean true/false - * @access public - */ - public function addRow($row, $loopname = null) - { - if (!$loopname) $loopname = $this->_currloopname[(count($this->_currloopname)-1)]; - - if (!isset($this->_currloop[$loopname]) || empty($this->_currloopname)) { - vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET', WARNING); - return false; - } - if (is_array($row)) { - $this->_currloop[$loopname][] = $row; - return true; - } else { - return false; - } - } - - /** - * Completes the 3 step loop process. This assigns the rows and resets - * the variables used. - * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() - * @return boolean true/false - * @access public - */ - public function addLoop($loopname = null) - { - if ($loopname == null) { // add last loop used - if (!empty($this->_currloop)) { - foreach ($this->_currloop as $k => $v) { - $this->setLoop($k, $v); - unset($this->_currloop[$k]); - } - $this->_currloopname = array(); - return true; - } else { - return false; - } - } elseif (!isset($this->_currloop[$loopname]) || empty($this->_currloopname)) { // newLoop not yet envoked - vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET', WARNING); - return false; - } else { // add a specific loop - $this->setLoop($loopname, $this->_currloop[$loopname]); - unset($this->_currloopname[$loopname], $this->_currloop[$loopname]); - } - return true; - } - - /** - * Unsets a loop which has already been set. - * Can only unset top level loops. - * @param string loop to remove use: vlibTemplate::unsetLoop(loop[, loop..]) - * @return boolean true/false returns true unless called with 0 params - * @access public - */ - public function unsetLoop() - { - $num_args = func_num_args(); - if ($num_args < 1) return false; - - for ($i = 0; $i < $num_args; $i++) { - $var = func_get_arg($i); - if ($this->OPTIONS['CASELESS']) $var = strtolower($var); - if (!preg_match('/^[A-Za-z_]+[A-Za-z0-9_]*$/', $var)) continue; - unset($this->_arrvars[$var]); - } - return true; - } - - /** - * Resets the vlibTemplate object. After using vlibTemplate::reset() you must - * use vlibTemplate::newTemplate(tmpl) to reuse, not passing in the options array. - * @return boolean true - * @access public - */ - public function reset() - { - $this->clearVars(); - $this->clearLoops(); - $this->_tmplfilename = null; - $this->_tmplfile = null; - $this->_tmplfilep = null; - $this->_tmploutput = null; - $this->_parsed = false; - $this->_unknowns = array(); - $this->_firstparsetime = null; - $this->_totalparsetime = null; - $this->_currloopname = null; - $this->_currloop = array(); - return true; - } - - /** - * Unsets all variables in the template - * @return boolean true - * @access public - */ - public function clearVars() - { - $this->_vars = array(); - return true; - } - - /** - * Unsets all loops in the template - * @return boolean true - * @access public - */ - public function clearLoops() - { - $this->_arrvars = array(); - $this->_currloopname = null; - $this->_currloop = array(); - return true; - } - - /** - * Unsets all variables and loops set using setVar/Loop() - * @return boolean true - * @access public - */ - public function clearAll() - { - $this->clearVars(); - $this->clearLoops(); - return true; - } - - /** - * Returns true if unknowns were found after parsing. - * Function MUST be called AFTER one of the parsing functions to have any relevance. - * @return boolean true/false - * @access public - */ - public function unknownsExist() - { - return (!empty($this->_unknowns)); - } - - /** - * Alias for unknownsExist. - * @access public - */ - public function unknowns() - { - return $this->unknownsExist(); - } - - /** - * Returns an array of all unknown vars found when parsing. - * This function is only relevant after parsing a document. - * @return array - * @access public - */ - public function getUnknowns() - { - return $this->_unknowns; - } - - /** - * Sets how you want to handle variables that were found in the - * template but not set in vlibTemplate using vlibTemplate::setVar(). - * @param string $arg ignore, remove, print, leave or comment - * @return boolean - * @access public - */ - public function setUnknowns($arg) - { - $arg = strtolower(trim($arg)); - if (preg_match('/^ignore|remove|print|leave|comment$/', $arg)) { - $this->OPTIONS['UNKNOWNS'] = $arg; - return true; - } - return false; - } - - /** - * function sets the paths to use when including files. - * Use of this function: vlibTemplate::setPath(string path [, string path, ..]); - * i.e. if $tmpl is your template object do: $tmpl->setPath('/web/htdocs/templates','/web/htdocs/www'); - * with as many paths as you like. - * if this function is called without any arguments, it will just delete any previously set paths. - * - * @param string path (mulitple) - * @return bool success - * @access public - */ - public function setPath() - { - $num_args = func_num_args(); - if ($num_args < 1) { - $this->OPTIONS['INCLUDE_PATHS'] = array(); - return true; - } - for ($i = 0; $i < $num_args; $i++) { - $thispath = func_get_arg($i); - array_push($this->OPTIONS['INCLUDE_PATHS'], realpath($thispath)); - } - return true; - } - - /** - * After using one of the parse functions, this will allow you - * access the time taken to parse the template. - * see OPTION 'TIME_PARSE'. - * - * @return float time taken to parse template - * @access public - */ - public function getParseTime() - { - if ($this->OPTIONS['TIME_PARSE'] && $this->_parsed) { - return $this->_totalparsetime; - } - return false; - } - - - /** - * Identical to pparse() except that it uses output buffering w/ gz compression thus - * printing the output directly and compressed if poss. - * Will possibly if parsing a huge template. - * - * @access public - * @return boolean true/false - */ - public function fastPrint() - { - $ret = $this->_parse('ob_gzhandler'); - print($this->_tmploutput); - return $ret; - } - - - /** - * Calls parse, and then prints out $this->_tmploutput - * @access public - * @return boolean true/false - */ - public function pparse() - { - if (!$this->_parsed) $this->_parse(); - print($this->_tmploutput); - return true; - } - - /** - * Alias for pparse() - * @access public - */ - public function pprint() - { - return $this->pparse(); - } - - - /** - * Returns the parsed output, ready for printing, passing to mail() ...etc. - * Invokes $this->_parse() if template has not yet been parsed. - * - * @access public - * @return boolean true/false - */ - public function grab() - { - if (!$this->_parsed) $this->_parse(); - return $this->_tmploutput; - } - - /*-----------------------------------------------------------------------------\ + } + + /** + * Sets the name for the curent loop in the 3 step loop process. + * @param string $name string to define loop name + * @return boolean true/false + * @access public + */ + public function newLoop($loopname) + { + if (preg_match('/^[a-z_]+[a-z0-9_]*$/i', $loopname)) { + $this->_currloopname[$loopname] = $loopname; + $this->_currloop[$loopname] = array(); + return true; + } else { + return false; + } + } + + /** + * Adds a row to the current loop in the 3 step loop process. + * @param array $row loop row to add to current loop + * @param string $loopname loop to which you want to add row, if not set will use last loop set using newLoop(). + * @return boolean true/false + * @access public + */ + public function addRow($row, $loopname = null) + { + if (!$loopname) $loopname = $this->_currloopname[(count($this->_currloopname)-1)]; + + if (!isset($this->_currloop[$loopname]) || empty($this->_currloopname)) { + vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET', WARNING); + return false; + } + if (is_array($row)) { + $this->_currloop[$loopname][] = $row; + return true; + } else { + return false; + } + } + + /** + * Completes the 3 step loop process. This assigns the rows and resets + * the variables used. + * @param string $loopname to commit loop. If not set, will use last loopname set using newLoop() + * @return boolean true/false + * @access public + */ + public function addLoop($loopname = null) + { + if ($loopname == null) { // add last loop used + if (!empty($this->_currloop)) { + foreach ($this->_currloop as $k => $v) { + $this->setLoop($k, $v); + unset($this->_currloop[$k]); + } + $this->_currloopname = array(); + return true; + } else { + return false; + } + } elseif (!isset($this->_currloop[$loopname]) || empty($this->_currloopname)) { // newLoop not yet envoked + vlibTemplateError::raiseError('VT_WARNING_LOOP_NOT_SET', WARNING); + return false; + } else { // add a specific loop + $this->setLoop($loopname, $this->_currloop[$loopname]); + unset($this->_currloopname[$loopname], $this->_currloop[$loopname]); + } + return true; + } + + /** + * Unsets a loop which has already been set. + * Can only unset top level loops. + * @param string loop to remove use: vlibTemplate::unsetLoop(loop[, loop..]) + * @return boolean true/false returns true unless called with 0 params + * @access public + */ + public function unsetLoop() + { + $num_args = func_num_args(); + if ($num_args < 1) return false; + + for ($i = 0; $i < $num_args; $i++) { + $var = func_get_arg($i); + if ($this->OPTIONS['CASELESS']) $var = strtolower($var); + if (!preg_match('/^[A-Za-z_]+[A-Za-z0-9_]*$/', $var)) continue; + unset($this->_arrvars[$var]); + } + return true; + } + + /** + * Resets the vlibTemplate object. After using vlibTemplate::reset() you must + * use vlibTemplate::newTemplate(tmpl) to reuse, not passing in the options array. + * @return boolean true + * @access public + */ + public function reset() + { + $this->clearVars(); + $this->clearLoops(); + $this->_tmplfilename = null; + $this->_tmplfile = null; + $this->_tmplfilep = null; + $this->_tmploutput = null; + $this->_parsed = false; + $this->_unknowns = array(); + $this->_firstparsetime = null; + $this->_totalparsetime = null; + $this->_currloopname = null; + $this->_currloop = array(); + return true; + } + + /** + * Unsets all variables in the template + * @return boolean true + * @access public + */ + public function clearVars() + { + $this->_vars = array(); + return true; + } + + /** + * Unsets all loops in the template + * @return boolean true + * @access public + */ + public function clearLoops() + { + $this->_arrvars = array(); + $this->_currloopname = null; + $this->_currloop = array(); + return true; + } + + /** + * Unsets all variables and loops set using setVar/Loop() + * @return boolean true + * @access public + */ + public function clearAll() + { + $this->clearVars(); + $this->clearLoops(); + return true; + } + + /** + * Returns true if unknowns were found after parsing. + * Function MUST be called AFTER one of the parsing functions to have any relevance. + * @return boolean true/false + * @access public + */ + public function unknownsExist() + { + return !empty($this->_unknowns); + } + + /** + * Alias for unknownsExist. + * @access public + */ + public function unknowns() + { + return $this->unknownsExist(); + } + + /** + * Returns an array of all unknown vars found when parsing. + * This function is only relevant after parsing a document. + * @return array + * @access public + */ + public function getUnknowns() + { + return $this->_unknowns; + } + + /** + * Sets how you want to handle variables that were found in the + * template but not set in vlibTemplate using vlibTemplate::setVar(). + * @param string $arg ignore, remove, print, leave or comment + * @return boolean + * @access public + */ + public function setUnknowns($arg) + { + $arg = strtolower(trim($arg)); + if (preg_match('/^ignore|remove|print|leave|comment$/', $arg)) { + $this->OPTIONS['UNKNOWNS'] = $arg; + return true; + } + return false; + } + + /** + * function sets the paths to use when including files. + * Use of this function: vlibTemplate::setPath(string path [, string path, ..]); + * i.e. if $tmpl is your template object do: $tmpl->setPath('/web/htdocs/templates','/web/htdocs/www'); + * with as many paths as you like. + * if this function is called without any arguments, it will just delete any previously set paths. + * + * @param string path (mulitple) + * @return bool success + * @access public + */ + public function setPath() + { + $num_args = func_num_args(); + if ($num_args < 1) { + $this->OPTIONS['INCLUDE_PATHS'] = array(); + return true; + } + for ($i = 0; $i < $num_args; $i++) { + $thispath = func_get_arg($i); + array_push($this->OPTIONS['INCLUDE_PATHS'], realpath($thispath)); + } + return true; + } + + /** + * After using one of the parse functions, this will allow you + * access the time taken to parse the template. + * see OPTION 'TIME_PARSE'. + * + * @return float time taken to parse template + * @access public + */ + public function getParseTime() + { + if ($this->OPTIONS['TIME_PARSE'] && $this->_parsed) { + return $this->_totalparsetime; + } + return false; + } + + + /** + * Identical to pparse() except that it uses output buffering w/ gz compression thus + * printing the output directly and compressed if poss. + * Will possibly if parsing a huge template. + * + * @access public + * @return boolean true/false + */ + public function fastPrint() + { + $ret = $this->_parse('ob_gzhandler'); + print($this->_tmploutput); + return $ret; + } + + + /** + * Calls parse, and then prints out $this->_tmploutput + * @access public + * @return boolean true/false + */ + public function pparse() + { + if (!$this->_parsed) $this->_parse(); + print($this->_tmploutput); + return true; + } + + /** + * Alias for pparse() + * @access public + */ + public function pprint() + { + return $this->pparse(); + } + + + /** + * Returns the parsed output, ready for printing, passing to mail() ...etc. + * Invokes $this->_parse() if template has not yet been parsed. + * + * @access public + * @return boolean true/false + */ + public function grab() + { + if (!$this->_parsed) $this->_parse(); + return $this->_tmploutput; + } + + /*-----------------------------------------------------------------------------\ | private functions | \-----------------------------------------------------------------------------*/ - /** - * vlibTemplate constructor. - * if $tmplfile has been passed to it, it will send to $this->newTemplate() - * @param string $tmplfile full path to template file - * @param array $options see above - * @return boolean true/false - * @access private - */ - public function __construct($tmplfile = null, $options = null) - { - if (is_array($tmplfile) && $options == null) { - $options = $tmplfile; - unset($tmplfile); - } + /** + * vlibTemplate constructor. + * if $tmplfile has been passed to it, it will send to $this->newTemplate() + * @param string $tmplfile full path to template file + * @param array $options see above + * @return boolean true/false + * @access private + */ + public function __construct($tmplfile = null, $options = null) + { + if (is_array($tmplfile) && $options == null) { + $options = $tmplfile; + unset($tmplfile); + } - $this->VLIBTEMPLATE_ROOT = dirname(realpath(__FILE__)); + $this->VLIBTEMPLATE_ROOT = dirname(realpath(__FILE__)); - if (is_array(vlibIni::vlibTemplate())) { - foreach (vlibIni::vlibTemplate() as $name => $val) { - $this->OPTIONS[$name] = $val; - } - } + if (is_array(vlibIni::vlibTemplate())) { + foreach (vlibIni::vlibTemplate() as $name => $val) { + $this->OPTIONS[$name] = $val; + } + } - if (is_array($options)) { - foreach($options as $key => $val) { - $key = strtoupper($key); - if ($key == 'PATH') { - $this->setPath($val); - } else { - $this->_setOption($key, strtolower($val)); - } - } - } - if($tmplfile) $this->newTemplate($tmplfile); - if ($this->OPTIONS['GLOBAL_CONTEXT_VARS']) $this->setContextVars(); - return true; - } - - /** - * function returns the text from the file, or if we're using cache, the text - * from the cache file. MUST RETURN DATA. - * @param string tmplfile contains path to template file - * @param do_eval used for included files. If set then this function must do the eval()'ing. - * @access private - * @return mixed data/string or boolean - */ - private function _getData ($tmplfile, $do_eval=false) - { - //* check the current file depth - if ($this->_includedepth > $this->OPTIONS['MAX_INCLUDES'] || $tmplfile == false) { - return; - } else { - if ($this->_debug){ - array_push ($this->_debugIncludedfiles, $tmplfile); - } - if ($do_eval) { - array_push($this->_currentincludedir, dirname($tmplfile)); - $this->_includedepth++; - } - } + if (is_array($options)) { + foreach($options as $key => $val) { + $key = strtoupper($key); + if ($key == 'PATH') { + $this->setPath($val); + } else { + $this->_setOption($key, strtolower($val)); + } + } + } + if($tmplfile) $this->newTemplate($tmplfile); + if ($this->OPTIONS['GLOBAL_CONTEXT_VARS']) $this->setContextVars(); + return true; + } + /** + * function returns the text from the file, or if we're using cache, the text + * from the cache file. MUST RETURN DATA. + * @param string tmplfile contains path to template file + * @param do_eval used for included files. If set then this function must do the eval()'ing. + * @access private + * @return mixed data/string or boolean + */ + private function _getData ($tmplfile, $do_eval=false) + { + //* check the current file depth + if ($this->_includedepth > $this->OPTIONS['MAX_INCLUDES'] || $tmplfile == false) { + return; + } else { + if ($this->_debug){ + array_push($this->_debugIncludedfiles, $tmplfile); + } + if ($do_eval) { + array_push($this->_currentincludedir, dirname($tmplfile)); + $this->_includedepth++; + } + } - if($this->_cache && $this->_checkCache($tmplfile)) { //* cache exists so lets use it - $data = fread($fp = fopen($this->_cachefile, 'r'), filesize($this->_cachefile)); - fclose($fp); - } else { //* no cache lets parse the file - $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile)); - fclose($fp); - - $regex = '/(<|<\/|{|{\/|){1}'; - $regex.= '([\r\n|\n|\r])?/i'; - $data = preg_replace_callback($regex, array($this, _parseTag), $data); - - if ($this->_cache) { // add cache if need be - $this->_createCache($data); - } - } - //* now we must parse the $data and check for any 's - if ($this->_debug) $this->doDebugWarnings(file($tmplfile), $tmplfile); + if($this->_cache && $this->_checkCache($tmplfile)) { //* cache exists so lets use it + $data = fread($fp = fopen($this->_cachefile, 'r'), filesize($this->_cachefile)); + fclose($fp); + } else { //* no cache lets parse the file + $data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile)); + fclose($fp); + + $regex = '/(<|<\/|{|{\/|){1}'; + $regex.= '([\r\n|\n|\r])?/i'; + $data = preg_replace_callback($regex, array($this, _parseTag), $data); + + if ($this->_cache) { // add cache if need be + $this->_createCache($data); + } + } + + //* now we must parse the $data and check for any 's + if ($this->_debug) $this->doDebugWarnings(file($tmplfile), $tmplfile); + + if ($do_eval) { + $success = @eval('?>'.$data.'_includedepth--; + array_pop($this->_currentincludedir); + return $success; + } else { + return $data; + } + } + + /** + * Searches for all possible instances of file { $file } + * @param string $file path of file we're looking for + * @access private + * @return mixed fullpath to file or boolean false + */ + private function _fileSearch($file) + { - if ($do_eval) { - $success = @eval('?>'.$data.'_includedepth--; - array_pop($this->_currentincludedir); - return $success; - } else { - return $data; - } - } - - /** - * Searches for all possible instances of file { $file } - * @param string $file path of file we're looking for - * @access private - * @return mixed fullpath to file or boolean false - */ - private function _fileSearch($file) - { - $filename = basename($file); - $filepath = dirname($file); - + $filepath = dirname($file); + if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['theme'])) { if(is_file(ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/templates/'.$_SESSION['s']['module']['name'].'/'.$filename)) { return ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/templates/'.$_SESSION['s']['module']['name'].'/'.$filename; } } - //* check fullpath first.. - $fullpath = $filepath.'/'.$filename; - if (is_file($fullpath)) return $fullpath; - - //* ..then check for relative path for current directory.. - if (!empty($this->_currentincludedir)) { - $currdir = $this->_currentincludedir[(count($this->_currentincludedir) -1)]; - $relativepath = realpath($currdir.'/'.$filepath.'/'.$filename); - if (is_file($relativepath)) { - array_push ($this->_currentincludedir, dirname($relativepath)); - return $relativepath; - } - } + //* check fullpath first.. + $fullpath = $filepath.'/'.$filename; + if (is_file($fullpath)) return $fullpath; + + //* ..then check for relative path for current directory.. + if (!empty($this->_currentincludedir)) { + $currdir = $this->_currentincludedir[(count($this->_currentincludedir) -1)]; + $relativepath = realpath($currdir.'/'.$filepath.'/'.$filename); + if (is_file($relativepath)) { + array_push($this->_currentincludedir, dirname($relativepath)); + return $relativepath; + } + } - //* ..then check for relative path for all additional given paths.. - if (!empty($this->OPTIONS['INCLUDE_PATHS'])) { - foreach ($this->OPTIONS['INCLUDE_PATHS'] as $currdir) { - $relativepath = realpath($currdir.'/'.$filepath.'/'.$filename); - if (is_file($relativepath)) { - return $relativepath; - } - } - } + //* ..then check for relative path for all additional given paths.. + if (!empty($this->OPTIONS['INCLUDE_PATHS'])) { + foreach ($this->OPTIONS['INCLUDE_PATHS'] as $currdir) { + $relativepath = realpath($currdir.'/'.$filepath.'/'.$filename); + if (is_file($relativepath)) { + return $relativepath; + } + } + } - //* ..then check path from TEMPLATE_DIR.. - if (!empty($this->OPTIONS['TEMPLATE_DIR'])) { - $fullpath = realpath($this->OPTIONS['TEMPLATE_DIR'].'/'.$filepath.'/'.$filename); - if (is_file($fullpath)) return $fullpath; - } + //* ..then check path from TEMPLATE_DIR.. + if (!empty($this->OPTIONS['TEMPLATE_DIR'])) { + $fullpath = realpath($this->OPTIONS['TEMPLATE_DIR'].'/'.$filepath.'/'.$filename); + if (is_file($fullpath)) return $fullpath; + } - //* ..then check relative path from executing php script.. - $fullpath = realpath($filepath.'/'.$filename); - if (is_file($fullpath)) return $fullpath; + //* ..then check relative path from executing php script.. + $fullpath = realpath($filepath.'/'.$filename); + if (is_file($fullpath)) return $fullpath; - //* ..then check path from template file. - if (!empty($this->VLIBTEMPLATE_ROOT)) { - $fullpath = realpath($this->VLIBTEMPLATE_ROOT.'/'.$filepath.'/'.$filename); - if (is_file($fullpath)) return $fullpath; - } + //* ..then check path from template file. + if (!empty($this->VLIBTEMPLATE_ROOT)) { + $fullpath = realpath($this->VLIBTEMPLATE_ROOT.'/'.$filepath.'/'.$filename); + if (is_file($fullpath)) return $fullpath; + } - return false; // uh oh, file not found - } - - /** - * Modifies the array $arr to add Template variables, __FIRST__, __LAST__ ..etc - * if $this->OPTIONS['LOOP_CONTEXT_VARS'] is true. - * Used by $this->setloop(). - * @param array $arr - * @return array new look array - * @access private - */ - private function _arrayBuild($arr) - { - if (is_array($arr) && !empty($arr)) { - $arr = array_values($arr); // to prevent problems w/ non sequential arrays - for ($i = 0; $i < count($arr); $i++) { - if(!is_array($arr[$i])) return false; - foreach ($arr[$i] as $k => $v) { - unset($arr[$i][$k]); - if ($this->OPTIONS['CASELESS']) $k = strtolower($k); - if (preg_match('/^[0-9]+$/', $k)) $k = '_'.$k; - - if (is_array($v)) { - if (($arr[$i][$k] = $this->_arrayBuild($v)) == false) return false; - } else { // reinsert the var - $arr[$i][$k] = $v; - } - } - if ($this->OPTIONS['LOOP_CONTEXT_VARS']) { - if ($i == 0) $arr[$i]['__FIRST__'] = true; - if (($i + 1) == count($arr)) $arr[$i]['__LAST__'] = true; - if ($i != 0 && (($i + 1) < count($arr))) $arr[$i]['__INNER__'] = true; - if (is_int(($i+1) / 2)) $arr[$i]['__EVEN__'] = true; - if (!is_int(($i+1) / 2)) $arr[$i]['__ODD__'] = true; - $arr[$i]['__ROWNUM__'] = ($i + 1); - } - } - return $arr; - } elseif (empty($arr)) { - return true; - } - } - - /** - * returns a string used for parsing in tmpl_if statements. - * @param string $varname - * @param string $value - * @param string $op - * @param string $namespace current namespace - * @access private - * @return string used for eval'ing - */ - private function _parseIf($varname, $value = null, $op = null, $namespace = null) - { - if (isset($namespace)) $namespace = substr($namespace, 0, -1); - $comp_str = ''; // used for extended if statements - - // work out what to put on the end id value="whatever" is used - if (isset($value)) { - - // add the correct operator depending on whether it's been specified or not - if (!empty($op)) { - if (in_array($op, $this->allowed_if_ops)) { - $comp_str .= $op; - } else { - vlibTemplateError::raiseError('VT_WARNING_INVALID_IF_OP', WARNING, $op); - } - } else { - $comp_str .= '=='; - } - - // now we add the value, if it's numeric, then we leave the quotes off - if (is_numeric($value)) { - $comp_str .= $value; - } else { - $comp_str .= '\''.$value.'\''; - } - } + return false; // uh oh, file not found + } - if (count($this->_namespace) == 0 || $namespace == 'global') return '$this->_vars[\''.$varname.'\']'.$comp_str; - $retstr = '$this->_arrvars'; - $numnamespaces = count($this->_namespace); - for ($i=0; $i < $numnamespaces; $i++) { - if ($this->_namespace[$i] == $namespace || (($i + 1) == $numnamespaces && !empty($namespace))) { - $retstr .= "['".$namespace."'][\$_".$i."]"; - break 1; - } else { - $retstr .= "['".$this->_namespace[$i]."'][\$_".$i."]"; - } - } - if ($this->OPTIONS['GLOBAL_VARS'] && empty($namespace)) { - return '(('.$retstr.'[\''.$varname.'\'] !== null) ? '.$retstr.'[\''.$varname.'\'] : $this->_vars[\''.$varname.'\'])'.$comp_str; - } else { - return $retstr."['".$varname."']".$comp_str; - } - } - - - /** - * returns a string used for parsing in tmpl_loop statements. - * @param string $varname - * @access private - * @return string used for eval'ing - */ - private function _parseLoop ($varname) - { - array_push($this->_namespace, $varname); - $tempvar = count($this->_namespace) - 1; - $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < count(\$this->_arrvars"; - for ($i=0; $i < count($this->_namespace); $i++) { - $retstr .= "['".$this->_namespace[$i]."']"; - if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; - } - return $retstr."); \$_".$tempvar."++) {"; - } - - /** - * returns a string used for parsing in tmpl_var statements. - * @param string $wholetag - * @param string $tag - * @param string $varname - * @param string $escape - * @param string $format - * @param string $namespace - * @access private - * @return string used for eval'ing - */ - private function _parseVar ($wholetag, $tag, $varname, $escape, $format, $namespace) - { - if (!empty($namespace)) $namespace = substr($namespace, 0, -1); - $wholetag = stripslashes($wholetag); - - if (count($this->_namespace) == 0 || $namespace == 'global') { - $var1 = '$this->_vars[\''.$varname.'\']'; - } else { - $var1build = "\$this->_arrvars"; - $numnamespaces = count($this->_namespace); - for ($i=0; $i < $numnamespaces; $i++) { - if ($this->_namespace[$i] == $namespace || (($i + 1) == $numnamespaces && !empty($namespace))) { - $var1build .= "['".$namespace."'][\$_".$i."]"; - break 1; - } else { - $var1build .= "['".$this->_namespace[$i]."'][\$_".$i."]"; - } - } - $var1 = $var1build . "['$varname']"; - if ($this->OPTIONS['GLOBAL_VARS'] && empty($namespace)) { - $var2 = '$this->_vars[\''.$varname.'\']'; - } - } + /** + * Modifies the array $arr to add Template variables, __FIRST__, __LAST__ ..etc + * if $this->OPTIONS['LOOP_CONTEXT_VARS'] is true. + * Used by $this->setloop(). + * @param array $arr + * @return array new look array + * @access private + */ + private function _arrayBuild($arr) + { + if (is_array($arr) && !empty($arr)) { + $arr = array_values($arr); // to prevent problems w/ non sequential arrays + for ($i = 0; $i < count($arr); $i++) { + if(!is_array($arr[$i])) return false; + foreach ($arr[$i] as $k => $v) { + unset($arr[$i][$k]); + if ($this->OPTIONS['CASELESS']) $k = strtolower($k); + if (preg_match('/^[0-9]+$/', $k)) $k = '_'.$k; + + if (is_array($v)) { + if (($arr[$i][$k] = $this->_arrayBuild($v)) == false) return false; + } else { // reinsert the var + $arr[$i][$k] = $v; + } + } + if ($this->OPTIONS['LOOP_CONTEXT_VARS']) { + if ($i == 0) $arr[$i]['__FIRST__'] = true; + if (($i + 1) == count($arr)) $arr[$i]['__LAST__'] = true; + if ($i != 0 && (($i + 1) < count($arr))) $arr[$i]['__INNER__'] = true; + if (is_int(($i+1) / 2)) $arr[$i]['__EVEN__'] = true; + if (!is_int(($i+1) / 2)) $arr[$i]['__ODD__'] = true; + $arr[$i]['__ROWNUM__'] = ($i + 1); + } + } + return $arr; + } elseif (empty($arr)) { + return true; + } + } - $beforevar = ''; - $aftervar = ''; - if (!empty($escape)&& isset($this->ESCAPE_TAGS[$escape])) { - $beforevar .= $this->ESCAPE_TAGS[$escape]['open']; - $aftervar = $this->ESCAPE_TAGS[$escape]['close'] . $aftervar; - } + /** + * returns a string used for parsing in tmpl_if statements. + * @param string $varname + * @param string $value + * @param string $op + * @param string $namespace current namespace + * @access private + * @return string used for eval'ing + */ + private function _parseIf($varname, $value = null, $op = null, $namespace = null) + { + if (isset($namespace)) $namespace = substr($namespace, 0, -1); + $comp_str = ''; // used for extended if statements + + // work out what to put on the end id value="whatever" is used + if (isset($value)) { + + // add the correct operator depending on whether it's been specified or not + if (!empty($op)) { + if (in_array($op, $this->allowed_if_ops)) { + $comp_str .= $op; + } else { + vlibTemplateError::raiseError('VT_WARNING_INVALID_IF_OP', WARNING, $op); + } + } else { + $comp_str .= '=='; + } - if (!empty($format)&& isset($this->FORMAT_TAGS[$format])) { - $beforevar .= $this->FORMAT_TAGS[$format]['open']; - $aftervar = $this->FORMAT_TAGS[$format]['close'] . $aftervar; - } + // now we add the value, if it's numeric, then we leave the quotes off + if (is_numeric($value)) { + $comp_str .= $value; + } else { + $comp_str .= '\''.$value.'\''; + } + } - //* build return values - $retstr = 'if ('.$var1.' !== null) { '; - $retstr .= 'print('.$beforevar.$var1.$aftervar.'); '; - $retstr .= '}'; + if (count($this->_namespace) == 0 || $namespace == 'global') return '$this->_vars[\''.$varname.'\']'.$comp_str; + $retstr = '$this->_arrvars'; + $numnamespaces = count($this->_namespace); + for ($i=0; $i < $numnamespaces; $i++) { + if ($this->_namespace[$i] == $namespace || (($i + 1) == $numnamespaces && !empty($namespace))) { + $retstr .= "['".$namespace."'][\$_".$i."]"; + break 1; + } else { + $retstr .= "['".$this->_namespace[$i]."'][\$_".$i."]"; + } + } + if ($this->OPTIONS['GLOBAL_VARS'] && empty($namespace)) { + return '(('.$retstr.'[\''.$varname.'\'] !== null) ? '.$retstr.'[\''.$varname.'\'] : $this->_vars[\''.$varname.'\'])'.$comp_str; + } else { + return $retstr."['".$varname."']".$comp_str; + } + } - if (@$var2) { - $retstr .= ' elseif ('.$var2.' !== null) { '; - $retstr .= 'print('.$beforevar.$var2.$aftervar.'); '; - $retstr .= '}'; - } - switch (strtolower($this->OPTIONS['UNKNOWNS'])) { - case 'comment': - $comment = addcslashes('/', '', $wholetag).'//-->', '"'); - $retstr .= ' else { print("'.$comment.'"); $this->_setUnknown("'.$varname.'"); }'; - return $retstr; + /** + * returns a string used for parsing in tmpl_loop statements. + * @param string $varname + * @access private + * @return string used for eval'ing + */ + private function _parseLoop ($varname) + { + array_push($this->_namespace, $varname); + $tempvar = count($this->_namespace) - 1; + $retstr = "for (\$_".$tempvar."=0 ; \$_".$tempvar." < count(\$this->_arrvars"; + for ($i=0; $i < count($this->_namespace); $i++) { + $retstr .= "['".$this->_namespace[$i]."']"; + if ($this->_namespace[$i] != $varname) $retstr .= "[\$_".$i."]"; + } + return $retstr."); \$_".$tempvar."++) {"; + } - case 'leave': - $retstr .= ' else { print("'.addcslashes($wholetag, '"').'"); $this->_setUnknown("'.$varname.'"); }'; - return $retstr; + /** + * returns a string used for parsing in tmpl_var statements. + * @param string $wholetag + * @param string $tag + * @param string $varname + * @param string $escape + * @param string $format + * @param string $namespace + * @access private + * @return string used for eval'ing + */ + private function _parseVar ($wholetag, $tag, $varname, $escape, $format, $namespace) + { + if (!empty($namespace)) $namespace = substr($namespace, 0, -1); + $wholetag = stripslashes($wholetag); + + if (count($this->_namespace) == 0 || $namespace == 'global') { + $var1 = '$this->_vars[\''.$varname.'\']'; + } else { + $var1build = "\$this->_arrvars"; + $numnamespaces = count($this->_namespace); + for ($i=0; $i < $numnamespaces; $i++) { + if ($this->_namespace[$i] == $namespace || (($i + 1) == $numnamespaces && !empty($namespace))) { + $var1build .= "['".$namespace."'][\$_".$i."]"; + break 1; + } else { + $var1build .= "['".$this->_namespace[$i]."'][\$_".$i."]"; + } + } + $var1 = $var1build . "['$varname']"; + if ($this->OPTIONS['GLOBAL_VARS'] && empty($namespace)) { + $var2 = '$this->_vars[\''.$varname.'\']'; + } + } - case 'print': - $retstr .= ' else { print("'.htmlspecialchars($wholetag, ENT_QUOTES).'"); $this->_setUnknown("'.$varname.'"); }'; - return $retstr; + $beforevar = ''; + $aftervar = ''; + if (!empty($escape)&& isset($this->ESCAPE_TAGS[$escape])) { + $beforevar .= $this->ESCAPE_TAGS[$escape]['open']; + $aftervar = $this->ESCAPE_TAGS[$escape]['close'] . $aftervar; + } - case 'ignore': - return $retstr; + if (!empty($format)&& isset($this->FORMAT_TAGS[$format])) { + $beforevar .= $this->FORMAT_TAGS[$format]['open']; + $aftervar = $this->FORMAT_TAGS[$format]['close'] . $aftervar; + } - case 'remove': - default: - $retstr .= ' else { $this->_setUnknown("'.$varname.'"); }'; - return $retstr; + //* build return values + $retstr = 'if ('.$var1.' !== null) { '; + $retstr .= 'print('.$beforevar.$var1.$aftervar.'); '; + $retstr .= '}'; - } - } - - /** - * takes values from preg_replace in $this->_intparse() and determines - * the replace string. - * - * @param array $args array of all matches found by preg_replace - * @access private - * @return string replace values - */ - private function _parseTag ($args) - { - $wholetag = $args[0]; - $openclose = $args[1]; - $tag = strtolower($args[2]); - $newline = $args[9]; - - if ($tag == 'else') return ''.$newline; - if ($tag == 'tmpl_include') return $wholetag; // ignore tmpl_include tags - - if (preg_match("/^<\/|{\/|/', '', $wholetag).'//-->', '"'); + $retstr .= ' else { print("'.$comment.'"); $this->_setUnknown("'.$varname.'"); }'; + return $retstr; - $var = ($this->OPTIONS['CASELESS']) ? strtolower($name) : $name; + case 'leave': + $retstr .= ' else { print("'.addcslashes($wholetag, '"').'"); $this->_setUnknown("'.$varname.'"); }'; + return $retstr; - if ($this->_debug && !empty($var)) { - if (preg_match("/^global\.([A-Za-z_]+[_A-Za-z0-9]*)$/", $var, $matches)) $var2 = $matches[1]; - if (empty($this->_debugTemplatevars[$tag])) $this->_debugTemplatevars[$tag] = array(); - if (!isset($var2)) $var2 = $var; - if (!in_array($var2, $this->_debugTemplatevars[$tag])) array_push($this->_debugTemplatevars[$tag], $var2); - } + case 'print': + $retstr .= ' else { print("'.htmlspecialchars($wholetag, ENT_QUOTES).'"); $this->_setUnknown("'.$varname.'"); }'; + return $retstr; - if (preg_match("/^([A-Za-z_]+[_A-Za-z0-9]*(\.)+)?([A-Za-z_]+[_A-Za-z0-9]*)$/", $var, $matches)) { - $var = $matches[3]; - $namespace = $matches[1]; - } + case 'ignore': + return $retstr; + case 'remove': + default: + $retstr .= ' else { $this->_setUnknown("'.$varname.'"); }'; + return $retstr; - //* return correct string (tag dependent) - switch ($tag) { - case 'var': - if (empty($escape) && (!empty($this->OPTIONS['DEFAULT_ESCAPE']) && strtolower($this->OPTIONS['DEFAULT_ESCAPE']) != 'none')) { - $escape = strtolower($this->OPTIONS['DEFAULT_ESCAPE']); - } - return '_parseVar ($wholetag, $tag, $var, @$escape, @$format, @$namespace)." ?>$newline"; + } + } + + /** + * takes values from preg_replace in $this->_intparse() and determines + * the replace string. + * + * @param array $args array of all matches found by preg_replace + * @access private + * @return string replace values + */ + private function _parseTag ($args) + { + $wholetag = $args[0]; + $openclose = $args[1]; + $tag = strtolower($args[2]); + $newline = $args[9]; + + if ($tag == 'else') return ''.$newline; + if ($tag == 'tmpl_include') return $wholetag; // ignore tmpl_include tags + + if (preg_match("/^<\/|{\/| MYSQL: $conf['db_new_link'] = false; $conf['db_client_flags'] = 0; -define('DB_TYPE',$conf['db_type']); -define('DB_HOST',$conf['db_host']); -define('DB_DATABASE',$conf['db_database']); -define('DB_USER',$conf['db_user']); -define('DB_PASSWORD',$conf['db_password']); -define('DB_CHARSET',$conf['db_charset']); +define('DB_TYPE', $conf['db_type']); +define('DB_HOST', $conf['db_host']); +define('DB_DATABASE', $conf['db_database']); +define('DB_USER', $conf['db_user']); +define('DB_PASSWORD', $conf['db_password']); +define('DB_CHARSET', $conf['db_charset']); //** Database settings for the master DB. This setting is only used in multiserver setups -$conf['dbmaster_type'] = 'mysql'; -$conf['dbmaster_host'] = '{mysql_master_server_host}'; -$conf['dbmaster_database'] = '{mysql_master_server_database}'; -$conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}'; -$conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}'; -$conf['dbmaster_new_link'] = false; +$conf['dbmaster_type'] = 'mysql'; +$conf['dbmaster_host'] = '{mysql_master_server_host}'; +$conf['dbmaster_database'] = '{mysql_master_server_database}'; +$conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}'; +$conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}'; +$conf['dbmaster_new_link'] = false; $conf['dbmaster_client_flags'] = 0; @@ -87,15 +87,15 @@ define('ISPC_WEB_TEMP_PATH', ISPC_WEB_PATH.'/temp'); // Path for downloads, acce define('ISPC_CACHE_PATH', ISPC_ROOT_PATH.'/cache'); //** Paths (Do not change!) -$conf['rootpath'] = substr(dirname(__FILE__),0,-4); +$conf['rootpath'] = substr(dirname(__FILE__), 0, -4); $conf['fs_div'] = '/'; // File system separator (divider), "\\" on Windows and "/" on Linux and UNIX $conf['classpath'] = $conf['rootpath'].$conf['fs_div'].'lib'.$conf['fs_div'].'classes'; $conf['temppath'] = $conf['rootpath'].$conf['fs_div'].'temp'; -define('FS_DIV',$conf['fs_div']); -define('SERVER_ROOT',$conf['rootpath']); -define('INCLUDE_ROOT',SERVER_ROOT.FS_DIV.'lib'); -define('CLASSES_ROOT',INCLUDE_ROOT.FS_DIV.'classes'); +define('FS_DIV', $conf['fs_div']); +define('SERVER_ROOT', $conf['rootpath']); +define('INCLUDE_ROOT', SERVER_ROOT.FS_DIV.'lib'); +define('CLASSES_ROOT', INCLUDE_ROOT.FS_DIV.'classes'); //** Server @@ -110,8 +110,8 @@ $conf['server_id'] = '1'; $conf['interface_modules_enabled'] = 'dashboard,mail,sites,dns,tools'; //** Demo mode -/* The demo mode is an option to restrict certain actions in the interface like -* changing the password of users with sys_userid < 3 etc. to be +/* The demo mode is an option to restrict certain actions in the interface like +* changing the password of users with sys_userid < 3 etc. to be * able to run the ISPConfig interface as online demo. It does not * affect the server part. The demo mode should be always set to false * on every normal installation @@ -154,8 +154,8 @@ $conf['start_session'] = true; //** Constants -define('LOGLEVEL_DEBUG',0); -define('LOGLEVEL_WARN',1); -define('LOGLEVEL_ERROR',2); +define('LOGLEVEL_DEBUG', 0); +define('LOGLEVEL_WARN', 1); +define('LOGLEVEL_ERROR', 2); ?> diff --git a/interface/lib/plugins/clients_template_plugin.inc.php b/interface/lib/plugins/clients_template_plugin.inc.php index 4bf222ec1..c4899bfa6 100644 --- a/interface/lib/plugins/clients_template_plugin.inc.php +++ b/interface/lib/plugins/clients_template_plugin.inc.php @@ -1,34 +1,36 @@ pixcept KG * @author (original tools.inc.php) Till Brehm, projektfarm Gmbh * @author (original tools.inc.php) Oliver Vogel www.muv.com */ - + + class clients_template_plugin { var $plugin_name = 'clients_template_plugin'; var $class_name = 'clients_template_plugin'; - - /* + + /* This function is called when the plugin is loaded */ - function onLoad() { - global $app; - //Register for the events - $app->plugin->registerEvent('client:client:on_after_insert','clients_template_plugin','apply_client_templates'); - $app->plugin->registerEvent('client:client:on_after_update','clients_template_plugin','apply_client_templates'); - $app->plugin->registerEvent('client:reseller:on_after_insert','clients_template_plugin','apply_client_templates'); - $app->plugin->registerEvent('client:reseller:on_after_update','clients_template_plugin','apply_client_templates'); - } - - function apply_client_templates($event_name, $page_form) { - global $app; - - $app->uses('client_templates'); - $app->client_templates->apply_client_templates($page_form->id); - } -} \ No newline at end of file + function onLoad() { + global $app; + //Register for the events + $app->plugin->registerEvent('client:client:on_after_insert', 'clients_template_plugin', 'apply_client_templates'); + $app->plugin->registerEvent('client:client:on_after_update', 'clients_template_plugin', 'apply_client_templates'); + $app->plugin->registerEvent('client:reseller:on_after_insert', 'clients_template_plugin', 'apply_client_templates'); + $app->plugin->registerEvent('client:reseller:on_after_update', 'clients_template_plugin', 'apply_client_templates'); + } + + function apply_client_templates($event_name, $page_form) { + global $app; + + $app->uses('client_templates'); + $app->client_templates->apply_client_templates($page_form->id); + } + +} diff --git a/interface/lib/plugins/mail_user_filter_plugin.inc.php b/interface/lib/plugins/mail_user_filter_plugin.inc.php index f376a777a..df939d376 100644 --- a/interface/lib/plugins/mail_user_filter_plugin.inc.php +++ b/interface/lib/plugins/mail_user_filter_plugin.inc.php @@ -29,44 +29,44 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ class mail_user_filter_plugin { - + var $plugin_name = 'mail_user_filter_plugin'; var $class_name = 'mail_user_filter_plugin'; - + /* This function is called when the plugin is loaded */ - + function onLoad() { global $app; - + /* Register for the events */ - - $app->plugin->registerEvent('mail:mail_user_filter:on_after_insert','mail_user_filter_plugin','mail_user_filter_edit'); - $app->plugin->registerEvent('mail:mail_user_filter:on_after_update','mail_user_filter_plugin','mail_user_filter_edit'); - $app->plugin->registerEvent('mail:mail_user_filter:on_after_delete','mail_user_filter_plugin','mail_user_filter_del'); - $app->plugin->registerEvent('mailuser:mail_user_filter:on_after_insert','mail_user_filter_plugin','mail_user_filter_edit'); - $app->plugin->registerEvent('mailuser:mail_user_filter:on_after_update','mail_user_filter_plugin','mail_user_filter_edit'); - $app->plugin->registerEvent('mailuser:mail_user_filter:on_after_delete','mail_user_filter_plugin','mail_user_filter_del'); - + + $app->plugin->registerEvent('mail:mail_user_filter:on_after_insert', 'mail_user_filter_plugin', 'mail_user_filter_edit'); + $app->plugin->registerEvent('mail:mail_user_filter:on_after_update', 'mail_user_filter_plugin', 'mail_user_filter_edit'); + $app->plugin->registerEvent('mail:mail_user_filter:on_after_delete', 'mail_user_filter_plugin', 'mail_user_filter_del'); + $app->plugin->registerEvent('mailuser:mail_user_filter:on_after_insert', 'mail_user_filter_plugin', 'mail_user_filter_edit'); + $app->plugin->registerEvent('mailuser:mail_user_filter:on_after_update', 'mail_user_filter_plugin', 'mail_user_filter_edit'); + $app->plugin->registerEvent('mailuser:mail_user_filter:on_after_delete', 'mail_user_filter_plugin', 'mail_user_filter_del'); + } - - + + /* - function to create the mail filter rule and insert it into the custom rules + function to create the mail filter rule and insert it into the custom rules field when a new mail filter is added or modified. */ - function mail_user_filter_edit($event_name,$page_form) { + function mail_user_filter_edit($event_name, $page_form) { global $app, $conf; - + $mailuser = $app->db->queryOneRecord("SELECT custom_mailfilter FROM mail_user WHERE mailuser_id = ".$page_form->dataRecord["mailuser_id"]); $skip = false; - $lines = explode("\n",$mailuser['custom_mailfilter']); + $lines = explode("\n", $mailuser['custom_mailfilter']); $out = ''; $found = false; - + foreach($lines as $line) { $line = rtrim($line); if($line == '### BEGIN FILTER_ID:'.$page_form->id) { @@ -79,27 +79,27 @@ class mail_user_filter_plugin { $skip = false; } } - + // We did not found our rule, so we add it now as first rule. if($found == false && $page_form->dataRecord["active"] == 'y') { $new_rule = $this->mail_user_filter_get_rule($page_form); $out = $new_rule . $out; } - + $out = $app->db->quote($out); $app->db->datalogUpdate('mail_user', "custom_mailfilter = '$out'", 'mailuser_id', $page_form->dataRecord["mailuser_id"]); - - + + } - - function mail_user_filter_del($event_name,$page_form) { + + function mail_user_filter_del($event_name, $page_form) { global $app, $conf; - + $mailuser = $app->db->queryOneRecord("SELECT custom_mailfilter FROM mail_user WHERE mailuser_id = ".$page_form->dataRecord["mailuser_id"]); $skip = false; - $lines = explode("\n",$mailuser['custom_mailfilter']); + $lines = explode("\n", $mailuser['custom_mailfilter']); $out = ''; - + foreach($lines as $line) { $line = trim($line); if($line == '### BEGIN FILTER_ID:'.$page_form->id) { @@ -110,40 +110,40 @@ class mail_user_filter_plugin { $skip = false; } } - + $out = $app->db->quote($out); $app->db->datalogUpdate('mail_user', "custom_mailfilter = '$out'", 'mailuser_id', $page_form->dataRecord["mailuser_id"]); } - - + + /* private function to create the mail filter rules in maildrop or sieve format. */ private function mail_user_filter_get_rule($page_form) { - - global $app,$conf; - + + global $app, $conf; + $app->uses("getconf"); $mailuser_rec = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = ".$app->functions->intval($page_form->dataRecord["mailuser_id"])); - $mail_config = $app->getconf->get_server_config($app->functions->intval($mailuser_rec["server_id"]),'mail'); - + $mail_config = $app->getconf->get_server_config($app->functions->intval($mailuser_rec["server_id"]), 'mail'); + if($mail_config['mail_filter_syntax'] == 'sieve') { - + // ####################################################### // Filter in Sieve Syntax // ####################################################### - + $content = ''; $content .= '### BEGIN FILTER_ID:'.$page_form->id."\n"; - + //$content .= 'require ["fileinto", "regex", "vacation"];'."\n"; - + $content .= 'if header :regex ["'.strtolower($page_form->dataRecord["source"]).'"] ["'; - + $searchterm = preg_quote($page_form->dataRecord["searchterm"]); - $searchterm = str_replace('\\[','\\\\[',$searchterm); - $searchterm = str_replace('\\]','\\\\]',$searchterm); - + $searchterm = str_replace('\\[', '\\\\[', $searchterm); + $searchterm = str_replace('\\]', '\\\\]', $searchterm); + if($page_form->dataRecord["op"] == 'contains') { $content .= ".*".$searchterm; } elseif ($page_form->dataRecord["op"] == 'is') { @@ -153,21 +153,21 @@ class mail_user_filter_plugin { } elseif ($page_form->dataRecord["op"] == 'ends') { $content .= ".*".$searchterm."$"; } - + $content .= '"] {'."\n"; - + if($page_form->dataRecord["action"] == 'move') { $content .= ' fileinto "'.$page_form->dataRecord["target"].'";' . "\n"; } else { $content .= " discard;\n"; } - + $content .= " stop;\n}\n"; - + $content .= '### END FILTER_ID:'.$page_form->id."\n"; - + } else { - + // ####################################################### // Filter in Maildrop Syntax // ####################################################### @@ -187,7 +187,7 @@ class mail_user_filter_plugin { if($page_form->dataRecord["action"] == 'move') { - $content .= " + $content .= " `test -e ".$TestChDirQuotes." && exit 1 || exit 0` if ( ".'$RETURNCODE'." != 1 ) { @@ -224,19 +224,19 @@ if ( ".'$RETURNCODE'." != 1 ) $content .= "}\n"; $content .= "}\n"; - + //} - + $content .= '### END FILTER_ID:'.$page_form->id."\n"; - + } - + return $content; } - + } // end class -?> \ No newline at end of file +?> diff --git a/interface/lib/plugins/sites_web_database_user_plugin.inc.php b/interface/lib/plugins/sites_web_database_user_plugin.inc.php index 791ee593b..1a880a1b1 100644 --- a/interface/lib/plugins/sites_web_database_user_plugin.inc.php +++ b/interface/lib/plugins/sites_web_database_user_plugin.inc.php @@ -1,41 +1,43 @@ pixcept KG 2012 */ - + + class sites_web_database_user_plugin { var $plugin_name = 'sites_web_database_user_plugin'; var $class_name = 'sites_web_database_user_plugin'; - - /* + + /* This function is called when the plugin is loaded */ - function onLoad() { - global $app; - //Register for the events - $app->plugin->registerEvent('sites:web_database_user:on_after_update','sites_web_database_user_plugin','sites_web_database_user_edit'); - $app->plugin->registerEvent('sites:web_database_user:on_after_insert','sites_web_database_user_plugin','sites_web_database_user_edit'); - } + function onLoad() { + global $app; + //Register for the events + $app->plugin->registerEvent('sites:web_database_user:on_after_update', 'sites_web_database_user_plugin', 'sites_web_database_user_edit'); + $app->plugin->registerEvent('sites:web_database_user:on_after_insert', 'sites_web_database_user_plugin', 'sites_web_database_user_edit'); + } - /* - Function to create the sites_web_database_user rule and insert it into the custom rules + /* + Function to create the sites_web_database_user rule and insert it into the custom rules */ - function sites_web_database_user_edit($event_name, $page_form) { - global $app, $conf; - - // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it - // also make sure that the user can not delete entry created by an admin - if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE database_user_id = ".$page_form->id); - } - if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_user_id = ".$page_form->id); - } - //$app->db->query("UPDATE web_database_user SET server_id = '" . $app->functions->intval($conf['server_id']) . "' WHERE database_user_id = ".$page_form->id); + function sites_web_database_user_edit($event_name, $page_form) { + global $app, $conf; + + // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it + // also make sure that the user can not delete entry created by an admin + if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) { + $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); + $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE database_user_id = ".$page_form->id); + } + if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) { + $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); + $app->db->query("UPDATE web_database_user SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE database_user_id = ".$page_form->id); + } + //$app->db->query("UPDATE web_database_user SET server_id = '" . $app->functions->intval($conf['server_id']) . "' WHERE database_user_id = ".$page_form->id); } -} \ No newline at end of file + +} diff --git a/interface/lib/plugins/sites_web_domain_plugin.inc.php b/interface/lib/plugins/sites_web_domain_plugin.inc.php index a21c56fa0..a84857aa8 100644 --- a/interface/lib/plugins/sites_web_domain_plugin.inc.php +++ b/interface/lib/plugins/sites_web_domain_plugin.inc.php @@ -1,20 +1,21 @@ BeezNest 2010 */ - + + class sites_web_domain_plugin { var $plugin_name = 'sites_web_domain_plugin'; var $class_name = 'sites_web_domain_plugin'; - + // TODO: This function is a duplicate from the one in interface/web/sites/web_domain_edit.php // There should be a single "token replacement" function to be called from modules and - // from the main code. + // from the main code. // Returna a "3/2/1" path hash from a numeric id '123' - function id_hash($id,$levels) { + function id_hash($id, $levels) { $hash = "" . $id % 10 ; $id /= 10 ; $levels -- ; @@ -26,67 +27,68 @@ class sites_web_domain_plugin { return $hash; } - /* + /* This function is called when the plugin is loaded */ - function onLoad() { - global $app; - //Register for the events - $app->plugin->registerEvent('sites:web_domain:on_after_insert','sites_web_domain_plugin','sites_web_domain_edit'); - } + function onLoad() { + global $app; + //Register for the events + $app->plugin->registerEvent('sites:web_domain:on_after_insert', 'sites_web_domain_plugin', 'sites_web_domain_edit'); + } - /* - Function to create the sites_web_domain rule and insert it into the custom rules + /* + Function to create the sites_web_domain rule and insert it into the custom rules */ - function sites_web_domain_edit($event_name, $page_form) { - global $app, $conf; - // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it - // also make sure that the user can not delete domain created by a admin - if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$page_form->id); - } - if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) { - $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$page_form->id); - } - // Get configuration for the web system - $app->uses("getconf"); - $web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']),'web'); - $document_root = str_replace("[website_id]",$page_form->id,$web_config["website_path"]); - $document_root = str_replace("[website_idhash_1]",$this->id_hash($page_form->id,1),$document_root); - $document_root = str_replace("[website_idhash_2]",$this->id_hash($page_form->id,1),$document_root); - $document_root = str_replace("[website_idhash_3]",$this->id_hash($page_form->id,1),$document_root); - $document_root = str_replace("[website_idhash_4]",$this->id_hash($page_form->id,1),$document_root); - - // get the ID of the client - if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id"); - $client_id = $app->functions->intval($client["client_id"]); - } else { - //$client_id = $app->functions->intval($this->dataRecord["client_group_id"]); - $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".$app->functions->intval($page_form->dataRecord["client_group_id"])); - $client_id = $app->functions->intval($client["client_id"]); - } + function sites_web_domain_edit($event_name, $page_form) { + global $app, $conf; + // make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it + // also make sure that the user can not delete domain created by a admin + if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($page_form->dataRecord["client_group_id"])) { + $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); + $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$page_form->id); + } + if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($page_form->dataRecord["client_group_id"])) { + $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); + $app->db->query("UPDATE web_domain SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE domain_id = ".$page_form->id); + } + // Get configuration for the web system + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web'); + $document_root = str_replace("[website_id]", $page_form->id, $web_config["website_path"]); + $document_root = str_replace("[website_idhash_1]", $this->id_hash($page_form->id, 1), $document_root); + $document_root = str_replace("[website_idhash_2]", $this->id_hash($page_form->id, 1), $document_root); + $document_root = str_replace("[website_idhash_3]", $this->id_hash($page_form->id, 1), $document_root); + $document_root = str_replace("[website_idhash_4]", $this->id_hash($page_form->id, 1), $document_root); + + // get the ID of the client + if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id"); + $client_id = $app->functions->intval($client["client_id"]); + } else { + //$client_id = $app->functions->intval($this->dataRecord["client_group_id"]); + $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".$app->functions->intval($page_form->dataRecord["client_group_id"])); + $client_id = $app->functions->intval($client["client_id"]); + } + + // Set the values for document_root, system_user and system_group + $system_user = $app->db->quote('web'.$page_form->id); + $system_group = $app->db->quote('client'.$client_id); + + $document_root = str_replace("[client_id]", $client_id, $document_root); + $document_root = str_replace("[client_idhash_1]", $this->id_hash($client_id, 1), $document_root); + $document_root = str_replace("[client_idhash_2]", $this->id_hash($client_id, 2), $document_root); + $document_root = str_replace("[client_idhash_3]", $this->id_hash($client_id, 3), $document_root); + $document_root = str_replace("[client_idhash_4]", $this->id_hash($client_id, 4), $document_root); + $document_root = $app->db->quote($document_root); + + $php_open_basedir = str_replace("[website_path]", $document_root, $web_config["php_open_basedir"]); + $php_open_basedir = $app->db->quote(str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir)); + + $htaccess_allow_override = $app->db->quote($web_config["htaccess_allow_override"]); - // Set the values for document_root, system_user and system_group - $system_user = $app->db->quote('web'.$page_form->id); - $system_group = $app->db->quote('client'.$client_id); - - $document_root = str_replace("[client_id]",$client_id,$document_root); - $document_root = str_replace("[client_idhash_1]",$this->id_hash($client_id,1),$document_root); - $document_root = str_replace("[client_idhash_2]",$this->id_hash($client_id,2),$document_root); - $document_root = str_replace("[client_idhash_3]",$this->id_hash($client_id,3),$document_root); - $document_root = str_replace("[client_idhash_4]",$this->id_hash($client_id,4),$document_root); - $document_root = $app->db->quote($document_root); - - $php_open_basedir = str_replace("[website_path]",$document_root,$web_config["php_open_basedir"]); - $php_open_basedir = $app->db->quote(str_replace("[website_domain]",$page_form->dataRecord['domain'],$php_open_basedir)); - - $htaccess_allow_override = $app->db->quote($web_config["htaccess_allow_override"]); - $sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir' WHERE domain_id = ".$page_form->id; $app->db->query($sql); } -} \ No newline at end of file + +} diff --git a/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php b/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php index e4de54a5e..e28c184ee 100644 --- a/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php +++ b/interface/lib/plugins/sites_web_vhost_subdomain_plugin.inc.php @@ -1,21 +1,22 @@ pixcept KG 2012, copied and adapted from web_domain plugin by: * @author Julio Montoya BeezNest 2010 */ - + + class sites_web_vhost_subdomain_plugin { var $plugin_name = 'sites_web_vhost_subdomain_plugin'; var $class_name = 'sites_web_vhost_subdomain_plugin'; - + // TODO: This function is a duplicate from the one in interface/web/sites/web_vhost_subdomain_edit.php // There should be a single "token replacement" function to be called from modules and - // from the main code. + // from the main code. // Returna a "3/2/1" path hash from a numeric id '123' - function id_hash($id,$levels) { + function id_hash($id, $levels) { $hash = "" . $id % 10 ; $id /= 10 ; $levels -- ; @@ -27,40 +28,41 @@ class sites_web_vhost_subdomain_plugin { return $hash; } - /* + /* This function is called when the plugin is loaded */ - function onLoad() { - global $app; - //Register for the events - // both event call the same function as the things to do do not differ here - $app->plugin->registerEvent('sites:web_vhost_subdomain:on_after_insert','sites_web_vhost_subdomain_plugin','sites_web_vhost_subdomain_edit'); - $app->plugin->registerEvent('sites:web_vhost_subdomain:on_after_update','sites_web_vhost_subdomain_plugin','sites_web_vhost_subdomain_edit'); - } + function onLoad() { + global $app; + //Register for the events + // both event call the same function as the things to do do not differ here + $app->plugin->registerEvent('sites:web_vhost_subdomain:on_after_insert', 'sites_web_vhost_subdomain_plugin', 'sites_web_vhost_subdomain_edit'); + $app->plugin->registerEvent('sites:web_vhost_subdomain:on_after_update', 'sites_web_vhost_subdomain_plugin', 'sites_web_vhost_subdomain_edit'); + } - /* - Function to create the sites_web_vhost_subdomain rule and insert it into the custom rules + /* + Function to create the sites_web_vhost_subdomain rule and insert it into the custom rules */ - function sites_web_vhost_subdomain_edit($event_name, $page_form) { - global $app, $conf; - + function sites_web_vhost_subdomain_edit($event_name, $page_form) { + global $app, $conf; + // Get configuration for the web system - $app->uses("getconf"); - $web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']),'web'); - - $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($page_form->dataRecord['parent_domain_id']) . "'"); - + $app->uses("getconf"); + $web_config = $app->getconf->get_server_config($app->functions->intval($page_form->dataRecord['server_id']), 'web'); + + $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($page_form->dataRecord['parent_domain_id']) . "'"); + // Set the values for document_root, system_user and system_group $system_user = $app->db->quote($parent_domain['system_user']); $system_group = $app->db->quote($parent_domain['system_group']); $document_root = $app->db->quote($parent_domain['document_root']); - $php_open_basedir = str_replace("[website_path]/web",$document_root.'/'.$page_form->dataRecord['web_folder'],$web_config["php_open_basedir"]); - $php_open_basedir = str_replace("[website_domain]/web",$page_form->dataRecord['domain'].'/'.$page_form->dataRecord['web_folder'],$php_open_basedir); - $php_open_basedir = str_replace("[website_path]",$document_root,$php_open_basedir); - $php_open_basedir = $app->db->quote(str_replace("[website_domain]",$page_form->dataRecord['domain'],$php_open_basedir)); + $php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$page_form->dataRecord['web_folder'], $web_config["php_open_basedir"]); + $php_open_basedir = str_replace("[website_domain]/web", $page_form->dataRecord['domain'].'/'.$page_form->dataRecord['web_folder'], $php_open_basedir); + $php_open_basedir = str_replace("[website_path]", $document_root, $php_open_basedir); + $php_open_basedir = $app->db->quote(str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir)); $htaccess_allow_override = $app->db->quote($parent_domain['allow_override']); $sql = "UPDATE web_domain SET sys_groupid = ".$app->functions->intval($parent_domain['sys_groupid']).",system_user = '$system_user', system_group = '$system_group', document_root = '$document_root', allow_override = '$htaccess_allow_override', php_open_basedir = '$php_open_basedir' WHERE domain_id = ".$page_form->id; $app->db->query($sql); } -} \ No newline at end of file + +} diff --git a/interface/lib/plugins/vm_openvz_plugin.inc.php b/interface/lib/plugins/vm_openvz_plugin.inc.php index 0e8696e16..98b0f9f42 100644 --- a/interface/lib/plugins/vm_openvz_plugin.inc.php +++ b/interface/lib/plugins/vm_openvz_plugin.inc.php @@ -1,10 +1,11 @@ plugin->registerEvent('vm:openvz_vm:on_after_insert','vm_openvz_plugin','openvz_vm_insert'); - $app->plugin->registerEvent('vm:openvz_vm:on_after_update','vm_openvz_plugin','openvz_vm_update'); - $app->plugin->registerEvent('vm:openvz_vm:on_after_delete','vm_openvz_plugin','openvz_vm_delete'); - } - - /* - Function that gets called after a new vm was inserted + function onLoad() { + global $app; + + //* Register for events + $app->plugin->registerEvent('vm:openvz_vm:on_after_insert', 'vm_openvz_plugin', 'openvz_vm_insert'); + $app->plugin->registerEvent('vm:openvz_vm:on_after_update', 'vm_openvz_plugin', 'openvz_vm_update'); + $app->plugin->registerEvent('vm:openvz_vm:on_after_delete', 'vm_openvz_plugin', 'openvz_vm_delete'); + } + + /* + Function that gets called after a new vm was inserted */ - function openvz_vm_insert($event_name, $page_form) { - global $app, $conf; + function openvz_vm_insert($event_name, $page_form) { + global $app, $conf; $this->id = $page_form->id; - $this->dataRecord = $page_form->dataRecord; - $this->oldDataRecord = $page_form->oldDataRecord; - + $this->dataRecord = $page_form->dataRecord; + $this->oldDataRecord = $page_form->oldDataRecord; + // make sure that the record belongs to the clinet group and not the admin group when admin inserts it // also make sure that the user can not delete domain created by a admin if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { @@ -46,37 +47,37 @@ class vm_openvz_plugin { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id); } - + // Set the VEID $tmp = $app->db->queryOneRecord('SELECT MAX(veid) + 1 as newveid FROM openvz_vm'); $veid = ($tmp['newveid'] > 100)?$tmp['newveid']:101; $app->db->query("UPDATE openvz_vm SET veid = ".$veid." WHERE vm_id = ".$this->id); unset($tmp); - + // Apply template values to the advanced tab settings $this->applyTemplate(); - + // Set the IP address $app->db->query("UPDATE openvz_ip SET vm_id = ".$this->id." WHERE ip_address = '".$this->dataRecord['ip_address']."'"); - + // Create the OpenVZ config file and store it in config field $this->makeOpenVZConfig(); - + // Create the DNS record $this->createDNS(); - + } - + /* - Function that gets called after a vm was updated + Function that gets called after a vm was updated */ - function openvz_vm_update($event_name, $page_form) { - global $app, $conf; - + function openvz_vm_update($event_name, $page_form) { + global $app, $conf; + $this->id = $page_form->id; $this->dataRecord = $page_form->dataRecord; - $this->oldDataRecord = $page_form->oldDataRecord; - + $this->oldDataRecord = $page_form->oldDataRecord; + // make sure that the record belongs to the clinet group and not the admin group when a admin inserts it // also make sure that the user can not delete domain created by a admin if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { @@ -87,40 +88,40 @@ class vm_openvz_plugin { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); $app->db->query("UPDATE openvz_vm SET sys_groupid = $client_group_id WHERE vm_id = ".$this->id); } - + if(isset($this->dataRecord["ostemplate_id"]) && $this->oldDataRecord["ostemplate_id"] != $this->dataRecord["ostemplate_id"]) { $this->applyTemplate(); } - + // Set the IP address if(isset($this->dataRecord['ip_address'])) $app->db->query("UPDATE openvz_ip SET vm_id = ".$this->id." WHERE ip_address = '".$this->dataRecord['ip_address']."'"); - + // Create the OpenVZ config file and store it in config field $this->makeOpenVZConfig(); - + // Create the DNS record - if((isset($this->dataRecord['hostname']) && $this->dataRecord['hostname'] != $this->oldDataRecord['hostname']) - or (isset($this->dataRecord['create_dns']) && $this->dataRecord['create_dns'] != $this->oldDataRecord['create_dns'])) { + if((isset($this->dataRecord['hostname']) && $this->dataRecord['hostname'] != $this->oldDataRecord['hostname']) + or (isset($this->dataRecord['create_dns']) && $this->dataRecord['create_dns'] != $this->oldDataRecord['create_dns'])) { $this->createDNS(); } - + } - + function openvz_vm_delete($event_name, $page_form) { - global $app, $conf; - + global $app, $conf; + //* Free the IP address $tmp = $app->db->queryOneRecord("SELECT ip_address_id FROM openvz_ip WHERE vm_id = ".$page_form->id); $app->db->datalogUpdate('openvz_ip', 'vm_id = 0', 'ip_address_id', $tmp['ip_address_id']); unset($tmp); - + } - + private function applyTemplate() { global $app, $conf; - + $tpl = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ".$this->dataRecord["template_id"]); - + $sql = "UPDATE openvz_vm SET "; $sql .= "diskspace = '".$tpl['diskspace']."', "; $sql .= "ram = '".$tpl['ram']."', "; @@ -134,113 +135,113 @@ class vm_openvz_plugin { $sql .= "capability = '".$tpl['capability']."' "; $sql .= "WHERE vm_id = ".$this->id; $app->db->query($sql); - + } - + private function makeOpenVZConfig() { global $app, $conf; - + $vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ".$this->id); $vm_template = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ".$vm['template_id']); $burst_ram = $vm['ram_burst']*256; $guar_ram = $vm['ram']*256; - + $app->load('tpl'); $tpl = new tpl(); $tpl->newTemplate('../vm/templates/openvz.conf.tpl'); - + $onboot = ($vm['start_boot'] == 'y')?'yes':'no'; - $tpl->setVar('onboot',$onboot); - - $tpl->setVar('kmemsize',$vm_template['kmemsize']); - $tpl->setVar('lockedpages',$vm_template['lockedpages']); - $tpl->setVar('privvmpages',$burst_ram.':'.$burst_ram); - $tpl->setVar('shmpages',$guar_ram.':'.$guar_ram); - $tpl->setVar('numproc',$vm_template['numproc']); - $tpl->setVar('physpages',$vm_template['physpages']); - $tpl->setVar('vmguarpages',$guar_ram.':'.$guar_ram); - $tpl->setVar('oomguarpages',$guar_ram.':'.$guar_ram); - $tpl->setVar('numtcpsock',$vm_template['numtcpsock']); - $tpl->setVar('numflock',$vm_template['numflock']); - $tpl->setVar('numpty',$vm_template['numpty']); - $tpl->setVar('numsiginfo',$vm_template['numsiginfo']); - $tpl->setVar('tcpsndbuf',$vm_template['tcpsndbuf']); - $tpl->setVar('tcprcvbuf',$vm_template['tcprcvbuf']); - $tpl->setVar('othersockbuf',$vm_template['othersockbuf']); - $tpl->setVar('dgramrcvbuf',$vm_template['dgramrcvbuf']); - $tpl->setVar('numothersock',$vm_template['numothersock']); - $tpl->setVar('dcachesize',$vm_template['dcachesize']); - $tpl->setVar('numfile',$vm_template['numfile']); - $tpl->setVar('avnumproc',$vm_template['avnumproc']); - $tpl->setVar('numiptent',$vm_template['numiptent']); - $tpl->setVar('swappages',$vm_template['swappages']); - + $tpl->setVar('onboot', $onboot); + + $tpl->setVar('kmemsize', $vm_template['kmemsize']); + $tpl->setVar('lockedpages', $vm_template['lockedpages']); + $tpl->setVar('privvmpages', $burst_ram.':'.$burst_ram); + $tpl->setVar('shmpages', $guar_ram.':'.$guar_ram); + $tpl->setVar('numproc', $vm_template['numproc']); + $tpl->setVar('physpages', $vm_template['physpages']); + $tpl->setVar('vmguarpages', $guar_ram.':'.$guar_ram); + $tpl->setVar('oomguarpages', $guar_ram.':'.$guar_ram); + $tpl->setVar('numtcpsock', $vm_template['numtcpsock']); + $tpl->setVar('numflock', $vm_template['numflock']); + $tpl->setVar('numpty', $vm_template['numpty']); + $tpl->setVar('numsiginfo', $vm_template['numsiginfo']); + $tpl->setVar('tcpsndbuf', $vm_template['tcpsndbuf']); + $tpl->setVar('tcprcvbuf', $vm_template['tcprcvbuf']); + $tpl->setVar('othersockbuf', $vm_template['othersockbuf']); + $tpl->setVar('dgramrcvbuf', $vm_template['dgramrcvbuf']); + $tpl->setVar('numothersock', $vm_template['numothersock']); + $tpl->setVar('dcachesize', $vm_template['dcachesize']); + $tpl->setVar('numfile', $vm_template['numfile']); + $tpl->setVar('avnumproc', $vm_template['avnumproc']); + $tpl->setVar('numiptent', $vm_template['numiptent']); + $tpl->setVar('swappages', $vm_template['swappages']); + $diskspace = $vm['diskspace']*1048576; $diskinodes = $vm['diskspace']*524288; - - $tpl->setVar('diskspace',$diskspace.":".$diskspace); - $tpl->setVar('diskinodes',$diskinodes.":".$diskinodes); - $tpl->setVar('io_priority',$vm['io_priority']); - - $tpl->setVar('cpu_num',$vm['cpu_num']); - $tpl->setVar('cpu_units',$vm['cpu_units']); - $tpl->setVar('cpu_limit',$vm['cpu_limit']); - - $hostname = str_replace('{VEID}',$vm['veid'],$vm['hostname']); - - $tpl->setVar('hostname',$hostname); - $tpl->setVar('ip_address',$vm['ip_address']); - $tpl->setVar('nameserver',$vm['nameserver']); - $tpl->setVar('capability',$vm['capability']); - + + $tpl->setVar('diskspace', $diskspace.":".$diskspace); + $tpl->setVar('diskinodes', $diskinodes.":".$diskinodes); + $tpl->setVar('io_priority', $vm['io_priority']); + + $tpl->setVar('cpu_num', $vm['cpu_num']); + $tpl->setVar('cpu_units', $vm['cpu_units']); + $tpl->setVar('cpu_limit', $vm['cpu_limit']); + + $hostname = str_replace('{VEID}', $vm['veid'], $vm['hostname']); + + $tpl->setVar('hostname', $hostname); + $tpl->setVar('ip_address', $vm['ip_address']); + $tpl->setVar('nameserver', $vm['nameserver']); + $tpl->setVar('capability', $vm['capability']); + $tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ".$vm['ostemplate_id']); - $tpl->setVar('ostemplate',$tmp['template_file']); + $tpl->setVar('ostemplate', $tmp['template_file']); unset($tmp); - + $openvz_config = $app->db->quote($tpl->grab()); $app->db->query("UPDATE openvz_vm SET config = '".$openvz_config."' WHERE vm_id = ".$this->id); - + unset($tpl); - + } - + private function createDNS() { global $app, $conf; - + $vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ".$this->id); - + if($vm['create_dns'] != 'y') return; - - $full_hostname = str_replace('{VEID}',$vm['veid'],$vm['hostname']); - $hostname_parts = explode('.',$full_hostname); + + $full_hostname = str_replace('{VEID}', $vm['veid'], $vm['hostname']); + $hostname_parts = explode('.', $full_hostname); $hostname = $hostname_parts[0]; unset($hostname_parts[0]); - $zone = implode('.',$hostname_parts); + $zone = implode('.', $hostname_parts); unset($hostname_parts); - + // Find the dns zone $zone_rec = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin = '$zone.'"); $rr_rec = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = '".$zone_rec['id']."' AND name = '$hostname'"); - + if($zone_rec['id'] > 0) { $ip_address = $vm['ip_address']; $sys_userid = $zone_rec['sys_userid']; $sys_groupid = $zone_rec['sys_groupid']; $server_id = $zone_rec['server_id']; $dns_soa_id = $zone_rec['id']; - + if($rr_rec['id'] > 0) { $app->uses('validate_dns'); $app->db->datalogUpdate('dns_rr', "data = '$ip_address'", 'id', $rr_rec['id']); $serial = $app->validate_dns->increase_serial($zone_rec['serial']); $app->db->datalogUpdate('dns_soa', "serial = '$serial'", 'id', $zone_rec['id']); } else { - $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$dns_soa_id', '$hostname', 'A', '$ip_address', '0', '3600', 'Y')"; $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); } - + } } -} \ No newline at end of file +} diff --git a/interface/web/admin/directive_snippets_del.php b/interface/web/admin/directive_snippets_del.php index ee1ab8b27..551634f0a 100644 --- a/interface/web/admin/directive_snippets_del.php +++ b/interface/web/admin/directive_snippets_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/directive_snippets.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -48,4 +48,4 @@ $app->auth->check_module_permissions('admin'); $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/directive_snippets_edit.php b/interface/web/admin/directive_snippets_edit.php index 317dc58bb..06cea79ff 100644 --- a/interface/web/admin/directive_snippets_edit.php +++ b/interface/web/admin/directive_snippets_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/directive_snippets.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -50,4 +50,4 @@ $app->uses('tpl,tform,tform_actions'); // let tform_actions handle the page $app->tform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/directive_snippets_list.php b/interface/web/admin/directive_snippets_list.php index 4f411942c..5fb75c759 100644 --- a/interface/web/admin/directive_snippets_list.php +++ b/interface/web/admin/directive_snippets_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -49,4 +49,4 @@ $app->uses('listform_actions'); $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/firewall_del.php b/interface/web/admin/firewall_del.php index 0df60d19f..c4ea5605c 100644 --- a/interface/web/admin/firewall_del.php +++ b/interface/web/admin/firewall_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/firewall.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -48,4 +48,4 @@ $app->auth->check_module_permissions('admin'); $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/firewall_edit.php b/interface/web/admin/firewall_edit.php index 03e0deff1..d0c35db8e 100644 --- a/interface/web/admin/firewall_edit.php +++ b/interface/web/admin/firewall_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/firewall.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -64,9 +64,10 @@ class page_action extends tform_actions { unset($rec); } } + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/firewall_list.php b/interface/web/admin/firewall_list.php index d958f4503..3d390504e 100644 --- a/interface/web/admin/firewall_list.php +++ b/interface/web/admin/firewall_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -49,4 +49,4 @@ $app->uses('listform_actions'); $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/dbsync.tform.php b/interface/web/admin/form/dbsync.tform.php index 27ad1f665..8a4181b88 100644 --- a/interface/web/admin/form/dbsync.tform.php +++ b/interface/web/admin/form/dbsync.tform.php @@ -62,14 +62,14 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //* Load 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') { +$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') { $modules_list[$file] = $file; } - } + } } } closedir($handle); @@ -77,10 +77,10 @@ closedir($handle); //* read data bases in with more activated db_history. $db_tables = array(); foreach($modules_list as $md) { - $handle = @opendir(ISPC_WEB_PATH."/$md/form"); - while ($file = @readdir ($handle)) { - if ($file != '.' && $file != '..' && substr($file, 0, 1) != '.') { - include_once(ISPC_WEB_PATH."/$md/form/$file"); + $handle = @opendir(ISPC_WEB_PATH."/$md/form"); + while ($file = @readdir($handle)) { + if ($file != '.' && $file != '..' && substr($file, 0, 1) != '.') { + include_once ISPC_WEB_PATH."/$md/form/$file"; if(isset($form['db_history']) && $form['db_history'] == 'yes') { $tmp_id = $form['db_table']; $db_tables[$tmp_id] = $form['db_table']; @@ -105,160 +105,160 @@ $form['auth'] = 'no'; $form['tabs']['dbsync'] = array ( - 'title' => 'DB sync', - 'width' => 80, - 'template' => 'templates/dbsync_edit.htm', - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## - 'jobname' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '/^.{1,30}$/', - 'errmsg' => 'jobname_err', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'sync_interval_minutes' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'db_type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => array('mysql' => 'mysql'), - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'db_host' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'db_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'db_username' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'db_password' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'db_tables' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOXARRAY', - 'regex' => '', - 'errmsg' => '', - 'default' => 'admin,forms', - 'value' => $db_tables, - 'separator' => ',', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'empty_datalog' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => array(0 => 0,1 => 1), - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'sync_datalog_external' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => array(0 => 0,1 => 1), - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ), - 'active' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'regex' => '', - 'errmsg' => '', - 'default' => '1', - 'value' => array(0 => 0,1 => 1), - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' - ) - ################################## - # ENDE Datenbankfelder - ################################## - ) + 'title' => 'DB sync', + 'width' => 80, + 'template' => 'templates/dbsync_edit.htm', + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# + 'jobname' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '/^.{1,30}$/', + 'errmsg' => 'jobname_err', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'sync_interval_minutes' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'db_type' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => array('mysql' => 'mysql'), + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'db_host' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'db_name' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'db_username' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'db_password' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'db_tables' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'regex' => '', + 'errmsg' => '', + 'default' => 'admin,forms', + 'value' => $db_tables, + 'separator' => ',', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'empty_datalog' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => array(0 => 0, 1 => 1), + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'sync_datalog_external' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => array(0 => 0, 1 => 1), + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ), + 'active' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'regex' => '', + 'errmsg' => '', + 'default' => '1', + 'value' => array(0 => 0, 1 => 1), + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' + ) + //################################# + // ENDE Datenbankfelder + //################################# + ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/directive_snippets.tform.php b/interface/web/admin/form/directive_snippets.tform.php index b41e0e4d7..2af05af6c 100644 --- a/interface/web/admin/form/directive_snippets.tform.php +++ b/interface/web/admin/form/directive_snippets.tform.php @@ -29,7 +29,7 @@ Hint: The ID field of the database table is not part of the datafield definition. The ID field must be always auto incement (int or bigint). - + Search: - searchable = 1 or searchable = 2 include the field in the search - searchable = 1: this field will be the title of the search result @@ -38,16 +38,16 @@ */ -$form["title"] = "Directive Snippets"; -$form["description"] = ""; -$form["name"] = "directive_snippets"; -$form["action"] = "directive_snippets_edit.php"; -$form["db_table"] = "directive_snippets"; -$form["db_table_idx"] = "directive_snippets_id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "directive_snippets"; -$form["list_default"] = "directive_snippets_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "Directive Snippets"; +$form["description"] = ""; +$form["name"] = "directive_snippets"; +$form["action"] = "directive_snippets_edit.php"; +$form["db_table"] = "directive_snippets"; +$form["db_table_idx"] = "directive_snippets_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "directive_snippets"; +$form["list_default"] = "directive_snippets_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 @@ -56,54 +56,54 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['directive_snippets'] = array ( - 'title' => "Directive Snippets", - 'width' => 100, - 'template' => "templates/directive_snippets_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Directive Snippets", + 'width' => 100, + 'template' => "templates/directive_snippets_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'directive_snippets_name_empty'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'directive_snippets_name_error_unique'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'directive_snippets_name_empty'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'directive_snippets_name_error_unique'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', 'searchable' => 1 ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => array('apache' => 'Apache','nginx' => 'nginx','php' => 'PHP','proxy' => 'Proxy'), + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP', 'proxy' => 'Proxy'), 'searchable' => 2 ), 'snippet' => array ( - 'datatype' => 'TEXT', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', + 'datatype' => 'TEXT', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', 'searchable' => 2 ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/filesync.tform.php b/interface/web/admin/form/filesync.tform.php index 45d081a7d..0dfa5b125 100644 --- a/interface/web/admin/form/filesync.tform.php +++ b/interface/web/admin/form/filesync.tform.php @@ -60,146 +60,146 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "Datei Synchronisation"; -$form["description"] = "Formular zum Anlegen von Datei-Synchronisierungen."; -$form["name"] = "filesync"; -$form["action"] = "filesync_edit.php"; -$form["db_table"] = "sys_filesync"; -$form["db_table_idx"] = "id"; -$form["tab_default"] = "filesync"; -$form["list_default"] = "filesync_list.php"; -$form["auth"] = 'no'; +$form["title"] = "Datei Synchronisation"; +$form["description"] = "Formular zum Anlegen von Datei-Synchronisierungen."; +$form["name"] = "filesync"; +$form["action"] = "filesync_edit.php"; +$form["db_table"] = "sys_filesync"; +$form["db_table_idx"] = "id"; +$form["tab_default"] = "filesync"; +$form["list_default"] = "filesync_list.php"; +$form["auth"] = 'no'; $form["tabs"]['filesync'] = array ( - 'title' => "Datei sync", - 'width' => 80, - 'template' => "templates/filesync_edit.htm", - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + 'title' => "Datei sync", + 'width' => 80, + 'template' => "templates/filesync_edit.htm", + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# 'jobname' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '/^.{1,30}$/', - 'errmsg' => 'jobname_err', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '/^.{1,30}$/', + 'errmsg' => 'jobname_err', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'sync_interval_minutes' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'ftp_host' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'ftp_path' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'ftp_username' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'ftp_password' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'local_path' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'wput_options' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '--timestamping --dont-continue', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '--timestamping --dont-continue', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'active' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'regex' => '', - 'errmsg' => '', - 'default' => '1', - 'value' => array(0 => 0,1 => 1), - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'regex' => '', + 'errmsg' => '', + 'default' => '1', + 'value' => array(0 => 0, 1 => 1), + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ) - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/firewall.tform.php b/interface/web/admin/form/firewall.tform.php index c5209fcb1..0bef6ebcc 100644 --- a/interface/web/admin/form/firewall.tform.php +++ b/interface/web/admin/form/firewall.tform.php @@ -33,16 +33,16 @@ */ -$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["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 @@ -51,62 +51,62 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $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 - ################################## + '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' => '' + '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,993,995,3306,8080,8081,10000', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + '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,993,995,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' + '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') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/groups.tform.php b/interface/web/admin/form/groups.tform.php index ce78a6635..c7b3f74fd 100644 --- a/interface/web/admin/form/groups.tform.php +++ b/interface/web/admin/form/groups.tform.php @@ -59,54 +59,54 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "Groups"; -$form["description"] = "groups_description"; -$form["name"] = "groups"; -$form["action"] = "groups_edit.php"; -$form["db_table"] = "sys_group"; -$form["db_table_idx"] = "groupid"; -$form["db_history"] = "yes"; -$form["tab_default"] = "groups"; -$form["list_default"] = "groups_list.php"; -$form["auth"] = 'no'; +$form["title"] = "Groups"; +$form["description"] = "groups_description"; +$form["name"] = "groups"; +$form["action"] = "groups_edit.php"; +$form["db_table"] = "sys_group"; +$form["db_table_idx"] = "groupid"; +$form["db_history"] = "yes"; +$form["tab_default"] = "groups"; +$form["list_default"] = "groups_list.php"; +$form["auth"] = 'no'; $form["tabs"]['groups'] = array ( - 'title' => "Groups", - 'width' => 80, - 'template' => "templates/groups_edit.htm", - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + 'title' => "Groups", + 'width' => 80, + 'template' => "templates/groups_edit.htm", + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'regex' => '/^.{1,30}$/', - 'errmsg' => 'name_err', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'regex' => '/^.{1,30}$/', + 'errmsg' => 'name_err', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'description' => array ( - 'datatype' => 'TEXT', - 'formtype' => 'TEXTAREA', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '', - 'maxlength' => '', - 'rows' => '5', - 'cols' => '30' + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '', + 'maxlength' => '', + 'rows' => '5', + 'cols' => '30' ) - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/iptables.tform.php b/interface/web/admin/form/iptables.tform.php index 87f7b7f83..7d09ca3f5 100644 --- a/interface/web/admin/form/iptables.tform.php +++ b/interface/web/admin/form/iptables.tform.php @@ -1,15 +1,15 @@ 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 @@ -18,92 +18,92 @@ $form["list_default"] = "iptables_list.php"; //$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['iptables'] = array ( - 'title' => "Rules", - 'width' => "100", - 'template' => "templates/iptables_edit.htm", - 'fields' => array ( + 'title' => "Rules", + 'width' => "100", + 'template' => "templates/iptables_edit.htm", + 'fields' => array ( 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - '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' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + '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' => '' ), 'protocol' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => array('none'=>'None','tcp'=>'TCP','udp'=>'UDP'), - 'width' => '', - 'maxlength' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => array('none'=>'None', 'tcp'=>'TCP', 'udp'=>'UDP'), + 'width' => '', + 'maxlength' => '' ), 'table' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', 'errmsg' => 'table_error_empty')), - 'default' => 'INPUT', - 'value' => array('INPUT'=>'INPUT','OUTPUT'=>'OUTPUT','FORWARD'=>'FORWARD'), - 'width' => '', - 'maxlength' => '' - ), + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', 'errmsg' => 'table_error_empty')), + 'default' => 'INPUT', + 'value' => array('INPUT'=>'INPUT', 'OUTPUT'=>'OUTPUT', 'FORWARD'=>'FORWARD'), + 'width' => '', + 'maxlength' => '' + ), 'source_ip' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '', - 'maxlength' => '' - ), + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '', + 'maxlength' => '' + ), 'destination_ip' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '', - 'maxlength' => '' - ), + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '', + 'maxlength' => '' + ), 'singleport' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '', - 'maxlength' => '' - ), + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '', + 'maxlength' => '' + ), 'multiport' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '', - 'maxlength' => '' - ), + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '', + 'maxlength' => '' + ), 'state' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '', - 'maxlength' => '' - ), + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '', + 'maxlength' => '' + ), 'target' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', 'errmsg' => 'target_error_empty')), - 'default' => '', - 'value' => array('ACCEPT'=>'ACCEPT','DROP'=>'DROP','REJECT'=>'REJECT'), - 'width' => '', - 'maxlength' => '' - ), + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', 'errmsg' => 'target_error_empty')), + 'default' => '', + 'value' => array('ACCEPT'=>'ACCEPT', 'DROP'=>'DROP', 'REJECT'=>'REJECT'), + 'width' => '', + 'maxlength' => '' + ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/remote_user.tform.php b/interface/web/admin/form/remote_user.tform.php index 5fb252989..fd765ce9f 100644 --- a/interface/web/admin/form/remote_user.tform.php +++ b/interface/web/admin/form/remote_user.tform.php @@ -40,21 +40,21 @@ $modules = explode(',', $_SESSION['s']['user']['modules']); if(is_array($modules)) { foreach($modules as $mt) { if(is_file(ISPC_WEB_PATH.'/'.$mt.'/lib/remote.conf.php')) { - include(ISPC_WEB_PATH."/$mt/lib/remote.conf.php"); + include ISPC_WEB_PATH."/$mt/lib/remote.conf.php"; } } } -$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["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 @@ -63,67 +63,67 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $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 - ################################## + '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' => '' + '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' + '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', + 'datatype' => 'VARCHAR', + 'formtype' => 'PASSWORD', 'encryption' => 'MD5', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + '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' + 'datatype' => 'TEXT', + 'formtype' => 'CHECKBOXARRAY', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => $function_list, + 'separator' => ';', + 'width' => '', + 'maxlength' => '', + 'rows' => '5', + 'cols' => '30' ) - - ################################## - # ENDE Datatable fields - ################################## + + //################################# + // ENDE Datatable fields + //################################# ) ); diff --git a/interface/web/admin/form/server.tform.php b/interface/web/admin/form/server.tform.php index 20947c8a0..a2eac6c3b 100644 --- a/interface/web/admin/form/server.tform.php +++ b/interface/web/admin/form/server.tform.php @@ -33,16 +33,16 @@ */ -$form["title"] = "Server"; -$form["description"] = ""; -$form["name"] = "server"; -$form["action"] = "server_edit.php"; -$form["db_table"] = "server"; -$form["db_table_idx"] = "server_id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "services"; -$form["list_default"] = "server_list.php"; -$form["auth"] = 'yes'; +$form["title"] = "Server"; +$form["description"] = ""; +$form["name"] = "server"; +$form["action"] = "server_edit.php"; +$form["db_table"] = "server"; +$form["db_table_idx"] = "server_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "services"; +$form["list_default"] = "server_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"] = 1; // 0 = default groupid of the user, > 0 id must match with groupid of current user @@ -51,62 +51,62 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['services'] = array ( - 'title' => "Services", - 'width' => 100, - 'template' => "templates/server_edit_services.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Services", + 'width' => 100, + 'template' => "templates/server_edit_services.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'mail_server' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'default' => '0', - 'value' => array(0 => 0,1 => 1) + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'default' => '0', + 'value' => array(0 => 0, 1 => 1) ), 'web_server' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'default' => '0', - 'value' => array(0 => 0,1 => 1) + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'default' => '0', + 'value' => array(0 => 0, 1 => 1) ), 'dns_server' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'default' => '0', - 'value' => array(0 => 0,1 => 1) + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'default' => '0', + 'value' => array(0 => 0, 1 => 1) ), 'file_server' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'default' => '0', - 'value' => array(0 => 0,1 => 1) + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'default' => '0', + 'value' => array(0 => 0, 1 => 1) ), 'db_server' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'default' => '0', - 'value' => array(0 => 0,1 => 1) + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'default' => '0', + 'value' => array(0 => 0, 1 => 1) ), 'vserver_server' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'CHECKBOX', - 'default' => '0', - 'value' => array(0 => 0,1 => 1) + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'default' => '0', + 'value' => array(0 => 0, 1 => 1) ), 'mirror_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), /* 'update' => array ( @@ -117,14 +117,14 @@ $form["tabs"]['services'] = array ( ), */ 'active' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '1', - 'value' => array(0 => 'No', 1 => 'Yes') + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'value' => array(0 => 'No', 1 => 'Yes') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -154,4 +154,4 @@ $form["tabs"]['config'] = array ( ); */ -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index 2f4b9e2dc..90c758984 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -55,9 +55,9 @@ $form["tabs"]['server'] = array( 'width' => 70, 'template' => "templates/server_config_server_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'auto_network_configuration' => array( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', @@ -89,10 +89,10 @@ $form["tabs"]['server'] = array( 'v6_prefix' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', - 'validators' => array(0 => array('type' => 'ISV6PREFIX', - 'errmsg' => 'v6_prefix_wrong'), - ), - 'default' => '' + 'validators' => array(0 => array('type' => 'ISV6PREFIX', + 'errmsg' => 'v6_prefix_wrong'), + ), + 'default' => '' ), 'gateway' => array( 'datatype' => 'VARCHAR', @@ -118,12 +118,12 @@ $form["tabs"]['server'] = array( 'formtype' => 'TEXT', 'default' => 'server1.domain.tld', 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), 'validators' => array(0 => array('type' => 'NOTEMPTY', 'errmsg' => 'hostname_error_empty'), ), @@ -181,10 +181,10 @@ $form["tabs"]['server'] = array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', 'default' => '', - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[0-9a-zA-Z\:\/\-\.\[\]]{0,255}$/', - 'errmsg'=> 'monit_url_error_regex'), - ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[0-9a-zA-Z\:\/\-\.\[\]]{0,255}$/', + 'errmsg'=> 'monit_url_error_regex'), + ), 'value' => '', 'width' => '40', 'maxlength' => '255' @@ -209,10 +209,10 @@ $form["tabs"]['server'] = array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', 'default' => '', - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[0-9a-zA-Z\:\/\-\.\[\]]{0,255}$/', - 'errmsg'=> 'munin_url_error_regex'), - ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[0-9a-zA-Z\:\/\-\.\[\]]{0,255}$/', + 'errmsg'=> 'munin_url_error_regex'), + ), 'value' => '', 'width' => '40', 'maxlength' => '255' @@ -233,9 +233,9 @@ $form["tabs"]['server'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -244,9 +244,9 @@ $form["tabs"]['mail'] = array( 'width' => 60, 'template' => "templates/server_config_mail_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'module' => array( 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', @@ -275,19 +275,19 @@ $form["tabs"]['mail'] = array( 'width' => '40', 'maxlength' => '255' ), - 'dkim_path' => array( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '/var/lib/amavis/dkim', - 'validators' => array ( 0 => array ('type' => 'CUSTOM', - 'class' => 'validate_dkim', - 'function' => 'check_dkim_path', - 'errmsg'=> 'dkim_path_error'), - ), - 'value' => '', - 'width' => '40', - 'maxlength' => '255' - ), + 'dkim_path' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '/var/lib/amavis/dkim', + 'validators' => array ( 0 => array ('type' => 'CUSTOM', + 'class' => 'validate_dkim', + 'function' => 'check_dkim_path', + 'errmsg'=> 'dkim_path_error'), + ), + 'value' => '', + 'width' => '40', + 'maxlength' => '255' + ), 'pop3_imap_daemon' => array( 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', @@ -388,16 +388,16 @@ $form["tabs"]['mail'] = array( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'value' => array(0 => 'n', 1 => 'y') ), 'realtime_blackhole_list' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', 'default' => '', - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])(,\s*(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))*)?$/', - 'errmsg'=> 'rbl_error_regex'), - ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^((([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])(,\s*(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)+([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9]))*)?$/', + 'errmsg'=> 'rbl_error_regex'), + ), 'value' => '', 'width' => '40', 'maxlength' => '255' @@ -428,9 +428,9 @@ $form["tabs"]['mail'] = array( 'default' => 'n', 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -439,9 +439,9 @@ $form["tabs"]['getmail'] = array( 'width' => 80, 'template' => "templates/server_config_getmail_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'getmail_config_dir' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -453,9 +453,9 @@ $form["tabs"]['getmail'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -464,9 +464,9 @@ $form["tabs"]['web'] = array( 'width' => 60, 'template' => "templates/server_config_web_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'server_type' => array( 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', @@ -510,7 +510,7 @@ $form["tabs"]['web'] = array( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'value' => array(0 => 'n', 1 => 'y') ), 'website_autoalias' => array( 'datatype' => 'VARCHAR', @@ -520,7 +520,7 @@ $form["tabs"]['web'] = array( 'width' => '40', 'maxlength' => '255' ), -/* + /* 'vhost_rewrite_v6' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', @@ -912,9 +912,9 @@ $form["tabs"]['web'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -923,9 +923,9 @@ $form["tabs"]['dns'] = array( 'width' => 60, 'template' => "templates/server_config_dns_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'bind_user' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -981,9 +981,9 @@ $form["tabs"]['dns'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -992,9 +992,9 @@ $form["tabs"]['fastcgi'] = array( 'width' => 80, 'template' => "templates/server_config_fastcgi_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'fastcgi_starter_path' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -1054,11 +1054,11 @@ $form["tabs"]['fastcgi'] = array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', 'default' => '', - 'validators' => array( 0 => array( 'type' => 'ISINT', - 'errmsg' => 'fastcgi_max_requests_error_empty'), - 1 => array( 'type' => 'RANGE', - 'range' => '0:', - 'errmsg' => 'fastcgi_max_requests_error_empty'), + 'validators' => array( 0 => array( 'type' => 'ISINT', + 'errmsg' => 'fastcgi_max_requests_error_empty'), + 1 => array( 'type' => 'RANGE', + 'range' => '0:', + 'errmsg' => 'fastcgi_max_requests_error_empty'), ), 'value' => '', 'width' => '40', @@ -1083,9 +1083,9 @@ $form["tabs"]['fastcgi'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -1095,9 +1095,9 @@ $form["tabs"]['jailkit'] = array( 'width' => 80, 'template' => "templates/server_config_jailkit_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'jailkit_chroot_home' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -1142,9 +1142,9 @@ $form["tabs"]['jailkit'] = array( 'width' => '40', 'maxlength' => '1000' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -1217,9 +1217,9 @@ $form["tabs"]['vlogger'] = array( 'width' => 80, 'template' => "templates/server_config_vlogger_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'config_dir' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -1231,9 +1231,9 @@ $form["tabs"]['vlogger'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -1244,9 +1244,9 @@ $form["tabs"]['cron'] = array( 'width' => 80, 'template' => "templates/server_config_cron_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'init_script' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -1280,9 +1280,9 @@ $form["tabs"]['cron'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -1291,9 +1291,9 @@ $form["tabs"]['rescue'] = array( 'width' => 80, 'template' => "templates/server_config_rescue_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'try_rescue' => array( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', @@ -1324,9 +1324,9 @@ $form["tabs"]['rescue'] = array( 'default' => 'n', 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); ?> diff --git a/interface/web/admin/form/server_ip.tform.php b/interface/web/admin/form/server_ip.tform.php index e565e1eec..c044f2d03 100644 --- a/interface/web/admin/form/server_ip.tform.php +++ b/interface/web/admin/form/server_ip.tform.php @@ -55,7 +55,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Hinweis: Das ID-Feld ist nicht bei den Table Values einzufügen. - + Search: - searchable = 1 or searchable = 2 include the field in the search - searchable = 1: this field will be the title of the search result @@ -64,16 +64,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "IP Addresses"; -$form["description"] = "Form to edit system IP Addresses"; -$form["name"] = "server_ip"; -$form["action"] = "server_ip_edit.php"; -$form["db_table"] = "server_ip"; -$form["db_table_idx"] = "server_ip_id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "server_ip"; -$form["list_default"] = "server_ip_list.php"; -$form["auth"] = 'yes'; +$form["title"] = "IP Addresses"; +$form["description"] = "Form to edit system IP Addresses"; +$form["name"] = "server_ip"; +$form["action"] = "server_ip_edit.php"; +$form["db_table"] = "server_ip"; +$form["db_table_idx"] = "server_ip_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "server_ip"; +$form["list_default"] = "server_ip_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 @@ -82,83 +82,83 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['server_ip'] = array ( - 'title' => "IP Address", - 'width' => 80, - 'template' => "templates/server_ip_edit.htm", - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + 'title' => "IP Address", + 'width' => 80, + 'template' => "templates/server_ip_edit.htm", + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - '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' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + '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' => '' ), 'client_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT client_id,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM client WHERE {AUTHSQL} ORDER BY contact_name", - 'keyfield'=> 'client_id', - 'valuefield'=> 'name' - ), - 'value' => array(0 => ' ') + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT client_id,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM client WHERE {AUTHSQL} ORDER BY contact_name", + 'keyfield'=> 'client_id', + 'valuefield'=> 'name' + ), + 'value' => array(0 => ' ') ), 'ip_type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6'), + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6'), 'searchable' => 2 ), 'ip_address' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISIP', - 'errmsg'=> 'ip_error_wrong'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'ip_error_unique'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '15', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISIP', + 'errmsg'=> 'ip_error_wrong'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'ip_error_unique'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '15', + 'rows' => '', + 'cols' => '', 'searchable' => 1 ), 'virtualhost' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), 'virtualhost_port' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^([0-9]{1,5}\,{0,1}){1,}$/i', - 'errmsg'=> 'error_port_syntax'), - ), - 'default' => '80,443', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '15', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^([0-9]{1,5}\,{0,1}){1,}$/i', + 'errmsg'=> 'error_port_syntax'), + ), + 'default' => '80,443', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '15', + 'rows' => '', + 'cols' => '' ), - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/server_php.tform.php b/interface/web/admin/form/server_php.tform.php index 58c1d7fd4..66bb504f0 100644 --- a/interface/web/admin/form/server_php.tform.php +++ b/interface/web/admin/form/server_php.tform.php @@ -59,16 +59,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "Additional PHP Versions"; -$form["description"] = "Form to edit additional PHP versions"; -$form["name"] = "server_php"; -$form["action"] = "server_php_edit.php"; -$form["db_table"] = "server_php"; -$form["db_table_idx"] = "server_php_id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "php_name"; -$form["list_default"] = "server_php_list.php"; -$form["auth"] = 'yes'; +$form["title"] = "Additional PHP Versions"; +$form["description"] = "Form to edit additional PHP versions"; +$form["name"] = "server_php"; +$form["action"] = "server_php_edit.php"; +$form["db_table"] = "server_php"; +$form["db_table_idx"] = "server_php_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "php_name"; +$form["list_default"] = "server_php_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 @@ -77,50 +77,50 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['php_name'] = array ( - 'title' => "Name", - 'width' => 80, - 'template' => "templates/server_php_name_edit.htm", - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + 'title' => "Name", + 'width' => 80, + 'template' => "templates/server_php_name_edit.htm", + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - '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' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + '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' => '' ), 'client_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT client_id,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM client WHERE {AUTHSQL} ORDER BY contact_name", - 'keyfield'=> 'client_id', - 'valuefield'=> 'name' - ), - 'value' => array(0 => ' ') + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT client_id,CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as name FROM client WHERE {AUTHSQL} ORDER BY contact_name", + 'keyfield'=> 'client_id', + 'valuefield'=> 'name' + ), + 'value' => array(0 => ' ') ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', 'validators' => array(0 => array('type' => 'NOTEMPTY', - 'errmsg' => 'server_php_name_error_empty'), + 'errmsg' => 'server_php_name_error_empty'), ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '40', - 'maxlength' => '255' + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '40', + 'maxlength' => '255' ), - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); @@ -129,9 +129,9 @@ $form["tabs"]['php_fastcgi'] = array( 'width' => 80, 'template' => "templates/server_php_fastcgi_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'php_fastcgi_binary' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -148,9 +148,9 @@ $form["tabs"]['php_fastcgi'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -159,9 +159,9 @@ $form["tabs"]['php_fpm'] = array( 'width' => 80, 'template' => "templates/server_php_fpm_edit.htm", 'fields' => array( - ################################## - # Begin Datatable fields - ################################## + //################################# + // Begin Datatable fields + //################################# 'php_fpm_init_script' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -186,9 +186,9 @@ $form["tabs"]['php_fpm'] = array( 'width' => '40', 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/software_package.tform.php b/interface/web/admin/form/software_package.tform.php index 96ce5aada..1db7056ac 100644 --- a/interface/web/admin/form/software_package.tform.php +++ b/interface/web/admin/form/software_package.tform.php @@ -59,16 +59,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "Software Package"; -$form["description"] = "Modify software package details"; -$form["name"] = "software_package"; -$form["action"] = "software_package_edit.php"; -$form["db_table"] = "software_package"; -$form["db_table_idx"] = "package_id"; -$form["db_history"] = "no"; -$form["tab_default"] = "software_package"; -$form["list_default"] = "software_package_list.php"; -$form["auth"] = 'yes'; +$form["title"] = "Software Package"; +$form["description"] = "Modify software package details"; +$form["name"] = "software_package"; +$form["action"] = "software_package_edit.php"; +$form["db_table"] = "software_package"; +$form["db_table_idx"] = "package_id"; +$form["db_history"] = "no"; +$form["tab_default"] = "software_package"; +$form["list_default"] = "software_package_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 @@ -77,40 +77,40 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['software_package'] = array ( - 'title' => "Software Package", - 'width' => 80, - 'template' => "templates/software_package_edit.htm", - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + 'title' => "Software Package", + 'width' => 80, + 'template' => "templates/software_package_edit.htm", + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# 'package_title' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '40', - 'maxlength' => '40', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '40', + 'maxlength' => '40', + 'rows' => '', + 'cols' => '' ), 'package_key' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '40', - 'maxlength' => '40', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '40', + 'maxlength' => '40', + 'rows' => '', + 'cols' => '' ), - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/software_repo.tform.php b/interface/web/admin/form/software_repo.tform.php index 0396e6f5d..6d1c50f92 100644 --- a/interface/web/admin/form/software_repo.tform.php +++ b/interface/web/admin/form/software_repo.tform.php @@ -59,16 +59,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "Software Repository"; -$form["description"] = "Software Repository which may contain addons or updates"; -$form["name"] = "software_repo"; -$form["action"] = "software_repo_edit.php"; -$form["db_table"] = "software_repo"; -$form["db_table_idx"] = "software_repo_id"; -$form["db_history"] = "no"; -$form["tab_default"] = "software_repo"; -$form["list_default"] = "software_repo_list.php"; -$form["auth"] = 'yes'; +$form["title"] = "Software Repository"; +$form["description"] = "Software Repository which may contain addons or updates"; +$form["name"] = "software_repo"; +$form["action"] = "software_repo_edit.php"; +$form["db_table"] = "software_repo"; +$form["db_table_idx"] = "software_repo_id"; +$form["db_history"] = "no"; +$form["tab_default"] = "software_repo"; +$form["list_default"] = "software_repo_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 @@ -77,77 +77,77 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['software_repo'] = array ( - 'title' => "Repository", - 'width' => 80, - 'template' => "templates/software_repo_edit.htm", - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + 'title' => "Repository", + 'width' => 80, + 'template' => "templates/software_repo_edit.htm", + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# 'repo_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'repo_name_empty'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'repo_name_unique'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '40', - 'maxlength' => '40', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'repo_name_empty'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'repo_name_unique'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '40', + 'maxlength' => '40', + 'rows' => '', + 'cols' => '' ), 'repo_url' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'repo_name_empty'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'repo_name_unique'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '40', - 'maxlength' => '40', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'repo_name_empty'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'repo_name_unique'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '40', + 'maxlength' => '40', + 'rows' => '', + 'cols' => '' ), 'repo_username' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '30', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '30', + 'rows' => '', + 'cols' => '' ), 'repo_password' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'PASSWORD', + 'datatype' => 'VARCHAR', + 'formtype' => 'PASSWORD', 'encryption' => 'CLEARTEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '30', - 'rows' => '', - 'cols' => '' + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '30', + 'rows' => '', + 'cols' => '' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/system_config.tform.php b/interface/web/admin/form/system_config.tform.php index f09d4db2e..155eeeb9d 100644 --- a/interface/web/admin/form/system_config.tform.php +++ b/interface/web/admin/form/system_config.tform.php @@ -33,16 +33,16 @@ */ -$form["title"] = "System Config"; -$form["description"] = "system_config_desc_txt"; -$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["title"] = "System Config"; +$form["description"] = "system_config_desc_txt"; +$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 @@ -51,135 +51,135 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $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 - ################################## + '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' + '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' + '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' + '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' + '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' + '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') + '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' + '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' + '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' ), 'vhost_subdomains' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'client_username_web_check_disabled' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'reseller_can_use_options' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); $form["tabs"]['mail'] = array ( - 'title' => "Mail", - 'width' => 70, - 'template' => "templates/system_config_mail_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Mail", + 'width' => 70, + 'template' => "templates/system_config_mail_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'enable_custom_login' => array( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', @@ -190,160 +190,160 @@ $form["tabs"]['mail'] = array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'value' => array(0 => 'n', 1 => 'y') ), 'mailbox_show_mail_filter_tab' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'value' => array(0 => 'n', 1 => 'y') ), 'mailbox_show_custom_rules_tab' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'value' => array(0 => 'n', 1 => 'y') ), 'mailboxlist_webmail_link' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + '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}(\?.+)?$/',*/ - 'regex' => '/^[0-9a-zA-Z\:\/\-\.\[\]]{0,255}$/', - 'errmsg'=> 'webmail_url_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + /*'regex' => '/^[0-9a-zA-Z\:\/\-\.]{0,255}(\?.+)?$/',*/ + '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') + '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' + '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', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'admin_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'smtp_enabled' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'smtp_host' => array ( - 'datatype' => 'VARCHAR', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'smtp_port' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '25', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '25', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'smtp_user' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'smtp_pass' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'smtp_crypt' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); $form["tabs"]['domains'] = array ( - 'title' => "Domains", - 'width' => 70, - 'template' => "templates/system_config_domains_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + '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') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'new_domain_html' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); @@ -372,106 +372,106 @@ $form["tabs"]['domains'] = array ( END: Branding */ $form["tabs"]['misc'] = array ( - 'title' => "Misc", - 'width' => 70, - 'template' => "templates/system_config_misc_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Misc", + 'width' => 70, + 'template' => "templates/system_config_misc_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'dashboard_atom_url_admin' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'http://www.ispconfig.org/atom', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'http://www.ispconfig.org/atom', + 'value' => '' ), 'dashboard_atom_url_reseller' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'http://www.ispconfig.org/atom', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'http://www.ispconfig.org/atom', + 'value' => '' ), 'dashboard_atom_url_client' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'http://www.ispconfig.org/atom', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'http://www.ispconfig.org/atom', + 'value' => '' ), 'monitor_key' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), 'tab_change_discard' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'tab_change_warning' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'use_loadindicator' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), 'use_combobox' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), 'maintenance_mode' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'admin_dashlets_left' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), 'admin_dashlets_right' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), 'reseller_dashlets_left' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), 'reseller_dashlets_right' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), 'client_dashlets_left' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), 'client_dashlets_right' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); diff --git a/interface/web/admin/form/tpl_default.tform.php b/interface/web/admin/form/tpl_default.tform.php index de63948b8..df52bbec5 100644 --- a/interface/web/admin/form/tpl_default.tform.php +++ b/interface/web/admin/form/tpl_default.tform.php @@ -59,16 +59,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "tpl_default_head_txt"; -$form["description"] = "tpl_default_desc_txt"; -$form["name"] = "tpl_default"; -$form["action"] = "tpl_default.php"; -$form["db_table"] = "sys_theme"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "basic"; -$form["list_default"] = "system_config_edit.php"; -$form["auth"] = 'yes'; +$form["title"] = "tpl_default_head_txt"; +$form["description"] = "tpl_default_desc_txt"; +$form["name"] = "tpl_default"; +$form["action"] = "tpl_default.php"; +$form["db_table"] = "sys_theme"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "basic"; +$form["list_default"] = "system_config_edit.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 @@ -77,37 +77,37 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['basic'] = array ( - 'title' => "Basic Settings", - 'width' => 80, - 'template' => "templates/tpl_default_basic.htm", - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + 'title' => "Basic Settings", + 'width' => 80, + 'template' => "templates/tpl_default_basic.htm", + 'fields' => array ( + //################################# + // Beginn Datenbankfelder + //################################# 'username' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', 'validators' => '', - 'default' => 'global', - 'value' => 'global', - 'separator' => '', - 'width' => '40', - 'maxlength' => '64' + 'default' => 'global', + 'value' => 'global', + 'separator' => '', + 'width' => '40', + 'maxlength' => '64' ), 'logo_url' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', 'validators' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '40', - 'maxlength' => '255' + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '40', + 'maxlength' => '255' ), - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/form/users.tform.php b/interface/web/admin/form/users.tform.php index b6ff5f3bd..06f07c07e 100644 --- a/interface/web/admin/form/users.tform.php +++ b/interface/web/admin/form/users.tform.php @@ -60,62 +60,62 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$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'; +$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; +$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; +$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'] = ''; +$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' && $file != 'mailuser') { +$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' && $file != 'mailuser') { $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")) { +$handle = @opendir(ISPC_THEMES_PATH); +while ($file = @readdir($handle)) { + if (substr($file, 0, 1) != '.') { + if(@is_dir(ISPC_THEMES_PATH."/$file")) { if(!file_exists(ISPC_THEMES_PATH."/$file/ispconfig_version") || (@file_exists(ISPC_THEMES_PATH."/$file/ispconfig_version") && trim(@file_get_contents(ISPC_THEMES_PATH."/$file/ispconfig_version")) == ISPC_APP_VERSION)) { - $themes_list[$file] = $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') { +$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; - } + } } } @@ -129,133 +129,133 @@ if(is_array($tmp_records)) { } $form['tabs']['users'] = array ( - 'title' => 'Users', - 'width' => 80, - 'template' => 'templates/users_user_edit.htm', - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + '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'), - 3 => array ( 'type' => 'CUSTOM', - 'class' => 'validate_client', - 'function' => 'username_collision', - 'errmsg'=> 'username_error_collision'), - ), - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '30', - 'rows' => '', - 'cols' => '' + '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'), + 3 => array ( 'type' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'username_collision', + 'errmsg'=> 'username_error_collision'), + ), + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '15', + 'maxlength' => '30', + 'rows' => '', + 'cols' => '' ), 'passwort' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'PASSWORD', + 'datatype' => 'VARCHAR', + 'formtype' => 'PASSWORD', 'encryption' => 'CRYPT', - 'regex' => '', - 'errmsg' => '', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '15', - 'maxlength' => '100', - 'rows' => '', - 'cols' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => $language_list, + 'separator' => '', + 'width' => '30', + 'maxlength' => '2', + 'rows' => '', + 'cols' => '' ) - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); /* @@ -419,44 +419,44 @@ $form['tabs']['address'] = array ( */ $form['tabs']['groups'] = array ( - 'title' => 'Groups', - 'width' => 80, - 'template' => 'templates/users_groups_edit.htm', - 'fields' => array ( - ################################## - # Beginn Datenbankfelder - ################################## + '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' => '' + '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' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'regex' => '', + 'errmsg' => '', + 'default' => '', + 'value' => $groups_list, + 'separator' => ',', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ) - ################################## - # ENDE Datenbankfelder - ################################## + //################################# + // ENDE Datenbankfelder + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/groups_del.php b/interface/web/admin/groups_del.php index 3303154f2..57b47d9f4 100644 --- a/interface/web/admin/groups_del.php +++ b/interface/web/admin/groups_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/groups.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -48,4 +48,4 @@ $app->auth->check_module_permissions('admin'); $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/groups_edit.php b/interface/web/admin/groups_edit.php index d2acf2b85..5ecf75fdf 100644 --- a/interface/web/admin/groups_edit.php +++ b/interface/web/admin/groups_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/groups.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -50,4 +50,4 @@ $app->uses('tpl,tform,tform_actions'); // let tform_actions handle the page $app->tform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/groups_list.php b/interface/web/admin/groups_list.php index f75f5de69..aa2c37c66 100644 --- a/interface/web/admin/groups_list.php +++ b/interface/web/admin/groups_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -48,4 +48,4 @@ $app->uses('listform_actions'); $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/index.php b/interface/web/admin/index.php index 3691df1d8..7cbfddbe9 100644 --- a/interface/web/admin/index.php +++ b/interface/web/admin/index.php @@ -34,14 +34,14 @@ class admin_index { var $target = ''; function render() { - + global $app; - + $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); - $app->tpl->setVar('error',$error); - $app->tpl->setInclude('content_tpl','admin/templates/index.htm'); + $app->tpl->setVar('error', $error); + $app->tpl->setInclude('content_tpl', 'admin/templates/index.htm'); return $app->tpl->grab(); /* $filename = 'test.txt'; @@ -69,10 +69,11 @@ $somecontent = $app->tpl->grab(); - + return 'dd'; */ } + } -?> \ No newline at end of file +?> diff --git a/interface/web/admin/iptables_del.php b/interface/web/admin/iptables_del.php index 2f1830fee..2497768c1 100644 --- a/interface/web/admin/iptables_del.php +++ b/interface/web/admin/iptables_del.php @@ -38,8 +38,8 @@ $tform_def_file = "form/iptables.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -47,4 +47,4 @@ $app->auth->check_module_permissions('admin'); $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/iptables_edit.php b/interface/web/admin/iptables_edit.php index cf9152b57..61d1ee331 100644 --- a/interface/web/admin/iptables_edit.php +++ b/interface/web/admin/iptables_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/iptables.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -49,10 +49,10 @@ $app->uses('tpl,tform,tform_actions'); $app->load('tform_actions'); class page_action extends tform_actions { - + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/iptables_list.php b/interface/web/admin/iptables_list.php index 71f888751..8110460c1 100644 --- a/interface/web/admin/iptables_list.php +++ b/interface/web/admin/iptables_list.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -48,4 +48,4 @@ $app->uses('listform_actions'); $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/language_add.php b/interface/web/admin/language_add.php index a2961715a..3444179a2 100644 --- a/interface/web/admin/language_add.php +++ b/interface/web/admin/language_add.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -46,13 +46,13 @@ $app->tpl->setInclude('content_tpl', 'templates/language_add.htm'); $language_option = ''; $error = ''; $msg = ''; -$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'],0,2):'en'; +$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'], 0, 2):'en'; if(!preg_match("/^[a-z]{2}$/i", $selected_language)) die('unallowed characters in selected language name.'); -$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); -while ($file = readdir ($handle)) { - if ($file != '.' && $file != '..') { - $tmp_lng = substr($file,0,-4); +$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); +while ($file = readdir($handle)) { + if ($file != '.' && $file != '..') { + $tmp_lng = substr($file, 0, -4); if($tmp_lng !='') { $selected = ($tmp_lng == $selected_language)?'SELECTED':''; $language_option .= ""; @@ -60,29 +60,29 @@ while ($file = readdir ($handle)) { } } } -$app->tpl->setVar('language_option',$language_option); -$app->tpl->setVar('error',$error); +$app->tpl->setVar('language_option', $language_option); +$app->tpl->setVar('error', $error); if(isset($_POST['lng_new']) && strlen($_POST['lng_new']) == 2 && $error == '') { $lng_new = $_POST['lng_new']; if(!preg_match("/^[a-z]{2}$/i", $lng_new)) die('unallowed characters in language name.'); - + //* Copy the main language file - copy(ISPC_LIB_PATH."/lang/$selected_language.lng",ISPC_LIB_PATH."/lang/$lng_new.lng"); - + copy(ISPC_LIB_PATH."/lang/$selected_language.lng", ISPC_LIB_PATH."/lang/$lng_new.lng"); + //* Make a copy of every language file $bgcolor = '#FFFFFF'; $language_files_list = array(); - $handle = @opendir(ISPC_WEB_PATH); - while ($file = @readdir ($handle)) { - if ($file != '.' && $file != '..') { - if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { + $handle = @opendir(ISPC_WEB_PATH); + while ($file = @readdir($handle)) { + if ($file != '.' && $file != '..') { + if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { $handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang'); - while ($lang_file = @readdir ($handle2)) { - if ($lang_file != '.' && $lang_file != '..' && substr($lang_file,0,2) == $selected_language) { - $new_lang_file = $lng_new.substr($lang_file,2); + while ($lang_file = @readdir($handle2)) { + if ($lang_file != '.' && $lang_file != '..' && substr($lang_file, 0, 2) == $selected_language) { + $new_lang_file = $lng_new.substr($lang_file, 2); //echo ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file.' ## '.ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$new_lang_file; - copy(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file,ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$new_lang_file); + copy(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file, ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$new_lang_file); $msg = 'Added new language '.$lng_new; } } @@ -91,15 +91,15 @@ if(isset($_POST['lng_new']) && strlen($_POST['lng_new']) == 2 && $error == '') { } } -$app->tpl->setVar('msg',$msg); +$app->tpl->setVar('msg', $msg); -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_add.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/language_complete.php b/interface/web/admin/language_complete.php index 75343bd82..67cfb86ed 100644 --- a/interface/web/admin/language_complete.php +++ b/interface/web/admin/language_complete.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -46,13 +46,13 @@ $app->tpl->setInclude('content_tpl', 'templates/language_complete.htm'); $language_option = ''; $error = ''; $msg = ''; -$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'],0,2):'en'; +$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'], 0, 2):'en'; if(!preg_match("/^[a-z]{2}$/i", $selected_language)) die('unallowed characters in selected language name.'); -$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); -while ($file = readdir ($handle)) { - if ($file != '.' && $file != '..') { - $tmp_lng = substr($file,0,-4); +$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); +while ($file = readdir($handle)) { + if ($file != '.' && $file != '..') { + $tmp_lng = substr($file, 0, -4); if($tmp_lng !='' && $tmp_lng != 'en') { $selected = ($tmp_lng == $selected_language)?'SELECTED':''; $language_option .= ""; @@ -60,65 +60,65 @@ while ($file = readdir ($handle)) { } } } -$app->tpl->setVar('language_option',$language_option); -$app->tpl->setVar('error',$error); +$app->tpl->setVar('language_option', $language_option); +$app->tpl->setVar('error', $error); // Export the language file if(isset($_POST['lng_select']) && $error == '') { - + // complete the global langauge file - merge_langfile(ISPC_LIB_PATH."/lang/".$selected_language.".lng",ISPC_LIB_PATH."/lang/en.lng"); - + merge_langfile(ISPC_LIB_PATH."/lang/".$selected_language.".lng", ISPC_LIB_PATH."/lang/en.lng"); + // Go trough all language files $bgcolor = '#FFFFFF'; $language_files_list = array(); - $handle = @opendir(ISPC_WEB_PATH); - while ($file = @readdir ($handle)) { - if ($file != '.' && $file != '..') { - if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { + $handle = @opendir(ISPC_WEB_PATH); + while ($file = @readdir($handle)) { + if ($file != '.' && $file != '..') { + if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { $handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang'); - while ($lang_file = @readdir ($handle2)) { - if ($lang_file != '.' && $lang_file != '..' && substr($lang_file,0,2) == 'en') { - $target_lang_file = $selected_language.substr($lang_file,2); - merge_langfile(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$target_lang_file,ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file); + while ($lang_file = @readdir($handle2)) { + if ($lang_file != '.' && $lang_file != '..' && substr($lang_file, 0, 2) == 'en') { + $target_lang_file = $selected_language.substr($lang_file, 2); + merge_langfile(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$target_lang_file, ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file); } } $handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang'); - while ($lang_file = @readdir ($handle2)) { - if ($lang_file != '.' && $lang_file != '..' && substr($lang_file,0,2) == $selected_language) { - $master_lang_file=ISPC_WEB_PATH.'/'.$file.'/lib/lang/en'.substr($lang_file,2); + while ($lang_file = @readdir($handle2)) { + if ($lang_file != '.' && $lang_file != '..' && substr($lang_file, 0, 2) == $selected_language) { + $master_lang_file=ISPC_WEB_PATH.'/'.$file.'/lib/lang/en'.substr($lang_file, 2); $target_lang_file=ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file; if(!file_exists($master_lang_file)){ - unlink($target_lang_file); - $msg.="File $target_lang_file removed because does not exist in master language
    "; + unlink($target_lang_file); + $msg.="File $target_lang_file removed because does not exist in master language
    "; } } }//Finish of remove the files how not exists in master language } } } -if($msg=='') -$msg="No files created, removed or modified
    "; + if($msg=='') + $msg="No files created, removed or modified
    "; } -function merge_langfile($langfile,$masterfile) { +function merge_langfile($langfile, $masterfile) { global $msg; - + if(is_file($langfile)) { - + // Load the english language file - include($masterfile); + include $masterfile; if(isset($wb) && is_array($wb)) { $wb_master = $wb; unset($wb); } else { $wb_master = array(); } - + // Load the incomplete language file $wb = array(); - include($langfile); - + include $langfile; + $n = 0; foreach($wb_master as $key => $val) { if(!isset($wb[$key])) { @@ -126,7 +126,7 @@ function merge_langfile($langfile,$masterfile) { $n++; } } - + $r = 0; foreach($wb as $key => $val) { if(!isset($wb_master[$key])) { @@ -134,35 +134,35 @@ function merge_langfile($langfile,$masterfile) { $r++; } } - + $file_content = " $val) { - $val = str_replace("'","\\'",$val); - $val = str_replace('"','\"',$val); + $val = str_replace("'", "\\'", $val); + $val = str_replace('"', '\"', $val); $file_content .= '$wb['."'$key'".'] = '."'$val';\n"; } $file_content .= "?>\n"; - + if($n!=0) - $msg .= "Added $n lines to the file $langfile
    "; + $msg .= "Added $n lines to the file $langfile
    "; if($r!=0) - $msg .= "Removed $r lines to the file $langfile
    "; - file_put_contents($langfile ,$file_content); + $msg .= "Removed $r lines to the file $langfile
    "; + file_put_contents($langfile , $file_content); } else { $msg .= "File does not exist yet. Copied file $masterfile to $langfile
    "; - copy($masterfile,$langfile); + copy($masterfile, $langfile); } } -$app->tpl->setVar('msg',$msg); +$app->tpl->setVar('msg', $msg); -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_complete.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/language_edit.php b/interface/web/admin/language_edit.php index ffba65d61..fda70a62a 100644 --- a/interface/web/admin/language_edit.php +++ b/interface/web/admin/language_edit.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -57,27 +57,27 @@ if(isset($_POST['records']) && is_array($_POST['records'])) { $file_content = " $val) { $val = stripslashes($val); - $val = str_replace('"','\"',$val); - $val = str_replace('$','',$val); + $val = str_replace('"', '\"', $val); + $val = str_replace('$', '', $val); $file_content .= '$wb['."'$key'".'] = "'.$val.'";'."\n"; $msg = 'File saved.'; } $file_content .= "?>\n"; if($module == 'global') { - file_put_contents(ISPC_LIB_PATH."/lang/$lang_file" ,$file_content); + file_put_contents(ISPC_LIB_PATH."/lang/$lang_file" , $file_content); } else { - file_put_contents(ISPC_WEB_PATH."/$module/lib/lang/$lang_file" ,$file_content); + file_put_contents(ISPC_WEB_PATH."/$module/lib/lang/$lang_file" , $file_content); } } -$app->tpl->setVar(array('module' => $module,'lang_file' => $lang_file, 'lang' => $lang, 'msg' => $msg)); +$app->tpl->setVar(array('module' => $module, 'lang_file' => $lang_file, 'lang' => $lang, 'msg' => $msg)); if($module == 'global') { - include(ISPC_LIB_PATH."/lang/$lang_file"); + include ISPC_LIB_PATH."/lang/$lang_file"; $file_path = ISPC_LIB_PATH."/lang/$lang_file"; } else { - include(ISPC_WEB_PATH."/$module/lib/lang/$lang_file"); + include ISPC_WEB_PATH."/$module/lib/lang/$lang_file"; $file_path = ISPC_WEB_PATH."/$module/lib/lang/$lang_file"; } $app->tpl->setVar("file_path", $file_path); @@ -85,7 +85,7 @@ $app->tpl->setVar("file_path", $file_path); $keyword_list = array(); if(isset($wb) && is_array($wb)) { foreach($wb as $key => $val) { - $keyword_list[] = array('key' => $key, 'val' => htmlentities($val,ENT_COMPAT | ENT_HTML401,'UTF-8')); + $keyword_list[] = array('key' => $key, 'val' => htmlentities($val, ENT_COMPAT | ENT_HTML401, 'UTF-8')); } $app->tpl->setLoop('records', $keyword_list); @@ -93,9 +93,9 @@ if(isset($wb) && is_array($wb)) { } -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_edit.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); diff --git a/interface/web/admin/language_export.php b/interface/web/admin/language_export.php index 5c192c3cf..a4c75f3df 100644 --- a/interface/web/admin/language_export.php +++ b/interface/web/admin/language_export.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -46,13 +46,13 @@ $app->tpl->setInclude('content_tpl', 'templates/language_export.htm'); $language_option = ''; $error = ''; $msg = ''; -$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'],0,2):'en'; +$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'], 0, 2):'en'; if(!preg_match("/^[a-z]{2}$/i", $selected_language)) die('unallowed characters in selected language name.'); -$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); -while ($file = readdir ($handle)) { - if ($file != '.' && $file != '..') { - $tmp_lng = substr($file,0,-4); +$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); +while ($file = readdir($handle)) { + if ($file != '.' && $file != '..') { + $tmp_lng = substr($file, 0, -4); if($tmp_lng !='') { $selected = ($tmp_lng == $selected_language)?'SELECTED':''; $language_option .= ""; @@ -60,34 +60,34 @@ while ($file = readdir ($handle)) { } } } -$app->tpl->setVar('language_option',$language_option); -$app->tpl->setVar('error',$error); +$app->tpl->setVar('language_option', $language_option); +$app->tpl->setVar('error', $error); // Export the language file if(isset($_POST['lng_select']) && $error == '') { //$lng_select = $_POST['lng_select']; //if(!preg_match("/^[a-z]{2}$/i", $lng_select)) die('unallowed characters in language name.'); - + // This variable contains the content of the language files $content = ''; $content .= "---|ISPConfig Language File|".$conf["app_version"]."|".$selected_language."\n"; - + //* get the global language file $content .= "--|global|".$selected_language."|".$selected_language.".lng\n"; $content .= file_get_contents(ISPC_LIB_PATH."/lang/".$selected_language.".lng")."\n"; - + //* Get the global file of the module //$content .= "---|$module|$selected_language|\n"; //copy(ISPC_WEB_PATH."/$module/lib/lang/$selected_language.lng",ISPC_WEB_PATH."/$module/lib/lang/$lng_new.lng"); $bgcolor = '#FFFFFF'; $language_files_list = array(); - $handle = @opendir(ISPC_WEB_PATH); - while ($file = @readdir ($handle)) { - if ($file != '.' && $file != '..') { - if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { + $handle = @opendir(ISPC_WEB_PATH); + while ($file = @readdir($handle)) { + if ($file != '.' && $file != '..') { + if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { $handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang'); - while ($lang_file = @readdir ($handle2)) { - if ($lang_file != '.' && $lang_file != '..' && substr($lang_file,0,2) == $selected_language) { + while ($lang_file = @readdir($handle2)) { + if ($lang_file != '.' && $lang_file != '..' && substr($lang_file, 0, 2) == $selected_language) { $content .= "--|".$file."|".$selected_language."|".$lang_file."\n"; $content .= file_get_contents(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file)."\n"; $msg .= 'Exported language file '.$lang_file.'
    '; @@ -96,26 +96,26 @@ if(isset($_POST['lng_select']) && $error == '') { } } } - + $content .= '---|EOF'; - + // Write the language file file_put_contents(ISPC_WEB_TEMP_PATH.'/'.$selected_language.'.lng', $content); - + $msg = "Exported language file to: /temp/".$selected_language.'.lng'; - + //$msg = nl2br($content); } -$app->tpl->setVar('msg',$msg); +$app->tpl->setVar('msg', $msg); -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_export.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/language_import.php b/interface/web/admin/language_import.php index c25406ae7..1dfaa1846 100644 --- a/interface/web/admin/language_import.php +++ b/interface/web/admin/language_import.php @@ -27,87 +27,87 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; function normalize_string($string, $quote, $allow_special = false) { - $escaped = false; - $in_string = true; - $new_string = ''; - - for($c = 0; $c < mb_strlen($string); $c++) { - $char = $string{$c}; - - if($in_string === true && $escaped === false && $char === $quote) { - // this marks a string end (e.g. for concatenation) - $in_string = false; - continue; - } elseif($in_string === false) { - if($escaped === false && $char === $quote) { - $in_string = true; - continue; - } else { - continue; // we strip everything from outside the string! - } - } - - if($char === '"' && $escaped === true && $quote === '"') { - // unescape this - $new_string .= $char; - $escaped = false; - continue; - } elseif($char === "'" && $escaped === false && $quote === '"') { - // escape this - $new_string .= '\\' . $char; - continue; - } - - if($escaped === true) { - // the next character is the escaped one. - if($allow_special === true && ($char === 'n' || $char === 'r' || $char === 't')) { - $new_string .= '\' . "\\' . $char . '" . \''; - } else { - $new_string .= '\\' . $char; - } - $escaped = false; - } else { - if($char === '\\') { - $escaped = true; - } else { - $new_string .= $char; - } - } - } - return $new_string; + $escaped = false; + $in_string = true; + $new_string = ''; + + for($c = 0; $c < mb_strlen($string); $c++) { + $char = $string{$c}; + + if($in_string === true && $escaped === false && $char === $quote) { + // this marks a string end (e.g. for concatenation) + $in_string = false; + continue; + } elseif($in_string === false) { + if($escaped === false && $char === $quote) { + $in_string = true; + continue; + } else { + continue; // we strip everything from outside the string! + } + } + + if($char === '"' && $escaped === true && $quote === '"') { + // unescape this + $new_string .= $char; + $escaped = false; + continue; + } elseif($char === "'" && $escaped === false && $quote === '"') { + // escape this + $new_string .= '\\' . $char; + continue; + } + + if($escaped === true) { + // the next character is the escaped one. + if($allow_special === true && ($char === 'n' || $char === 'r' || $char === 't')) { + $new_string .= '\' . "\\' . $char . '" . \''; + } else { + $new_string .= '\\' . $char; + } + $escaped = false; + } else { + if($char === '\\') { + $escaped = true; + } else { + $new_string .= $char; + } + } + } + return $new_string; } function validate_line($line) { - $line = trim($line); - if($line === '' || $line === '') return $line; // don't treat empty lines as malicious - - $ok = preg_match('/^\s*\$wb\[(["\'])(.*?)\\1\]\s*=\s*(["\'])(.*?)\\3\s*;\s*$/', $line, $matches); - if(!$ok) return false; // this line has invalid form and could lead to malfunction - - $keyquote = $matches[1]; // ' or " - $key = $matches[2]; - if(strpos($key, '"') !== false || strpos($key, "'") !== false) return false; - - $textquote = $matches[3]; // ' or " - $text = $matches[4]; - - $new_line = '$wb[\''; - - // validate the language key - $key = normalize_string($key, $keyquote); - - $new_line .= $key . '\'] = \''; - - // validate this text to avoid code injection - $text = normalize_string($text, $textquote, true); - - $new_line .= $text . '\';'; - - return $new_line; + $line = trim($line); + if($line === '' || $line === '') return $line; // don't treat empty lines as malicious + + $ok = preg_match('/^\s*\$wb\[(["\'])(.*?)\\1\]\s*=\s*(["\'])(.*?)\\3\s*;\s*$/', $line, $matches); + if(!$ok) return false; // this line has invalid form and could lead to malfunction + + $keyquote = $matches[1]; // ' or " + $key = $matches[2]; + if(strpos($key, '"') !== false || strpos($key, "'") !== false) return false; + + $textquote = $matches[3]; // ' or " + $text = $matches[4]; + + $new_line = '$wb[\''; + + // validate the language key + $key = normalize_string($key, $keyquote); + + $new_line .= $key . '\'] = \''; + + // validate this text to avoid code injection + $text = normalize_string($text, $textquote, true); + + $new_line .= $text . '\';'; + + return $new_line; } //* Check permissions for module @@ -130,20 +130,20 @@ $error = ''; if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name'])) { $lines = file($_FILES['file']['tmp_name']); // initial check - $parts = explode('|',$lines[0]); + $parts = explode('|', $lines[0]); if($parts[0] == '---' && $parts[1] == 'ISPConfig Language File') { if($_POST['ignore_version'] != 1 && $parts[2] != $conf["app_version"]) { $error .= 'Application version does not match. Appversion: '.$conf["app_version"].' Lanfile version: '.$parts[2]; } else { unset($lines[0]); - + $buffer = ''; $langfile_path = ''; // all other lines - $ln = 1; + $ln = 1; foreach($lines as $line) { - $ln++; - $parts = explode('|',$line); + $ln++; + $parts = explode('|', $line); if(is_array($parts) && count($parts) > 0 && $parts[0] == '--') { // Write language file, if its not the first file if($buffer != '' && $langfile_path != '') { @@ -151,7 +151,7 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $error .= "File exists, not written: $langfile_path
    "; } else { $msg .= "File written: $langfile_path
    "; - file_put_contents($langfile_path,$buffer); + file_put_contents($langfile_path, $buffer); } } // empty buffer and set variables @@ -161,17 +161,17 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $file_name = trim($parts[3]); if(!preg_match("/^[a-z]{2}$/i", $selected_language)) die("unallowed characters in selected language name: $selected_language"); if(!preg_match("/^[a-z_]+$/i", $module_name)) die('unallowed characters in module name.'); - if(!preg_match("/^[a-z\._\-]+$/i", $file_name) || stristr($file_name,'..')) die("unallowed characters in language file name: '$file_name'"); + if(!preg_match("/^[a-z\._\-]+$/i", $file_name) || stristr($file_name, '..')) die("unallowed characters in language file name: '$file_name'"); if($module_name == 'global') { $langfile_path = trim(ISPC_LIB_PATH."/lang/".$selected_language.".lng"); } else { $langfile_path = trim(ISPC_WEB_PATH.'/'.$module_name.'/lib/lang/'.$file_name); } } elseif(is_array($parts) && count($parts) > 1 && $parts[0] == '---' && $parts[1] == 'EOF') { - // EOF line, ignore it. - } else { - $line = validate_line($line); - if($line === false) $error .= "Language file contains invalid language entry on line $ln.
    "; + // EOF line, ignore it. + } else { + $line = validate_line($line); + if($line === false) $error .= "Language file contains invalid language entry on line $ln.
    "; else $buffer .= $line."\n"; } } @@ -179,16 +179,16 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' } } -$app->tpl->setVar('msg',$msg); -$app->tpl->setVar('error',$error); +$app->tpl->setVar('msg', $msg); +$app->tpl->setVar('error', $error); -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_import.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/language_list.php b/interface/web/admin/language_list.php index 84b800713..2cb28dc18 100644 --- a/interface/web/admin/language_list.php +++ b/interface/web/admin/language_list.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -46,45 +46,45 @@ $bgcolor = '#FFFFFF'; //* reading languages $language_option = ''; -$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'],0,2):$_SESSION['s']['language']; -$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); -while ($file = readdir ($handle)) { - if ($file != '.' && $file != '..') { - $tmp_lng = substr($file,0,-4); +$selected_language = (isset($_REQUEST['lng_select']))?substr($_REQUEST['lng_select'], 0, 2):$_SESSION['s']['language']; +$handle = opendir(ISPC_ROOT_PATH.'/lib/lang/'); +while ($file = readdir($handle)) { + if ($file != '.' && $file != '..') { + $tmp_lng = substr($file, 0, -4); if($tmp_lng !='') { $selected = ($tmp_lng == $selected_language)?'SELECTED':''; $language_option .= ""; - + //$bgcolor = ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF'; if($file == $selected_language.'.lng') { - $language_files_list[] = array( 'module' => 'global', - 'lang_file' => $file, - 'lang_file_date' => date("Y-m-d H:i:s", filectime(ISPC_ROOT_PATH.'/lib/lang/'.$file)), - 'bgcolor' => $bgcolor, - 'lang' => $selected_language); + $language_files_list[] = array( 'module' => 'global', + 'lang_file' => $file, + 'lang_file_date' => date("Y-m-d H:i:s", filectime(ISPC_ROOT_PATH.'/lib/lang/'.$file)), + 'bgcolor' => $bgcolor, + 'lang' => $selected_language); } - - + + } } } -$app->tpl->setVar('language_option',$language_option); +$app->tpl->setVar('language_option', $language_option); // $app->tpl->setLoop('records', $language_list); //* list all language files of the selected language -$handle = @opendir(ISPC_WEB_PATH); -while ($file = @readdir ($handle)) { - if ($file != '.' && $file != '..') { - if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { +$handle = @opendir(ISPC_WEB_PATH); +while ($file = @readdir($handle)) { + if ($file != '.' && $file != '..') { + if(@is_dir(ISPC_WEB_PATH.'/'.$file.'/lib/lang')) { $handle2 = opendir(ISPC_WEB_PATH.'/'.$file.'/lib/lang'); - while ($lang_file = @readdir ($handle2)) { - if ($lang_file != '.' && $lang_file != '..' && substr($lang_file,0,2) == $selected_language) { + while ($lang_file = @readdir($handle2)) { + if ($lang_file != '.' && $lang_file != '..' && substr($lang_file, 0, 2) == $selected_language) { $bgcolor = ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF'; - $language_files_list[] = array( 'module' => $file, - 'lang_file' => $lang_file, - 'lang_file_date' => date("Y-m-d H:i:s", filectime(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file)), - 'bgcolor' => $bgcolor, - 'lang' => $selected_language); + $language_files_list[] = array( 'module' => $file, + 'lang_file' => $lang_file, + 'lang_file_date' => date("Y-m-d H:i:s", filectime(ISPC_WEB_PATH.'/'.$file.'/lib/lang/'.$lang_file)), + 'bgcolor' => $bgcolor, + 'lang' => $selected_language); } } } @@ -96,9 +96,9 @@ $app->tpl->setLoop('records', $language_files_list); -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_language_list.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php index 92e1979b1..7f4d19da1 100644 --- a/interface/web/admin/lib/module.conf.php +++ b/interface/web/admin/lib/module.conf.php @@ -2,61 +2,61 @@ global $conf; -$module['name'] = 'admin'; -$module['title'] = 'top_menu_system'; -$module['template'] = 'module.tpl.htm'; -$module['startpage'] = 'admin/server_list.php'; +$module['name'] = 'admin'; +$module['title'] = 'top_menu_system'; +$module['template'] = 'module.tpl.htm'; +$module['startpage'] = 'admin/server_list.php'; $module['tab_width'] = '60'; $items[] = array( 'title' => 'CP Users', - 'target' => 'content', - 'link' => 'admin/users_list.php', - 'html_id' => 'user_list'); + 'target' => 'content', + 'link' => 'admin/users_list.php', + 'html_id' => 'user_list'); -$items[] = array( 'title' => 'Remote Users', - 'target' => 'content', - 'link' => 'admin/remote_user_list.php', - 'html_id' => 'remote_user_list'); +$items[] = array( 'title' => 'Remote Users', + 'target' => 'content', + 'link' => 'admin/remote_user_list.php', + 'html_id' => 'remote_user_list'); -$module['nav'][] = array( 'title' => 'User Management', - 'open' => 1, - 'items' => $items); +$module['nav'][] = array( 'title' => 'User Management', + 'open' => 1, + 'items' => $items); // cleanup unset($items); -$items[] = array( 'title' => 'Server Services', - 'target' => 'content', - 'link' => 'admin/server_list.php', - 'html_id' => 'server_list'); +$items[] = array( 'title' => 'Server Services', + 'target' => 'content', + 'link' => 'admin/server_list.php', + 'html_id' => 'server_list'); -$items[] = array( 'title' => 'Server Config', - 'target' => 'content', - 'link' => 'admin/server_config_list.php', - 'html_id' => 'server_config_list'); +$items[] = array( 'title' => 'Server Config', + 'target' => 'content', + 'link' => 'admin/server_config_list.php', + 'html_id' => 'server_config_list'); -$items[] = array( 'title' => 'Server IP addresses', - 'target' => 'content', - 'link' => 'admin/server_ip_list.php', - 'html_id' => 'server_ip_list'); +$items[] = array( 'title' => 'Server IP addresses', + 'target' => 'content', + 'link' => 'admin/server_ip_list.php', + 'html_id' => 'server_ip_list'); -$items[] = array( 'title' => 'Additional PHP Versions', - 'target' => 'content', - 'link' => 'admin/server_php_list.php', - 'html_id' => 'server_php_list'); - -$items[] = array( 'title' => 'Directive Snippets', - 'target' => 'content', - 'link' => 'admin/directive_snippets_list.php', - 'html_id' => 'directive_snippets_list'); +$items[] = array( 'title' => 'Additional PHP Versions', + 'target' => 'content', + 'link' => 'admin/server_php_list.php', + 'html_id' => 'server_php_list'); -$items[] = array( 'title' => 'Firewall', - 'target' => 'content', - 'link' => 'admin/firewall_list.php', - 'html_id' => 'firewall_list'); +$items[] = array( 'title' => 'Directive Snippets', + 'target' => 'content', + 'link' => 'admin/directive_snippets_list.php', + 'html_id' => 'directive_snippets_list'); + +$items[] = array( 'title' => 'Firewall', + 'target' => 'content', + 'link' => 'admin/firewall_list.php', + 'html_id' => 'firewall_list'); /* $items[] = array( 'title' => 'Firewall IPTables', @@ -65,104 +65,104 @@ $items[] = array( 'title' => 'Firewall IPTables', $items[] = array( 'title' => 'Packet Filter', 'target' => 'content', - 'link' => 'admin/firewall_filter_list.php'); + 'link' => 'admin/firewall_filter_list.php'); $items[] = array( 'title' => 'Port Forward', 'target' => 'content', - 'link' => 'admin/firewall_forward_list.php'); + 'link' => 'admin/firewall_forward_list.php'); */ $module['nav'][] = array( 'title' => 'System', - 'open' => 1, - 'items' => $items); + 'open' => 1, + 'items' => $items); // cleanup unset($items); -$items[] = array( 'title' => 'Interface Config', - 'target' => 'content', - 'link' => 'admin/system_config_edit.php?id=1', - 'html_id' => 'interface_config'); +$items[] = array( 'title' => 'Interface Config', + 'target' => 'content', + 'link' => 'admin/system_config_edit.php?id=1', + 'html_id' => 'interface_config'); $module['nav'][] = array( 'title' => 'Interface', - 'open' => "1", - 'items' => $items); + 'open' => "1", + 'items' => $items); // cleanup unset($items); -$items[] = array( 'title' => 'Repositories', - 'target' => 'content', - 'link' => 'admin/software_repo_list.php', - 'html_id' => 'software_repo_list'); +$items[] = array( 'title' => 'Repositories', + 'target' => 'content', + 'link' => 'admin/software_repo_list.php', + 'html_id' => 'software_repo_list'); -$items[] = array( 'title' => 'Packages', - 'target' => 'content', - 'link' => 'admin/software_package_list.php', - 'html_id' => 'software_package_list'); +$items[] = array( 'title' => 'Packages', + 'target' => 'content', + 'link' => 'admin/software_package_list.php', + 'html_id' => 'software_package_list'); -$items[] = array( 'title' => 'Updates', - 'target' => 'content', - 'link' => 'admin/software_update_list.php', - 'html_id' => 'software_update_list'); +$items[] = array( 'title' => 'Updates', + 'target' => 'content', + 'link' => 'admin/software_update_list.php', + 'html_id' => 'software_update_list'); $module['nav'][] = array( 'title' => 'Software', - 'open' => 1, - 'items' => $items); + 'open' => 1, + 'items' => $items); // cleanup unset($items); -$items[] = array( 'title' => 'Languages', - 'target' => 'content', - 'link' => 'admin/language_list.php', - 'html_id' => 'language_list'); +$items[] = array( 'title' => 'Languages', + 'target' => 'content', + 'link' => 'admin/language_list.php', + 'html_id' => 'language_list'); -$items[] = array( 'title' => 'New Language', - 'target' => 'content', - 'link' => 'admin/language_add.php', - 'html_id' => 'language_add'); +$items[] = array( 'title' => 'New Language', + 'target' => 'content', + 'link' => 'admin/language_add.php', + 'html_id' => 'language_add'); -$items[] = array( 'title' => 'Merge', - 'target' => 'content', - 'link' => 'admin/language_complete.php', - 'html_id' => 'language_complete'); +$items[] = array( 'title' => 'Merge', + 'target' => 'content', + 'link' => 'admin/language_complete.php', + 'html_id' => 'language_complete'); -$items[] = array( 'title' => 'Export', - 'target' => 'content', - 'link' => 'admin/language_export.php', - 'html_id' => 'language_export'); +$items[] = array( 'title' => 'Export', + 'target' => 'content', + 'link' => 'admin/language_export.php', + 'html_id' => 'language_export'); -$items[] = array( 'title' => 'Import', - 'target' => 'content', - 'link' => 'admin/language_import.php', - 'html_id' => 'language_import'); +$items[] = array( 'title' => 'Import', + 'target' => 'content', + 'link' => 'admin/language_import.php', + 'html_id' => 'language_import'); $module['nav'][] = array( 'title' => 'Language Editor', - 'open' => 1, - 'items' => $items); + 'open' => 1, + 'items' => $items); // cleanup unset($items); -$items[] = array( 'title' => 'Do OS-Update', - 'target' => 'content', - 'link' => 'admin/remote_action_osupdate.php', - 'html_id' => 'osupdate'); +$items[] = array( 'title' => 'Do OS-Update', + 'target' => 'content', + 'link' => 'admin/remote_action_osupdate.php', + 'html_id' => 'osupdate'); // ISPConfig interface update has been removed. Please use ispconfig_update.sh on the shell instead. -$items[] = array( 'title' => 'Do ISPConfig-Update', - 'target' => 'content', - 'link' => 'admin/remote_action_ispcupdate.php', - 'html_id' => 'ispcupdate'); +$items[] = array( 'title' => 'Do ISPConfig-Update', + 'target' => 'content', + 'link' => 'admin/remote_action_ispcupdate.php', + 'html_id' => 'ispcupdate'); -$module['nav'][] = array( 'title' => 'Remote Actions', - 'open' => 1, - 'items' => $items); +$module['nav'][] = array( 'title' => 'Remote Actions', + 'open' => 1, + 'items' => $items); // Getting the admin options from other modules @@ -171,7 +171,7 @@ if(is_array($modules)) { foreach($modules as $mt) { if(is_file($mt.'/lib/admin.conf.php')) { $options = array(); - include_once(ISPC_WEB_PATH."/$mt/lib/admin.conf.php"); + include_once ISPC_WEB_PATH."/$mt/lib/admin.conf.php"; if(is_array($options)) { foreach($options as $opt) { $module['nav'][] = $opt; @@ -181,4 +181,4 @@ if(is_array($modules)) { } } -?> \ No newline at end of file +?> diff --git a/interface/web/admin/lib/remote.conf.php b/interface/web/admin/lib/remote.conf.php index 6a87e9579..4268f47e1 100644 --- a/interface/web/admin/lib/remote.conf.php +++ b/interface/web/admin/lib/remote.conf.php @@ -2,4 +2,4 @@ $function_list['server_get,get_function_list,client_templates_get_all,server_get_serverid_by_ip,server_ip_add,server_ip_update,server_ip_delete'] = 'Server functions'; -?> \ No newline at end of file +?> diff --git a/interface/web/admin/list/directive_snippets.list.php b/interface/web/admin/list/directive_snippets.list.php index 593ff80a2..8522e0764 100644 --- a/interface/web/admin/list/directive_snippets.list.php +++ b/interface/web/admin/list/directive_snippets.list.php @@ -13,66 +13,66 @@ // Name of the list -$liste["name"] = "directive_snippets"; +$liste["name"] = "directive_snippets"; // Database table -$liste["table"] = "directive_snippets"; +$liste["table"] = "directive_snippets"; // Index index field of the database table -$liste["table_idx"] = "directive_snippets_id"; +$liste["table_idx"] = "directive_snippets_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "directive_snippets_list.php"; +$liste["file"] = "directive_snippets_list.php"; // Script file of the edit form -$liste["edit_file"] = "directive_snippets_edit.php"; +$liste["edit_file"] = "directive_snippets_edit.php"; // Script File of the delete script -$liste["delete_file"] = "directive_snippets_del.php"; +$liste["delete_file"] = "directive_snippets_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** * Suchfelder *****************************************************/ -$liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('y' => "
    Yes
    ",'n' => "
    No
    ")); - - -$liste["item"][] = array( 'field' => "name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "type", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP', 'proxy' => 'Proxy')); - -?> \ No newline at end of file +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
    Yes
    ", 'n' => "
    No
    ")); + + +$liste["item"][] = array( 'field' => "name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "type", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP', 'proxy' => 'Proxy')); + +?> diff --git a/interface/web/admin/list/firewall.list.php b/interface/web/admin/list/firewall.list.php index 97d2fe9a9..058e86c80 100644 --- a/interface/web/admin/list/firewall.list.php +++ b/interface/web/admin/list/firewall.list.php @@ -13,81 +13,81 @@ // Name of the list -$liste["name"] = "firewall"; +$liste["name"] = "firewall"; // Database table -$liste["table"] = "firewall"; +$liste["table"] = "firewall"; // Index index field of the database table -$liste["table_idx"] = "firewall_id"; +$liste["table_idx"] = "firewall_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "firewall_list.php"; +$liste["file"] = "firewall_list.php"; // Script file of the edit form -$liste["edit_file"] = "firewall_edit.php"; +$liste["edit_file"] = "firewall_edit.php"; // Script File of the delete script -$liste["delete_file"] = "firewall_del.php"; +$liste["delete_file"] = "firewall_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** * Suchfelder *****************************************************/ -$liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('y' => "
    Yes
    ",'n' => "
    No
    ")); - -$liste["item"][] = array( 'field' => "server_id", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'width' => "", - 'value' => ""); - - -$liste["item"][] = array( 'field' => "tcp_port", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - - -$liste["item"][] = array( 'field' => "udp_port", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -?> \ No newline at end of file +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
    Yes
    ", 'n' => "
    No
    ")); + +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => "", + 'value' => ""); + + +$liste["item"][] = array( 'field' => "tcp_port", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + + +$liste["item"][] = array( 'field' => "udp_port", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +?> diff --git a/interface/web/admin/list/groups.list.php b/interface/web/admin/list/groups.list.php index ded130624..9d8d4c902 100644 --- a/interface/web/admin/list/groups.list.php +++ b/interface/web/admin/list/groups.list.php @@ -10,52 +10,52 @@ */ //* Name of list -$liste['name'] = 'groups'; +$liste['name'] = 'groups'; //* Database table -$liste['table'] = 'sys_group'; +$liste['table'] = 'sys_group'; //* Primary index column -$liste['table_idx'] = 'groupid'; +$liste['table_idx'] = 'groupid'; //* Search Field Prefix -$liste['search_prefix'] = 'search_'; +$liste['search_prefix'] = 'search_'; //* Records per page -$liste['records_per_page'] = "15"; +$liste['records_per_page'] = "15"; //* Script file for listing -$liste['file'] = 'groups_list.php'; +$liste['file'] = 'groups_list.php'; //* Script file to edit -$liste['edit_file'] = 'groups_edit.php'; +$liste['edit_file'] = 'groups_edit.php'; //* Script file for deleting -$liste['delete_file'] = 'groups_del.php'; +$liste['delete_file'] = 'groups_del.php'; //* Paging Template -$liste['paging_tpl'] = 'templates/paging.tpl.htm'; +$liste['paging_tpl'] = 'templates/paging.tpl.htm'; //* Enable auth -$liste['auth'] = 'no'; +$liste['auth'] = 'no'; /***************************************************** * Suchfelder *****************************************************/ -$liste['item'][] = array( 'field' => 'name', - 'datatype' => 'VARCHAR', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => ''); - -$liste['item'][] = array( 'field' => 'description', - 'datatype' => 'VARCHAR', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => ''); - -?> \ No newline at end of file +$liste['item'][] = array( 'field' => 'name', + 'datatype' => 'VARCHAR', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => ''); + +$liste['item'][] = array( 'field' => 'description', + 'datatype' => 'VARCHAR', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => ''); + +?> diff --git a/interface/web/admin/list/iptables.list.php b/interface/web/admin/list/iptables.list.php index 657f52133..ad487e5b6 100644 --- a/interface/web/admin/list/iptables.list.php +++ b/interface/web/admin/list/iptables.list.php @@ -1,107 +1,107 @@ "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array("y" => "
    Yes
    ","n" => "
    No
    ")); +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array("y" => "
    Yes
    ", "n" => "
    No
    ")); -$liste["item"][] = array( 'field' => "server_id", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'datasource' => array ( 'type' => "SQL", - 'querystring' => "SELECT server_id,server_name FROM server WHERE {AUTHSQL} AND db_server = 1 ORDER BY server_name", - 'keyfield'=> "server_id", - 'valuefield'=> "server_name"), - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'datasource' => array ( 'type' => "SQL", + 'querystring' => "SELECT server_id,server_name FROM server WHERE {AUTHSQL} AND db_server = 1 ORDER BY server_name", + 'keyfield'=> "server_id", + 'valuefield'=> "server_name"), + 'width' => "", + 'value' => ""); -$liste["item"][] = array( 'field' => "singleport", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "singleport", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); -$liste["item"][] = array( 'field' => "multiport", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "multiport", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); $liste["item"][] = array( 'field' => "protocol", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('none'=>'None','tcp' => "TCP",'udp' => "UDP")); + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('none'=>'None', 'tcp' => "TCP", 'udp' => "UDP")); $liste["item"][] = array( 'field' => "table", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('INPUT' => "INPUT",'OUTPUT' => "OUTPUT",'FORWARD' => "FORWARD")); + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('INPUT' => "INPUT", 'OUTPUT' => "OUTPUT", 'FORWARD' => "FORWARD")); $liste["item"][] = array( 'field' => "source_ip", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "16", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "16", + 'value' => ""); $liste["item"][] = array( 'field' => "destination_ip", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "16", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "16", + 'value' => ""); -$liste["item"][] = array( 'field' => "target", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('ACCEPT' => "ACCEPT",'DROP' => "DROP",'REJECT' => "REJECT",'LOG' => "LOG")); +$liste["item"][] = array( 'field' => "target", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('ACCEPT' => "ACCEPT", 'DROP' => "DROP", 'REJECT' => "REJECT", 'LOG' => "LOG")); -$liste["item"][] = array( 'field' => "state", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); -?> \ No newline at end of file +$liste["item"][] = array( 'field' => "state", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); +?> diff --git a/interface/web/admin/list/remote_user.list.php b/interface/web/admin/list/remote_user.list.php index 09f4e3d7f..7dc0fbf43 100644 --- a/interface/web/admin/list/remote_user.list.php +++ b/interface/web/admin/list/remote_user.list.php @@ -34,32 +34,31 @@ $liste['auth'] = 'yes'; //****** Search fields $liste['item'][] = array( - 'field' => 'remote_userid', - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'op' => '=', - 'prefix' => '', - 'suffix' => '', - 'width' => '', - 'datasource' => array( - 'type' => 'SQL', - 'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username', - 'keyfield' => 'remote_userid', - 'valuefield' => 'remote_userid' - ), - 'value' => '' - ); + 'field' => 'remote_userid', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', + 'width' => '', + 'datasource' => array( + 'type' => 'SQL', + 'querystring' => 'SELECT remote_userid,remote_username FROM remote_user WHERE {AUTHSQL} ORDER BY remote_username', + 'keyfield' => 'remote_userid', + 'valuefield' => 'remote_userid' + ), + 'value' => '' +); $liste['item'][] = array( - 'field' => 'remote_username', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => '' - ); + 'field' => 'remote_username', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => '' +); ?> - diff --git a/interface/web/admin/list/server.list.php b/interface/web/admin/list/server.list.php index acca81a92..85b6e656f 100644 --- a/interface/web/admin/list/server.list.php +++ b/interface/web/admin/list/server.list.php @@ -10,104 +10,104 @@ */ //* Name of the list -$liste['name'] = 'server'; +$liste['name'] = 'server'; //* Database table -$liste['table'] = 'server'; +$liste['table'] = 'server'; //* Index index field of the database table -$liste['table_idx'] = 'server_id'; +$liste['table_idx'] = 'server_id'; //* Search Field Prefix -$liste['search_prefix'] = 'search_'; +$liste['search_prefix'] = 'search_'; //* Records per page -$liste['records_per_page'] = "15"; +$liste['records_per_page'] = "15"; //* Script File of the list -$liste['file'] = 'server_list.php'; +$liste['file'] = 'server_list.php'; //* Script file of the edit form -$liste['edit_file'] = 'server_edit.php'; +$liste['edit_file'] = 'server_edit.php'; //* Script File of the delete script -$liste['delete_file'] = 'server_del.php'; +$liste['delete_file'] = 'server_del.php'; //* Paging Template -$liste['paging_tpl'] = 'templates/paging.tpl.htm'; +$liste['paging_tpl'] = 'templates/paging.tpl.htm'; //* Enable auth -$liste['auth'] = 'yes'; +$liste['auth'] = 'yes'; /***************************************************** * Suchfelder *****************************************************/ -$liste['item'][] = array( 'field' => 'server_name', - 'datatype' => 'VARCHAR', - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => ''); - -$liste['item'][] = array( 'field' => 'mail_server', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => array('1' => "
    Yes
    ",'0' => "
    No
    ")); - -$liste['item'][] = array( 'field' => 'web_server', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => array('1' => "
    Yes
    ",'0' => "
    No
    ")); - -$liste['item'][] = array( 'field' => 'dns_server', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => array('1' => "
    Yes
    ",'0' => "
    No
    ")); - -$liste['item'][] = array( 'field' => 'file_server', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => array('1' => "
    Yes
    ",'0' => "
    No
    ")); - -$liste['item'][] = array( 'field' => 'db_server', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => array('1' => "
    Yes
    ",'0' => "
    No
    ")); - -$liste['item'][] = array( 'field' => 'vserver_server', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => array('1' => "
    Yes
    ",'0' => "
    No
    ")); - -?> \ No newline at end of file +$liste['item'][] = array( 'field' => 'server_name', + 'datatype' => 'VARCHAR', + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => ''); + +$liste['item'][] = array( 'field' => 'mail_server', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => array('1' => "
    Yes
    ", '0' => "
    No
    ")); + +$liste['item'][] = array( 'field' => 'web_server', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => array('1' => "
    Yes
    ", '0' => "
    No
    ")); + +$liste['item'][] = array( 'field' => 'dns_server', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => array('1' => "
    Yes
    ", '0' => "
    No
    ")); + +$liste['item'][] = array( 'field' => 'file_server', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => array('1' => "
    Yes
    ", '0' => "
    No
    ")); + +$liste['item'][] = array( 'field' => 'db_server', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => array('1' => "
    Yes
    ", '0' => "
    No
    ")); + +$liste['item'][] = array( 'field' => 'vserver_server', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => array('1' => "
    Yes
    ", '0' => "
    No
    ")); + +?> diff --git a/interface/web/admin/list/server_config.list.php b/interface/web/admin/list/server_config.list.php index f0540f442..fb7ac32b6 100644 --- a/interface/web/admin/list/server_config.list.php +++ b/interface/web/admin/list/server_config.list.php @@ -13,48 +13,48 @@ // Name of the list -$liste["name"] = "server_config"; +$liste["name"] = "server_config"; // Database table -$liste["table"] = "server"; +$liste["table"] = "server"; // Index index field of the database table -$liste["table_idx"] = "server_id"; +$liste["table_idx"] = "server_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "server_config_list.php"; +$liste["file"] = "server_config_list.php"; // Script file of the edit form -$liste["edit_file"] = "server_config_edit.php"; +$liste["edit_file"] = "server_config_edit.php"; // Script File of the delete script -$liste["delete_file"] = "server_config_del.php"; +$liste["delete_file"] = "server_config_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** * Suchfelder *****************************************************/ -$liste["item"][] = array( 'field' => "server_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "server_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/list/server_ip.list.php b/interface/web/admin/list/server_ip.list.php index 10001fb11..dba0c68cb 100644 --- a/interface/web/admin/list/server_ip.list.php +++ b/interface/web/admin/list/server_ip.list.php @@ -10,99 +10,99 @@ */ //* Name of list -$liste['name'] = 'server_ip'; +$liste['name'] = 'server_ip'; //* Database table -$liste['table'] = 'server_ip'; +$liste['table'] = 'server_ip'; //* Primary index column -$liste['table_idx'] = 'server_ip_id'; +$liste['table_idx'] = 'server_ip_id'; //* Search Field Prefix -$liste['search_prefix'] = 'search_'; +$liste['search_prefix'] = 'search_'; //* Records per page -$liste['records_per_page'] = "15"; +$liste['records_per_page'] = "15"; //* Script file for listing -$liste['file'] = 'server_ip_list.php'; +$liste['file'] = 'server_ip_list.php'; //* Script file to edit -$liste['edit_file'] = 'server_ip_edit.php'; +$liste['edit_file'] = 'server_ip_edit.php'; //* Script file to delete -$liste['delete_file'] = 'server_ip_del.php'; +$liste['delete_file'] = 'server_ip_del.php'; //* Paging template -$liste['paging_tpl'] = 'templates/paging.tpl.htm'; +$liste['paging_tpl'] = 'templates/paging.tpl.htm'; //* Enable auth -$liste['auth'] = 'no'; +$liste['auth'] = 'no'; /***************************************************** * Suchfelder *****************************************************/ -$liste['item'][] = array( 'field' => 'server_id', - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'width' => '', - 'value' => ''); - -$liste['item'][] = array( 'field' => 'client_id', - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', - 'keyfield'=> 'client_id', - 'valuefield'=> 'contact_name' - ), - 'width' => '', - 'value' => ''); - -$liste['item'][] = array( 'field' => 'ip_type', - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'op' => '=', - 'prefix' => '', - 'suffix' => '', - 'width' => '', - 'value' => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6')); - -$liste['item'][] = array( 'field' => 'ip_address', - 'datatype' => 'VARCHAR', - 'op' => '=', - 'prefix' => '', - 'suffix' => '', - 'width' => ''); - -$liste["item"][] = array( 'field' => "virtualhost", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('y' => "
    Yes
    ",'n' => "
    No
    ")); - - -$liste['item'][] = array( 'field' => 'virtualhost_port', - 'datatype' => 'VARCHAR', - 'op' => '=', - 'prefix' => '', - 'suffix' => '', - 'width' => ''); - -?> \ No newline at end of file +$liste['item'][] = array( 'field' => 'server_id', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => '', + 'value' => ''); + +$liste['item'][] = array( 'field' => 'client_id', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', + 'keyfield'=> 'client_id', + 'valuefield'=> 'contact_name' + ), + 'width' => '', + 'value' => ''); + +$liste['item'][] = array( 'field' => 'ip_type', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', + 'width' => '', + 'value' => array('IPv4' => 'IPv4', 'IPv6' => 'IPv6')); + +$liste['item'][] = array( 'field' => 'ip_address', + 'datatype' => 'VARCHAR', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', + 'width' => ''); + +$liste["item"][] = array( 'field' => "virtualhost", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
    Yes
    ", 'n' => "
    No
    ")); + + +$liste['item'][] = array( 'field' => 'virtualhost_port', + 'datatype' => 'VARCHAR', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', + 'width' => ''); + +?> diff --git a/interface/web/admin/list/server_php.list.php b/interface/web/admin/list/server_php.list.php index 1464d161f..ce8944d5a 100644 --- a/interface/web/admin/list/server_php.list.php +++ b/interface/web/admin/list/server_php.list.php @@ -10,73 +10,73 @@ */ //* Name of list -$liste['name'] = 'server_php'; +$liste['name'] = 'server_php'; //* Database table -$liste['table'] = 'server_php'; +$liste['table'] = 'server_php'; //* Primary index column -$liste['table_idx'] = 'server_php_id'; +$liste['table_idx'] = 'server_php_id'; //* Search Field Prefix -$liste['search_prefix'] = 'search_'; +$liste['search_prefix'] = 'search_'; //* Records per page -$liste['records_per_page'] = "15"; +$liste['records_per_page'] = "15"; //* Script file for listing -$liste['file'] = 'server_php_list.php'; +$liste['file'] = 'server_php_list.php'; //* Script file to edit -$liste['edit_file'] = 'server_php_edit.php'; +$liste['edit_file'] = 'server_php_edit.php'; //* Script file to delete -$liste['delete_file'] = 'server_php_del.php'; +$liste['delete_file'] = 'server_php_del.php'; //* Paging template -$liste['paging_tpl'] = 'templates/paging.tpl.htm'; +$liste['paging_tpl'] = 'templates/paging.tpl.htm'; //* Enable auth -$liste['auth'] = 'no'; +$liste['auth'] = 'no'; /***************************************************** * Suchfelder *****************************************************/ -$liste['item'][] = array( 'field' => 'server_id', - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'width' => '', - 'value' => ''); - -$liste['item'][] = array( 'field' => 'client_id', - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', - 'keyfield'=> 'client_id', - 'valuefield'=> 'contact_name' - ), - 'width' => '', - 'value' => ''); - -$liste['item'][] = array( 'field' => 'name', - 'datatype' => 'VARCHAR', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => ''); - -?> \ No newline at end of file +$liste['item'][] = array( 'field' => 'server_id', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => '', + 'value' => ''); + +$liste['item'][] = array( 'field' => 'client_id', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', + 'keyfield'=> 'client_id', + 'valuefield'=> 'contact_name' + ), + 'width' => '', + 'value' => ''); + +$liste['item'][] = array( 'field' => 'name', + 'datatype' => 'VARCHAR', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => ''); + +?> diff --git a/interface/web/admin/list/software_repo.list.php b/interface/web/admin/list/software_repo.list.php index 7c11113eb..2eb3dd520 100644 --- a/interface/web/admin/list/software_repo.list.php +++ b/interface/web/admin/list/software_repo.list.php @@ -13,66 +13,66 @@ // Name of the list -$liste["name"] = "software_repo"; +$liste["name"] = "software_repo"; // Database table -$liste["table"] = "software_repo"; +$liste["table"] = "software_repo"; // Index index field of the database table -$liste["table_idx"] = "software_repo_id"; +$liste["table_idx"] = "software_repo_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "software_repo_list.php"; +$liste["file"] = "software_repo_list.php"; // Script file of the edit form -$liste["edit_file"] = "software_repo_edit.php"; +$liste["edit_file"] = "software_repo_edit.php"; // Script File of the delete script -$liste["delete_file"] = "software_repo_del.php"; +$liste["delete_file"] = "software_repo_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** * Suchfelder *****************************************************/ -$liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('y' => "
    Yes
    ",'n' => "
    No
    ")); - -$liste["item"][] = array( 'field' => "repo_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - - -$liste["item"][] = array( 'field' => "repo_url", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -?> \ No newline at end of file +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
    Yes
    ", 'n' => "
    No
    ")); + +$liste["item"][] = array( 'field' => "repo_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + + +$liste["item"][] = array( 'field' => "repo_url", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +?> diff --git a/interface/web/admin/list/users.list.php b/interface/web/admin/list/users.list.php index 69cd880fa..b260c2b3c 100644 --- a/interface/web/admin/list/users.list.php +++ b/interface/web/admin/list/users.list.php @@ -13,31 +13,31 @@ $liste['name'] = 'users'; //* Database table -$liste['table'] = 'sys_user'; +$liste['table'] = 'sys_user'; //* Primary index column -$liste['table_idx'] = 'userid'; +$liste['table_idx'] = 'userid'; //* Search column prefix -$liste['search_prefix'] = 'search_'; +$liste['search_prefix'] = 'search_'; //* Records per page -$liste['records_per_page'] = "15"; +$liste['records_per_page'] = "15"; //* Script file for list -$liste['file'] = 'users_list.php'; +$liste['file'] = 'users_list.php'; //* Script file to edit -$liste['edit_file'] = 'users_edit.php'; +$liste['edit_file'] = 'users_edit.php'; //* Script file to delete -$liste['delete_file'] = 'users_del.php'; +$liste['delete_file'] = 'users_del.php'; //* Paging template -$liste['paging_tpl'] = 'templates/paging.tpl.htm'; +$liste['paging_tpl'] = 'templates/paging.tpl.htm'; //* Enable auth -$liste['auth'] = 'no'; +$liste['auth'] = 'no'; /***************************************************** @@ -45,35 +45,35 @@ $liste['auth'] = 'no'; *****************************************************/ $liste["item"][] = array( 'field' => "client_id", - 'datatype' => "INTEGER", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('1' => "
    Yes
    ",'0' => "
    No
    ")); - -$liste['item'][] = array( 'field' => 'username', - 'datatype' => 'VARCHAR', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => ''); - -$liste['item'][] = array( 'field' => 'groups', - 'datatype' => 'VARCHAR', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => ''); - -?> \ No newline at end of file + 'datatype' => "INTEGER", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('1' => "
    Yes
    ", '0' => "
    No
    ")); + +$liste['item'][] = array( 'field' => 'username', + 'datatype' => 'VARCHAR', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => ''); + +$liste['item'][] = array( 'field' => 'groups', + 'datatype' => 'VARCHAR', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => ''); + +?> diff --git a/interface/web/admin/login_as.php b/interface/web/admin/login_as.php index f7103b7aa..a5a34f13f 100644 --- a/interface/web/admin/login_as.php +++ b/interface/web/admin/login_as.php @@ -28,8 +28,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /* Check permissions for module */ $app->auth->check_module_permissions('admin'); @@ -41,7 +41,7 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin') { /* get the id of the user (must be int!) */ if (!isset($_GET['id']) && !isset($_GET['cid'])){ - die ("No user selected!"); + die ("No user selected!"); } if(isset($_GET['id'])) { @@ -61,16 +61,16 @@ if(isset($_GET['id'])) { * Get the data to login as user x */ $dbData = $app->db->queryOneRecord( - "SELECT username, passwort FROM sys_user WHERE userid = " . $userId); + "SELECT username, passwort FROM sys_user WHERE userid = " . $userId); /* * Now generate the login-Form * TODO: move the login_as form to a template file -> themeability */ - - $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_login_as.lng'; -include($lng_file); - + +$lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_login_as.lng'; +include $lng_file; + echo '



    '.$wb['login_1_txt'].' ' . $dbData['username'] . '?
    diff --git a/interface/web/admin/remote_action_ispcupdate.php b/interface/web/admin/remote_action_ispcupdate.php index a72f9426f..e8c8b2441 100644 --- a/interface/web/admin/remote_action_ispcupdate.php +++ b/interface/web/admin/remote_action_ispcupdate.php @@ -29,8 +29,8 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //die('Function has been removed.'); -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -45,7 +45,7 @@ $app->tpl->setInclude('content_tpl', 'templates/remote_action_ispcupdate.htm'); //* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_remote_action.lng'; -include($lng_file); +include $lng_file; /* * We need a list of all Servers @@ -80,20 +80,20 @@ if (1 == 0 && isset($_POST['server_select'])) { } foreach ($servers as $serverId) { $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$serverId . ", " . - time() . ", " . - "'ispc_update', " . - "'', " . - "'pending', " . - "''" . - ")"; + "VALUES (". + (int)$serverId . ", " . + time() . ", " . + "'ispc_update', " . + "'', " . + "'pending', " . + "''" . + ")"; $app->db->query($sql); } $msg = $wb['action_scheduled']; } -$app->tpl->setVar('msg',$msg); +$app->tpl->setVar('msg', $msg); $app->tpl->setVar($wb); @@ -101,4 +101,4 @@ $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/remote_action_osupdate.php b/interface/web/admin/remote_action_osupdate.php index b0f287863..08925b069 100644 --- a/interface/web/admin/remote_action_osupdate.php +++ b/interface/web/admin/remote_action_osupdate.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -43,7 +43,7 @@ $app->tpl->setInclude('content_tpl', 'templates/remote_action_osupdate.htm'); //* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_remote_action.lng'; -include($lng_file); +include $lng_file; /* * We need a list of all Servers @@ -75,20 +75,20 @@ if (isset($_POST['server_select'])) { } foreach ($servers as $serverId) { $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$serverId . ", " . - time() . ", " . - "'os_update', " . - "'', " . - "'pending', " . - "''" . - ")"; + "VALUES (". + (int)$serverId . ", " . + time() . ", " . + "'os_update', " . + "'', " . + "'pending', " . + "''" . + ")"; $app->db->query($sql); } $msg = $wb['action_scheduled']; } -$app->tpl->setVar('msg',$msg); +$app->tpl->setVar('msg', $msg); $app->tpl->setVar($wb); @@ -96,4 +96,4 @@ $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/remote_user_del.php b/interface/web/admin/remote_user_del.php index 277910588..e3a383272 100644 --- a/interface/web/admin/remote_user_del.php +++ b/interface/web/admin/remote_user_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/remote_user.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -48,14 +48,15 @@ $app->auth->check_module_permissions('admin'); $app->uses('tpl,tform'); $app->load('tform_actions'); -// Create a class page_action that extends the tform_actions base class +// Create a class page_action that extends the tform_actions base class -class page_action extends tform_actions { +class page_action extends tform_actions { // Customisations for the page actions will be defined here - + } + $page = new page_action; $page->onDelete(); diff --git a/interface/web/admin/remote_user_edit.php b/interface/web/admin/remote_user_edit.php index a99e9837d..962aa5752 100644 --- a/interface/web/admin/remote_user_edit.php +++ b/interface/web/admin/remote_user_edit.php @@ -4,13 +4,13 @@ $tform_def_file = 'form/remote_user.tform.php'; // include the core configuration and application classes -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; // Check the module permissions and redirect if not allowed. -if(!stristr($_SESSION['s']['user']['modules'],'admin')) { - header('Location: ../index.php'); - die; +if(!stristr($_SESSION['s']['user']['modules'], 'admin')) { + header('Location: ../index.php'); + die; } // Disable this function in demo mode @@ -23,15 +23,15 @@ $app->load('tform_actions'); // Create a class page_action that extends the tform_actions base class class page_action extends tform_actions { - //* Customisations for the page actions will be defined here + //* Customisations for the page actions will be defined here function onShow() { global $app; - + // Translate the items, very bad trick... :( because the language file is not loaded yet when the form file gets parsed foreach($app->tform->formDef["tabs"]['remote_user']['fields']['remote_functions']['value'] as $key => $val) { $app->tform->formDef["tabs"]['remote_user']['fields']['remote_functions']['value'][$key] = $app->tform->lng($val).'
    '; } - + parent::onShow(); } diff --git a/interface/web/admin/remote_user_list.php b/interface/web/admin/remote_user_list.php index 90a92b517..1830ba562 100644 --- a/interface/web/admin/remote_user_list.php +++ b/interface/web/admin/remote_user_list.php @@ -1,15 +1,15 @@ auth->check_module_permissions('admin'); @@ -49,4 +49,4 @@ if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mo $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_config_edit.php b/interface/web/admin/server_config_edit.php index 2ebf0a177..a47118114 100644 --- a/interface/web/admin/server_config_edit.php +++ b/interface/web/admin/server_config_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/server_config.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -49,39 +49,39 @@ $app->uses('tpl,tform,tform_actions'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowEdit() { global $app, $conf; - + if($_SESSION["s"]["user"]["typ"] != 'admin') die('This function needs admin priveliges'); - + if($app->tform->errorMessage == '') { $app->uses('ini_parser,getconf'); - + $section = $this->active_tab; $server_id = $this->id; - - $this->dataRecord = $app->getconf->get_server_config($server_id,$section); + + $this->dataRecord = $app->getconf->get_server_config($server_id, $section); } - - $record = $app->tform->getHTML($this->dataRecord, $this->active_tab,'EDIT'); - + + $record = $app->tform->getHTML($this->dataRecord, $this->active_tab, 'EDIT'); + $record['id'] = $this->id; $app->tpl->setVar($record); } - + function onUpdateSave($sql) { - global $app,$conf; - + global $app, $conf; + if($_SESSION["s"]["user"]["typ"] != 'admin') die('This function needs admin priveliges'); $app->uses('ini_parser,getconf'); - + if($conf['demo_mode'] != true) { $section = $app->tform->getCurrentTab(); $server_id = $this->id; - + $server_config_array = $app->getconf->get_server_config($server_id); - + foreach($app->tform->formDef['tabs'][$section]['fields'] as $key => $field) { if ($field['formtype'] == 'CHECKBOX') { if($this->dataRecord[$key] == '') { @@ -90,18 +90,18 @@ class page_action extends tform_actions { } } } - - $server_config_array[$section] = $app->tform->encode($this->dataRecord,$section); + + $server_config_array[$section] = $app->tform->encode($this->dataRecord, $section); $server_config_str = $app->ini_parser->get_ini_string($server_config_array); - + $app->db->datalogUpdate('server', "config = '".$app->db->quote($server_config_str)."'", 'server_id', $server_id); } } - + } $app->tform_actions = new page_action; $app->tform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_config_list.php b/interface/web/admin/server_config_list.php index 5fc8ddb90..5a1d61517 100644 --- a/interface/web/admin/server_config_list.php +++ b/interface/web/admin/server_config_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -50,4 +50,4 @@ $app->uses('listform_actions'); $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_del.php b/interface/web/admin/server_del.php index d5b3b9639..c39b73238 100644 --- a/interface/web/admin/server_del.php +++ b/interface/web/admin/server_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/server.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -49,4 +49,4 @@ if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mo $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_edit.php b/interface/web/admin/server_edit.php index e71857687..c81c6ee8b 100644 --- a/interface/web/admin/server_edit.php +++ b/interface/web/admin/server_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/server.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -52,8 +52,8 @@ class page_action extends tform_actions { function onShowEnd() { global $app, $conf; - - // Getting Servers + + // Getting Servers $sql = "SELECT server_id,server_name FROM server WHERE server_id != $this->id ORDER BY server_name"; $mirror_servers = $app->db->queryAllRecords($sql); $mirror_server_select = ''; @@ -63,19 +63,19 @@ class page_action extends tform_actions { $mirror_server_select .= "\r\n"; } } - $app->tpl->setVar("mirror_server_id",$mirror_server_select); - + $app->tpl->setVar("mirror_server_id", $mirror_server_select); + parent::onShowEnd(); } - + function onSubmit() { global $app; - + //* We do not want to mirror the the server itself if($this->id == $this->dataRecord['mirror_server_id']) $this->dataRecord['mirror_server_id'] = 0; - + parent::onSubmit(); - + } } @@ -83,4 +83,4 @@ class page_action extends tform_actions { $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_ip_del.php b/interface/web/admin/server_ip_del.php index 1229958e3..e1df93483 100644 --- a/interface/web/admin/server_ip_del.php +++ b/interface/web/admin/server_ip_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/server_ip.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -48,4 +48,4 @@ $app->auth->check_module_permissions('admin'); $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_ip_edit.php b/interface/web/admin/server_ip_edit.php index baffa1467..be48434cc 100644 --- a/interface/web/admin/server_ip_edit.php +++ b/interface/web/admin/server_ip_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/server_ip.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -65,9 +65,10 @@ class page_action extends tform_actions { unset($rec); } } + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_ip_list.php b/interface/web/admin/server_ip_list.php index 939d41f34..29622428a 100644 --- a/interface/web/admin/server_ip_list.php +++ b/interface/web/admin/server_ip_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -51,4 +51,4 @@ $app->listform_actions->SQLOrderBy = "ORDER BY server_ip.server_id, server_ip.ip $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_list.php b/interface/web/admin/server_list.php index 985dac677..30ba12373 100644 --- a/interface/web/admin/server_list.php +++ b/interface/web/admin/server_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -48,4 +48,4 @@ $app->uses('listform_actions'); $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_php_del.php b/interface/web/admin/server_php_del.php index 9b6a6fed9..d9c7baf2d 100644 --- a/interface/web/admin/server_php_del.php +++ b/interface/web/admin/server_php_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/server_php.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -48,4 +48,4 @@ $app->auth->check_module_permissions('admin'); $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_php_edit.php b/interface/web/admin/server_php_edit.php index aeac62113..e88575eb9 100644 --- a/interface/web/admin/server_php_edit.php +++ b/interface/web/admin/server_php_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/server_php.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -65,9 +65,10 @@ class page_action extends tform_actions { unset($rec); } } + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/server_php_list.php b/interface/web/admin/server_php_list.php index bcd323bbe..7d69ab7d2 100644 --- a/interface/web/admin/server_php_list.php +++ b/interface/web/admin/server_php_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -51,4 +51,4 @@ $app->listform_actions->SQLOrderBy = "ORDER BY server_php.server_id, server_php. $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/software_package_del.php b/interface/web/admin/software_package_del.php index bd43b3409..ff9ab6e5b 100644 --- a/interface/web/admin/software_package_del.php +++ b/interface/web/admin/software_package_del.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -37,7 +37,7 @@ if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mo $software_update_inst_id = $app->functions->intval($_GET['software_update_inst_id']); -if($software_update_inst_id > 0) { +if($software_update_inst_id > 0) { $app->db->datalogDelete('software_update_inst', 'software_update_inst_id', $software_update_inst_id); //header('Location: admin/software_package_list.php'); die('HEADER_REDIRECT: admin/software_package_list.php'); @@ -50,4 +50,4 @@ if($software_update_inst_id > 0) { -?> \ No newline at end of file +?> diff --git a/interface/web/admin/software_package_edit.php b/interface/web/admin/software_package_edit.php index 27a40f26d..038f377e7 100644 --- a/interface/web/admin/software_package_edit.php +++ b/interface/web/admin/software_package_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/software_package.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -50,10 +50,10 @@ $app->uses('tpl,tform,tform_actions'); $app->load('tform_actions'); class page_action extends tform_actions { - + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/software_package_install.php b/interface/web/admin/software_package_install.php index f8381777f..6150709fe 100644 --- a/interface/web/admin/software_package_install.php +++ b/interface/web/admin/software_package_install.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -49,20 +49,20 @@ $message_ok = ''; //* verify the key if($package['package_installable'] == 'key' && $install_key != '') { - + $repo = $app->db->queryOneRecord("SELECT * FROM software_repo WHERE software_repo_id = ".$package['software_repo_id']); - + $client = new SoapClient(null, array('location' => $repo['repo_url'], - 'uri' => $repo['repo_url'])); - + 'uri' => $repo['repo_url'])); + $install_key_verified = $client->check_installable($package_name, $install_key, $repo['repo_username'], $repo['repo_password']); - + if($install_key_verified == false) { //$install_key = ''; $message_err = 'Verification of the key failed.'; } else { // Store the verified key into the database - $app->db->datalogUpdate('software_package', "package_key = '$install_key'", 'package_id',$package['package_id']); + $app->db->datalogUpdate('software_package', "package_key = '$install_key'", 'package_id', $package['package_id']); } } else { $message_ok = 'Please enter the software key for the package.'; @@ -73,64 +73,64 @@ if($install_server_id > 0 && $package_name != '' && ($package['package_installab $sql = "SELECT software_update_id, package_name, update_title FROM software_update WHERE type = 'full' AND package_name = '$package_name' ORDER BY v1 DESC, v2 DESC, v3 DESC, v4 DESC LIMIT 0,1"; $tmp = $app->db->queryOneRecord($sql); $software_update_id = $tmp['software_update_id']; - + //* if package requires a DB and there is no data for a db in config, then we create this data now if($package['package_requires_db'] == 'mysql') { $app->uses('ini_parser,getconf'); - + $package_config_array = array(); if(trim($package['package_config']) != '') { $package_config_array = $app->ini_parser->parse_ini_string(stripslashes($package['package_config'])); } - + if(!isset($package_config_array['mysql'])) { - $package_config_array['mysql'] = array( 'database_name' => 'ispapp'.$package['package_id'], - 'database_user' => 'ispapp'.$package['package_id'], - 'database_password' => md5(mt_rand()), - 'database_host' => 'localhost'); + $package_config_array['mysql'] = array( 'database_name' => 'ispapp'.$package['package_id'], + 'database_user' => 'ispapp'.$package['package_id'], + 'database_password' => md5(mt_rand()), + 'database_host' => 'localhost'); $package_config_str = $app->ini_parser->get_ini_string($package_config_array); $package['package_config'] = $package_config_str; - $app->db->datalogUpdate('software_package', "package_config = '".$app->db->quote($package_config_str)."'", 'package_id',$package['package_id']); + $app->db->datalogUpdate('software_package', "package_config = '".$app->db->quote($package_config_str)."'", 'package_id', $package['package_id']); } } - + //* If the packages requires a remote user if($package['package_remote_functions'] != '') { - + if(trim($package['package_config']) != '') { $package_config_array = $app->ini_parser->parse_ini_string(stripslashes($package['package_config'])); } - + if(!isset($package_config_array['remote_api'])) { $remote_user = 'ispapp'.$package['package_id']; $remote_password = md5(mt_rand()); $remote_functions = $app->db->quote($package['package_remote_functions']); - + $package_config_array['remote_api'] = array( - 'remote_hostname' => $_SERVER['HTTP_HOST'], - 'remote_user' => $remote_user, - 'remote_password' => $remote_password - ); + 'remote_hostname' => $_SERVER['HTTP_HOST'], + 'remote_user' => $remote_user, + 'remote_password' => $remote_password + ); $package_config_str = $app->ini_parser->get_ini_string($package_config_array); $package['package_config'] = $package_config_str; $remote_password_md5 = md5($remote_password); - $app->db->datalogUpdate('software_package', "package_config = '".$app->db->quote($package_config_str)."'", 'package_id',$package['package_id']); - + $app->db->datalogUpdate('software_package', "package_config = '".$app->db->quote($package_config_str)."'", 'package_id', $package['package_id']); + $sql = "INSERT INTO `remote_user` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `remote_username`, `remote_password`, `remote_functions`) VALUES (1, 1, 'riud', 'riud', '', '$remote_user', '$remote_password_md5', '$remote_functions');"; - + $app->db->query($sql); - + } - + } - + //* Add the record to start the install process $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$install_server_id', '$software_update_id','installing')"; $app->db->datalogInsert('software_update_inst', $insert_data, 'software_update_inst_id'); $message_ok = 'Starting package installation '."".$app->lng('next').""; - + } if(count($_POST) > 2 && $install_key == '') { @@ -147,17 +147,17 @@ if($package['package_installable'] == 'key' && !$install_key_verified) { // Loading the template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/software_package_install.htm'); +$app->tpl->setInclude('content_tpl', 'templates/software_package_install.htm'); -$app->tpl->setVar('message_ok',$message_ok); -$app->tpl->setVar('message_err',$message_err); -$app->tpl->setVar('insert_key',$insert_key); -$app->tpl->setVar('install_key',$install_key); -$app->tpl->setVar('package_name',$package_name); -$app->tpl->setVar('server_id',$install_server_id); +$app->tpl->setVar('message_ok', $message_ok); +$app->tpl->setVar('message_err', $message_err); +$app->tpl->setVar('insert_key', $insert_key); +$app->tpl->setVar('install_key', $install_key); +$app->tpl->setVar('package_name', $package_name); +$app->tpl->setVar('server_id', $install_server_id); -include_once('lib/lang/en_software_package_install.lng'); +include_once 'lib/lang/en_software_package_install.lng'; $app->tpl->setVar($wb); diff --git a/interface/web/admin/software_package_list.php b/interface/web/admin/software_package_list.php index af6887b66..e05ccc9f8 100644 --- a/interface/web/admin/software_package_list.php +++ b/interface/web/admin/software_package_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -43,14 +43,14 @@ $repos = $app->db->queryAllRecords("SELECT software_repo_id, repo_url, repo_user if(is_array($repos) && isset($_GET['action']) && $_GET['action'] == 'repoupdate' ) { foreach($repos as $repo) { $client = new SoapClient(null, array('location' => $repo['repo_url'], - 'uri' => $repo['repo_url'])); - + 'uri' => $repo['repo_url'])); + $packages = $client->get_packages($repo['repo_username'], $repo['repo_password']); if(is_array($packages)) { foreach($packages as $p) { $package_name = $app->db->quote($p['name']); $tmp = $app->db->queryOneRecord("SELECT package_id FROM software_package WHERE package_name = '$package_name'"); - + $package_title = $app->db->quote($p['title']); $package_description = $app->db->quote($p['description']); $software_repo_id = $app->functions->intval($repo['software_repo_id']); @@ -58,7 +58,7 @@ if(is_array($repos) && isset($_GET['action']) && $_GET['action'] == 'repoupdate' $package_installable = $app->db->quote($p['installable']); $package_requires_db = $app->db->quote($p['requires_db']); $package_remote_functions = $app->db->quote($p['remote_functions']); - + if(empty($tmp['package_id'])) { //$sql = "INSERT INTO software_package (software_repo_id, package_name, package_title, package_description,package_type,package_installable,package_requires_db) VALUES ($software_repo_id, '$package_name', '$package_title', '$package_description','$package_type','$package_installable','$package_requires_db')"; //$app->db->query($sql); @@ -70,53 +70,53 @@ if(is_array($repos) && isset($_GET['action']) && $_GET['action'] == 'repoupdate' //$app->db->query($sql); $update_data = "software_repo_id = $software_repo_id, package_title = '$package_title', package_description = '$package_description', package_type = '$package_type', package_installable = '$package_installable', package_requires_db = '$package_requires_db', package_remote_functions = '$package_remote_functions'"; //echo $update_data; - $app->db->datalogUpdate('software_package', $update_data, 'package_id',$tmp['package_id']); + $app->db->datalogUpdate('software_package', $update_data, 'package_id', $tmp['package_id']); } } } - - $packages = $app->db->queryAllRecords("SELECT software_package.package_name, v1, v2, v3, v4 FROM software_package LEFT JOIN software_update ON ( software_package.package_name = software_update.package_name ) GROUP BY package_name ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC"); - if(is_array($packages)) { - foreach($packages as $p) { - - $version = $p['v1'].'.'.$p['v2'].'.'.$p['v3'].'.'.$p['v4']; - $updates = $client->get_updates($p['package_name'], $version,$repo['repo_username'], $repo['repo_password']); - - if(is_array($updates)) { - foreach($updates as $u) { - - $version_array = explode('.',$u['version']); - $v1 = $app->functions->intval($version_array[0]); - $v2 = $app->functions->intval($version_array[1]); - $v3 = $app->functions->intval($version_array[2]); - $v4 = $app->functions->intval($version_array[3]); - - $package_name = $app->db->quote($u['package_name']); - $software_repo_id = $app->functions->intval($repo['software_repo_id']); - $update_url = $app->db->quote($u['url']); - $update_md5 = $app->db->quote($u['md5']); - $update_dependencies = (isset($u['dependencies']))?$app->db->quote($u['dependencies']):''; - $update_title = $app->db->quote($u['title']); - $type = $app->db->quote($u['type']); - - // Check that we do not have this update in the database yet - $sql = "SELECT * FROM software_update WHERE package_name = '$package_name' and v1 = '$v1' and v2 = '$v2' and v3 = '$v3' and v4 = '$v4'"; - $tmp = $app->db->queryOneRecord($sql); - if(!isset($tmp['software_update_id'])) { - // Insert the update in the datbase - //$sql = "INSERT INTO software_update (software_repo_id, package_name, update_url, update_md5, update_dependencies, update_title, v1, v2, v3, v4, type) - //VALUES ($software_repo_id, '$package_name', '$update_url', '$update_md5', '$update_dependencies', '$update_title', '$v1', '$v2', '$v3', '$v4', '$type')"; - //die($sql); - //$app->db->query($sql); - $insert_data = "(software_repo_id, package_name, update_url, update_md5, update_dependencies, update_title, v1, v2, v3, v4, type) + + $packages = $app->db->queryAllRecords("SELECT software_package.package_name, v1, v2, v3, v4 FROM software_package LEFT JOIN software_update ON ( software_package.package_name = software_update.package_name ) GROUP BY package_name ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC"); + if(is_array($packages)) { + foreach($packages as $p) { + + $version = $p['v1'].'.'.$p['v2'].'.'.$p['v3'].'.'.$p['v4']; + $updates = $client->get_updates($p['package_name'], $version, $repo['repo_username'], $repo['repo_password']); + + if(is_array($updates)) { + foreach($updates as $u) { + + $version_array = explode('.', $u['version']); + $v1 = $app->functions->intval($version_array[0]); + $v2 = $app->functions->intval($version_array[1]); + $v3 = $app->functions->intval($version_array[2]); + $v4 = $app->functions->intval($version_array[3]); + + $package_name = $app->db->quote($u['package_name']); + $software_repo_id = $app->functions->intval($repo['software_repo_id']); + $update_url = $app->db->quote($u['url']); + $update_md5 = $app->db->quote($u['md5']); + $update_dependencies = (isset($u['dependencies']))?$app->db->quote($u['dependencies']):''; + $update_title = $app->db->quote($u['title']); + $type = $app->db->quote($u['type']); + + // Check that we do not have this update in the database yet + $sql = "SELECT * FROM software_update WHERE package_name = '$package_name' and v1 = '$v1' and v2 = '$v2' and v3 = '$v3' and v4 = '$v4'"; + $tmp = $app->db->queryOneRecord($sql); + if(!isset($tmp['software_update_id'])) { + // Insert the update in the datbase + //$sql = "INSERT INTO software_update (software_repo_id, package_name, update_url, update_md5, update_dependencies, update_title, v1, v2, v3, v4, type) + //VALUES ($software_repo_id, '$package_name', '$update_url', '$update_md5', '$update_dependencies', '$update_title', '$v1', '$v2', '$v3', '$v4', '$type')"; + //die($sql); + //$app->db->query($sql); + $insert_data = "(software_repo_id, package_name, update_url, update_md5, update_dependencies, update_title, v1, v2, v3, v4, type) VALUES ($software_repo_id, '$package_name', '$update_url', '$update_md5', '$update_dependencies', '$update_title', '$v1', '$v2', '$v3', '$v4', '$type')"; $app->db->datalogInsert('software_update', $insert_data, 'software_update_id'); - } - - } - } - } - } + } + + } + } + } + } } } @@ -128,7 +128,7 @@ if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != $sql = "SELECT software_update_id, package_name, update_title FROM software_update WHERE type = 'full' AND package_name = '$package_name' ORDER BY v1 DESC, v2 DESC, v3 DESC, v4 DESC LIMIT 0,1"; $tmp = $app->db->queryOneRecord($sql); $software_update_id = $tmp['software_update_id']; - + $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installing')"; // $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installed')"; $app->db->datalogInsert('software_update_inst', $insert_data, 'software_update_inst_id'); @@ -141,7 +141,7 @@ if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != // Loading the template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/software_package_list.htm'); +$app->tpl->setInclude('content_tpl', 'templates/software_package_list.htm'); $servers = $app->db->queryAllRecords('SELECT server_id, server_name FROM server ORDER BY server_name'); @@ -152,13 +152,13 @@ if(is_array($packages) && count($packages) > 0) { foreach($servers as $s) { $inst = $app->db->queryOneRecord("SELECT * FROM software_update, software_update_inst WHERE software_update_inst.software_update_id = software_update.software_update_id AND software_update_inst.package_name = '".addslashes($p["package_name"])."' AND server_id = '".$s["server_id"]."'"); $version = $inst['v1'].'.'.$inst['v2'].'.'.$inst['v3'].'.'.$inst['v4']; - + if($inst['status'] == 'installed') { $installed_txt .= $s['server_name'].": ".$app->lng("Installed version $version")."
    "; - } elseif ($inst['status'] == 'installing') { - $installed_txt .= $s['server_name'].": ".$app->lng("Installation in progress")."
    "; - } elseif ($inst['status'] == 'failed') { - $installed_txt .= $s['server_name'].": ".$app->lng("Installation failed")."
    "; + } elseif ($inst['status'] == 'installing') { + $installed_txt .= $s['server_name'].": ".$app->lng("Installation in progress")."
    "; + } elseif ($inst['status'] == 'failed') { + $installed_txt .= $s['server_name'].": ".$app->lng("Installation failed")."
    "; } elseif ($inst['status'] == 'deleting') { $installed_txt .= $s['server_name'].": ".$app->lng("Deletion in progress")."
    "; } else { @@ -172,17 +172,17 @@ if(is_array($packages) && count($packages) > 0) { $packages[$key]['software_update_inst_id'] = intval($inst['software_update_inst_id']); $packages[$key]['installed'] = $installed_txt; } - $app->tpl->setVar('has_packages',1); + $app->tpl->setVar('has_packages', 1); } else { - $app->tpl->setVar('has_packages',0); + $app->tpl->setVar('has_packages', 0); } -$app->tpl->setLoop('records',$packages); +$app->tpl->setLoop('records', $packages); $language = (isset($_SESSION['s']['language']))?$_SESSION['s']['language']:$conf['language']; -include_once('lib/lang/'.$language.'_software_package_list.lng'); +include_once 'lib/lang/'.$language.'_software_package_list.lng'; $app->tpl->setVar($wb); @@ -190,4 +190,4 @@ $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/software_repo_del.php b/interface/web/admin/software_repo_del.php index a6522fa5b..b8effc1d5 100644 --- a/interface/web/admin/software_repo_del.php +++ b/interface/web/admin/software_repo_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/software_repo.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -49,4 +49,4 @@ if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mo $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/software_repo_edit.php b/interface/web/admin/software_repo_edit.php index 17902f152..2a6a4f422 100644 --- a/interface/web/admin/software_repo_edit.php +++ b/interface/web/admin/software_repo_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/software_repo.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -50,10 +50,10 @@ $app->uses('tpl,tform,tform_actions'); $app->load('tform_actions'); class page_action extends tform_actions { - + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/software_repo_list.php b/interface/web/admin/software_repo_list.php index 0c05490ba..b8afc8f9b 100644 --- a/interface/web/admin/software_repo_list.php +++ b/interface/web/admin/software_repo_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -49,4 +49,4 @@ $app->uses('listform_actions'); $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/software_update_list.php b/interface/web/admin/software_update_list.php index 682a644bc..9a1df8a37 100644 --- a/interface/web/admin/software_update_list.php +++ b/interface/web/admin/software_update_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -42,7 +42,7 @@ $updates_added = 0; $repos = $app->db->queryAllRecords("SELECT software_repo_id, repo_url, repo_username, repo_password FROM software_repo WHERE active = 'y'"); if(is_array($repos)) { foreach($repos as $repo) { - + /* SELECT software_package.package_name, v1, v2, v3, v4 FROM software_package @@ -51,26 +51,26 @@ if(is_array($repos)) { GROUP BY package_name ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC */ - + $client = new SoapClient(null, array('location' => $repo['repo_url'], - 'uri' => $repo['repo_url'])); - + 'uri' => $repo['repo_url'])); + $packages = $app->db->queryAllRecords("SELECT software_package.package_name, v1, v2, v3, v4 FROM software_package LEFT JOIN software_update ON ( software_package.package_name = software_update.package_name ) GROUP BY package_name ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC"); if(is_array($packages)) { foreach($packages as $p) { - + $version = $p['v1'].'.'.$p['v2'].'.'.$p['v3'].'.'.$p['v4']; - $updates = $client->get_updates($p['package_name'], $version,$repo['repo_username'], $repo['repo_password']); - + $updates = $client->get_updates($p['package_name'], $version, $repo['repo_username'], $repo['repo_password']); + if(is_array($updates)) { foreach($updates as $u) { - - $version_array = explode('.',$u['version']); + + $version_array = explode('.', $u['version']); $v1 = $app->functions->intval($version_array[0]); $v2 = $app->functions->intval($version_array[1]); $v3 = $app->functions->intval($version_array[2]); $v4 = $app->functions->intval($version_array[3]); - + $package_name = $app->db->quote($u['package_name']); $software_repo_id = $app->functions->intval($repo['software_repo_id']); $update_url = $app->db->quote($u['url']); @@ -78,18 +78,18 @@ if(is_array($repos)) { $update_dependencies = (isset($u['dependencies']))?$app->db->quote($u['dependencies']):''; $update_title = $app->db->quote($u['title']); $type = $app->db->quote($u['type']); - + // Check that we do not have this update in the database yet $sql = "SELECT * FROM software_update WHERE package_name = '$package_name' and v1 = '$v1' and v2 = '$v2' and v3 = '$v3' and v4 = '$v4'"; $tmp = $app->db->queryOneRecord($sql); if(!isset($tmp['software_update_id'])) { // Insert the update in the datbase - $sql = "INSERT INTO software_update (software_repo_id, package_name, update_url, update_md5, update_dependencies, update_title, v1, v2, v3, v4, type) + $sql = "INSERT INTO software_update (software_repo_id, package_name, update_url, update_md5, update_dependencies, update_title, v1, v2, v3, v4, type) VALUES ($software_repo_id, '$package_name', '$update_url', '$update_md5', '$update_dependencies', '$update_title', '$v1', '$v2', '$v3', '$v4', '$type')"; //die($sql); $app->db->query($sql); } - + } } } @@ -103,11 +103,11 @@ if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != $package_name = $app->db->quote($_GET['package']); $server_id = $app->functions->intval($_GET['server_id']); $software_update_id = $app->functions->intval($_GET['id']); - + $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installing')"; // $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('$package_name', '$server_id', '$software_update_id','installed')"; $app->db->datalogInsert('software_update_inst', $insert_data, 'software_update_inst_id'); - + } @@ -116,7 +116,7 @@ if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != // Loading the template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/software_update_list.htm'); +$app->tpl->setInclude('content_tpl', 'templates/software_update_list.htm'); /* SELECT software_package.package_name, software_package.package_title, software_update.update_title, v1, v2, v3, v4, software_update_inst.status @@ -144,7 +144,7 @@ foreach($servers as $key => $server) { } } -$app->tpl->setLoop('servers',$servers); +$app->tpl->setLoop('servers', $servers); $sql = "SELECT v1, v2, v3, v4, software_update.update_title, software_update.software_update_id, software_update.package_name, v1, v2, v3, v4, software_update_inst.status FROM software_update LEFT JOIN software_update_inst ON ( software_update.software_update_id = software_update_inst.software_update_id ) @@ -159,25 +159,25 @@ $records_out = array(); if(is_array($installed_packages)) { foreach($installed_packages as $ip) { - + // Get version number of the latest installed version $sql = "SELECT v1, v2, v3, v4 FROM software_update, software_update_inst WHERE software_update.software_update_id = software_update_inst.software_update_id AND server_id = ".$server_id." ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC LIMIT 0,1"; $lu = $app->db->queryOneRecord($sql); - + // Get all installable updates $sql = "SELECT * FROM software_update WHERE v1 >= $lu[v1] AND v2 >= $lu[v2] AND v3 >= $lu[v3] AND v4 >= $lu[v4] AND package_name = '$ip[package_name]' ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC"; $updates = $app->db->queryAllRecords($sql); //die($sql); - + if(is_array($updates)) { // Delete the last record as it is already installed unset($updates[count($updates)-1]); - + foreach($updates as $key => $u) { $version = $u['v1'].'.'.$u['v2'].'.'.$u['v3'].'.'.$u['v4']; $installed_txt = "Install Update
    "; $records_out[] = array('version' => $version, 'update_title' => $u["update_title"], 'installed' => $installed_txt); - + } } } @@ -193,7 +193,7 @@ $updates = $app->db->queryAllRecords('SELECT software_update.update_title, softw if(is_array($updates)) { foreach($updates as $key => $u) { $installed_txt = ''; - + $version = $u['v1'].'.'.$u['v2'].'.'.$u['v3'].'.'.$u['v4']; $updates[$key]['version'] = $version; if($u['status'] == 'installed' || $u['status'] == 'installing' || $u['status'] == 'deleting') { @@ -202,17 +202,17 @@ if(is_array($updates)) { $installed_txt .= "Install now
    "; } $updates[$key]['installed'] = $installed_txt; - + } } */ -$app->tpl->setLoop('records',$records_out); +$app->tpl->setLoop('records', $records_out); $language = (isset($_SESSION['s']['language']))?$_SESSION['s']['language']:$conf['language']; -include_once('lib/lang/'.$language.'_software_update_list.lng'); +include_once 'lib/lang/'.$language.'_software_update_list.lng'; $app->tpl->setVar($wb); @@ -220,4 +220,4 @@ $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/system_config_edit.php b/interface/web/admin/system_config_edit.php index c2702c78f..d267c8eea 100644 --- a/interface/web/admin/system_config_edit.php +++ b/interface/web/admin/system_config_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/system_config.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -54,15 +54,15 @@ class page_action extends tform_actions { function onShowEdit() { global $app, $conf; - + if($_SESSION["s"]["user"]["typ"] != 'admin') die('This function needs admin priveliges'); - + if($app->tform->errorMessage == '') { $app->uses('ini_parser,getconf'); - + $section = $this->active_tab; $server_id = $this->id; - + $this->dataRecord = $app->getconf->get_global_config($section); if ($section == 'domains'){ if (isset($this->dataRecord['use_domain_module'])){ @@ -70,61 +70,61 @@ class page_action extends tform_actions { } } } - - $record = $app->tform->getHTML($this->dataRecord, $this->active_tab,'EDIT'); - + + $record = $app->tform->getHTML($this->dataRecord, $this->active_tab, 'EDIT'); + $record['warning'] = $app->tform->lng('warning'); $record['id'] = $this->id; $app->tpl->setVar($record); } - + function onShowEnd() { global $app, $conf; - + // available dashlets $available_dashlets_txt = ''; - $handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); - while ($file = @readdir ($handle)) { + $handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); + while ($file = @readdir($handle)) { if ($file != '.' && $file != '..' && !is_dir($file)) { - $available_dashlets_txt .= '['.substr($file,0,-4).'] '; + $available_dashlets_txt .= '['.substr($file, 0, -4).'] '; } } - + if($available_dashlets_txt == '') $available_dashlets_txt = '------'; - $app->tpl->setVar("available_dashlets_txt",$available_dashlets_txt); - + $app->tpl->setVar("available_dashlets_txt", $available_dashlets_txt); + parent::onShowEnd(); } - - function onSubmit() { - global $app; - - $app->uses('ini_parser,getconf'); - - $section = $app->tform->getCurrentTab(); - + + function onSubmit() { + global $app; + + $app->uses('ini_parser,getconf'); + + $section = $app->tform->getCurrentTab(); + $server_config_array = $app->getconf->get_global_config(); - $new_config = $app->tform->encode($this->dataRecord,$section); - if($section == 'mail') { - if($new_config['smtp_pass'] == '') $new_config['smtp_pass'] = $server_config_array['smtp_pass']; - if($new_config['smtp_enabled'] == 'y' && ($new_config['admin_mail'] == '' || $new_config['admin_name'] == '')) { - $app->tform->errorMessage .= $app->tform->lng("smtp_missing_admin_mail_txt"); - } - } - - parent::onSubmit(); - } - + $new_config = $app->tform->encode($this->dataRecord, $section); + if($section == 'mail') { + if($new_config['smtp_pass'] == '') $new_config['smtp_pass'] = $server_config_array['smtp_pass']; + if($new_config['smtp_enabled'] == 'y' && ($new_config['admin_mail'] == '' || $new_config['admin_name'] == '')) { + $app->tform->errorMessage .= $app->tform->lng("smtp_missing_admin_mail_txt"); + } + } + + parent::onSubmit(); + } + function onUpdateSave($sql) { - global $app,$conf; - + global $app, $conf; + if($_SESSION["s"]["user"]["typ"] != 'admin') die('This function needs admin priveliges'); $app->uses('ini_parser,getconf'); - + $section = $app->tform->getCurrentTab(); - + $server_config_array = $app->getconf->get_global_config(); - + foreach($app->tform->formDef['tabs'][$section]['fields'] as $key => $field) { if ($field['formtype'] == 'CHECKBOX') { if($this->dataRecord[$key] == '') { @@ -133,26 +133,26 @@ class page_action extends tform_actions { } } } - + /* if((isset($this->dataRecord['use_loadindicator']) && $this->dataRecord['use_loadindicator'] != $server_config_array[$section]['use_loadindicator']) || (isset($this->dataRecord['use_combobox']) && $this->dataRecord['use_combobox'] != $server_config_array[$section]['use_combobox'])){ $this->_js_changed = true; } */ - $new_config = $app->tform->encode($this->dataRecord,$section); - if($section == 'sites' && $new_config['vhost_subdomains'] != 'y' && $server_config_array['vhost_subdomains'] == 'y') { - // check for existing vhost subdomains, if found the mode cannot be disabled - $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain'"); - if($check['cnt'] > 0) { - $new_config['vhost_subdomains'] = 'y'; - } - } elseif($section == 'mail') { - if($new_config['smtp_pass'] == '') $new_config['smtp_pass'] = $server_config_array['smtp_pass']; - } - $server_config_array[$section] = $new_config; + $new_config = $app->tform->encode($this->dataRecord, $section); + if($section == 'sites' && $new_config['vhost_subdomains'] != 'y' && $server_config_array['vhost_subdomains'] == 'y') { + // check for existing vhost subdomains, if found the mode cannot be disabled + $check = $app->db->queryOneRecord("SELECT COUNT(*) as `cnt` FROM `web_domain` WHERE `type` = 'vhostsubdomain'"); + if($check['cnt'] > 0) { + $new_config['vhost_subdomains'] = 'y'; + } + } elseif($section == 'mail') { + if($new_config['smtp_pass'] == '') $new_config['smtp_pass'] = $server_config_array['smtp_pass']; + } + $server_config_array[$section] = $new_config; $server_config_str = $app->ini_parser->get_ini_string($server_config_array); - + //$sql = "UPDATE sys_ini SET config = '".$app->db->quote($server_config_str)."' WHERE sysini_id = 1"; //if($conf['demo_mode'] != true) $app->db->query($sql); if($conf['demo_mode'] != true) $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($server_config_str)."'", 'sysini_id', 1); @@ -161,9 +161,9 @@ class page_action extends tform_actions { * If we should use the domain-module, we have to insert all existing domains into the table * (only the first time!) */ - if (($section == 'domains') && - ($_SESSION['use_domain_module_old_value'] == '') && - ($server_config_array['domains']['use_domain_module'] == 'y')){ + if (($section == 'domains') && + ($_SESSION['use_domain_module_old_value'] == '') && + ($server_config_array['domains']['use_domain_module'] == 'y')){ $sql = "REPLACE INTO domain (sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain ) " . "SELECT sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, domain " . "FROM mail_domain"; @@ -173,7 +173,7 @@ class page_action extends tform_actions { "FROM web_domain WHERE type NOT IN ('subdomain','vhostsubdomain')"; $app->db->query($sql); } - + // Maintenance mode if($server_config_array['misc']['maintenance_mode'] == 'y'){ //print_r($_SESSION); @@ -181,7 +181,7 @@ class page_action extends tform_actions { $app->db->query("DELETE FROM sys_session WHERE session_id != '".$_SESSION['s']['id']."'"); } } - + /* function onAfterUpdate() { if($this->_js_changed == true) { @@ -192,11 +192,11 @@ class page_action extends tform_actions { } } */ - + } $app->tform_actions = new page_action; $app->tform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/tpl_default.php b/interface/web/admin/tpl_default.php index 80de37b8e..b9477f1e3 100644 --- a/interface/web/admin/tpl_default.php +++ b/interface/web/admin/tpl_default.php @@ -38,8 +38,8 @@ $tform_def_file = "form/tpl_default.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -50,24 +50,24 @@ $app->load('tform_actions'); class page_action extends tform_actions { -// function onBeforeUpdate() { -// global $app, $conf; -// -// //* Check if the server has been changed -// // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway -// if(($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) && isset($this->dataRecord["server_id"])) { -// $rec = $app->db->queryOneRecord("SELECT server_id from server_php WHERE server_php_id = ".$this->id); -// if($rec['server_id'] != $this->dataRecord["server_id"]) { -// //* Add a error message and switch back to old server -// $app->tform->errorMessage .= $app->lng('The Server can not be changed.'); -// $this->dataRecord["server_id"] = $rec['server_id']; -// } -// unset($rec); -// } -// } + // function onBeforeUpdate() { + // global $app, $conf; + // + // //* Check if the server has been changed + // // We do this only for the admin or reseller users, as normal clients can not change the server ID anyway + // if(($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) && isset($this->dataRecord["server_id"])) { + // $rec = $app->db->queryOneRecord("SELECT server_id from server_php WHERE server_php_id = ".$this->id); + // if($rec['server_id'] != $this->dataRecord["server_id"]) { + // //* Add a error message and switch back to old server + // $app->tform->errorMessage .= $app->lng('The Server can not be changed.'); + // $this->dataRecord["server_id"] = $rec['server_id']; + // } + // unset($rec); + // } + // } } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/users_del.php b/interface/web/admin/users_del.php index dfea88974..299eed275 100644 --- a/interface/web/admin/users_del.php +++ b/interface/web/admin/users_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/users.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -49,4 +49,4 @@ if($conf['demo_mode'] == true && $_REQUEST['id'] <= 3) $app->error('This functio $app->uses("tform_actions"); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/users_edit.php b/interface/web/admin/users_edit.php index 487be72ce..d94ef6124 100644 --- a/interface/web/admin/users_edit.php +++ b/interface/web/admin/users_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/users.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('admin'); @@ -49,33 +49,33 @@ $app->uses('tpl,tform,tform_actions'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onBeforeInsert() { global $app, $conf; - - if(!in_array($this->dataRecord['startmodule'],$this->dataRecord['modules'])) { + + if(!in_array($this->dataRecord['startmodule'], $this->dataRecord['modules'])) { $app->tform->errorMessage .= $app->tform->wordbook['startmodule_err']; } } - + function onBeforeUpdate() { global $app, $conf; - + if($conf['demo_mode'] == true && $_REQUEST['id'] <= 3) $app->error('This function is disabled in demo mode.'); - - if(@is_array($this->dataRecord['modules']) && !in_array($this->dataRecord['startmodule'],$this->dataRecord['modules'])) { + + if(@is_array($this->dataRecord['modules']) && !in_array($this->dataRecord['startmodule'], $this->dataRecord['modules'])) { $app->tform->errorMessage .= $app->tform->wordbook['startmodule_err']; } $this->oldDataRecord = $app->tform->getDataRecord($this->id); } - + /* This function is called automatically right after the data was successful updated in the database. */ function onAfterUpdate() { global $app, $conf; - + $client = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = ".$this->id); $client_id = $client['client_id']; $username = $app->db->quote($this->dataRecord["username"]); @@ -89,28 +89,28 @@ class page_action extends tform_actions { $app->db->datalogUpdate("sys_group", "name = '$username'", 'groupid', $tmp['groupid']); unset($tmp); } - + // password changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord["passwort"]) && $this->dataRecord["passwort"] != '') { $password = $app->db->quote($this->dataRecord["passwort"]); $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n=0;$n<8;$n++) { - $salt.=$base64_alphabet[mt_rand(0,63)]; + $salt.=$base64_alphabet[mt_rand(0, 63)]; } $salt.="$"; - $password = crypt(stripslashes($password),$salt); + $password = crypt(stripslashes($password), $salt); $sql = "UPDATE client SET password = '$password' WHERE client_id = $client_id AND username = '$username'"; $app->db->query($sql); } - + // language changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['language']) && $this->dataRecord['language'] != '' && $this->oldDataRecord['language'] != $this->dataRecord['language']) { $language = $app->db->quote($this->dataRecord["language"]); $sql = "UPDATE client SET language = '$language' WHERE client_id = $client_id AND username = '$username'"; $app->db->query($sql); } - + // reseller status changed /* if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) { @@ -130,4 +130,4 @@ class page_action extends tform_actions { $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/admin/users_list.php b/interface/web/admin/users_list.php index 412d4fa56..1f8325892 100644 --- a/interface/web/admin/users_list.php +++ b/interface/web/admin/users_list.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -49,4 +49,4 @@ $app->listform_actions->SQLOrderBy = 'ORDER BY sys_user.username'; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/capp.php b/interface/web/capp.php index 7917aa0bb..2c143180f 100644 --- a/interface/web/capp.php +++ b/interface/web/capp.php @@ -28,8 +28,8 @@ 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'); +require_once '../lib/config.inc.php'; +require_once '../lib/app.inc.php'; //* Import module variable $mod = $_REQUEST["mod"]; @@ -45,28 +45,28 @@ if($_SESSION["s"]["user"]['active'] != 1) { if(!preg_match("/^[a-z]{2,20}$/i", $mod)) die('module name contains unallowed chars.'); //* Check if user may use the module. -$user_modules = explode(",",$_SESSION["s"]["user"]["modules"]); +$user_modules = explode(",", $_SESSION["s"]["user"]["modules"]); -if(!in_array($mod,$user_modules)) $app->error($app->lng(301)); +if(!in_array($mod, $user_modules)) $app->error($app->lng(301)); //* Load module configuration into the session. if(is_file($mod."/lib/module.conf.php")) { - include_once($mod."/lib/module.conf.php"); - - $menu_dir = ISPC_WEB_PATH.'/' . $mod . '/lib/menu.d'; + include_once $mod."/lib/module.conf.php"; - if (is_dir($menu_dir)) { - if ($dh = opendir($menu_dir)) { - //** Go through all files in the menu dir - while (($file = readdir($dh)) !== false) { - if ($file != '.' && $file != '..' && substr($file, -9, 9) == '.menu.php' && $file != 'dns_resync.menu.php') { - include_once($menu_dir . '/' . $file); - } - } - } - } - - $_SESSION["s"]["module"] = $module; + $menu_dir = ISPC_WEB_PATH.'/' . $mod . '/lib/menu.d'; + + if (is_dir($menu_dir)) { + if ($dh = opendir($menu_dir)) { + //** Go through all files in the menu dir + while (($file = readdir($dh)) !== false) { + if ($file != '.' && $file != '..' && substr($file, -9, 9) == '.menu.php' && $file != 'dns_resync.menu.php') { + include_once $menu_dir . '/' . $file; + } + } + } + } + + $_SESSION["s"]["module"] = $module; session_write_close(); if($redirect == ''){ echo "HEADER_REDIRECT:".$_SESSION["s"]["module"]["startpage"]; @@ -77,4 +77,4 @@ if(is_file($mod."/lib/module.conf.php")) { } else { $app->error($app->lng(302)); } -?> \ No newline at end of file +?> diff --git a/interface/web/client/client_circle_del.php b/interface/web/client/client_circle_del.php index 5764eb52c..702d54721 100644 --- a/interface/web/client/client_circle_del.php +++ b/interface/web/client/client_circle_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/client_circle.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); diff --git a/interface/web/client/client_circle_edit.php b/interface/web/client/client_circle_edit.php index 407efba55..679b8023a 100644 --- a/interface/web/client/client_circle_edit.php +++ b/interface/web/client/client_circle_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/client_circle.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); diff --git a/interface/web/client/client_circle_list.php b/interface/web/client/client_circle_list.php index f37da3871..94c6d164e 100644 --- a/interface/web/client/client_circle_list.php +++ b/interface/web/client/client_circle_list.php @@ -1,6 +1,6 @@ listform_actions->SQLOrderBy = 'ORDER BY client_circle.circle_name, client $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/client/client_del.php b/interface/web/client/client_del.php index ecee8f5b6..a8cd7cc95 100644 --- a/interface/web/client/client_del.php +++ b/interface/web/client/client_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/client.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -50,90 +50,90 @@ $app->uses('tpl,tform'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onDelete() { - global $app, $conf,$list_def_file,$tform_def_file; - + global $app, $conf, $list_def_file, $tform_def_file; + // Loading tform framework - if(!is_object($app->tform)) $app->uses('tform'); - + if(!is_object($app->tform)) $app->uses('tform'); + if($_POST["confirm"] == 'yes') { parent::onDelete(); } else { - - $app->uses('tpl'); - $app->tpl->newTemplate("form.tpl.htm"); - $app->tpl->setInclude('content_tpl', 'templates/client_del.htm'); - - include_once($list_def_file); - - // Load table definition from file - $app->tform->loadFormDef($tform_def_file); - - $this->id = $app->functions->intval($_REQUEST["id"]); - - $this->dataRecord = $app->tform->getDataRecord($this->id); - $client_id = $app->functions->intval($this->dataRecord['client_id']); - - //$parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']); - //$parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id"); - $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id"); - - // Get all records (sub-clients, mail, web, etc....) of this client. - $tables = 'cron,client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain'; - $tables_array = explode(',',$tables); - $client_group_id = $app->functions->intval($client_group['groupid']); - - $table_list = array(); - if($client_group_id > 1) { - foreach($tables_array as $table) { - if($table != '') { - $records = $app->db->queryAllRecords("SELECT * FROM $table WHERE sys_groupid = ".$client_group_id); - $number = count($records); - if($number > 0) $table_list[] = array('table' => $table."(".$number.")"); + $app->uses('tpl'); + $app->tpl->newTemplate("form.tpl.htm"); + $app->tpl->setInclude('content_tpl', 'templates/client_del.htm'); + + include_once $list_def_file; + + // Load table definition from file + $app->tform->loadFormDef($tform_def_file); + + $this->id = $app->functions->intval($_REQUEST["id"]); + + $this->dataRecord = $app->tform->getDataRecord($this->id); + $client_id = $app->functions->intval($this->dataRecord['client_id']); + + + //$parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']); + //$parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id"); + $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id"); + + // Get all records (sub-clients, mail, web, etc....) of this client. + $tables = 'cron,client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain'; + $tables_array = explode(',', $tables); + $client_group_id = $app->functions->intval($client_group['groupid']); + + $table_list = array(); + if($client_group_id > 1) { + foreach($tables_array as $table) { + if($table != '') { + $records = $app->db->queryAllRecords("SELECT * FROM $table WHERE sys_groupid = ".$client_group_id); + $number = count($records); + if($number > 0) $table_list[] = array('table' => $table."(".$number.")"); + } } } - } - - $app->tpl->setVar('id',$this->id); - $app->tpl->setVar('number_records',$number); - $app->tpl->setLoop('records', $table_list); - - //* load language file - $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_client_del.lng'; - include($lng_file); - $app->tpl->setVar($wb); - - $app->tpl_defaults(); - $app->tpl->pparse(); + + $app->tpl->setVar('id', $this->id); + $app->tpl->setVar('number_records', $number); + $app->tpl->setLoop('records', $table_list); + + //* load language file + $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_client_del.lng'; + include $lng_file; + $app->tpl->setVar($wb); + + $app->tpl_defaults(); + $app->tpl->pparse(); } } - - - - + + + + function onBeforeDelete() { global $app, $conf; - + $client_id = $app->functions->intval($this->dataRecord['client_id']); - - if($client_id > 0) { + + if($client_id > 0) { // remove the group of the client from the resellers group $parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']); $parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id"); $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id"); - $app->auth->remove_group_from_user($parent_user['userid'],$client_group['groupid']); - + $app->auth->remove_group_from_user($parent_user['userid'], $client_group['groupid']); + // delete the group of the client $app->db->query("DELETE FROM sys_group WHERE client_id = $client_id"); - + // delete the sys user(s) of the client $app->db->query("DELETE FROM sys_user WHERE client_id = $client_id"); - + // Delete all records (sub-clients, mail, web, etc....) of this client. $tables = 'client,dns_rr,dns_soa,dns_slave,ftp_user,mail_access,mail_content_filter,mail_domain,mail_forwarding,mail_get,mail_user,mail_user_filter,shell_user,spamfilter_users,support_message,web_database,web_database_user,web_domain,web_folder,web_folder_user,domain'; - $tables_array = explode(',',$tables); + $tables_array = explode(',', $tables); $client_group_id = $app->functions->intval($client_group['groupid']); if($client_group_id > 1) { foreach($tables_array as $table) { @@ -161,16 +161,17 @@ class page_action extends tform_actions { } } } - + } } } - - - + + + } - + } + } $page = new page_action; diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index ab33d9e12..3fa783774 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/client.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -49,18 +49,18 @@ $app->uses('tpl,tform,tform_actions'); $app->load('tform_actions'); class page_action extends tform_actions { - var $_template_additional = array(); - + var $_template_additional = array(); + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another website. if($client["limit_client"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id"); @@ -69,21 +69,21 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - - + + function onSubmit() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user' && $this->id == 0) { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another website. if($client["limit_client"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id"); @@ -92,28 +92,28 @@ class page_action extends tform_actions { } } } - - if($this->id != 0) { - $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $this->id); - if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) { - // check previous type of storing templates - $tpls = explode('/', $this->oldDataRecord['template_additional']); - $this->oldTemplatesAssigned = array(); - foreach($tpls as $item) { - $item = trim($item); - if(!$item) continue; - $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $this->id); - } - unset($tpls); - } - } else { - $this->oldTemplatesAssigned = array(); - } - - $this->_template_additional = explode('/', $this->dataRecord['template_additional']); - $this->dataRecord['template_additional'] = ''; - - parent::onSubmit(); + + if($this->id != 0) { + $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $this->id); + if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) { + // check previous type of storing templates + $tpls = explode('/', $this->oldDataRecord['template_additional']); + $this->oldTemplatesAssigned = array(); + foreach($tpls as $item) { + $item = trim($item); + if(!$item) continue; + $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $this->id); + } + unset($tpls); + } + } else { + $this->oldTemplatesAssigned = array(); + } + + $this->_template_additional = explode('/', $this->dataRecord['template_additional']); + $this->dataRecord['template_additional'] = ''; + + parent::onSubmit(); } function onShowEnd() { @@ -128,54 +128,54 @@ class page_action extends tform_actions { $option .= ''; $tpl[$item['template_id']] = $item['template_name']; } - $app->tpl->setVar('tpl_add_select',$option); - - // check for new-style records - $result = $app->db->queryAllRecords('SELECT assigned_template_id, client_template_id FROM client_template_assigned WHERE client_id = ' . $this->id); - if($result && count($result) > 0) { - // new style - $items = array(); - $text = ''; - foreach($result as $item){ - if (trim($item['client_template_id']) != ''){ - if ($text != '') $text .= ''; - $text .= '
  • ' . $tpl[$item['client_template_id']]; - $text .= ''; - $tmp = new stdClass(); - $tmp->id = $item['assigned_template_id']; - $tmp->data = ''; - $app->plugin->raiseEvent('get_client_template_details', $tmp); - if($tmp->data != '') $text .= '
    ' . $tmp->data . ''; - - $text .= '
  • '; - $items[] = $item['assigned_template_id'] . ':' . $item['client_template_id']; - } - } - - $tmprec = $app->tform->getHTML(array('template_additional' => implode('/', $items)), $this->active_tab, 'EDIT'); - $app->tpl->setVar('template_additional', $tmprec['template_additional']); - unset($tmprec); - } else { - // old style - $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id; - $result = $app->db->queryOneRecord($sql); - $tplAdd = explode("/", $result['template_additional']); - $text = ''; - foreach($tplAdd as $item){ - if (trim($item) != ''){ - if ($text != '') $text .= ''; - $text .= '
  • ' . $tpl[$item]. '
  • '; - } - } - } + $app->tpl->setVar('tpl_add_select', $option); + + // check for new-style records + $result = $app->db->queryAllRecords('SELECT assigned_template_id, client_template_id FROM client_template_assigned WHERE client_id = ' . $this->id); + if($result && count($result) > 0) { + // new style + $items = array(); + $text = ''; + foreach($result as $item){ + if (trim($item['client_template_id']) != ''){ + if ($text != '') $text .= ''; + $text .= '
  • ' . $tpl[$item['client_template_id']]; + $text .= ''; + $tmp = new stdClass(); + $tmp->id = $item['assigned_template_id']; + $tmp->data = ''; + $app->plugin->raiseEvent('get_client_template_details', $tmp); + if($tmp->data != '') $text .= '
    ' . $tmp->data . ''; + + $text .= '
  • '; + $items[] = $item['assigned_template_id'] . ':' . $item['client_template_id']; + } + } + + $tmprec = $app->tform->getHTML(array('template_additional' => implode('/', $items)), $this->active_tab, 'EDIT'); + $app->tpl->setVar('template_additional', $tmprec['template_additional']); + unset($tmprec); + } else { + // old style + $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id; + $result = $app->db->queryOneRecord($sql); + $tplAdd = explode("/", $result['template_additional']); + $text = ''; + foreach($tplAdd as $item){ + if (trim($item) != ''){ + if ($text != '') $text .= ''; + $text .= '
  • ' . $tpl[$item]. '
  • '; + } + } + } $app->tpl->setVar('template_additional_list', $text); - $app->tpl->setVar('app_module','client'); + $app->tpl->setVar('app_module', 'client'); parent::onShowEnd(); } - + /* This function is called automatically right after the data was successful inserted in the database. @@ -185,36 +185,36 @@ class page_action extends tform_actions { // Create the group for the client $groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('".$app->db->quote($this->dataRecord["username"])."','',".$this->id.")", 'groupid'); $groups = $groupid; - + $username = $app->db->quote($this->dataRecord["username"]); $password = $app->db->quote($this->dataRecord["password"]); $modules = $conf['interface_modules_enabled']; if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] > 0) $modules .= ',client'; - $startmodule = (stristr($modules,'dashboard'))?'dashboard':'client'; + $startmodule = (stristr($modules, 'dashboard'))?'dashboard':'client'; $usertheme = $app->db->quote($this->dataRecord["usertheme"]); $type = 'user'; $active = 1; $language = $app->db->quote($this->dataRecord["language"]); $password = $app->auth->crypt_password($password); - + // Create the controlpaneluser for the client //Generate ssh-rsa-keys exec('ssh-keygen -t rsa -C '.$username.'-rsa-key-'.time().' -f /tmp/id_rsa -N ""'); $app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".$app->db->quote(@file_get_contents('/tmp/id_rsa'))."', ssh_rsa = '".$app->db->quote(@file_get_contents('/tmp/id_rsa.pub'))."' WHERE client_id = ".$this->id); exec('rm -f /tmp/id_rsa /tmp/id_rsa.pub'); - + // Create the controlpaneluser for the client $sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id) VALUES ('$username','$password','$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,".$this->id.")"; $app->db->query($sql); - - //* If the user who inserted the client is a reseller (not admin), we will have to add this new client group + + //* If the user who inserted the client is a reseller (not admin), we will have to add this new client group //* to his groups, so he can administrate the records of this client. if($_SESSION['s']['user']['typ'] == 'user') { - $app->auth->add_group_to_user($_SESSION['s']['user']['userid'],$groupid); + $app->auth->add_group_to_user($_SESSION['s']['user']['userid'], $groupid); $app->db->query("UPDATE client SET parent_client_id = ".$app->functions->intval($_SESSION['s']['user']['client_id'])." WHERE client_id = ".$this->id); } - + //* Set the default servers $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE mail_server = 1 AND mirror_server_id = 0 LIMIT 0,1'); $default_mailserver = $app->functions->intval($tmp['server_id']); @@ -224,19 +224,19 @@ class page_action extends tform_actions { $default_dnsserver = $app->functions->intval($tmp['server_id']); $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE db_server = 1 AND mirror_server_id = 0 LIMIT 0,1'); $default_dbserver = $app->functions->intval($tmp['server_id']); - + $sql = "UPDATE client SET default_mailserver = $default_mailserver, default_webserver = $default_webserver, default_dnsserver = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, default_dbserver = $default_dbserver WHERE client_id = ".$this->id; $app->db->query($sql); - - if(isset($this->dataRecord['template_master'])) { - $app->uses('client_templates'); - $app->client_templates->update_client_templates($this->id, $this->_template_additional); - } + + if(isset($this->dataRecord['template_master'])) { + $app->uses('client_templates'); + $app->client_templates->update_client_templates($this->id, $this->_template_additional); + } parent::onAfterInsert(); } - - + + /* This function is called automatically right after the data was successful updated in the database. @@ -249,120 +249,121 @@ class page_action extends tform_actions { $client_id = $this->id; $sql = "UPDATE sys_user SET username = '$username' WHERE client_id = $client_id"; $app->db->query($sql); - + $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = $client_id"); $app->db->datalogUpdate("sys_group", "name = '$username'", 'groupid', $tmp['groupid']); unset($tmp); } - + // password changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') { $password = $app->db->quote($this->dataRecord["password"]); $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n=0;$n<8;$n++) { - $salt.=$base64_alphabet[mt_rand(0,63)]; + $salt.=$base64_alphabet[mt_rand(0, 63)]; } $salt.="$"; - $password = crypt(stripslashes($password),$salt); + $password = crypt(stripslashes($password), $salt); $client_id = $this->id; $sql = "UPDATE sys_user SET passwort = '$password' WHERE client_id = $client_id"; $app->db->query($sql); } - - if(!isset($this->dataRecord['locked'])) $this->dataRecord['locked'] = 'n'; - if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["locked"] != $this->oldDataRecord['locked']) { - /** lock all the things like web, mail etc. - easy to extend */ - - // get tmp_data of client - $client_data = $app->db->queryOneRecord('SELECT `tmp_data` FROM `client` WHERE `client_id` = ' . $this->id); - - if($client_data['tmp_data'] == '') $tmp_data = array(); - else $tmp_data = unserialize($client_data['tmp_data']); - - if(!is_array($tmp_data)) $tmp_data = array(); - - // database tables with their primary key columns - $to_disable = array('cron' => 'id', - 'ftp_user' => 'ftp_user_id', - 'mail_domain' => 'domain_id', - 'mail_forwarding' => 'forwarding_id', - 'mail_get' => 'mailget_id', - 'openvz_vm' => 'vm_id', - 'shell_user' => 'shell_user_id', - 'webdav_user' => 'webdav_user_id', - 'web_database' => 'database_id', - 'web_domain' => 'domain_id', - 'web_folder' => 'web_folder_id', - 'web_folder_user' => 'web_folder_user_id' - ); - - $udata = $app->db->queryOneRecord('SELECT `userid` FROM `sys_user` WHERE `client_id` = ' . $this->id); - $gdata = $app->db->queryOneRecord('SELECT `groupid` FROM `sys_group` WHERE `client_id` = ' . $this->id); - $sys_groupid = $gdata['groupid']; - $sys_userid = $udata['userid']; - - $entries = array(); - if($this->dataRecord['locked'] == 'y') { - $prev_active = array(); - $prev_sysuser = array(); - foreach($to_disable as $current => $keycolumn) { - $prev_active[$current] = array(); - $prev_sysuser[$current] = array(); - - $entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id`, `sys_userid`, `active` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid); - foreach($entries as $item) { - - if($item['active'] != 'y') $prev_active[$current][$item['id']]['active'] = 'n'; - if($item['sys_userid'] != $sys_userid) $prev_sysuser[$current][$item['id']]['active'] = $item['sys_userid']; - // we don't have to store these if y, as everything without previous state gets enabled later - - $app->db->datalogUpdate($current, array('active' => 'n', 'sys_userid' => $_SESSION["s"]["user"]["userid"]), $keycolumn, $item['id']); - } - } - - $tmp_data['prev_active'] = $prev_active; - $tmp_data['prev_sys_userid'] = $prev_sysuser; - $app->db->query("UPDATE `client` SET `tmp_data` = '" . $app->db->quote(serialize($tmp_data)) . "' WHERE `client_id` = " . $this->id); - unset($prev_active); - unset($prev_sysuser); - } elseif($this->dataRecord['locked'] == 'n') { - foreach($to_disable as $current => $keycolumn) { - $entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid); - foreach($entries as $item) { - $set_active = 'y'; - $set_sysuser = $sys_userid; - if(array_key_exists('prev_active', $tmp_data) == true - && array_key_exists($current, $tmp_data['prev_active']) == true - && array_key_exists($item['id'], $tmp_data['prev_active'][$current]) == true - && $tmp_data['prev_active'][$current][$item['id']] == 'n') $set_active = 'n'; - if(array_key_exists('prev_sysuser', $tmp_data) == true - && array_key_exists($current, $tmp_data['prev_sysuser']) == true - && array_key_exists($item['id'], $tmp_data['prev_sysuser'][$current]) == true - && $tmp_data['prev_sysuser'][$current][$item['id']] != $sys_userid) $set_sysuser = $tmp_data['prev_sysuser'][$current][$item['id']]; - - $app->db->datalogUpdate($current, array('active' => $set_active, 'sys_userid' => $set_sysuser), $keycolumn, $item['id']); - } - } - if(array_key_exists('prev_active', $tmp_data)) unset($tmp_data['prev_active']); - $app->db->query("UPDATE `client` SET `tmp_data` = '" . $app->db->quote(serialize($tmp_data)) . "' WHERE `client_id` = " . $this->id); - } - unset($tmp_data); - unset($entries); - unset($to_disable); - } - - if(!isset($this->dataRecord['canceled'])) $this->dataRecord['canceled'] = 'n'; - if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["canceled"] != $this->oldDataRecord['canceled']) { - if($this->dataRecord['canceled'] == 'y') { - $sql = "UPDATE sys_user SET active = '0' WHERE client_id = " . $this->id; - $app->db->query($sql); - } elseif($this->dataRecord['canceled'] == 'n') { - $sql = "UPDATE sys_user SET active = '1' WHERE client_id = " . $this->id; - $app->db->query($sql); - } - } - + + if(!isset($this->dataRecord['locked'])) $this->dataRecord['locked'] = 'n'; + if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["locked"] != $this->oldDataRecord['locked']) { + /** lock all the things like web, mail etc. - easy to extend */ + + + // get tmp_data of client + $client_data = $app->db->queryOneRecord('SELECT `tmp_data` FROM `client` WHERE `client_id` = ' . $this->id); + + if($client_data['tmp_data'] == '') $tmp_data = array(); + else $tmp_data = unserialize($client_data['tmp_data']); + + if(!is_array($tmp_data)) $tmp_data = array(); + + // database tables with their primary key columns + $to_disable = array('cron' => 'id', + 'ftp_user' => 'ftp_user_id', + 'mail_domain' => 'domain_id', + 'mail_forwarding' => 'forwarding_id', + 'mail_get' => 'mailget_id', + 'openvz_vm' => 'vm_id', + 'shell_user' => 'shell_user_id', + 'webdav_user' => 'webdav_user_id', + 'web_database' => 'database_id', + 'web_domain' => 'domain_id', + 'web_folder' => 'web_folder_id', + 'web_folder_user' => 'web_folder_user_id' + ); + + $udata = $app->db->queryOneRecord('SELECT `userid` FROM `sys_user` WHERE `client_id` = ' . $this->id); + $gdata = $app->db->queryOneRecord('SELECT `groupid` FROM `sys_group` WHERE `client_id` = ' . $this->id); + $sys_groupid = $gdata['groupid']; + $sys_userid = $udata['userid']; + + $entries = array(); + if($this->dataRecord['locked'] == 'y') { + $prev_active = array(); + $prev_sysuser = array(); + foreach($to_disable as $current => $keycolumn) { + $prev_active[$current] = array(); + $prev_sysuser[$current] = array(); + + $entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id`, `sys_userid`, `active` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid); + foreach($entries as $item) { + + if($item['active'] != 'y') $prev_active[$current][$item['id']]['active'] = 'n'; + if($item['sys_userid'] != $sys_userid) $prev_sysuser[$current][$item['id']]['active'] = $item['sys_userid']; + // we don't have to store these if y, as everything without previous state gets enabled later + + $app->db->datalogUpdate($current, array('active' => 'n', 'sys_userid' => $_SESSION["s"]["user"]["userid"]), $keycolumn, $item['id']); + } + } + + $tmp_data['prev_active'] = $prev_active; + $tmp_data['prev_sys_userid'] = $prev_sysuser; + $app->db->query("UPDATE `client` SET `tmp_data` = '" . $app->db->quote(serialize($tmp_data)) . "' WHERE `client_id` = " . $this->id); + unset($prev_active); + unset($prev_sysuser); + } elseif($this->dataRecord['locked'] == 'n') { + foreach($to_disable as $current => $keycolumn) { + $entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid); + foreach($entries as $item) { + $set_active = 'y'; + $set_sysuser = $sys_userid; + if(array_key_exists('prev_active', $tmp_data) == true + && array_key_exists($current, $tmp_data['prev_active']) == true + && array_key_exists($item['id'], $tmp_data['prev_active'][$current]) == true + && $tmp_data['prev_active'][$current][$item['id']] == 'n') $set_active = 'n'; + if(array_key_exists('prev_sysuser', $tmp_data) == true + && array_key_exists($current, $tmp_data['prev_sysuser']) == true + && array_key_exists($item['id'], $tmp_data['prev_sysuser'][$current]) == true + && $tmp_data['prev_sysuser'][$current][$item['id']] != $sys_userid) $set_sysuser = $tmp_data['prev_sysuser'][$current][$item['id']]; + + $app->db->datalogUpdate($current, array('active' => $set_active, 'sys_userid' => $set_sysuser), $keycolumn, $item['id']); + } + } + if(array_key_exists('prev_active', $tmp_data)) unset($tmp_data['prev_active']); + $app->db->query("UPDATE `client` SET `tmp_data` = '" . $app->db->quote(serialize($tmp_data)) . "' WHERE `client_id` = " . $this->id); + } + unset($tmp_data); + unset($entries); + unset($to_disable); + } + + if(!isset($this->dataRecord['canceled'])) $this->dataRecord['canceled'] = 'n'; + if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["canceled"] != $this->oldDataRecord['canceled']) { + if($this->dataRecord['canceled'] == 'y') { + $sql = "UPDATE sys_user SET active = '0' WHERE client_id = " . $this->id; + $app->db->query($sql); + } elseif($this->dataRecord['canceled'] == 'n') { + $sql = "UPDATE sys_user SET active = '1' WHERE client_id = " . $this->id; + $app->db->query($sql); + } + } + // language changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['language']) && $this->dataRecord['language'] != '' && $this->oldDataRecord['language'] != $this->dataRecord['language']) { $language = $app->db->quote($this->dataRecord["language"]); @@ -370,7 +371,7 @@ class page_action extends tform_actions { $sql = "UPDATE sys_user SET language = '$language' WHERE client_id = $client_id"; $app->db->query($sql); } - + // reseller status changed if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) { $modules = $conf['interface_modules_enabled']; @@ -380,14 +381,15 @@ class page_action extends tform_actions { $sql = "UPDATE sys_user SET modules = '$modules' WHERE client_id = $client_id"; $app->db->query($sql); } - - if(isset($this->dataRecord['template_master'])) { - $app->uses('client_templates'); - $app->client_templates->update_client_templates($this->id, $this->_template_additional); - } - + + if(isset($this->dataRecord['template_master'])) { + $app->uses('client_templates'); + $app->client_templates->update_client_templates($this->id, $this->_template_additional); + } + parent::onAfterUpdate(); } + } $page = new page_action; diff --git a/interface/web/client/client_list.php b/interface/web/client/client_list.php index 35258b858..7d0921771 100644 --- a/interface/web/client/client_list.php +++ b/interface/web/client/client_list.php @@ -1,6 +1,6 @@ listform_actions->SQLExtSelect = ', client.country as countryiso'; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/client/client_message.php b/interface/web/client/client_message.php index 73c43bb4c..4275edb30 100644 --- a/interface/web/client/client_message.php +++ b/interface/web/client/client_message.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -41,9 +41,9 @@ $app->uses('tpl,tform'); $app->tpl->newTemplate('form.tpl.htm'); $app->tpl->setInclude('content_tpl', 'templates/client_message.htm'); -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_client_message.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $msg = ''; @@ -51,18 +51,18 @@ $error = ''; //* Save data if(isset($_POST) && count($_POST) > 1) { - + //* Check values if(!preg_match("/^\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-zA-Z0-9\-]{2,30}$/i", $_POST['sender'])) $error .= $wb['sender_invalid_error'].'
    '; if(empty($_POST['subject'])) $error .= $wb['subject_invalid_error'].'
    '; if(empty($_POST['message'])) $error .= $wb['message_invalid_error'].'
    '; - + //* Send message if($error == '') { if($app->functions->intval($_POST['recipient']) > 0){ $circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ".$app->functions->intval($_POST['recipient'])." AND ".$app->tform->getAuthSQL('r')); if(isset($circle['client_ids']) && $circle['client_ids'] != ''){ - $tmp_client_ids = explode(',',$circle['client_ids']); + $tmp_client_ids = explode(',', $circle['client_ids']); $where = array(); foreach($tmp_client_ids as $tmp_client_id){ $where[] = 'client_id = '.$tmp_client_id; @@ -82,7 +82,7 @@ if(isset($_POST) && count($_POST) > 1) { $sql = "SELECT * FROM client WHERE email != '' AND parent_client_id = '$client_id'"; } } - + //* Get clients $clients = $app->db->queryAllRecords($sql); if(is_array($clients)) { @@ -92,28 +92,28 @@ if(isset($_POST) && count($_POST) > 1) { $message = $_POST['message']; foreach($client as $key => $val) { switch ($key) { - case 'password': - $message = str_replace('{'.$key.'}', '---', $message); - break; - case 'gender': - $message = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $message); - break; - default: - $message = str_replace('{'.$key.'}', $val, $message); + case 'password': + $message = str_replace('{'.$key.'}', '---', $message); + break; + case 'gender': + $message = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $message); + break; + default: + $message = str_replace('{'.$key.'}', $val, $message); } } - + //* Send the email $app->functions->mail($client['email'], $_POST['subject'], $message, $_POST['sender']); $msg .= $client['email'].', '; } - $msg = substr($msg,0,-2); + $msg = substr($msg, 0, -2); } - + } else { - $app->tpl->setVar('sender',$_POST['sender']); - $app->tpl->setVar('subject',$_POST['subject']); - $app->tpl->setVar('message',$_POST['message']); + $app->tpl->setVar('sender', $_POST['sender']); + $app->tpl->setVar('subject', $_POST['subject']); + $app->tpl->setVar('message', $_POST['message']); } } else { // pre-fill Sender field with reseller's email address @@ -122,7 +122,7 @@ if(isset($_POST) && count($_POST) > 1) { if($client_id > 0){ $sql = "SELECT email FROM client WHERE client_id = ".$client_id; $client = $app->db->queryOneRecord($sql); - if($client['email'] != '') $app->tpl->setVar('sender',$client['email']); + if($client['email'] != '') $app->tpl->setVar('sender', $client['email']); } } } @@ -136,12 +136,12 @@ if(is_array($circles) && !empty($circles)){ $recipient .= ''; } } -$app->tpl->setVar('recipient',$recipient); +$app->tpl->setVar('recipient', $recipient); if($_SESSION["s"]["user"]["typ"] == 'admin'){ - $app->tpl->setVar('form_legend_txt',$wb['form_legend_admin_txt']); + $app->tpl->setVar('form_legend_txt', $wb['form_legend_admin_txt']); } else { - $app->tpl->setVar('form_legend_txt',$wb['form_legend_client_txt']); + $app->tpl->setVar('form_legend_txt', $wb['form_legend_client_txt']); } //message variables @@ -159,10 +159,10 @@ if(!empty($field_names) && is_array($field_names)){ } } } -$app->tpl->setVar('message_variables',trim($message_variables)); +$app->tpl->setVar('message_variables', trim($message_variables)); -$app->tpl->setVar('okmsg',$msg); -$app->tpl->setVar('error',$error); +$app->tpl->setVar('okmsg', $msg); +$app->tpl->setVar('error', $error); $app->tpl_defaults(); $app->tpl->pparse(); diff --git a/interface/web/client/client_template_del.php b/interface/web/client/client_template_del.php index 647ad7c54..b57224f8e 100644 --- a/interface/web/client/client_template_del.php +++ b/interface/web/client/client_template_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/client_template.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -52,23 +52,24 @@ $app->load('tform_actions'); class page_action extends tform_actions { function onBeforeDelete() { global $app; - + // check new style - $rec = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client_template_assigned WHERE client_template_id = ".$this->id); + $rec = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client_template_assigned WHERE client_template_id = ".$this->id); if($rec['number'] > 0) { $app->error($app->tform->lng('template_del_aborted_txt')); } - - // check old style + + // check old style $rec = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE template_master = ".$this->id." OR template_additional like '%/".$this->id."/%'"); if($rec['number'] > 0) { $app->error($app->tform->lng('template_del_aborted_txt')); } - + } + } $page = new page_action; $page->onDelete() -?> \ No newline at end of file +?> diff --git a/interface/web/client/client_template_edit.php b/interface/web/client/client_template_edit.php index e14c7465a..d956faf98 100644 --- a/interface/web/client/client_template_edit.php +++ b/interface/web/client/client_template_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/client_template.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -53,7 +53,7 @@ class page_action extends tform_actions { function onBeforeUpdate() { global $app; - + if(isset($this->dataRecord['template_type'])) { //* Check if the template_type has been changed $rec = $app->db->queryOneRecord("SELECT template_type from client_template WHERE template_id = ".$this->id); @@ -65,16 +65,16 @@ class page_action extends tform_actions { unset($rec); } } - - + + /* This function is called automatically right after the data was successful updated in the database. */ function onAfterUpdate() { global $app; - - $app->uses('client_templates'); + + $app->uses('client_templates'); /* * the template has changed. apply the new data to all clients */ @@ -86,10 +86,11 @@ class page_action extends tform_actions { $clients = $app->db->queryAllRecords($sql); if (is_array($clients)){ foreach ($clients as $client){ - $app->client_templates->apply_client_templates($client['client_id']); + $app->client_templates->apply_client_templates($client['client_id']); } } } + } $page = new page_action; diff --git a/interface/web/client/client_template_list.php b/interface/web/client/client_template_list.php index bdfe1d11e..c87cea01e 100644 --- a/interface/web/client/client_template_list.php +++ b/interface/web/client/client_template_list.php @@ -26,8 +26,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration diff --git a/interface/web/client/domain_del.php b/interface/web/client/domain_del.php index 6e8048005..2ec8e86ba 100644 --- a/interface/web/client/domain_del.php +++ b/interface/web/client/domain_del.php @@ -38,8 +38,8 @@ $tform_def_file = "form/domain.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -52,11 +52,11 @@ class page_action extends tform_actions { function onBeforeDelete() { global $app; $conf; - + //* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng'; - include($lng_file); - + include $lng_file; + /* * We can only delete domains if they are NOT in use */ @@ -67,16 +67,17 @@ class page_action extends tform_actions { if (is_array($res)){ $app->error($wb['error_domain_in mailuse']); } - + $sql = "SELECT domain_id FROM web_domain WHERE domain = '" . $app->db->quote($domain) . "'"; $res = $app->db->queryOneRecord($sql); if (is_array($res)){ $app->error($wb['error_domain_in webuse']); } } + } $page = new page_action; $page->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/client/domain_edit.php b/interface/web/client/domain_edit.php index 13e35b81a..3c20ddbae 100644 --- a/interface/web/client/domain_edit.php +++ b/interface/web/client/domain_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/domain.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -50,7 +50,7 @@ $app->load('tform_actions'); //* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng'; -include($lng_file); +include $lng_file; class page_action extends tform_actions { @@ -80,7 +80,7 @@ class page_action extends tform_actions { $client_select .= "\r\n"; } } - $app->tpl->setVar("client_group_id",$client_select); + $app->tpl->setVar("client_group_id", $client_select); } @@ -146,9 +146,10 @@ class page_action extends tform_actions { $app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id); } } + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/client/domain_list.php b/interface/web/client/domain_list.php index e4ef725b0..622e52a97 100644 --- a/interface/web/client/domain_list.php +++ b/interface/web/client/domain_list.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -49,4 +49,4 @@ $app->uses('listform_actions'); $app->listform_actions->SQLOrderBy = 'ORDER BY domain.domain'; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/client/domain_new_client.php b/interface/web/client/domain_new_client.php index 81ce07536..d24174a77 100644 --- a/interface/web/client/domain_new_client.php +++ b/interface/web/client/domain_new_client.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 37d51bdd8..16e68c01e 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -29,7 +29,7 @@ Hint: The ID field of the database table is not part of the datafield definition. The ID field must be always auto incement (int or bigint). - + Search: - searchable = 1 or searchable = 2 include the field in the search - searchable = 1: this field will be the title of the search result @@ -38,16 +38,16 @@ */ -$form["title"] = "Client"; +$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["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 @@ -58,1033 +58,1033 @@ $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = //* 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') { +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")) { +$handle = @opendir(ISPC_THEMES_PATH); +while ($file = @readdir($handle)) { + if (substr($file, 0, 1) != '.') { + if(@is_dir(ISPC_THEMES_PATH."/$file")) { if(!file_exists(ISPC_THEMES_PATH."/$file/ispconfig_version") || (@file_exists(ISPC_THEMES_PATH."/$file/ispconfig_version") && trim(@file_get_contents(ISPC_THEMES_PATH."/$file/ispconfig_version")) == ISPC_APP_VERSION)) { - $themes_list[$file] = $file; - } - } + $themes_list[$file] = $file; + } + } } } $form["tabs"]['address'] = array ( - 'title' => "Address", - 'width' => 100, - 'template' => "templates/client_edit_address.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + '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' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'gender' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => array('' => '', 'm' => 'gender_m_txt', 'f' => 'gender_f_txt') + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => array('' => '', 'm' => 'gender_m_txt', 'f' => 'gender_f_txt') ), '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' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'contact_error_empty'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 1 ), 'customer_no' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'customer_no_error_unique', - 'allowempty' => 'y'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'customer_no_error_unique', + 'allowempty' => 'y'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), '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' => 'CUSTOM', - 'class' => 'validate_client', - 'function' => 'username_collision', - 'errmsg'=> 'username_error_collision'), - 3 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\_]{0,64}$/', - 'errmsg'=> 'username_error_regex'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + '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' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'username_collision', + 'errmsg'=> 'username_error_collision'), + 3 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\_]{0,64}$/', + 'errmsg'=> 'username_error_regex'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'password' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'PASSWORD', + 'datatype' => 'VARCHAR', + 'formtype' => 'PASSWORD', 'encryption'=> 'CRYPT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + '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' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => $conf["language"], + 'value' => $language_list, + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'usertheme' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => $conf["theme"], - 'value' => $themes_list, - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => $conf["theme"], + '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' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'zip' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'city' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'state' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'country' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => (isset($conf['language']) ? strtoupper($conf['language']) : ''), - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT iso,printable_name FROM country ORDER BY iso ASC', - 'keyfield' => 'iso', - 'valuefield' => 'printable_name' - ), - 'value' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => (isset($conf['language']) ? strtoupper($conf['language']) : ''), + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT iso,printable_name FROM country ORDER BY iso ASC', + 'keyfield' => 'iso', + 'valuefield' => 'printable_name' + ), + 'value' => '' ), 'telephone' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'mobile' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'fax' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'email' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i', - 'errmsg'=> 'email_error_isemail'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i', + 'errmsg'=> 'email_error_isemail'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'internet' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'http://', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'http://', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'icq' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + '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' => '' + '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' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_account_owner' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_account_number' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_code' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_account_iban' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_account_swift' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + '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' + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '', + 'maxlength' => '', + 'rows' => '10', + 'cols' => '30' ), 'paypal_email' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i', - 'errmsg'=> 'paypal_email_error_isemail'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i', + 'errmsg'=> 'paypal_email_error_isemail'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'locked' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'canceled' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') - ), - ################################## - # END Datatable fields - ################################## + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + //################################# + // END Datatable fields + //################################# ) ); $form["tabs"]['limits'] = array ( - 'title' => "Limits", - 'width' => 80, - 'template' => "templates/client_edit_limits.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + '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' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'master_templates' + ), + 'value' => '' ), 'template_additional' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', + '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' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' + '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' => '' + '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' => '' + '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', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'web_php_options_notempty'), - ), - 'default' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'web_php_options_notempty'), + ), + 'default' => '', 'separator' => ',', 'valuelimit' => 'client:web_php_options', - 'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM') + 'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM') ), 'limit_cgi' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ssi' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_perl' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ruby' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_python' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'force_suexec' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_hterror' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_wildcard' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ssl' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'ssh_chroot_notempty'), - ), - 'default' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'ssh_chroot_notempty'), + ), + 'default' => '', 'separator' => ',', 'valuelimit' => 'client:ssh_chroot', - 'value' => array('no' => 'None', 'jailkit' => 'Jailkit') + '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' => '' + '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' + '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' => '' + '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' => '' ), 'default_slave_dnsserver' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '1', - 'datasource' => array ( 'type' => 'CUSTOM', - 'class'=> 'custom_datasource', - 'function'=> 'client_servers' - ), - 'value' => '', - 'name' => 'default_slave_dnsserver' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'client_servers' + ), + 'value' => '', + 'name' => 'default_slave_dnsserver' ), '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' => '' - ), + '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' => '' + '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' => '' + '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' + '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' => '' - ), + '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' => '' + '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' => '' ), 'limit_openvz_vm' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'limit_openvz_vm_error_notint'), - ), - 'default' => '0', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_openvz_vm_error_notint'), + ), + 'default' => '0', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' ), 'limit_openvz_vm_template_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name', - 'keyfield'=> 'template_id', - 'valuefield'=> 'template_name' - ), - 'value' => array(0 => ' ') + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name', + 'keyfield'=> 'template_id', + 'valuefield'=> 'template_name' + ), + 'value' => array(0 => ' ') ), 'limit_aps' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'limit_aps_error_notint'), - ), - 'default' => '-1', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' - ), - ################################## - # END Datatable fields - ################################## + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_aps_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + //################################# + // END Datatable fields + //################################# ) ); diff --git a/interface/web/client/form/client_circle.tform.php b/interface/web/client/form/client_circle.tform.php index bb5a140f3..91b96b354 100644 --- a/interface/web/client/form/client_circle.tform.php +++ b/interface/web/client/form/client_circle.tform.php @@ -29,7 +29,7 @@ Hint: The ID field of the database table is not part of the datafield definition. The ID field must be always auto incement (int or bigint). - + Search: - searchable = 1 or searchable = 2 include the field in the search - searchable = 1: this field will be the title of the search result @@ -38,16 +38,16 @@ */ -$form["title"] = "Client Circle"; -$form["description"] = ""; -$form["name"] = "client_circle"; -$form["action"] = "client_circle_edit.php"; -$form["db_table"] = "client_circle"; -$form["db_table_idx"] = "circle_id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "circle"; -$form["list_default"] = "client_circle_list.php"; -$form["auth"] = 'yes'; +$form["title"] = "Client Circle"; +$form["description"] = ""; +$form["name"] = "client_circle"; +$form["action"] = "client_circle_edit.php"; +$form["db_table"] = "client_circle"; +$form["db_table_idx"] = "circle_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "circle"; +$form["list_default"] = "client_circle_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 @@ -58,80 +58,80 @@ $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = //* 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') { +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")) { +$handle = @opendir(ISPC_THEMES_PATH); +while ($file = @readdir($handle)) { + if (substr($file, 0, 1) != '.') { + if(@is_dir(ISPC_THEMES_PATH."/$file")) { if($file == 'default' || (@file_exists(ISPC_THEMES_PATH."/$file/ISPC_VERSION") && trim(@file_get_contents(ISPC_THEMES_PATH."/$file/ISPC_VERSION")) == ISPC_APP_VERSION)) { - $themes_list[$file] = $file; - } - } + $themes_list[$file] = $file; + } + } } } $form["tabs"]['circle'] = array ( - 'title' => "Circle", - 'width' => 100, - 'template' => "templates/client_circle_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Circle", + 'width' => 100, + 'template' => "templates/client_circle_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'circle_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'client_ids' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOXARRAY', - 'default' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'default' => '', 'separator' => ',', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', - 'keyfield'=> 'client_id', - 'valuefield'=> 'contact_name' - ), - 'value' => '' + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', + 'keyfield'=> 'client_id', + 'valuefield'=> 'contact_name' + ), + 'value' => '' ), 'description' => array ( - 'datatype' => 'TEXT', - 'formtype' => 'TEXTAREA', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '', - 'maxlength' => '', - 'rows' => '10', - 'cols' => '30' + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '', + 'maxlength' => '', + 'rows' => '10', + 'cols' => '30' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), - ################################## - # END Datatable fields - ################################## + //################################# + // END Datatable fields + //################################# ) ); diff --git a/interface/web/client/form/client_template.tform.php b/interface/web/client/form/client_template.tform.php index 917266eef..ecf61f7af 100644 --- a/interface/web/client/form/client_template.tform.php +++ b/interface/web/client/form/client_template.tform.php @@ -33,16 +33,16 @@ */ -$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["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 @@ -53,465 +53,465 @@ $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = //* 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') { +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 - ################################## + '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"), + '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 - ################################## + '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 - ################################## + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '', + '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', 'php-fpm' => 'PHP-FPM') + 'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM') ), 'limit_cgi' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ssi' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_perl' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ruby' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_python' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'force_suexec' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_hterror' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_wildcard' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ssl' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' ), 'ssh_chroot' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOXARRAY', - 'validators' => array ( - 0 => array ( - 'type'=> 'NOTEMPTY', - 'errmsg'=> 'ssh_chroot_notempty' - ), - ), - 'default' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'validators' => array ( + 0 => array ( + 'type'=> 'NOTEMPTY', + 'errmsg'=> 'ssh_chroot_notempty' + ), + ), + 'default' => '', 'separator' => ',', 'valuelimit' => 'client:ssh_chroot', - 'value' => array('no' => 'None', 'jailkit' => 'Jailkit') + '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' => '0', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' + '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' => '' + '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_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' => '' + '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 ( @@ -530,109 +530,109 @@ $form["tabs"]['limits'] = array ( ), */ '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' => '' + '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_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' => '' + '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' => '' ), 'limit_openvz_vm' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'limit_openvz_vm_error_notint'), - ), - 'default' => '0', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_openvz_vm_error_notint'), + ), + 'default' => '0', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' ), 'limit_openvz_vm_template_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name', - 'keyfield'=> 'template_id', - 'valuefield'=> 'template_name' - ), - 'value' => array(0 => ' ') + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name', + 'keyfield'=> 'template_id', + 'valuefield'=> 'template_name' + ), + 'value' => array(0 => ' ') ), 'limit_aps' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'limit_aps_error_notint'), - ), - 'default' => '-1', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' - ), - ################################## - # END Datatable fields - ################################## + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_aps_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + //################################# + // END Datatable fields + //################################# ) ); diff --git a/interface/web/client/form/domain.tform.php b/interface/web/client/form/domain.tform.php index 40f9a90a8..a12878380 100644 --- a/interface/web/client/form/domain.tform.php +++ b/interface/web/client/form/domain.tform.php @@ -60,16 +60,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$form["title"] = "Domain"; -$form["description"] = ""; -$form["name"] = "domain"; -$form["action"] = "domain_edit.php"; -$form["db_table"] = "domain"; -$form["db_table_idx"] = "domain_id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "domain"; -$form["list_default"] = "domain_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "Domain"; +$form["description"] = ""; +$form["name"] = "domain"; +$form["action"] = "domain_edit.php"; +$form["db_table"] = "domain"; +$form["db_table_idx"] = "domain_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "domain"; +$form["list_default"] = "domain_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 @@ -78,41 +78,41 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['domain'] = array ( - 'title' => "Domain", - 'width' => 100, - 'template' => "templates/domain_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Domain", + 'width' => 100, + 'template' => "templates/domain_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'domain' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'domain_error_empty'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'domain_error_unique'), - 2 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z\-]{2,10}$/', - 'errmsg'=> 'domain_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'domain_error_empty'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'domain_error_unique'), + 2 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z\-]{2,10}$/', + 'errmsg'=> 'domain_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php index c78ed8ea4..fad0cd765 100644 --- a/interface/web/client/form/reseller.tform.php +++ b/interface/web/client/form/reseller.tform.php @@ -29,7 +29,7 @@ Hint: The ID field of the database table is not part of the datafield definition. The ID field must be always auto incement (int or bigint). - + Search: - searchable = 1 or searchable = 2 include the field in the search - searchable = 1: this field will be the title of the search result @@ -38,16 +38,16 @@ */ -$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["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 @@ -58,1031 +58,1031 @@ $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = //* 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")) { +while ($file = @readdir($handle)) { + if (substr($file, 0, 1) != '.') { + if(@is_dir(ISPC_THEMES_PATH."/$file")) { if(!file_exists(ISPC_THEMES_PATH."/$file/ispconfig_version") || (@file_exists(ISPC_THEMES_PATH."/$file/ispconfig_version") && trim(@file_get_contents(ISPC_THEMES_PATH."/$file/ispconfig_version")) == ISPC_APP_VERSION)) { - $themes_list[$file] = $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') { +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 - ################################## + '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' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'gender' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => array('' => '', 'm' => 'gender_m_txt', 'f' => 'gender_f_txt') + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => array('' => '', 'm' => 'gender_m_txt', 'f' => 'gender_f_txt') ), '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' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'contact_error_empty'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 1 ), 'customer_no' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'customer_no_error_unique', - 'allowempty' => 'y'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'customer_no_error_unique', + 'allowempty' => 'y'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), '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' => 'CUSTOM', - 'class' => 'validate_client', - 'function' => 'username_collision', - 'errmsg'=> 'username_error_collision'), - 3 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\_]{0,64}$/', - 'errmsg'=> 'username_error_regex'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + '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' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'username_collision', + 'errmsg'=> 'username_error_collision'), + 3 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\_]{0,64}$/', + 'errmsg'=> 'username_error_regex'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'password' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'PASSWORD', + 'datatype' => 'VARCHAR', + 'formtype' => 'PASSWORD', 'encryption'=> 'CRYPT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + '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' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => $conf["language"], + 'value' => $language_list, + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'usertheme' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => $conf["theme"], - 'value' => $themes_list, - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => $conf["theme"], + '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' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'zip' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'city' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'state' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'country' => array ( - 'datatype' => 'VARCHAR', + 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'default' => (isset($conf['language']) ? strtoupper($conf['language']) : ''), - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name', - 'keyfield'=> 'iso', - 'valuefield'=> 'printable_name' - ), - 'value' => '' + 'formtype' => 'SELECT', + 'default' => (isset($conf['language']) ? strtoupper($conf['language']) : ''), + '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' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'mobile' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'fax' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'email' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'internet' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'http://', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'http://', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'icq' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + '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' => '' + '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' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '20', + 'rows' => '', + 'cols' => '' ), 'bank_account_owner' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_account_number' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_code' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_account_iban' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ), 'bank_account_swift' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '' + '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' + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '', + 'maxlength' => '', + 'rows' => '10', + 'cols' => '30' ), 'paypal_email' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i', - 'errmsg'=> 'paypal_email_error_isemail'), - ), - 'default' => '', - 'value' => '', - 'separator' => '', - 'width' => '30', - 'maxlength' => '255', - 'rows' => '', - 'cols' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i', + 'errmsg'=> 'paypal_email_error_isemail'), + ), + 'default' => '', + 'value' => '', + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '', 'searchable' => 2 ), 'locked' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'canceled' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') - ), - ################################## - # END Datatable fields - ################################## + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + //################################# + // END Datatable fields + //################################# ) ); $form["tabs"]['limits'] = array ( - 'title' => "Limits", - 'width' => 80, - 'template' => "templates/reseller_edit_limits.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + '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' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'master_templates' + ), + 'value' => '' ), 'template_additional' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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_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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'web_php_options_notempty'), - ), - 'default' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'web_php_options_notempty'), + ), + 'default' => '', 'separator' => ',', - 'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM') + 'value' => array('no' => 'Disabled', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM') ), 'limit_cgi' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ssi' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_perl' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ruby' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_python' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'force_suexec' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'y', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_hterror' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_wildcard' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), 'limit_ssl' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'n', - 'value' => array(0 => 'n',1 => 'y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') ), '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' => '' + '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' => '' + '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' => '' + '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' => '' + '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', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'ssh_chroot_notempty'), - ), - 'default' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'ssh_chroot_notempty'), + ), + 'default' => '', 'separator' => ',', - 'value' => array('no' => 'None', 'jailkit' => 'Jailkit') + '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' => '' + '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' => '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' => '' + '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' => '' + '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' => '' ), 'default_slave_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_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' => '' - ), + '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_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' => '' + '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' => '' + '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' => '' + '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' => '' - ), + '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' => '' + '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' => '' ), 'limit_openvz_vm' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'limit_openvz_vm_error_notint'), - ), - 'default' => '0', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_openvz_vm_error_notint'), + ), + 'default' => '0', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' ), 'limit_openvz_vm_template_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name', - 'keyfield'=> 'template_id', - 'valuefield'=> 'template_name' - ), - 'value' => array(0 => ' ') + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name', + 'keyfield'=> 'template_id', + 'valuefield'=> 'template_name' + ), + 'value' => array(0 => ' ') ), 'limit_aps' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'limit_aps_error_notint'), - ), - 'default' => '-1', - 'value' => '', - 'separator' => '', - 'width' => '10', - 'maxlength' => '10', - 'rows' => '', - 'cols' => '' - ), - ################################## - # END Datatable fields - ################################## + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_aps_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + //################################# + // END Datatable fields + //################################# ) ); diff --git a/interface/web/client/lib/admin.conf.php b/interface/web/client/lib/admin.conf.php index 67c94a574..acb6c3546 100644 --- a/interface/web/client/lib/admin.conf.php +++ b/interface/web/client/lib/admin.conf.php @@ -1,2 +1,2 @@ \ No newline at end of file +?> diff --git a/interface/web/client/lib/module.conf.php b/interface/web/client/lib/module.conf.php index f0564f126..bfb6ac80d 100644 --- a/interface/web/client/lib/module.conf.php +++ b/interface/web/client/lib/module.conf.php @@ -1,68 +1,68 @@ "Edit Client", - 'target' => 'content', - 'link' => 'client/client_list.php', - 'html_id' => 'client_list'); +$items[] = array( 'title' => "Edit Client", + 'target' => 'content', + 'link' => 'client/client_list.php', + 'html_id' => 'client_list'); + +$items[] = array( 'title' => "Add Client", + 'target' => 'content', + 'link' => 'client/client_edit.php', + 'html_id' => 'client_add'); -$items[] = array( 'title' => "Add Client", - 'target' => 'content', - 'link' => 'client/client_edit.php', - 'html_id' => 'client_add'); - if($_SESSION["s"]["user"]["typ"] == 'admin'){ -$items[] = array( 'title' => "Edit Client-Templates", - 'target' => 'content', - 'link' => 'client/client_template_list.php', - 'html_id' => 'client_template_list'); + $items[] = array( 'title' => "Edit Client-Templates", + 'target' => 'content', + 'link' => 'client/client_template_list.php', + 'html_id' => 'client_template_list'); } -$module["nav"][] = array( 'title' => 'Clients', - 'open' => 1, - 'items' => $items); +$module["nav"][] = array( 'title' => 'Clients', + 'open' => 1, + 'items' => $items); unset($items); if($_SESSION["s"]["user"]["typ"] == 'admin'){ -$items[] = array( 'title' => "Edit Reseller", - 'target' => 'content', - 'link' => 'client/reseller_list.php', - 'html_id' => 'reseller_list'); + $items[] = array( 'title' => "Edit Reseller", + 'target' => 'content', + 'link' => 'client/reseller_list.php', + 'html_id' => 'reseller_list'); -$items[] = array( 'title' => "Add Reseller", - 'target' => 'content', - 'link' => 'client/reseller_edit.php', - 'html_id' => 'reseller_add'); + $items[] = array( 'title' => "Add Reseller", + 'target' => 'content', + 'link' => 'client/reseller_edit.php', + 'html_id' => 'reseller_add'); -$module["nav"][] = array( 'title' => 'Resellers', - 'open' => 1, - 'items' => $items); + $module["nav"][] = array( 'title' => 'Resellers', + 'open' => 1, + 'items' => $items); -unset($items); + unset($items); } -$items[] = array( 'title' => "Edit Client Circle", - 'target' => 'content', - 'link' => 'client/client_circle_list.php', - 'html_id' => 'client_circle_list'); +$items[] = array( 'title' => "Edit Client Circle", + 'target' => 'content', + 'link' => 'client/client_circle_list.php', + 'html_id' => 'client_circle_list'); -$items[] = array( 'title' => "Send email", - 'target' => 'content', - 'link' => 'client/client_message.php', - 'html_id' => 'reseller_add'); +$items[] = array( 'title' => "Send email", + 'target' => 'content', + 'link' => 'client/client_message.php', + 'html_id' => 'reseller_add'); -$module["nav"][] = array( 'title' => 'Messaging', - 'open' => 1, - 'items' => $items); +$module["nav"][] = array( 'title' => 'Messaging', + 'open' => 1, + 'items' => $items); unset($items); @@ -71,13 +71,13 @@ $settings = $app->getconf->get_global_config('domains'); if ($settings['use_domain_module'] == 'y') { $items = array(); - $items[] = array( 'title' => 'Domains', - 'target' => 'content', - 'link' => 'client/domain_list.php'); + $items[] = array( 'title' => 'Domains', + 'target' => 'content', + 'link' => 'client/domain_list.php'); - $module['nav'][] = array( 'title' => 'Domains', - 'open' => 1, - 'items' => $items); + $module['nav'][] = array( 'title' => 'Domains', + 'open' => 1, + 'items' => $items); unset($items); } @@ -97,4 +97,4 @@ $module["nav"][] = array( 'title' => 'Reseller Panel', unset($items); } */ -?> \ No newline at end of file +?> diff --git a/interface/web/client/list/client.list.php b/interface/web/client/list/client.list.php index 0169810e4..40af2a7b0 100644 --- a/interface/web/client/list/client.list.php +++ b/interface/web/client/list/client.list.php @@ -13,34 +13,34 @@ // Name of the list -$liste["name"] = "clients"; +$liste["name"] = "clients"; // Database table -$liste["table"] = "client"; +$liste["table"] = "client"; // Index index field of the database table -$liste["table_idx"] = "client_id"; +$liste["table_idx"] = "client_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "client_list.php"; +$liste["file"] = "client_list.php"; // Script file of the edit form -$liste["edit_file"] = "client_edit.php"; +$liste["edit_file"] = "client_edit.php"; // Script File of the delete script -$liste["delete_file"] = "client_del.php"; +$liste["delete_file"] = "client_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable authe -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** @@ -48,71 +48,71 @@ $liste["auth"] = "yes"; *****************************************************/ $liste["item"][] = array( 'field' => "client_id", - 'datatype' => "INTEGER", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); + 'datatype' => "INTEGER", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); $liste["item"][] = array( 'field' => "company_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); $liste["item"][] = array( 'field' => "contact_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); $liste["item"][] = array( 'field' => "customer_no", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); $liste["item"][] = array( 'field' => "username", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); $liste["item"][] = array( 'field' => "city", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); $liste["item"][] = array( 'field' => "country", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'datasource'=> array ( 'type' => 'SQL', - 'querystring' => 'SELECT iso,printable_name FROM country ORDER BY iso ASC', - 'keyfield' => 'iso', - 'valuefield' => 'printable_name' - ), - 'width' => "", - 'value' => ""); - -?> \ No newline at end of file + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'datasource'=> array ( 'type' => 'SQL', + 'querystring' => 'SELECT iso,printable_name FROM country ORDER BY iso ASC', + 'keyfield' => 'iso', + 'valuefield' => 'printable_name' + ), + 'width' => "", + 'value' => ""); + +?> diff --git a/interface/web/client/list/client_circle.list.php b/interface/web/client/list/client_circle.list.php index 075c9cda2..d1ef3ad50 100644 --- a/interface/web/client/list/client_circle.list.php +++ b/interface/web/client/list/client_circle.list.php @@ -13,74 +13,74 @@ // Name of the list -$liste["name"] = "client_circle"; +$liste["name"] = "client_circle"; // Database table -$liste["table"] = "client_circle"; +$liste["table"] = "client_circle"; // Index index field of the database table -$liste["table_idx"] = "circle_id"; +$liste["table_idx"] = "circle_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "client_circle_list.php"; +$liste["file"] = "client_circle_list.php"; // Script file of the edit form -$liste["edit_file"] = "client_circle_edit.php"; +$liste["edit_file"] = "client_circle_edit.php"; // Script File of the delete script -$liste["delete_file"] = "client_circle_del.php"; +$liste["delete_file"] = "client_circle_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable authe -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** * Suchfelder *****************************************************/ -$liste["item"][] = array( 'field' => "circle_id", - 'datatype' => "INTEGER", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('y' => "
    Yes
    ",'n' => "
    No
    ")); - -$liste["item"][] = array( 'field' => "circle_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "description", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -?> \ No newline at end of file +$liste["item"][] = array( 'field' => "circle_id", + 'datatype' => "INTEGER", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
    Yes
    ", 'n' => "
    No
    ")); + +$liste["item"][] = array( 'field' => "circle_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "description", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +?> diff --git a/interface/web/client/list/client_template.list.php b/interface/web/client/list/client_template.list.php index ef348e371..cb37eb3f2 100644 --- a/interface/web/client/list/client_template.list.php +++ b/interface/web/client/list/client_template.list.php @@ -11,65 +11,65 @@ */ // Name of the list -$liste["name"] = "client_template"; +$liste["name"] = "client_template"; // Database table -$liste["table"] = "client_template"; +$liste["table"] = "client_template"; // Index index field of the database table -$liste["table_idx"] = "template_id"; +$liste["table_idx"] = "template_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "client_template_list.php"; +$liste["file"] = "client_template_list.php"; // Script file of the edit form -$liste["edit_file"] = "client_template_edit.php"; +$liste["edit_file"] = "client_template_edit.php"; // Script File of the delete script -$liste["delete_file"] = "client_template_del.php"; +$liste["delete_file"] = "client_template_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** * Suchfelder *****************************************************/ -$liste["item"][] = array( 'field' => "template_id", - 'datatype' => "INTEGER", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); - - -$liste["item"][] = array( 'field' => "template_type", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('m' => "Main Template",'a' => "Additional Template")); - -$liste["item"][] = array( 'field' => "template_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "template_id", + 'datatype' => "INTEGER", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); + + +$liste["item"][] = array( 'field' => "template_type", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('m' => "Main Template", 'a' => "Additional Template")); + +$liste["item"][] = array( 'field' => "template_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); ?> diff --git a/interface/web/client/list/domain.list.php b/interface/web/client/list/domain.list.php index a7534a228..82c677215 100644 --- a/interface/web/client/list/domain.list.php +++ b/interface/web/client/list/domain.list.php @@ -40,63 +40,63 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // Name of the list -$liste["name"] = "domain"; +$liste["name"] = "domain"; // Database table -$liste["table"] = "domain"; +$liste["table"] = "domain"; // Index index field of the database table -$liste["table_idx"] = "domain_id"; +$liste["table_idx"] = "domain_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = 15; +$liste["records_per_page"] = 15; // Script File of the list -$liste["file"] = "domain_list.php"; +$liste["file"] = "domain_list.php"; // Script file of the edit form -$liste["edit_file"] = "domain_edit.php"; +$liste["edit_file"] = "domain_edit.php"; // Script File of the delete script -$liste["delete_file"] = "domain_del.php"; +$liste["delete_file"] = "domain_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** * Suchfelder *****************************************************/ -$liste["item"][] = array( 'field' => "domain", - 'datatype' => "VARCHAR", - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => "TEXT", - 'op' => "LIKE", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "sys_groupid", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT a.groupid, a.name FROM sys_group a, domain b WHERE (a.groupid = b.sys_groupid) AND ({AUTHSQL-B}) ORDER BY name', - 'keyfield'=> 'groupid', - 'valuefield'=> 'name' - ), - 'width' => "", - 'value' => ""); - -?> \ No newline at end of file +$liste["item"][] = array( 'field' => "domain", + 'datatype' => "VARCHAR", + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => "TEXT", + 'op' => "LIKE", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "sys_groupid", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT a.groupid, a.name FROM sys_group a, domain b WHERE (a.groupid = b.sys_groupid) AND ({AUTHSQL-B}) ORDER BY name', + 'keyfield'=> 'groupid', + 'valuefield'=> 'name' + ), + 'width' => "", + 'value' => ""); + +?> diff --git a/interface/web/client/list/reseller.list.php b/interface/web/client/list/reseller.list.php index 67ae88274..625a5cf27 100644 --- a/interface/web/client/list/reseller.list.php +++ b/interface/web/client/list/reseller.list.php @@ -13,34 +13,34 @@ // Name of the list -$liste["name"] = "resellers"; +$liste["name"] = "resellers"; // Database table -$liste["table"] = "client"; +$liste["table"] = "client"; // Index index field of the database table -$liste["table_idx"] = "client_id"; +$liste["table_idx"] = "client_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "reseller_list.php"; +$liste["file"] = "reseller_list.php"; // Script file of the edit form -$liste["edit_file"] = "reseller_edit.php"; +$liste["edit_file"] = "reseller_edit.php"; // Script File of the delete script -$liste["delete_file"] = "reseller_del.php"; +$liste["delete_file"] = "reseller_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable authe -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** @@ -48,71 +48,71 @@ $liste["auth"] = "yes"; *****************************************************/ $liste["item"][] = array( 'field' => "client_id", - 'datatype' => "INTEGER", - 'formtype' => "TEXT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "company_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "contact_name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - + 'datatype' => "INTEGER", + 'formtype' => "TEXT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "company_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "contact_name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + $liste["item"][] = array( 'field' => "customer_no", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + $liste["item"][] = array( 'field' => "username", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "city", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "country", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'datasource'=> array ( 'type' => 'SQL', - 'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name ASC', - 'keyfield' => 'iso', - 'valuefield' => 'printable_name' - ), - 'width' => "", - 'value' => "" ); - -?> \ No newline at end of file + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "city", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "country", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'datasource'=> array ( 'type' => 'SQL', + 'querystring' => 'SELECT iso,printable_name FROM country ORDER BY printable_name ASC', + 'keyfield' => 'iso', + 'valuefield' => 'printable_name' + ), + 'width' => "", + 'value' => "" ); + +?> diff --git a/interface/web/client/reseller_del.php b/interface/web/client/reseller_del.php index 2cf2003fd..e9d1dd32b 100644 --- a/interface/web/client/reseller_del.php +++ b/interface/web/client/reseller_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/reseller.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -51,44 +51,45 @@ $app->uses('tpl,tform'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onBeforeDelete() { global $app, $conf; - + if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); - + $client_id = $app->functions->intval($this->dataRecord['client_id']); - + $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE parent_client_id = ".$client_id); if($tmp["number"] > 0) $app->error($app->lng('error_has_clients')); - + } - + function onAfterDelete() { global $app, $conf; - + $client_id = $app->functions->intval($this->dataRecord['client_id']); - + if($client_id > 0) { // TODO: Delete all records (sub-clients, mail, web, etc....) of this client. - + // remove the group of the client from the resellers group $parent_client_id = $app->functions->intval($this->dataRecord['parent_client_id']); $parent_user = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE client_id = $parent_client_id"); $client_group = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = $client_id"); - $app->auth->remove_group_from_user($parent_user['userid'],$client_group['groupid']); - + $app->auth->remove_group_from_user($parent_user['userid'], $client_group['groupid']); + // delete the group of the client $app->db->query("DELETE FROM sys_group WHERE client_id = $client_id"); - + // delete the sys user(s) of the client $app->db->query("DELETE FROM sys_user WHERE client_id = $client_id"); } - + } + } $page = new page_action; $page->onDelete() -?> \ No newline at end of file +?> diff --git a/interface/web/client/reseller_edit.php b/interface/web/client/reseller_edit.php index ca2780cea..3007ce0a8 100644 --- a/interface/web/client/reseller_edit.php +++ b/interface/web/client/reseller_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/reseller.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('client'); @@ -55,14 +55,14 @@ class page_action extends tform_actions { function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another website. if($client["limit_client"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id"); @@ -71,21 +71,21 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - - + + function onSubmit() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user' && $this->id == 0) { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another website. if($client["limit_client"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = $client_group_id"); @@ -94,7 +94,7 @@ class page_action extends tform_actions { } } } - + parent::onSubmit(); } @@ -111,32 +111,32 @@ class page_action extends tform_actions { $option .= ''; $tpl[$item['template_id']] = $item['template_name']; } - $app->tpl->setVar('tpl_add_select',$option); - - // check for new-style records - $result = $app->db->queryAllRecords('SELECT assigned_template_id, client_template_id FROM client_template_assigned WHERE client_id = ' . $this->id); - if($result && count($result) > 0) { - // new style - $text = ''; - foreach($result as $item){ - if (trim($item['client_template_id']) != ''){ - if ($text != '') $text .= ''; - $text .= '
  • ' . $tpl[$item['client_template_id']]. '
  • '; - } - } - } else { - // old style - $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id; - $result = $app->db->queryOneRecord($sql); - $tplAdd = explode("/", $result['template_additional']); - $text = ''; - foreach($tplAdd as $item){ - if (trim($item) != ''){ - if ($text != '') $text .= ''; - $text .= '
  • ' . $tpl[$item]. '
  • '; - } - } - } + $app->tpl->setVar('tpl_add_select', $option); + + // check for new-style records + $result = $app->db->queryAllRecords('SELECT assigned_template_id, client_template_id FROM client_template_assigned WHERE client_id = ' . $this->id); + if($result && count($result) > 0) { + // new style + $text = ''; + foreach($result as $item){ + if (trim($item['client_template_id']) != ''){ + if ($text != '') $text .= ''; + $text .= '
  • ' . $tpl[$item['client_template_id']]. '
  • '; + } + } + } else { + // old style + $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id; + $result = $app->db->queryOneRecord($sql); + $tplAdd = explode("/", $result['template_additional']); + $text = ''; + foreach($tplAdd as $item){ + if (trim($item) != ''){ + if ($text != '') $text .= ''; + $text .= '
  • ' . $tpl[$item]. '
  • '; + } + } + } $app->tpl->setVar('template_additional_list', $text); @@ -153,32 +153,32 @@ class page_action extends tform_actions { // Create the group for the reseller $groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('".$app->db->quote($this->dataRecord["username"])."','',".$this->id.")", 'groupid'); $groups = $groupid; - + $username = $app->db->quote($this->dataRecord["username"]); $password = $app->db->quote($this->dataRecord["password"]); $modules = $conf['interface_modules_enabled'] . ',client'; - $startmodule = (stristr($modules,'dashboard'))?'dashboard':'client'; + $startmodule = (stristr($modules, 'dashboard'))?'dashboard':'client'; $usertheme = $app->db->quote($this->dataRecord["usertheme"]); $type = 'user'; $active = 1; $language = $app->db->quote($this->dataRecord["language"]); - + $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n=0;$n<8;$n++) { - $salt.=$base64_alphabet[mt_rand(0,63)]; + $salt.=$base64_alphabet[mt_rand(0, 63)]; } $salt.="$"; - $password = crypt(stripslashes($password),$salt); - + $password = crypt(stripslashes($password), $salt); + // Create the controlpaneluser for the reseller $sql = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id) VALUES ('$username','$password','$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,".$this->id.")"; $app->db->query($sql); - + //* set the number of clients to 1 $app->db->query("UPDATE client SET limit_client = 1 WHERE client_id = ".$this->id); - + //* Set the default servers $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE mail_server = 1 LIMIT 0,1'); $default_mailserver = $app->functions->intval($tmp['server_id']); @@ -188,33 +188,33 @@ class page_action extends tform_actions { $default_dnsserver = $app->functions->intval($tmp['server_id']); $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE db_server = 1 LIMIT 0,1'); $default_dbserver = $app->functions->intval($tmp['server_id']); - + $sql = "UPDATE client SET default_mailserver = $default_mailserver, default_webserver = $default_webserver, default_dnsserver = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, default_dbserver = $default_dbserver WHERE client_id = ".$this->id; $app->db->query($sql); parent::onAfterInsert(); } - - + + /* This function is called automatically right after the data was successful updated in the database. */ function onAfterUpdate() { global $app, $conf; - + // username changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['username']) && $this->dataRecord['username'] != '' && $this->oldDataRecord['username'] != $this->dataRecord['username']) { $username = $app->db->quote($this->dataRecord["username"]); $client_id = $this->id; $sql = "UPDATE sys_user SET username = '$username' WHERE client_id = $client_id"; $app->db->query($sql); - + $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = $client_id"); $app->db->datalogUpdate("sys_group", "name = '$username'", 'groupid', $tmp['groupid']); unset($tmp); } - + // password changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') { $password = $app->db->quote($this->dataRecord["password"]); @@ -222,14 +222,14 @@ class page_action extends tform_actions { $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n=0;$n<8;$n++) { - $salt.=$base64_alphabet[mt_rand(0,63)]; + $salt.=$base64_alphabet[mt_rand(0, 63)]; } $salt.="$"; - $password = crypt(stripslashes($password),$salt); + $password = crypt(stripslashes($password), $salt); $sql = "UPDATE sys_user SET passwort = '$password' WHERE client_id = $client_id"; $app->db->query($sql); } - + // language changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['language']) && $this->dataRecord['language'] != '' && $this->oldDataRecord['language'] != $this->dataRecord['language']) { $language = $app->db->quote($this->dataRecord["language"]); @@ -237,14 +237,14 @@ class page_action extends tform_actions { $sql = "UPDATE sys_user SET language = '$language' WHERE client_id = $client_id"; $app->db->query($sql); } - + // ensure that a reseller is not converted to a client in demo mode when client_id <= 2 if(isset($conf['demo_mode']) && $conf['demo_mode'] == true && $this->id <= 2) { if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != -1) { $app->db->query('UPDATE client set limit_client = -1 WHERE client_id = '.$this->id); } } - + // reseller status changed if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) { $modules = $conf['interface_modules_enabled'] . ',client'; @@ -256,9 +256,10 @@ class page_action extends tform_actions { parent::onAfterUpdate(); } + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/client/reseller_list.php b/interface/web/client/reseller_list.php index fd8fca0c7..83f5d6199 100644 --- a/interface/web/client/reseller_list.php +++ b/interface/web/client/reseller_list.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; /****************************************** * Begin Form configuration @@ -53,4 +53,4 @@ $app->listform_actions->SQLExtSelect = ', client.country as countryiso'; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/content.php b/interface/web/content.php index 52ea21652..ea23f5a25 100644 --- a/interface/web/content.php +++ b/interface/web/content.php @@ -28,8 +28,8 @@ 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'); +require_once '../lib/config.inc.php'; +require_once '../lib/app.inc.php'; /* $module = $_REQUEST["s_mod"]; @@ -43,36 +43,36 @@ if(!preg_match("/^[a-z]{2,20}$/i", $module)) die('module name contains unallowed if(!preg_match("/^[a-z]{2,20}$/i", $page)) die('page name contains unallowed chars.'); if(is_file(ISPC_WEB_PATH."/$module/$page.php")) { - - include_once(ISPC_WEB_PATH."/$module/$page.php"); + + include_once ISPC_WEB_PATH."/$module/$page.php"; $classname = $module.'_'.$page; $page = new $classname(); - + $content = $page->render(); if($page->status == 'OK') { echo $content; } elseif($page->status == 'REDIRECT') { - $target_parts = explode(':',$page->target); + $target_parts = explode(':', $page->target); $module = $target_parts[0]; $page = $target_parts[1]; if(!preg_match("/^[a-z]{2,20}$/i", $module)) die('target module name contains unallowed chars.'); if(!preg_match("/^[a-z]{2,20}$/i", $page)) die('target page name contains unallowed chars.'); - + if(is_file(ISPC_WEB_PATH."/$module/$page.php")) { - include_once(ISPC_WEB_PATH."/$module/$page.php"); - + include_once ISPC_WEB_PATH."/$module/$page.php"; + $classname = $module.'_'.$page; $page = new $classname(); - + $content = $page->render(); if($page->status == 'OK') { echo $content; } } - + } - + } elseif (is_array($_SESSION["s"]['user']) or is_array($_SESSION["s"]["module"])) { // If the user is logged in, we try to load the default page of the module die('- error -'); @@ -80,4 +80,4 @@ if(is_file(ISPC_WEB_PATH."/$module/$page.php")) { die('Page does not exist.'); } -?> \ No newline at end of file +?> diff --git a/interface/web/dashboard/ajax_get_json.php b/interface/web/dashboard/ajax_get_json.php index e761f3e83..48294188d 100644 --- a/interface/web/dashboard/ajax_get_json.php +++ b/interface/web/dashboard/ajax_get_json.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dashboard'); @@ -40,46 +40,46 @@ $type = $_GET["type"]; //if($_SESSION["s"]["user"]["typ"] == 'admin') { - - if($type == 'globalsearch'){ - $q = $app->db->quote(trim($_GET["q"])); - $authsql = " AND ".$app->tform->getAuthSQL('r'); - $modules = explode(',', $_SESSION['s']['user']['modules']); - - $result = array(); - - // clients - $result[] = _search('client', 'client', "AND limit_client = 0"); - - // resellers - $result[] = _search('client', 'reseller', "AND limit_client != 0"); - - // web sites - $result[] = _search('sites', 'web_domain', "AND type = 'vhost'"); - - // subdomains - $result[] = _search('sites', 'web_subdomain', "AND type = 'subdomain'"); - - // web site aliases - $result[] = _search('sites', 'web_aliasdomain', "AND type = 'alias'"); - - // vhostsubdomains - $result[] = _search('sites', 'web_vhost_subdomain', "AND type = 'vhostsubdomain'"); - - // FTP users - $result[] = _search('sites', 'ftp_user'); - - // shell users - $result[] = _search('sites', 'shell_user'); - - // databases - /* + +if($type == 'globalsearch'){ + $q = $app->db->quote(trim($_GET["q"])); + $authsql = " AND ".$app->tform->getAuthSQL('r'); + $modules = explode(',', $_SESSION['s']['user']['modules']); + + $result = array(); + + // clients + $result[] = _search('client', 'client', "AND limit_client = 0"); + + // resellers + $result[] = _search('client', 'reseller', "AND limit_client != 0"); + + // web sites + $result[] = _search('sites', 'web_domain', "AND type = 'vhost'"); + + // subdomains + $result[] = _search('sites', 'web_subdomain', "AND type = 'subdomain'"); + + // web site aliases + $result[] = _search('sites', 'web_aliasdomain', "AND type = 'alias'"); + + // vhostsubdomains + $result[] = _search('sites', 'web_vhost_subdomain', "AND type = 'vhostsubdomain'"); + + // FTP users + $result[] = _search('sites', 'ftp_user'); + + // shell users + $result[] = _search('sites', 'shell_user'); + + // databases + /* $result_databases = array('cheader' => array(), 'cdata' => array()); if(in_array('sites', $modules)){ $sql = "SELECT * FROM web_database WHERE database_name LIKE '%".$q."%' OR database_user LIKE '%".$q."%' OR remote_ips LIKE '%".$q."%'".$authsql." ORDER BY database_name"; $results = $app->db->queryAllRecords($sql); - if(is_array($results) && !empty($results)){ + if(is_array($results) && !empty($results)){ $result_databases['cheader'] = array('title' => 'Databases', 'total' => count($results), 'limit' => count($results) @@ -91,65 +91,65 @@ $type = $_GET["type"]; 'onclick' => 'capp(\'sites\',\'sites/database_edit.php?id='.$result['database_id'].'\');', 'fill_text' => strtolower($result['database_name']) ); - } + } } } */ - $result[] = _search('sites', 'database'); - - // database users - $result[] = _search('sites', 'database_user'); - - // email domains - $result[] = _search('mail', 'mail_domain'); - - // email alias domains - $result[] = _search('mail', 'mail_aliasdomain', "AND type = 'aliasdomain'"); - - // email mailboxes - $result[] = _search('mail', 'mail_user'); - - // email aliases - $result[] = _search('mail', 'mail_alias', "AND type = 'alias'"); - - // email forwards - $result[] = _search('mail', 'mail_forward', "AND type = 'forward'"); - - // email catchalls - $result[] = _search('mail', 'mail_domain_catchall', "AND type = 'catchall'"); - - // email transports - $result[] = _search('mail', 'mail_transport'); - - // mailinglists - $result[] = _search('mail', 'mail_mailinglist'); - - // getmails - $result[] = _search('mail', 'mail_get'); - - // dns zones - $result[] = _search('dns', 'dns_soa'); - - // secondary dns zones - $result[] = _search('dns', 'dns_slave'); - - // virtual machines - $result[] = _search('vm', 'openvz_vm'); - - // virtual machines os templates - $result[] = _search('vm', 'openvz_ostemplate'); - - // virtual machines vm templates - $result[] = _search('vm', 'openvz_template'); - - // virtual machines ip addresses - $result[] = _search('vm', 'openvz_ip'); - - // directive snippets - $result[] = _search('admin', 'directive_snippets'); - - $json = $app->functions->json_encode($result); - } + $result[] = _search('sites', 'database'); + + // database users + $result[] = _search('sites', 'database_user'); + + // email domains + $result[] = _search('mail', 'mail_domain'); + + // email alias domains + $result[] = _search('mail', 'mail_aliasdomain', "AND type = 'aliasdomain'"); + + // email mailboxes + $result[] = _search('mail', 'mail_user'); + + // email aliases + $result[] = _search('mail', 'mail_alias', "AND type = 'alias'"); + + // email forwards + $result[] = _search('mail', 'mail_forward', "AND type = 'forward'"); + + // email catchalls + $result[] = _search('mail', 'mail_domain_catchall', "AND type = 'catchall'"); + + // email transports + $result[] = _search('mail', 'mail_transport'); + + // mailinglists + $result[] = _search('mail', 'mail_mailinglist'); + + // getmails + $result[] = _search('mail', 'mail_get'); + + // dns zones + $result[] = _search('dns', 'dns_soa'); + + // secondary dns zones + $result[] = _search('dns', 'dns_slave'); + + // virtual machines + $result[] = _search('vm', 'openvz_vm'); + + // virtual machines os templates + $result[] = _search('vm', 'openvz_ostemplate'); + + // virtual machines vm templates + $result[] = _search('vm', 'openvz_template'); + + // virtual machines ip addresses + $result[] = _search('vm', 'openvz_ip'); + + // directive snippets + $result[] = _search('admin', 'directive_snippets'); + + $json = $app->functions->json_encode($result); +} //} @@ -161,14 +161,14 @@ function _search($module, $section, $additional_sql = ''){ $search_fields = array(); $desc_fields = array(); if(is_file('../'.$module.'/form/'.$section.'.tform.php')){ - include_once('../'.$module.'/form/'.$section.'.tform.php'); - + include_once '../'.$module.'/form/'.$section.'.tform.php'; + $category_title = $form["title"]; $form_file = $form["action"]; $db_table = $form["db_table"]; $db_table_idx = $form["db_table_idx"]; $order_by = $db_table_idx; - + if(is_array($form["tabs"]) && !empty($form["tabs"])){ foreach($form["tabs"] as $tab){ if(is_array($tab['fields']) && !empty($tab['fields'])){ @@ -189,7 +189,7 @@ function _search($module, $section, $additional_sql = ''){ } } unset($form); - + $where_clause = ''; if(!empty($search_fields)){ $where_clause = implode(' OR ', $search_fields); @@ -201,17 +201,17 @@ function _search($module, $section, $additional_sql = ''){ if($additional_sql != '') $where_clause .= ' '.$additional_sql.' '; $order_clause = ''; if($order_by != '') $order_clause = ' ORDER BY '.$order_by; - + $sql = "SELECT * FROM ".$db_table." WHERE ".$where_clause.$authsql.$order_clause." LIMIT 0,10"; $results = $app->db->queryAllRecords($sql); - - if(is_array($results) && !empty($results)){ + + if(is_array($results) && !empty($results)){ $lng_file = '../'.$module.'/lib/lang/'.$_SESSION['s']['language'].'_'.$section.'.lng'; - if(is_file($lng_file)) include($lng_file); + if(is_file($lng_file)) include $lng_file; $result_array['cheader'] = array('title' => $category_title, - 'total' => count($results), - 'limit' => count($results) - ); + 'total' => count($results), + 'limit' => count($results) + ); foreach($results as $result){ $description = ''; if(!empty($desc_fields)){ @@ -221,18 +221,18 @@ function _search($module, $section, $additional_sql = ''){ } if(!empty($desc_items)) $description = implode(' - ', $desc_items); } - + $result_array['cdata'][] = array('title' => $wb[$title_key.'_txt'].': '.$result[$title_key], - 'description' => $description, - 'onclick' => "capp('".$module."','".$module."/".$form_file."?id=".$result[$db_table_idx]."');", - 'fill_text' => strtolower($result[$title_key]) - ); - } + 'description' => $description, + 'onclick' => "capp('".$module."','".$module."/".$form_file."?id=".$result[$db_table_idx]."');", + 'fill_text' => strtolower($result[$title_key]) + ); + } } } return $result_array; } - + header('Content-type: application/json'); echo $json; -?> \ No newline at end of file +?> diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php index 0626758d0..485bb3206 100644 --- a/interface/web/dashboard/dashboard.php +++ b/interface/web/dashboard/dashboard.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dashboard'); @@ -39,7 +39,7 @@ $app->tpl->newTemplate("templates/dashboard.htm"); //* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); //* set Default - Values @@ -94,12 +94,12 @@ $app->tpl->setVar('welcome_user', $welcome); $info = array(); if(isset($_SESSION['show_info_msg'])) { - $info[] = array('info_msg' => '

    '.$_SESSION['show_info_msg'].'

    '); - unset($_SESSION['show_info_msg']); + $info[] = array('info_msg' => '

    '.$_SESSION['show_info_msg'].'

    '); + unset($_SESSION['show_info_msg']); } if(isset($_SESSION['show_error_msg'])) { - $app->tpl->setloop('error', array(array('error_msg' => '

    '.$_SESSION['show_error_msg'].'

    '))); - unset($_SESSION['show_error_msg']); + $app->tpl->setloop('error', array(array('error_msg' => '

    '.$_SESSION['show_error_msg'].'

    '))); + unset($_SESSION['show_error_msg']); } @@ -113,7 +113,7 @@ if($_SESSION["s"]["user"]["typ"] == 'admin') { } $v1 = ISPC_APP_VERSION; $v2 = $_SESSION['s']['new_ispconfig_version']; - $this_version = explode(".",$v1); + $this_version = explode(".", $v1); /* $this_fullversion = (($this_version[0] < 10) ? '0'.$this_version[0] : $this_version[0]) . ((isset($this_version[1]) && $this_version[1] < 10) ? '0'.$this_version[1] : $this_version[1]) . @@ -121,20 +121,20 @@ if($_SESSION["s"]["user"]["typ"] == 'admin') { ((isset($this_version[3]) && $this_version[3] < 10) ? (($this_version[3] < 1) ? '00' : '0'.$this_version[3]) : @$this_version[3]); */ - - $new_version = explode(".",$v2); + + $new_version = explode(".", $v2); /* $new_fullversion = (($new_version[0] < 10) ? '0'.$new_version[0] : $new_version[0]) . ((isset($new_version[1]) && $new_version[1] < 10) ? '0'.$new_version[1] : $new_version[1]) . ((isset($new_version[2]) && $new_version[2] < 10) ? '0'.$new_version[2] : $new_version[2]) . ((isset($new_version[3]) && $new_version[3] < 10) ? (($new_version[3] < 1) ? '00' : '0'.$new_version[3]) : @$new_version[3]); */ - - $this_fullversion = str_pad($this_version[0], 2,'0',STR_PAD_LEFT).str_pad($this_version[1], 2,'0',STR_PAD_LEFT).@str_pad($this_version[2], 2,'0',STR_PAD_LEFT).@str_pad($this_version[3], 2,'0',STR_PAD_LEFT); - $new_fullversion = str_pad($new_version[0], 2,'0',STR_PAD_LEFT).str_pad($new_version[1], 2,'0',STR_PAD_LEFT).@str_pad($new_version[2], 2,'0',STR_PAD_LEFT).@str_pad($new_version[3], 2,'0',STR_PAD_LEFT); + + $this_fullversion = str_pad($this_version[0], 2, '0', STR_PAD_LEFT).str_pad($this_version[1], 2, '0', STR_PAD_LEFT).@str_pad($this_version[2], 2, '0', STR_PAD_LEFT).@str_pad($this_version[3], 2, '0', STR_PAD_LEFT); + $new_fullversion = str_pad($new_version[0], 2, '0', STR_PAD_LEFT).str_pad($new_version[1], 2, '0', STR_PAD_LEFT).@str_pad($new_version[2], 2, '0', STR_PAD_LEFT).@str_pad($new_version[3], 2, '0', STR_PAD_LEFT); if($new_fullversion > $this_fullversion) { - $info[] = array('info_msg' => '

    There is a new Version of ISPConfig 3 available!

    ' . - '

    This Version: ' . $v1 . '

    ' . + $info[] = array('info_msg' => '

    There is a new Version of ISPConfig 3 available!

    ' . + '

    This Version: ' . $v1 . '

    ' . '

    New Version : ' . $v2 . '

    ' . '

    See more...

    '); } @@ -144,12 +144,12 @@ $app->tpl->setloop('info', $info); /* Load the dashlets*/ $dashlet_list = array(); -$handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); -while ($file = @readdir ($handle)) { - if ($file != '.' && $file != '..' && !is_dir($file)) { - $dashlet_name = substr($file,0,-4); +$handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); +while ($file = @readdir($handle)) { + if ($file != '.' && $file != '..' && !is_dir($file)) { + $dashlet_name = substr($file, 0, -4); $dashlet_class = 'dashlet_'.$dashlet_name; - include_once(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file); + include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file; $dashlet_list[$dashlet_name] = new $dashlet_class; } } @@ -157,7 +157,7 @@ while ($file = @readdir ($handle)) { /* Which dashlets in which column */ /******************************************************************************/ -$default_leftcol_dashlets = array('modules','invoices','quota','mailquota'); +$default_leftcol_dashlets = array('modules', 'invoices', 'quota', 'mailquota'); $default_rightcol_dashlets = array('limits'); $app->uses('getconf'); @@ -165,10 +165,10 @@ $dashlets_config = $app->getconf->get_global_config('misc'); //* Client: If the logged in user is not admin and has no sub clients (no reseller) if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { $role = 'client'; -//* Reseller: If the logged in user is not admin and has sub clients (is a reseller) + //* Reseller: If the logged in user is not admin and has sub clients (is a reseller) } elseif ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { $role = 'reseller'; -//* Admin: If the logged in user is admin + //* Admin: If the logged in user is admin } else { $role = 'admin'; } @@ -177,7 +177,7 @@ $dashlets_config[$role.'_dashlets_right'] = trim($dashlets_config[$role.'_dashle if($dashlets_config[$role.'_dashlets_left'] != ''){ preg_match_all('@\[(.*?)\]@', $dashlets_config[$role.'_dashlets_left'], $matches); - $leftcol_dashlets = $matches[1]; + $leftcol_dashlets = $matches[1]; } else { $leftcol_dashlets = $default_leftcol_dashlets; } @@ -212,4 +212,4 @@ $app->tpl->setloop('rightcol', $rightcol); //* Do Output $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/dashboard/dashlets/limits.php b/interface/web/dashboard/dashlets/limits.php index 16144f218..2d63925b4 100644 --- a/interface/web/dashboard/dashlets/limits.php +++ b/interface/web/dashboard/dashlets/limits.php @@ -1,136 +1,136 @@ 'limit_maildomain', - 'db_table' => 'mail_domain', - 'db_where' => ''); - + 'db_table' => 'mail_domain', + 'db_where' => ''); + $limits[] = array('field' => 'limit_mailmailinglist', - 'db_table' => 'mail_mailinglist', - 'db_where' => ''); - + 'db_table' => 'mail_mailinglist', + 'db_where' => ''); + $limits[] = array('field' => 'limit_mailbox', - 'db_table' => 'mail_user', - 'db_where' => ''); - + 'db_table' => 'mail_user', + 'db_where' => ''); + $limits[] = array('field' => 'limit_mailalias', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'alias'"); - + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'alias'"); + $limits[] = array('field' => 'limit_mailaliasdomain', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'aliasdomain'"); - + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'aliasdomain'"); + $limits[] = array('field' => 'limit_mailforward', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'forward'"); - + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'forward'"); + $limits[] = array('field' => 'limit_mailcatchall', - 'db_table' => 'mail_forwarding', - 'db_where' => "type = 'catchall'"); - + 'db_table' => 'mail_forwarding', + 'db_where' => "type = 'catchall'"); + $limits[] = array('field' => 'limit_mailrouting', - 'db_table' => 'mail_transport', - 'db_where' => ""); - + 'db_table' => 'mail_transport', + 'db_where' => ""); + $limits[] = array('field' => 'limit_mailfilter', - 'db_table' => 'mail_user_filter', - 'db_where' => ""); - + 'db_table' => 'mail_user_filter', + 'db_where' => ""); + $limits[] = array('field' => 'limit_fetchmail', - 'db_table' => 'mail_get', - 'db_where' => ""); - + 'db_table' => 'mail_get', + 'db_where' => ""); + $limits[] = array('field' => 'limit_spamfilter_wblist', - 'db_table' => 'spamfilter_wblist', - 'db_where' => ""); - + 'db_table' => 'spamfilter_wblist', + 'db_where' => ""); + $limits[] = array('field' => 'limit_spamfilter_user', - 'db_table' => 'spamfilter_users', - 'db_where' => ""); - + 'db_table' => 'spamfilter_users', + 'db_where' => ""); + $limits[] = array('field' => 'limit_spamfilter_policy', - 'db_table' => 'spamfilter_policy', - 'db_where' => ""); - + 'db_table' => 'spamfilter_policy', + 'db_where' => ""); + $limits[] = array('field' => 'limit_web_domain', - 'db_table' => 'web_domain', - 'db_where' => "type = 'vhost'"); - + 'db_table' => 'web_domain', + 'db_where' => "type = 'vhost'"); + $limits[] = array('field' => 'limit_web_subdomain', - 'db_table' => 'web_domain', - 'db_where' => "(type = 'subdomain' OR type = 'vhostsubdomain')"); - + 'db_table' => 'web_domain', + 'db_where' => "(type = 'subdomain' OR type = 'vhostsubdomain')"); + $limits[] = array('field' => 'limit_web_aliasdomain', - 'db_table' => 'web_domain', - 'db_where' => "type = 'alias'"); - + 'db_table' => 'web_domain', + 'db_where' => "type = 'alias'"); + $limits[] = array('field' => 'limit_ftp_user', - 'db_table' => 'ftp_user', - 'db_where' => ""); + 'db_table' => 'ftp_user', + 'db_where' => ""); $limits[] = array('field' => 'limit_shell_user', - 'db_table' => 'shell_user', - 'db_where' => ""); - + 'db_table' => 'shell_user', + 'db_where' => ""); + $limits[] = array('field' => 'limit_dns_zone', - 'db_table' => 'dns_soa', - 'db_where' => ""); + 'db_table' => 'dns_soa', + 'db_where' => ""); $limits[] = array('field' => 'limit_dns_slave_zone', - 'db_table' => 'dns_slave', - 'db_where' => ""); + 'db_table' => 'dns_slave', + 'db_where' => ""); $limits[] = array('field' => 'limit_dns_record', - 'db_table' => 'dns_rr', - 'db_where' => ""); - + 'db_table' => 'dns_rr', + 'db_where' => ""); + $limits[] = array('field' => 'limit_database', - 'db_table' => 'web_database', - 'db_where' => ""); - + 'db_table' => 'web_database', + 'db_where' => ""); + $limits[] = array('field' => 'limit_cron', - 'db_table' => 'cron', - 'db_where' => ""); - + 'db_table' => 'cron', + 'db_where' => ""); + $limits[] = array('field' => 'limit_client', - 'db_table' => 'client', - 'db_where' => ""); - - - - + 'db_table' => 'client', + 'db_where' => ""); + + + + //* Loading Template $app->uses('tpl,tform'); - + $tpl = new tpl; $tpl->newTemplate("dashlets/templates/limits.htm"); - + $wb = array(); $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_limits.lng'; - if(is_file($lng_file)) include($lng_file); + if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - + if($app->auth->is_admin()) { $user_is_admin = true; } else { $user_is_admin = false; } - $tpl->setVar('is_admin',$user_is_admin); - + $tpl->setVar('is_admin', $user_is_admin); + if($user_is_admin == false) { $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT * FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); } - + $rows = array(); foreach($limits as $limit) { $field = $limit['field']; @@ -142,29 +142,29 @@ class dashlet_limits { if($value != 0 || $value == $wb['unlimited_txt']) { $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; $rows[] = array('field' => $field, - 'field_txt' => $wb[$field.'_txt'], - 'value' => $value_formatted, - 'usage' => $this->_get_limit_usage($limit)); + 'field_txt' => $wb[$field.'_txt'], + 'value' => $value_formatted, + 'usage' => $this->_get_limit_usage($limit)); } } - $tpl->setLoop('rows',$rows); - - + $tpl->setLoop('rows', $rows); + + return $tpl->grab(); - + } - + function _get_limit_usage($limit) { global $app; - + $sql = "SELECT count(sys_userid) as number FROM ".$limit['db_table']." WHERE "; if($limit['db_where'] != '') $sql .= $limit['db_where']." AND "; $sql .= $app->tform->getAuthSQL('r'); $rec = $app->db->queryOneRecord($sql); return $rec['number']; - + } - + } diff --git a/interface/web/dashboard/dashlets/mailquota.php b/interface/web/dashboard/dashlets/mailquota.php index dd8d72bbf..956c4e65c 100644 --- a/interface/web/dashboard/dashlets/mailquota.php +++ b/interface/web/dashboard/dashlets/mailquota.php @@ -1,21 +1,21 @@ uses('tpl'); - + $tpl = new tpl; $tpl->newTemplate("dashlets/templates/mailquota.htm"); - + $wb = array(); $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_mailquota.lng'; - if(is_file($lng_file)) include($lng_file); + if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - + $tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'email_quota' ORDER BY created DESC"); $monitor_data = array(); if(is_array($tmp_rec)) { @@ -33,7 +33,7 @@ class dashlet_mailquota { if($_SESSION["s"]["user"]["typ"] != 'admin'){ $sql_where = " AND sys_groupid = ".$_SESSION['s']['user']['default_group']; } - + $has_mailquota = false; // select email accounts belonging to client $emails = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE 1".$sql_where); @@ -41,11 +41,11 @@ class dashlet_mailquota { if(is_array($emails) && !empty($emails)){ for($i=0;$i 0); - + if (!is_numeric($emails[$i]['used'])) $emails[$i]['used']=$emails[$i]['used'][1]; - + // colours $emails[$i]['display_colour'] = '#000000'; if($emails[$i]['quota'] > 0){ @@ -59,28 +59,29 @@ class dashlet_mailquota { if($emails[$i]['quota'] == 0){ $emails[$i]['quota'] = $app->lng('unlimited'); } else { - $emails[$i]['quota'] = round($emails[$i]['quota'] / 1048576,4).' MB'; + $emails[$i]['quota'] = round($emails[$i]['quota'] / 1048576, 4).' MB'; } if($emails[$i]['used'] < 1544000) { - $emails[$i]['used'] = round($emails[$i]['used'] / 1024,4).' KB'; + $emails[$i]['used'] = round($emails[$i]['used'] / 1024, 4).' KB'; } else { - $emails[$i]['used'] = round($emails[$i]['used'] / 1048576,4).' MB'; - } - + $emails[$i]['used'] = round($emails[$i]['used'] / 1048576, 4).' MB'; + } + } $has_mailquota = true; $tpl->setloop('mailquota', $emails); } //print_r($sites); - - $tpl->setVar('has_mailquota',$has_mailquota); - + + $tpl->setVar('has_mailquota', $has_mailquota); + return $tpl->grab(); - - + + } + } @@ -90,4 +91,4 @@ class dashlet_mailquota { -?> \ No newline at end of file +?> diff --git a/interface/web/dashboard/dashlets/modules.php b/interface/web/dashboard/dashlets/modules.php index 2f16329f8..1b1d2ef99 100644 --- a/interface/web/dashboard/dashlets/modules.php +++ b/interface/web/dashboard/dashlets/modules.php @@ -1,21 +1,21 @@ uses('tpl'); - + $tpl = new tpl; $tpl->newTemplate("dashlets/templates/modules.htm"); - + $wb = array(); $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_modules.lng'; - if(is_file($lng_file)) include($lng_file); + if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - + /* * Show all modules, the user is allowed to use */ @@ -25,28 +25,29 @@ class dashlet_modules { foreach($modules as $mt) { if(is_file('../' . $mt . '/lib/module.conf.php')) { if(!preg_match("/^[a-z]{2,20}$/i", $mt)) die('module name contains unallowed chars.'); - include_once('../' . $mt.'/lib/module.conf.php'); + include_once '../' . $mt.'/lib/module.conf.php'; /* We don't want to show the dashboard */ if ($mt != 'dashboard') { $module_title = $app->lng($module['title']); if(function_exists('mb_strlen')) { - if(mb_strlen($module_title,"UTF-8") > 8) $module_title = mb_substr($module_title,0,7,"UTF-8").'..'; + if(mb_strlen($module_title, "UTF-8") > 8) $module_title = mb_substr($module_title, 0, 7, "UTF-8").'..'; } else { - if(strlen($module_title) > 8) $module_title = substr($module_title,0,7).'..'; + if(strlen($module_title) > 8) $module_title = substr($module_title, 0, 7).'..'; } - $mod[] = array( 'modules_title' => $module_title, - 'modules_startpage' => $module['startpage'], - 'modules_name' => $module['name']); + $mod[] = array( 'modules_title' => $module_title, + 'modules_startpage' => $module['startpage'], + 'modules_name' => $module['name']); } } } $tpl->setloop('modules', $mod); } - + return $tpl->grab(); - + } + } @@ -56,4 +57,4 @@ class dashlet_modules { -?> \ No newline at end of file +?> diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index 29d1d3b83..1cb567136 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -1,33 +1,33 @@ uses('tpl'); - + $tpl = new tpl; $tpl->newTemplate("dashlets/templates/quota.htm"); - + $wb = array(); $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_quota.lng'; - if(is_file($lng_file)) include($lng_file); + if(is_file($lng_file)) include $lng_file; $tpl->setVar($wb); - + $tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'harddisk_quota' ORDER BY created DESC"); $monitor_data = array(); if(is_array($tmp_rec)) { foreach ($tmp_rec as $tmp_mon) { - $monitor_data = array_merge_recursive($monitor_data,unserialize($app->db->unquote($tmp_mon['data']))); + $monitor_data = array_merge_recursive($monitor_data, unserialize($app->db->unquote($tmp_mon['data']))); } } //print_r($monitor_data); if($_SESSION["s"]["user"]["typ"] != 'admin'){ $sql_where = " AND sys_groupid = ".$_SESSION['s']['user']['default_group']; } - + $has_quota = false; // select websites belonging to client $sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND type = 'vhost'".$sql_where); @@ -39,7 +39,7 @@ class dashlet_quota { $sites[$i]['soft'] = $monitor_data['user'][$username]['soft']; $sites[$i]['hard'] = $monitor_data['user'][$username]['hard']; $sites[$i]['files'] = $monitor_data['user'][$username]['files']; - + if (!is_numeric($sites[$i]['used'])){ if ($sites[$i]['used'][0] > $sites[$i]['used'][1]){ $sites[$i]['used'] = $sites[$i]['used'][0]; @@ -50,7 +50,7 @@ class dashlet_quota { if (!is_numeric($sites[$i]['soft'])) $sites[$i]['soft']=$sites[$i]['soft'][1]; if (!is_numeric($sites[$i]['hard'])) $sites[$i]['hard']=$sites[$i]['hard'][1]; if (!is_numeric($sites[$i]['files'])) $sites[$i]['files']=$sites[$i]['files'][1]; - + // colours $sites[$i]['display_colour'] = '#000000'; if($sites[$i]['soft'] > 0){ @@ -60,50 +60,51 @@ class dashlet_quota { } if($used_ratio >= 0.8) $sites[$i]['display_colour'] = '#fd934f'; if($used_ratio >= 1) $sites[$i]['display_colour'] = '#cc0000'; - + if($sites[$i]['used'] > 1024) { - $sites[$i]['used'] = round($sites[$i]['used'] / 1024,2).' MB'; + $sites[$i]['used'] = round($sites[$i]['used'] / 1024, 2).' MB'; } else { if ($sites[$i]['used'] != '') $sites[$i]['used'] .= ' KB'; } - + if($sites[$i]['soft'] > 1024) { - $sites[$i]['soft'] = round($sites[$i]['soft'] / 1024,2).' MB'; + $sites[$i]['soft'] = round($sites[$i]['soft'] / 1024, 2).' MB'; } else { $sites[$i]['soft'] .= ' KB'; } - + if($sites[$i]['hard'] > 1024) { - $sites[$i]['hard'] = round($sites[$i]['hard'] / 1024,2).' MB'; + $sites[$i]['hard'] = round($sites[$i]['hard'] / 1024, 2).' MB'; } else { $sites[$i]['hard'] .= ' KB'; } - + if($sites[$i]['soft'] == " KB") $sites[$i]['soft'] = $app->lng('unlimited'); if($sites[$i]['hard'] == " KB") $sites[$i]['hard'] = $app->lng('unlimited'); - - + + /* if(!strstr($sites[$i]['used'],'M') && !strstr($sites[$i]['used'],'K')) $sites[$i]['used'].= ' B'; if(!strstr($sites[$i]['soft'],'M') && !strstr($sites[$i]['soft'],'K')) $sites[$i]['soft'].= ' B'; if(!strstr($sites[$i]['hard'],'M') && !strstr($sites[$i]['hard'],'K')) $sites[$i]['hard'].= ' B'; */ - + if($sites[$i]['soft'] == '0 B' || $sites[$i]['soft'] == '0 KB' || $sites[$i]['soft'] == '0') $sites[$i]['soft'] = $app->lng('unlimited'); if($sites[$i]['hard'] == '0 B' || $sites[$i]['hard'] == '0 KB' || $sites[$i]['hard'] == '0') $sites[$i]['hard'] = $app->lng('unlimited'); - + } $has_quota = true; $tpl->setloop('quota', $sites); } //print_r($sites); - - $tpl->setVar('has_quota',$has_quota); - + + $tpl->setVar('has_quota', $has_quota); + return $tpl->grab(); - - + + } + } @@ -113,4 +114,4 @@ class dashlet_quota { -?> \ No newline at end of file +?> diff --git a/interface/web/dashboard/lib/admin.conf.php b/interface/web/dashboard/lib/admin.conf.php index 584f28bad..b4b2eb916 100644 --- a/interface/web/dashboard/lib/admin.conf.php +++ b/interface/web/dashboard/lib/admin.conf.php @@ -26,4 +26,4 @@ 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. */ -?> \ No newline at end of file +?> diff --git a/interface/web/dashboard/lib/custom_menu.inc.php b/interface/web/dashboard/lib/custom_menu.inc.php index 8796023c6..b71bd16f6 100644 --- a/interface/web/dashboard/lib/custom_menu.inc.php +++ b/interface/web/dashboard/lib/custom_menu.inc.php @@ -38,24 +38,24 @@ $misc_config = $app->getconf->get_global_config('misc'); switch($_SESSION['s']['user']['typ']) { - case 'admin': - $atom_url = $misc_config['dashboard_atom_url_admin']; - break; - case 'user': - if ($app->auth->has_clients($_SESSION['s']['user']['userid']) === true) - $atom_url = $misc_config['dashboard_atom_url_reseller']; - else - $atom_url = $misc_config['dashboard_atom_url_client']; - break; - default: - $atom_url = ""; +case 'admin': + $atom_url = $misc_config['dashboard_atom_url_admin']; + break; +case 'user': + if ($app->auth->has_clients($_SESSION['s']['user']['userid']) === true) + $atom_url = $misc_config['dashboard_atom_url_reseller']; + else + $atom_url = $misc_config['dashboard_atom_url_client']; + break; +default: + $atom_url = ""; } $rows = array(); if( $atom_url != '' ) { if(!isset($_SESSION['s']['rss_news'])) { - + $app->simplepie->set_feed_url($atom_url); $app->simplepie->enable_cache(false); $app->simplepie->init(); @@ -69,24 +69,24 @@ if( $atom_url != '' ) { //* We want to show only the first 10 news records if($n <= 10) { $rows[] = array('title' => $item->get_title(), - 'link' => $item->get_link(), - 'content' => $item->get_content(), - 'date' => $item->get_date('Y-m-d') - ); + 'link' => $item->get_link(), + 'content' => $item->get_content(), + 'date' => $item->get_date('Y-m-d') + ); } $n++; } - + $_SESSION['s']['rss_news'] = $rows; - + } else { $rows = $_SESSION['s']['rss_news']; } - - $app->tpl->setVar('latest_news_txt',$app->lng('latest_news_txt')); + + $app->tpl->setVar('latest_news_txt', $app->lng('latest_news_txt')); } -$app->tpl->setLoop('news',$rows); +$app->tpl->setLoop('news', $rows); ?> diff --git a/interface/web/dashboard/lib/module.conf.php b/interface/web/dashboard/lib/module.conf.php index 337d6b700..67f769e6b 100644 --- a/interface/web/dashboard/lib/module.conf.php +++ b/interface/web/dashboard/lib/module.conf.php @@ -27,22 +27,22 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -$module['name'] = 'dashboard'; -$module['title'] = 'top_menu_dashboard'; -$module['template'] = 'dashboard.tpl.htm'; -$module['startpage'] = 'dashboard/dashboard.php'; +$module['name'] = 'dashboard'; +$module['title'] = 'top_menu_dashboard'; +$module['template'] = 'dashboard.tpl.htm'; +$module['startpage'] = 'dashboard/dashboard.php'; $module['tab_width'] = ''; //$items = array(); // -//$items[] = array( 'title' => 'Dashboard 1', -// 'target' => 'content', -// 'link' => 'dashboard/dashboard.php'); +//$items[] = array( 'title' => 'Dashboard 1', +// 'target' => 'content', +// 'link' => 'dashboard/dashboard.php'); // -//$module['nav'][] = array( 'title' => 'Dashboard 2', -// 'open' => 1, -// 'items' => $items); +//$module['nav'][] = array( 'title' => 'Dashboard 2', +// 'open' => 1, +// 'items' => $items); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/form_edit.php b/interface/web/designer/form_edit.php index 90acd2e1b..2127fea68 100644 --- a/interface/web/designer/form_edit.php +++ b/interface/web/designer/form_edit.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); @@ -39,15 +39,15 @@ $app->auth->check_module_permissions('designer'); // Lade Template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/form_edit.htm'); +$app->tpl->setInclude('content_tpl', 'templates/form_edit.htm'); // Importing variables $module_name = $_REQUEST["module_name"]; $form_name = $_REQUEST["form_name"]; // Checking imported variables -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$form_name)) die("form_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)) die("module_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $form_name)) die("form_name contains invalid chars."); $id = $form_name; @@ -59,52 +59,52 @@ if(count($_POST) > 1) { $action = 'INSERT'; } - + if($error == '') { - + $filename = "../".$module_name."/form/".$form_name.".tform.php"; $form_new = $_POST["form"]; - + if(@is_file($filename)) { - include_once($filename); + include_once $filename; $tabs = $form["tabs"]; unset($form["tabs"]); $form_new["tabs"] = $tabs; } - - $file_content = ""; - + + $file_content = ""; + die($file_content); - + // writing module.conf - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - - if (!fwrite($handle, $file_content)) { - print "Cannot write to file ($filename)"; - exit; - } - + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + + if (!fwrite($handle, $file_content)) { + print "Cannot write to file ($filename)"; + exit; + } + fclose($handle); - + // zu Liste springen - header("Location: form_list.php"); - exit; - + header("Location: form_list.php"); + exit; + } else { - $app->tpl->setVar("error","Fehler:
    ".$error); + $app->tpl->setVar("error", "Fehler:
    ".$error); $app->tpl->setVar($_POST); } } if($id != '') { -// Datensatz besteht bereits + // Datensatz besteht bereits // bestehenden Datensatz anzeigen if($error == '') { // es liegt ein Fehler vor - include_once("../".$module_name."/form/".$form_name.".tform.php"); + include_once "../".$module_name."/form/".$form_name.".tform.php"; //$tabs = $form["tabs"]; unset($form["tabs"]); $record = $form; @@ -123,7 +123,7 @@ if($id != '') { } $record["readonly"] = 'style="background-color: #EEEEEE;" readonly'; } else { -// neuer datensatz + // neuer datensatz if($error == '') { // es liegt kein Fehler vor // Pewsets @@ -132,7 +132,7 @@ if($id != '') { // ein Fehler $record = $_POST; unset($_POST["tabs"]); - + } $record["readonly"] = ''; } @@ -141,7 +141,7 @@ $record["id"] = $form_name; $app->tpl->setVar($record); -include_once("lib/lang/".$_SESSION["s"]["language"]."_form_edit.lng"); +include_once "lib/lang/".$_SESSION["s"]["language"]."_form_edit.lng"; $app->tpl->setVar($wb); // Defaultwerte setzen @@ -150,4 +150,4 @@ $app->tpl_defaults(); // Template parsen $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/form_list.php b/interface/web/designer/form_list.php index 6bd8bc69c..009327597 100644 --- a/interface/web/designer/form_list.php +++ b/interface/web/designer/form_list.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('designer'); @@ -40,50 +40,50 @@ $app->tpl->setInclude('content_tpl', 'templates/form_list.htm'); function getinfo($file, $form_file, $bgcolor) { $module_name = $file; - include(ISPC_WEB_PATH."/$file/form/$form_file"); - return array( 'name' => $form['name'], - 'title' => $form['title'], - 'description' => $form['description'], - 'module_name' => $module_name, - 'bgcolor' => $bgcolor - ); + include ISPC_WEB_PATH."/$file/form/$form_file"; + return array( 'name' => $form['name'], + 'title' => $form['title'], + 'description' => $form['description'], + 'module_name' => $module_name, + 'bgcolor' => $bgcolor + ); } // lese Module aus $bgcolor = '#FFFFFF'; $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') { +$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') { if(@is_dir(ISPC_WEB_PATH."/$file/form")) { $handle2 = opendir(ISPC_WEB_PATH."/$file/form"); - while ($form_file = @readdir ($handle2)) { - if (substr($form_file,0,1) != ".") { - //echo ISPC_ROOT_PATH."/web/".$file."/form/$form_file
    "; + while ($form_file = @readdir($handle2)) { + if (substr($form_file, 0, 1) != ".") { + //echo ISPC_ROOT_PATH."/web/".$file."/form/$form_file
    "; //include_once(ISPC_ROOT_PATH."/web/".$file."/form/$form_file"); // Farbwechsel - $bgcolor = ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF'; + $bgcolor = ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF'; $modules_list[] = getinfo($file, $form_file, $bgcolor); } } } } - } + } } } $app->tpl->setLoop('records', $modules_list); -//* load language file +//* load language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_form_list.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/form_show.php b/interface/web/designer/form_show.php index 4cb805668..74e609bf1 100644 --- a/interface/web/designer/form_show.php +++ b/interface/web/designer/form_show.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('designer'); @@ -38,26 +38,26 @@ if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/form_show.htm'); +$app->tpl->setInclude('content_tpl', 'templates/form_show.htm'); // TODO: Check ID for malicius chars $module_name = $_REQUEST["module_name"]; $form_name = $_REQUEST["form_name"]; -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$form_name)) die("form_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)) die("module_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $form_name)) die("form_name contains invalid chars."); -include_once("../".$module_name."/form/".$form_name.".tform.php"); +include_once "../".$module_name."/form/".$form_name.".tform.php"; $tabs = $form["tabs"]; unset($form["tabs"]); $record = $form; $record["form_name"] = $form_name; $record["module_name"] = $module_name; -// loading language file +// loading language file $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_form_show.lng"; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); // baue Tabs navi @@ -65,8 +65,8 @@ $content = ""; $n1 = 0; $n2 = 0; if(is_array($tabs)) { -foreach($tabs as $tab_id => $tab) { - $content .= " + foreach($tabs as $tab_id => $tab) { + $content .= " @@ -79,12 +79,12 @@ foreach($tabs as $tab_id => $tab) { "; - //$content .= "\r\n"; - foreach($tab["fields"] as $field_id => $field) { - //$content .= "\r\n"; - //$content .= "\r\n"; - //$content .= "\r\n"; - $content .= " + //$content .= "\r\n"; + foreach($tab["fields"] as $field_id => $field) { + //$content .= "\r\n"; + //$content .= "\r\n"; + //$content .= "\r\n"; + $content .= ""; - $n2++; - } - $content .= " + $n2++; + } + $content .= "
    Bereich:
    Titel:
    Ziel:       
    Link:       
    Bereich:
    Titel:
    Ziel:       
    Link:       
    $field_id @@ -93,14 +93,14 @@ foreach($tabs as $tab_id => $tab) {
     
     
    "; - $n1++; -} + $n1++; + } } $record["nav"] = $content; @@ -109,11 +109,11 @@ $record["nav"] = $content; $app->tpl->setVar($record); -$app->tpl->setLoop('records',$modules_list); +$app->tpl->setLoop('records', $modules_list); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/index.php b/interface/web/designer/index.php index e69de29bb..8b1378917 100644 --- a/interface/web/designer/index.php +++ b/interface/web/designer/index.php @@ -0,0 +1 @@ + diff --git a/interface/web/designer/lib/admin.conf.php b/interface/web/designer/lib/admin.conf.php index dc10d5633..6eff33c4e 100644 --- a/interface/web/designer/lib/admin.conf.php +++ b/interface/web/designer/lib/admin.conf.php @@ -1,4 +1,4 @@ \ No newline at end of file +?> diff --git a/interface/web/designer/lib/module.conf.php b/interface/web/designer/lib/module.conf.php index 117f79b56..6104f497c 100644 --- a/interface/web/designer/lib/module.conf.php +++ b/interface/web/designer/lib/module.conf.php @@ -1,47 +1,47 @@ 'designer', - 'title' => 'BE Designer', - 'template' => 'module.tpl.htm', - 'navframe_page' => '', - 'startpage' => 'designer/module_list.php', - 'tab_width' => '', - 'nav' => - array ( - 0 => - array ( - 'title' => 'Modules', - 'open' => '1', - 'items' => - array ( - 0 => - array ( - 'title' => 'Add', - 'target' => 'content', - 'link' => 'designer/module_edit.php', - ), - 1 => - array ( - 'title' => 'Edit', - 'target' => 'content', - 'link' => 'designer/module_list.php', - ), - ), - ), - /* - 1 => + 'name' => 'designer', + 'title' => 'BE Designer', + 'template' => 'module.tpl.htm', + 'navframe_page' => '', + 'startpage' => 'designer/module_list.php', + 'tab_width' => '', + 'nav' => + array ( + 0 => + array ( + 'title' => 'Modules', + 'open' => '1', + 'items' => + array ( + 0 => + array ( + 'title' => 'Add', + 'target' => 'content', + 'link' => 'designer/module_edit.php', + ), + 1 => + array ( + 'title' => 'Edit', + 'target' => 'content', + 'link' => 'designer/module_list.php', + ), + ), + ), + /* + 1 => array ( 'title' => 'Formulare', 'open' => '1', - 'items' => + 'items' => array ( - 2 => + 2 => array ( 'title' => 'Add', 'target' => 'content', 'link' => 'designer/form_edit.php', ), - 3 => + 3 => array ( 'title' => 'Edit', 'target' => 'content', @@ -49,19 +49,19 @@ $module = array ( ), ), ), - 2 => + 2 => array ( 'title' => 'Lists', 'open' => '1', - 'items' => + 'items' => array ( - 4 => + 4 => array ( 'title' => 'Add', 'target' => 'content', 'link' => 'designer/list_edit.php', ), - 5 => + 5 => array ( 'title' => 'Edit', 'target' => 'content', @@ -69,19 +69,19 @@ $module = array ( ), ), ), - 3 => + 3 => array ( 'title' => 'Languages', 'open' => '1', - 'items' => + 'items' => array ( - 6 => + 6 => array ( 'title' => 'Add', 'target' => 'content', 'link' => 'designer/lang_edit.php', ), - 7 => + 7 => array ( 'title' => 'Edit', 'target' => 'content', @@ -90,6 +90,6 @@ $module = array ( ), ), */ - ), + ), ) -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_edit.php b/interface/web/designer/module_edit.php index 26e229a7d..af7dbb027 100644 --- a/interface/web/designer/module_edit.php +++ b/interface/web/designer/module_edit.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); @@ -39,11 +39,11 @@ $app->auth->check_module_permissions('designer'); // Lade Template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/module_edit.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_edit.htm'); // ID importieren $id = $_REQUEST["id"]; -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$id)) die("id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $id)) die("id contains invalid chars."); if(count($_POST) > 1) { // Bestimme aktion @@ -53,24 +53,24 @@ if(count($_POST) > 1) { $action = 'INSERT'; } - + if($error == '') { - + $id = $_POST["module"]["name"]; - if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$id)) die("id contains invalid chars."); - + if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $id)) die("id contains invalid chars."); + $filename = "../".$id."/lib/module.conf.php"; $module_new = $_POST["module"]; - + if(@is_file($filename)) { - include_once($filename); + include_once $filename; $navi = $module["nav"]; unset($module); $module_new["nav"] = $navi; } - - $m = ""; - + + $m = ""; + // creating the module directories if(!@is_dir("../".$id)) mkdir("../".$id) or die("Cannot make directory: ../".$id); if(!@is_dir("../".$id."/lib")) mkdir("../".$id."/lib") or die("Cannot make directory: ../".$id."/lib"); @@ -78,52 +78,52 @@ if(count($_POST) > 1) { if(!@is_dir("../".$id."/form")) mkdir("../".$id."/form") or die("Cannot make directory: ../".$id."/form"); if(!@is_dir("../".$id."/list")) mkdir("../".$id."/list") or die("Cannot make directory: ../".$id."/list"); if(!@is_dir("../".$id."/templates")) mkdir("../".$id."/templates") or die("Cannot make directory: ../".$id."/templates"); - + // writing module.conf - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - - if (!fwrite($handle, $m)) { - print "Cannot write to file ($filename)"; - exit; - } - + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + + if (!fwrite($handle, $m)) { + print "Cannot write to file ($filename)"; + exit; + } + fclose($handle); - + // writing admin conf $admin_conf_filename = "../".$id."/lib/admin.conf.php"; if(!is_file($admin_conf_filename)) { - if (!$handle = fopen($admin_conf_filename, 'w')) { - print "Cannot open file ($admin_conf_filename)"; - exit; - } - - if (!fwrite($handle, "")) { - print "Cannot write to file ($admin_conf_filename)"; - exit; - } - - fclose($handle); + if (!$handle = fopen($admin_conf_filename, 'w')) { + print "Cannot open file ($admin_conf_filename)"; + exit; + } + + if (!fwrite($handle, "")) { + print "Cannot write to file ($admin_conf_filename)"; + exit; + } + + fclose($handle); } - + // zu Liste springen - header("Location: module_list.php"); - exit; - + header("Location: module_list.php"); + exit; + } else { - $app->tpl->setVar("error","Fehler:
    ".$error); + $app->tpl->setVar("error", "Fehler:
    ".$error); $app->tpl->setVar($_POST); } } if($id != '') { -// Datensatz besteht bereits + // Datensatz besteht bereits // bestehenden Datensatz anzeigen if($error == '') { // es liegt ein Fehler vor - include_once("../".$id."/lib/module.conf.php"); + include_once "../".$id."/lib/module.conf.php"; //$navi = $module["nav"]; unset($module["nav"]); $record = $module; @@ -135,7 +135,7 @@ if($id != '') { } $record["readonly"] = 'style="background-color: #EEEEEE;" readonly'; } else { -// neuer datensatz + // neuer datensatz if($error == '') { // es liegt ein Fehler vor $record["template"] = "module.tpl.htm"; @@ -144,7 +144,7 @@ if($id != '') { $record = $_POST; //$navi = $_POST["nav"]; unset($_POST["nav"]); - + } $record["readonly"] = ''; } @@ -172,7 +172,7 @@ $record["nav"] = $content; $app->tpl->setVar($record); -include_once("lib/lang/".$_SESSION["s"]["language"]."_module_edit.lng"); +include_once "lib/lang/".$_SESSION["s"]["language"]."_module_edit.lng"; $app->tpl->setVar($wb); // Defaultwerte setzen @@ -181,4 +181,4 @@ $app->tpl_defaults(); // Template parsen $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_list.php b/interface/web/designer/module_list.php index 92aa4f0e8..b08707e14 100644 --- a/interface/web/designer/module_list.php +++ b/interface/web/designer/module_list.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('designer'); @@ -36,34 +36,34 @@ $app->auth->check_module_permissions('designer'); $app->uses('tpl'); $app->tpl->newTemplate('form.tpl.htm'); -$app->tpl->setInclude('content_tpl','templates/module_list.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_list.htm'); //* Pick out modules $bgcolor = '#FFFFFF'; $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') { - include_once(ISPC_WEB_PATH."/$file/lib/module.conf.php"); - $modules_list[] = array( 'module' => $module['name'], - 'title' => $module['title'], - 'bgcolor' => ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF' - ); +$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') { + include_once ISPC_WEB_PATH."/$file/lib/module.conf.php"; + $modules_list[] = array( 'module' => $module['name'], + 'title' => $module['title'], + 'bgcolor' => ($bgcolor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF' + ); } - } + } } } $app->tpl->setLoop('records', $modules_list); -//* loading language file +//* loading language file $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_module_list.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_nav_del.php b/interface/web/designer/module_nav_del.php index b0fd55a7b..c5781d979 100644 --- a/interface/web/designer/module_nav_del.php +++ b/interface/web/designer/module_nav_del.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); @@ -39,43 +39,43 @@ if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mo // Lade Template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/module_nav_edit.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_nav_edit.htm'); // ID importieren $module_name = $_REQUEST["module_name"]; $nav_id = $_REQUEST["nav_id"]; -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$nav_id)) die("nav_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)) die("module_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $nav_id)) die("nav_id contains invalid chars."); if(empty($module_name)) die("module is empty."); if($nav_id != '') { $filename = "../".$module_name."/lib/module.conf.php"; - + if(!@is_file($filename)) die("File not found: $filename"); - include_once($filename); - + include_once $filename; + unset($module["nav"][$nav_id]); - - $m = ""; - + + $m = ""; + // writing module.conf - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - if (!fwrite($handle, $m)) { - print "Cannot write to file ($filename)"; - exit; - } - + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + if (!fwrite($handle, $m)) { + print "Cannot write to file ($filename)"; + exit; + } + fclose($handle); - - + + // zu Liste springen - header("Location: module_show.php?id=$module_name"); - exit; + header("Location: module_show.php?id=$module_name"); + exit; } -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_nav_edit.php b/interface/web/designer/module_nav_edit.php index a7acf40c1..e7e63e149 100644 --- a/interface/web/designer/module_nav_edit.php +++ b/interface/web/designer/module_nav_edit.php @@ -27,12 +27,12 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Security checkpoint if($_SESSION['s']['user']['typ'] != 'admin'){ - die('Admin permissions required.'); + die('Admin permissions required.'); } if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); @@ -50,61 +50,61 @@ $nav_id = $_REQUEST['nav_id']; //** Sanity checks of module if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)){ - die('module_name contains invalid chars.'); + die('module_name contains invalid chars.'); } if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $nav_id)){ - die('nav_id contains invalid chars.'); + die('nav_id contains invalid chars.'); } if(empty($module_name)){ - die('module is empty.'); + die('module is empty.'); } if(count($_POST) > 0) { //* Determine Action $action = ($nav_id != '') ? 'UPDATE' : 'INSERT'; $error = ''; - + // TODO: Check variables - + if($error == '') { - + $filename = '../'.$module_name.'/lib/module.conf.php'; - + if(!@is_file($filename)){ - die("File not found: $filename"); - } - include_once($filename); - - $items = ($action == 'UPDATE') ? $module['nav'][$nav_id]['items'] : array(); - + die("File not found: $filename"); + } + include_once $filename; + + $items = ($action == 'UPDATE') ? $module['nav'][$nav_id]['items'] : array(); + $tmp = array('title' => $_POST['nav']['title'], - 'open' => 1, - 'items' => $items); - + 'open' => 1, + 'items' => $items); + if($action == 'UPDATE') { $module['nav'][$nav_id] = $tmp; } else { $module['nav'][] = $tmp; } - - $m = ""; - + + $m = ""; + //* writing module.conf - if (!$handle = fopen($filename, 'w')) { - die("Cannot open file ($filename)"); - } - - if (!fwrite($handle, $m)) { - die("Cannot write to file ($filename)"); - } - + if (!$handle = fopen($filename, 'w')) { + die("Cannot open file ($filename)"); + } + + if (!fwrite($handle, $m)) { + die("Cannot write to file ($filename)"); + } + fclose($handle); - - + + //* Jump to list - header('Location: module_show.php?id='.urlencode($module_name)); - exit; - + header('Location: module_show.php?id='.urlencode($module_name)); + exit; + } else { $app->tpl->setVar('error', 'Fehler:
    '.$error); $app->tpl->setVar($_POST); @@ -112,9 +112,9 @@ if(count($_POST) > 0) { } if($nav_id != '') { - //* Data record exists + //* Data record exists if($error == '') { - include_once('../'.$module_name.'/lib/module.conf.php'); + include_once '../'.$module_name.'/lib/module.conf.php'; $record = $module['nav'][$nav_id]; } else { //* error @@ -122,13 +122,13 @@ if($nav_id != '') { } //$record["readonly"] = 'style="background-color: #EEEEEE;" readonly'; } else { - //* New data record + //* New data record if($error == '') { //* es liegt kein Fehler vor } else { //* error $record = $_POST; - + } //$record["readonly"] = ''; } @@ -138,10 +138,10 @@ $record['module_name'] = $module_name; $app->tpl->setVar($record); -include_once('lib/lang/'.$_SESSION['s']['language'].'_module_nav_edit.lng'); +include_once 'lib/lang/'.$_SESSION['s']['language'].'_module_nav_edit.lng'; $app->tpl->setVar($wb); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_nav_flip.php b/interface/web/designer/module_nav_flip.php index 6599a5ff6..09cdd17bf 100644 --- a/interface/web/designer/module_nav_flip.php +++ b/interface/web/designer/module_nav_flip.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); @@ -39,54 +39,54 @@ if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mo // Lade Template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/module_nav_edit.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_nav_edit.htm'); // ID importieren $module_name = $_REQUEST["module_name"]; $nav_id = $_REQUEST["nav_id"]; $dir = $_REQUEST["dir"]; -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$nav_id)) die("nav_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)) die("module_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $nav_id)) die("nav_id contains invalid chars."); if(empty($module_name)) die("module is empty."); if($nav_id != '') { $filename = "../".$module_name."/lib/module.conf.php"; - + if(!@is_file($filename)) die("File not found: $filename"); - include_once($filename); - + include_once $filename; + if($dir == 'up' and $nav_id > 0) { $tmp = $module["nav"][$nav_id - 1]; $module["nav"][$nav_id - 1] = $module["nav"][$nav_id]; $module["nav"][$nav_id] = $tmp; } - + if($dir == 'down' and $nav_id < count($module["nav"]) -1) { $tmp = $module["nav"][$nav_id + 1]; $module["nav"][$nav_id + 1] = $module["nav"][$nav_id]; $module["nav"][$nav_id] = $tmp; } - - $m = ""; - + + $m = ""; + // writing module.conf - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - if (!fwrite($handle, $m)) { - print "Cannot write to file ($filename)"; - exit; - } - + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + if (!fwrite($handle, $m)) { + print "Cannot write to file ($filename)"; + exit; + } + fclose($handle); - - + + // zu Liste springen - echo "HEADER_REDIRECT:designer/module_show.php?id=$module_name"; - exit; + echo "HEADER_REDIRECT:designer/module_show.php?id=$module_name"; + exit; } -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_nav_item_del.php b/interface/web/designer/module_nav_item_del.php index 6360c46ed..66a17b589 100644 --- a/interface/web/designer/module_nav_item_del.php +++ b/interface/web/designer/module_nav_item_del.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); @@ -39,45 +39,45 @@ $app->auth->check_module_permissions('designer'); // Lade Template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/module_nav_edit.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_nav_edit.htm'); // ID importieren $module_name = $_REQUEST["module_name"]; $nav_id = $_REQUEST["nav_id"]; $item_id = $_REQUEST["item_id"]; -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$nav_id)) die("nav_id contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$item_id)) die("item_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)) die("module_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $nav_id)) die("nav_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $item_id)) die("item_id contains invalid chars."); if(empty($module_name)) die("module is empty."); if($nav_id != '') { $filename = "../".$module_name."/lib/module.conf.php"; - + if(!@is_file($filename)) die("File not found: $filename"); - include_once($filename); - + include_once $filename; + unset($module["nav"][$nav_id]["items"][$item_id]); - - $m = ""; - + + $m = ""; + // writing module.conf - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - if (!fwrite($handle, $m)) { - print "Cannot write to file ($filename)"; - exit; - } - + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + if (!fwrite($handle, $m)) { + print "Cannot write to file ($filename)"; + exit; + } + fclose($handle); - - + + // zu Liste springen - header("Location: module_show.php?id=$module_name"); - exit; + header("Location: module_show.php?id=$module_name"); + exit; } -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_nav_item_edit.php b/interface/web/designer/module_nav_item_edit.php index 21e1e3594..2faff74fe 100644 --- a/interface/web/designer/module_nav_item_edit.php +++ b/interface/web/designer/module_nav_item_edit.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); @@ -39,16 +39,16 @@ $app->auth->check_module_permissions('designer'); // Lade Template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/module_nav_item_edit.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_nav_item_edit.htm'); // ID importieren $module_name = $_REQUEST["module_name"]; $nav_id = $_REQUEST["nav_id"]; $item_id = $_REQUEST["item_id"]; -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$nav_id)) die("nav_id contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$item_id)) die("item_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)) die("module_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $nav_id)) die("nav_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $item_id)) die("item_id contains invalid chars."); if(empty($module_name)) die("module is empty."); @@ -59,61 +59,61 @@ if(count($_POST) > 0) { } else { $action = 'INSERT'; } - + $error = ''; - + // TODO: Check variables - + if($error == '') { - + $filename = "../".$module_name."/lib/module.conf.php"; - + if(!@is_file($filename)) die("File not found: $filename"); - include_once($filename); - + include_once $filename; + $tmp = array('title' =>$_POST["title"], - 'target' => $_POST["target"], - 'link' => $_POST["link"]); - + 'target' => $_POST["target"], + 'link' => $_POST["link"]); + if($action == 'UPDATE') { $module["nav"][$nav_id]["items"][$item_id] = $tmp; } else { $module["nav"][$nav_id]["items"][] = $tmp; } - - $m = ""; - + + $m = ""; + // writing module.conf - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - - if (!fwrite($handle, $m)) { - print "Cannot write to file ($filename)"; - exit; - } - + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + + if (!fwrite($handle, $m)) { + print "Cannot write to file ($filename)"; + exit; + } + fclose($handle); - - + + // zu Liste springen - header("Location: module_show.php?id=$module_name"); - exit; - + header("Location: module_show.php?id=$module_name"); + exit; + } else { - $app->tpl->setVar("error","Fehler:
    ".$error); + $app->tpl->setVar("error", "Fehler:
    ".$error); $app->tpl->setVar($_POST); } } if($item_id != '') { -// Datensatz besteht bereits + // Datensatz besteht bereits // bestehenden Datensatz anzeigen if($error == '') { // es liegt ein Fehler vor - include_once("../".$module_name."/lib/module.conf.php"); + include_once "../".$module_name."/lib/module.conf.php"; $record = $module["nav"][$nav_id]["items"][$item_id]; } else { // ein Fehler @@ -121,14 +121,14 @@ if($item_id != '') { } //$record["readonly"] = 'style="background-color: #EEEEEE;" readonly'; } else { -// neuer datensatz + // neuer datensatz if($error == '') { // es liegt kein Fehler vor $record["target"] = "content"; } else { // ein Fehler $record = $_POST; - + } //$record["readonly"] = ''; } @@ -139,7 +139,7 @@ $record["module_name"] = $module_name; $app->tpl->setVar($record); -include_once("lib/lang/".$_SESSION["s"]["language"]."_module_nav_item_edit.lng"); +include_once "lib/lang/".$_SESSION["s"]["language"]."_module_nav_item_edit.lng"; $app->tpl->setVar($wb); // Defaultwerte setzen @@ -148,4 +148,4 @@ $app->tpl_defaults(); // Template parsen $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_nav_item_flip.php b/interface/web/designer/module_nav_item_flip.php index 1aec179ff..94f210b13 100644 --- a/interface/web/designer/module_nav_item_flip.php +++ b/interface/web/designer/module_nav_item_flip.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); @@ -39,7 +39,7 @@ $app->auth->check_module_permissions('designer'); // Lade Template $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/module_nav_edit.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_nav_edit.htm'); // ID importieren $module_name = $_REQUEST["module_name"]; @@ -47,48 +47,48 @@ $nav_id = $_REQUEST["nav_id"]; $item_id = $_REQUEST["item_id"]; $dir = $_REQUEST["dir"]; -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$module_name)) die("module_name contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{1,50}$/',$nav_id)) die("nav_id contains invalid chars."); -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$item_id)) die("item_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $module_name)) die("module_name contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{1,50}$/', $nav_id)) die("nav_id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $item_id)) die("item_id contains invalid chars."); if(empty($module_name)) die("module is empty."); if($nav_id != '') { $filename = "../".$module_name."/lib/module.conf.php"; - + if(!@is_file($filename)) die("File not found: $filename"); - include_once($filename); - + include_once $filename; + if($dir == 'up' and $item_id > 0) { $tmp = $module["nav"][$nav_id]["items"][$item_id - 1]; $module["nav"][$nav_id]["items"][$item_id -1] = $module["nav"][$nav_id]["items"][$item_id]; $module["nav"][$nav_id]["items"][$item_id] = $tmp; } - + if($dir == 'down' and $item_id < count($module["nav"][$nav_id]["items"]) -1) { $tmp = $module["nav"][$nav_id]["items"][$item_id + 1]; $module["nav"][$nav_id]["items"][$item_id + 1] = $module["nav"][$nav_id]["items"][$item_id]; $module["nav"][$nav_id]["items"][$item_id] = $tmp; } - - $m = ""; - + + $m = ""; + // writing module.conf - if (!$handle = fopen($filename, 'w')) { - print "Cannot open file ($filename)"; - exit; - } - if (!fwrite($handle, $m)) { - print "Cannot write to file ($filename)"; - exit; - } - + if (!$handle = fopen($filename, 'w')) { + print "Cannot open file ($filename)"; + exit; + } + if (!fwrite($handle, $m)) { + print "Cannot write to file ($filename)"; + exit; + } + fclose($handle); - - + + // zu Liste springen - header("Location: module_show.php?id=$module_name"); - exit; + header("Location: module_show.php?id=$module_name"); + exit; } -?> \ No newline at end of file +?> diff --git a/interface/web/designer/module_show.php b/interface/web/designer/module_show.php index 504d313d5..f3e9812f9 100644 --- a/interface/web/designer/module_show.php +++ b/interface/web/designer/module_show.php @@ -27,8 +27,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('designer'); @@ -38,20 +38,20 @@ if($_SESSION["s"]["user"]["typ"] != "admin") die("Admin permissions required."); $app->uses('tpl'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/module_show.htm'); +$app->tpl->setInclude('content_tpl', 'templates/module_show.htm'); $module_name = $_REQUEST["id"]; -if(!preg_match('/^[A-Za-z0-9_]{0,50}$/',$module_name)) die("id contains invalid chars."); +if(!preg_match('/^[A-Za-z0-9_]{0,50}$/', $module_name)) die("id contains invalid chars."); -include_once("../".$module_name."/lib/module.conf.php"); +include_once "../".$module_name."/lib/module.conf.php"; $navi = $module["nav"]; unset($module["nav"]); $record = $module; -// loading language file +// loading language file $lng_file = "lib/lang/".$_SESSION["s"]["user"]["language"]."_module_show.lng"; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); // baue Modul navi @@ -59,8 +59,8 @@ $content = ""; $n1 = 0; $n2 = 0; if(is_array($navi)) { -foreach($navi as $nav_id => $section) { - $content .= " + foreach($navi as $nav_id => $section) { + $content .= " @@ -73,12 +73,12 @@ foreach($navi as $nav_id => $section) {
    "; - //$content .= "\r\n"; - foreach($section["items"] as $item_id => $item) { - //$content .= "\r\n"; - //$content .= "\r\n"; - //$content .= "\r\n"; - $content .= " + //$content .= "\r\n"; + foreach($section["items"] as $item_id => $item) { + //$content .= "\r\n"; + //$content .= "\r\n"; + //$content .= "\r\n"; + $content .= ""; - $n2++; - } - $content .= " + $n2++; + } + $content .= "
    Bereich:
    Titel:
    Ziel:       
    Link:       
    Bereich:
    Titel:
    Ziel:       
    Link:       
    $item[title]
    @@ -87,14 +87,14 @@ foreach($navi as $nav_id => $section) {
     
     
    "; - $n1++; -} + $n1++; + } } $record["nav"] = $content; @@ -103,11 +103,11 @@ $record["nav"] = $content; $app->tpl->setVar($record); -$app->tpl->setLoop('records',$modules_list); +$app->tpl->setLoop('records', $modules_list); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/ajax_get_json.php b/interface/web/dns/ajax_get_json.php index 4ff46c234..781fa8e8c 100644 --- a/interface/web/dns/ajax_get_json.php +++ b/interface/web/dns/ajax_get_json.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -40,34 +40,34 @@ $type = $_GET["type"]; //if($_SESSION["s"]["user"]["typ"] == 'admin') { - - if($type == 'get_ipv4'){ - //$q = $app->db->quote(trim($_GET["q"])); - //$authsql = " AND ".$app->tform->getAuthSQL('r'); - //$modules = explode(',', $_SESSION['s']['user']['modules']); - - $result = array(); - - // ipv4 - //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); - $result[] = $app->functions->suggest_ips('IPv4'); - - $json = $app->functions->json_encode($result); - } - - if($type == 'get_ipv6'){ - //$q = $app->db->quote(trim($_GET["q"])); - //$authsql = " AND ".$app->tform->getAuthSQL('r'); - //$modules = explode(',', $_SESSION['s']['user']['modules']); - - $result = array(); - - // ipv6 - //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); - $result[] = $app->functions->suggest_ips('IPv6'); - - $json = $app->functions->json_encode($result); - } + +if($type == 'get_ipv4'){ + //$q = $app->db->quote(trim($_GET["q"])); + //$authsql = " AND ".$app->tform->getAuthSQL('r'); + //$modules = explode(',', $_SESSION['s']['user']['modules']); + + $result = array(); + + // ipv4 + //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv4' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); + $result[] = $app->functions->suggest_ips('IPv4'); + + $json = $app->functions->json_encode($result); +} + +if($type == 'get_ipv6'){ + //$q = $app->db->quote(trim($_GET["q"])); + //$authsql = " AND ".$app->tform->getAuthSQL('r'); + //$modules = explode(',', $_SESSION['s']['user']['modules']); + + $result = array(); + + // ipv6 + //$result[] = _search('admin', 'server_ip', "AND ip_type = 'IPv6' AND (client_id = 0 OR client_id=".$app->functions->intval($_SESSION['s']['user']['client_id']).")"); + $result[] = $app->functions->suggest_ips('IPv6'); + + $json = $app->functions->json_encode($result); +} //} @@ -81,13 +81,13 @@ function _search($module, $section, $additional_sql = '', $unique = false){ $desc_fields = array(); if(is_file('../'.$module.'/form/'.$section.'.tform.php')){ include_once('../'.$module.'/form/'.$section.'.tform.php'); - + $category_title = $form["title"]; $form_file = $form["action"]; $db_table = $form["db_table"]; $db_table_idx = $form["db_table_idx"]; $order_by = $db_table_idx; - + if(is_array($form["tabs"]) && !empty($form["tabs"])){ foreach($form["tabs"] as $tab){ if(is_array($tab['fields']) && !empty($tab['fields'])){ @@ -108,7 +108,7 @@ function _search($module, $section, $additional_sql = '', $unique = false){ } } unset($form); - + $where_clause = ''; if(!empty($search_fields)){ $where_clause = implode(' OR ', $search_fields); @@ -120,11 +120,11 @@ function _search($module, $section, $additional_sql = '', $unique = false){ if($additional_sql != '') $where_clause .= ' '.$additional_sql.' '; $order_clause = ''; if($order_by != '') $order_clause = ' ORDER BY '.$order_by; - + $sql = "SELECT * FROM ".$db_table." WHERE ".$where_clause.$authsql.$order_clause." LIMIT 0,10"; $results = $app->db->queryAllRecords($sql); - - if(is_array($results) && !empty($results)){ + + if(is_array($results) && !empty($results)){ $lng_file = '../'.$module.'/lib/lang/'.$_SESSION['s']['language'].'_'.$section.'.lng'; if(is_file($lng_file)) include($lng_file); $result_array['cheader'] = array('title' => $category_title, @@ -140,7 +140,7 @@ function _search($module, $section, $additional_sql = '', $unique = false){ } if(!empty($desc_items)) $description = implode(' - ', $desc_items); } - + $result_array['cdata'][] = array( 'title' => $wb[$title_key.'_txt'].': '.$result[$title_key], 'description' => $description, 'onclick' => '', @@ -156,7 +156,7 @@ function _search($module, $section, $additional_sql = '', $unique = false){ return $result_array; } */ - + header('Content-type: application/json'); echo $json; -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_a_edit.php b/interface/web/dns/dns_a_edit.php index 1f94633ff..99d0d9925 100644 --- a/interface/web/dns/dns_a_edit.php +++ b/interface/web/dns/dns_a_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_a.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,27 +95,27 @@ class page_action extends tform_actions { } } } // end if user is not admin - + //* Check for duplicates where IP and hostname are the same $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'A' AND name = '".$this->dataRecord["name"]."' AND zone = '".$this->dataRecord["zone"]."' and data = '".$this->dataRecord["data"]."' and id != ".$this->id.") OR (type = 'CNAME' AND name = '".$this->dataRecord["name"]."' AND zone = '".$this->dataRecord["zone"]."' and id != ".$this->id.")"); if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("data_error_duplicate")."
    "; unset($tmp); - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -125,17 +125,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + } $page = new page_action; diff --git a/interface/web/dns/dns_a_list.php b/interface/web/dns/dns_a_list.php index afe76b6cd..d525585f0 100644 --- a/interface/web/dns/dns_a_list.php +++ b/interface/web/dns/dns_a_list.php @@ -1,6 +1,6 @@ listform_actions->SQLExtWhere = "dns_rr.type = 'A'"; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_aaaa_edit.php b/interface/web/dns/dns_aaaa_edit.php index ccd6fe8ad..02aea58cd 100644 --- a/interface/web/dns/dns_aaaa_edit.php +++ b/interface/web/dns/dns_aaaa_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_aaaa.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,22 +95,22 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -120,17 +120,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + } $page = new page_action; diff --git a/interface/web/dns/dns_alias_edit.php b/interface/web/dns/dns_alias_edit.php index 86a6dcd07..dc370a642 100644 --- a/interface/web/dns/dns_alias_edit.php +++ b/interface/web/dns/dns_alias_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_alias.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,22 +95,22 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -120,16 +120,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_cname_edit.php b/interface/web/dns/dns_cname_edit.php index 75ec7c45b..5d9d19bfb 100644 --- a/interface/web/dns/dns_cname_edit.php +++ b/interface/web/dns/dns_cname_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_cname.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,27 +95,27 @@ class page_action extends tform_actions { } } } // end if user is not admin - + //* Check for duplicates where IP and hostname are the same $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE (type = 'A' AND name = '".$this->dataRecord["name"]."' AND zone = '".$this->dataRecord["zone"]."' and id != ".$this->id.") OR (type = 'CNAME' AND name = '".$this->dataRecord["name"]."' AND zone = '".$this->dataRecord["zone"]."' and id != ".$this->id.")"); if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng("data_error_duplicate")."
    "; unset($tmp); - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -125,16 +125,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_dkim_edit.php b/interface/web/dns/dns_dkim_edit.php index 2395bb01d..46c5a1390 100644 --- a/interface/web/dns/dns_dkim_edit.php +++ b/interface/web/dns/dns_dkim_edit.php @@ -39,8 +39,8 @@ $tform_def_file = "form/dns_dkim.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -50,16 +50,16 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another record. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -78,7 +78,7 @@ class page_action extends tform_actions { $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client @@ -92,10 +92,10 @@ class page_action extends tform_actions { } } } // end if user is not admin - + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // add dkim-settings to the public-key in the txt-record $this->dataRecord['data']='v=DKIM1; t=s; p='.$this->dataRecord['data']; $this->dataRecord['name']='default._domainkey.'.$this->dataRecord['name']; @@ -104,17 +104,17 @@ class page_action extends tform_actions { $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + // check for duplicate entry $check=$app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ".$this->dataRecord["zone"]." AND type = '".$this->dataRecord["type"]."' AND data ='".$this->dataRecord["data"]."' AND name = '".$this->dataRecord['name']."'"); if ($check!='') $app->tform->errorMessage .= $app->tform->wordbook["record_exists_txt"]; parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -124,16 +124,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_dkim_get.php b/interface/web/dns/dns_dkim_get.php index da917b96b..6c58d4078 100644 --- a/interface/web/dns/dns_dkim_get.php +++ b/interface/web/dns/dns_dkim_get.php @@ -1,42 +1,42 @@ auth->check_module_permissions('dns'); @@ -49,33 +49,34 @@ $app->uses('tform,tform_actions'); header('Content-Type: text/xml; charset=utf-8'); header('Cache-Control: must-revalidate, pre-check=0, no-store, no-cache, max-age=0, post-check=0'); -/** -* This function fix PHP's messing up POST input containing characters space, dot, -* open square bracket and others to be compatible with with the deprecated register_globals -* @return array POST -*/ +/** + * This function fix PHP's messing up POST input containing characters space, dot, + * open square bracket and others to be compatible with with the deprecated register_globals + * @return array POST + */ function getRealPOST() { - $pairs = explode("&", file_get_contents("php://input")); - $vars = array(); - foreach ($pairs as $pair) { - $nv = explode("=", $pair, 2); - $name = urldecode($nv[0]); - $value = $nv[1]; - $vars[$name] = $value; - } - return $vars; + $pairs = explode("&", file_get_contents("php://input")); + $vars = array(); + foreach ($pairs as $pair) { + $nv = explode("=", $pair, 2); + $name = urldecode($nv[0]); + $value = $nv[1]; + $vars[$name] = $value; + } + return $vars; } + /** -* This function formats the public-key -* @param array $pubkey -* @return string public-key -*/ + * This function formats the public-key + * @param array $pubkey + * @return string public-key + */ function pub_key($pubkey) { - $public_key=''; - foreach($pubkey as $values) $public_key=$public_key.$values; - return $public_key; + $public_key=''; + foreach($pubkey as $values) $public_key=$public_key.$values; + return $public_key; } $_POST=getRealPost(); @@ -84,11 +85,11 @@ if (ctype_digit($_POST['zone'])) { // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->db->quote($_POST['zone'])."' AND ".$app->tform->getAuthSQL('r')); - $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".substr_replace($soa['origin'],'',-1)."' AND ".$app->tform->getAuthSQL('r')); + $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".substr_replace($soa['origin'], '', -1)."' AND ".$app->tform->getAuthSQL('r')); $public_key=pub_key($public_key); - $public_key=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$public_key); + $public_key=str_replace(array('-----BEGIN PUBLIC KEY-----', '-----END PUBLIC KEY-----', "\r", "\n"), '', $public_key); echo "\n"; echo "\n"; diff --git a/interface/web/dns/dns_hinfo_edit.php b/interface/web/dns/dns_hinfo_edit.php index 910ebeaba..0c3f0045c 100644 --- a/interface/web/dns/dns_hinfo_edit.php +++ b/interface/web/dns/dns_hinfo_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_hinfo.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,22 +95,22 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -120,16 +120,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_import.php b/interface/web/dns/dns_import.php index 255d29063..b015453ff 100644 --- a/interface/web/dns/dns_import.php +++ b/interface/web/dns/dns_import.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -40,7 +40,7 @@ $error = ''; // Loading the template $app->uses('tpl,validate_dns'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/dns_import.htm'); +$app->tpl->setInclude('content_tpl', 'templates/dns_import.htm'); $app->load_language_file('/web/dns/lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng'); // import variables @@ -69,11 +69,11 @@ foreach($records as $rec){ $n++; } unset($n); -$app->tpl->setVar("template_id_option",$template_id_option); +$app->tpl->setVar("template_id_option", $template_id_option); // If the user is administrator if($_SESSION['s']['user']['typ'] == 'admin') { - + // Load the list of servers $records = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 ORDER BY server_name"); $server_id_option = ''; @@ -81,8 +81,8 @@ if($_SESSION['s']['user']['typ'] == 'admin') { $checked = ($rec['server_id'] == $server_id)?' SELECTED':''; $server_id_option .= ''; } - $app->tpl->setVar("server_id",$server_id_option); - + $app->tpl->setVar("server_id", $server_id_option); + // load the list of clients $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY sys_group.name"; $clients = $app->db->queryAllRecords($sql); @@ -95,16 +95,16 @@ if($_SESSION['s']['user']['typ'] == 'admin') { } } - $app->tpl->setVar("client_group_id",$client_select); + $app->tpl->setVar("client_group_id", $client_select); } if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // load the list of clients $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']; $clients = $app->db->queryAllRecords($sql); @@ -117,37 +117,37 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO } } - $app->tpl->setVar("client_group_id",$client_select); + $app->tpl->setVar("client_group_id", $client_select); } $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dns_import.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); // Import the zone-file //if(1=="1") if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name'])){ $valid_zone_file = FALSE; - + $sql = "SELECT server_name FROM `server` WHERE server_id=".$app->functions->intval($server_id)." OR mirror_server_id=".$app->functions->intval($server_id)." ORDER BY server_name ASC"; $servers = $app->db->queryAllRecords($sql); for ($i=0;$ifunctions->intval(substr($parts[1],0,-1)); - break; - case 'm': - $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 60; - break; - case 'h': - $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 3600; - break; - case 'd': - $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 86400; - break; - case 'w': - $soa['ttl'] = $app->functions->intval(substr($parts[1],0,-1)) * 604800; - break; - default: - $soa['ttl'] = $app->functions->intval($parts[1]); + case 's': + $soa['ttl'] = $app->functions->intval(substr($parts[1], 0, -1)); + break; + case 'm': + $soa['ttl'] = $app->functions->intval(substr($parts[1], 0, -1)) * 60; + break; + case 'h': + $soa['ttl'] = $app->functions->intval(substr($parts[1], 0, -1)) * 3600; + break; + case 'd': + $soa['ttl'] = $app->functions->intval(substr($parts[1], 0, -1)) * 86400; + break; + case 'w': + $soa['ttl'] = $app->functions->intval(substr($parts[1], 0, -1)) * 604800; + break; + default: + $soa['ttl'] = $app->functions->intval($parts[1]); } unset($time_format); } @@ -237,103 +237,103 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' if($i == ($soa_array_key + 1)) $soa['serial'] = $app->functions->intval($parts[0]); // REFRESH if($i == ($soa_array_key + 2)){ - $time_format = strtolower(substr($parts[0],-1)); + $time_format = strtolower(substr($parts[0], -1)); switch ($time_format) { - case 's': - $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)); - break; - case 'm': - $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 60; - break; - case 'h': - $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600; - break; - case 'd': - $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400; - break; - case 'w': - $soa['refresh'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800; - break; - default: - $soa['refresh'] = $app->functions->intval($parts[0]); + case 's': + $soa['refresh'] = $app->functions->intval(substr($parts[0], 0, -1)); + break; + case 'm': + $soa['refresh'] = $app->functions->intval(substr($parts[0], 0, -1)) * 60; + break; + case 'h': + $soa['refresh'] = $app->functions->intval(substr($parts[0], 0, -1)) * 3600; + break; + case 'd': + $soa['refresh'] = $app->functions->intval(substr($parts[0], 0, -1)) * 86400; + break; + case 'w': + $soa['refresh'] = $app->functions->intval(substr($parts[0], 0, -1)) * 604800; + break; + default: + $soa['refresh'] = $app->functions->intval($parts[0]); } unset($time_format); } // RETRY if($i == ($soa_array_key + 3)){ - $time_format = strtolower(substr($parts[0],-1)); + $time_format = strtolower(substr($parts[0], -1)); switch ($time_format) { - case 's': - $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)); - break; - case 'm': - $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 60; - break; - case 'h': - $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600; - break; - case 'd': - $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400; - break; - case 'w': - $soa['retry'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800; - break; - default: - $soa['retry'] = $app->functions->intval($parts[0]); + case 's': + $soa['retry'] = $app->functions->intval(substr($parts[0], 0, -1)); + break; + case 'm': + $soa['retry'] = $app->functions->intval(substr($parts[0], 0, -1)) * 60; + break; + case 'h': + $soa['retry'] = $app->functions->intval(substr($parts[0], 0, -1)) * 3600; + break; + case 'd': + $soa['retry'] = $app->functions->intval(substr($parts[0], 0, -1)) * 86400; + break; + case 'w': + $soa['retry'] = $app->functions->intval(substr($parts[0], 0, -1)) * 604800; + break; + default: + $soa['retry'] = $app->functions->intval($parts[0]); } unset($time_format); } // EXPIRE if($i == ($soa_array_key + 4)){ - $time_format = strtolower(substr($parts[0],-1)); + $time_format = strtolower(substr($parts[0], -1)); switch ($time_format) { - case 's': - $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)); - break; - case 'm': - $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 60; - break; - case 'h': - $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600; - break; - case 'd': - $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400; - break; - case 'w': - $soa['expire'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800; - break; - default: - $soa['expire'] = $app->functions->intval($parts[0]); + case 's': + $soa['expire'] = $app->functions->intval(substr($parts[0], 0, -1)); + break; + case 'm': + $soa['expire'] = $app->functions->intval(substr($parts[0], 0, -1)) * 60; + break; + case 'h': + $soa['expire'] = $app->functions->intval(substr($parts[0], 0, -1)) * 3600; + break; + case 'd': + $soa['expire'] = $app->functions->intval(substr($parts[0], 0, -1)) * 86400; + break; + case 'w': + $soa['expire'] = $app->functions->intval(substr($parts[0], 0, -1)) * 604800; + break; + default: + $soa['expire'] = $app->functions->intval($parts[0]); } unset($time_format); } // MINIMUM if($i == ($soa_array_key + 5)){ - $time_format = strtolower(substr($parts[0],-1)); + $time_format = strtolower(substr($parts[0], -1)); switch ($time_format) { - case 's': - $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)); - break; - case 'm': - $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 60; - break; - case 'h': - $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 3600; - break; - case 'd': - $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 86400; - break; - case 'w': - $soa['minimum'] = $app->functions->intval(substr($parts[0],0,-1)) * 604800; - break; - default: - $soa['minimum'] = $app->functions->intval($parts[0]); + case 's': + $soa['minimum'] = $app->functions->intval(substr($parts[0], 0, -1)); + break; + case 'm': + $soa['minimum'] = $app->functions->intval(substr($parts[0], 0, -1)) * 60; + break; + case 'h': + $soa['minimum'] = $app->functions->intval(substr($parts[0], 0, -1)) * 3600; + break; + case 'd': + $soa['minimum'] = $app->functions->intval(substr($parts[0], 0, -1)) * 86400; + break; + case 'w': + $soa['minimum'] = $app->functions->intval(substr($parts[0], 0, -1)) * 604800; + break; + default: + $soa['minimum'] = $app->functions->intval($parts[0]); } unset($time_format); } // RESOURCE RECORDS if($i > ($soa_array_key + 5)){ - if(substr($parts[0],-1) == '.' || $parts[0] == '@' || ($parts[0] != 'a' && $parts[0] != 'aaaa' && $parts[0] != 'ns' && $parts[0] != 'cname' && $parts[0] != 'hinfo' && $parts[0] != 'mx' && $parts[0] != 'naptr' && $parts[0] != 'ptr' && $parts[0] != 'rp' && $parts[0] != 'srv' && $parts[0] != 'txt')){ + if(substr($parts[0], -1) == '.' || $parts[0] == '@' || ($parts[0] != 'a' && $parts[0] != 'aaaa' && $parts[0] != 'ns' && $parts[0] != 'cname' && $parts[0] != 'hinfo' && $parts[0] != 'mx' && $parts[0] != 'naptr' && $parts[0] != 'ptr' && $parts[0] != 'rp' && $parts[0] != 'srv' && $parts[0] != 'txt')){ if(is_numeric($parts[1])){ if($parts[2] == 'in'){ $resource_type = $parts[3]; @@ -363,20 +363,20 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $dns_rr[$r]['ttl'] = $soa['ttl']; } switch ($resource_type) { - case 'mx': - case 'srv': - $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2)); - break; - case 'txt': - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); - if(substr($dns_rr[$r]['data'],0,1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],1); - if(substr($dns_rr[$r]['data'],-1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],0,-1); - break; - default: - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); + case 'mx': + case 'srv': + $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+2)); + break; + case 'txt': + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); + if(substr($dns_rr[$r]['data'], 0, 1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 1); + if(substr($dns_rr[$r]['data'], -1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 0, -1); + break; + default: + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); } } else { // a 3600 IN A 1.2.3.4 @@ -387,22 +387,22 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $dns_rr[$r]['name'] = $parts[0]; $dns_rr[$r]['ttl'] = $app->functions->intval($parts[1]); switch ($resource_type) { - case 'mx': - case 'srv': - $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2)); - break; - case 'txt': - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); - if(substr($dns_rr[$r]['data'],0,1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],1); - if(substr($dns_rr[$r]['data'],-1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],0,-1); - break; - default: - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); + case 'mx': + case 'srv': + $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+2)); + break; + case 'txt': + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); + if(substr($dns_rr[$r]['data'], 0, 1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 1); + if(substr($dns_rr[$r]['data'], -1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 0, -1); + break; + default: + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); } - } + } // a IN A 1.2.3.4 elseif($parts[1] == 'in' && ($parts[2] == 'a' || $parts[2] == 'aaaa' || $parts[2] == 'ns'|| $parts[2] == 'cname' || $parts[2] == 'hinfo' || $parts[2] == 'mx' || $parts[2] == 'naptr' || $parts[2] == 'ptr' || $parts[2] == 'rp' || $parts[2] == 'srv' || $parts[2] == 'txt')){ $resource_type = $parts[2]; @@ -411,22 +411,22 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $dns_rr[$r]['name'] = $parts[0]; $dns_rr[$r]['ttl'] = $soa['ttl']; switch ($resource_type) { - case 'mx': - case 'srv': - $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2)); - break; - case 'txt': - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); - if(substr($dns_rr[$r]['data'],0,1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],1); - if(substr($dns_rr[$r]['data'],-1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],0,-1); - break; - default: - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); + case 'mx': + case 'srv': + $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+2)); + break; + case 'txt': + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); + if(substr($dns_rr[$r]['data'], 0, 1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 1); + if(substr($dns_rr[$r]['data'], -1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 0, -1); + break; + default: + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); } - } + } // a 3600 A 1.2.3.4 elseif(is_numeric($parts[1]) && ($parts[2] == 'a' || $parts[2] == 'aaaa' || $parts[2] == 'ns'|| $parts[2] == 'cname' || $parts[2] == 'hinfo' || $parts[2] == 'mx' || $parts[2] == 'naptr' || $parts[2] == 'ptr' || $parts[2] == 'rp' || $parts[2] == 'srv' || $parts[2] == 'txt')){ $resource_type = $parts[2]; @@ -435,22 +435,22 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $dns_rr[$r]['name'] = $parts[0]; $dns_rr[$r]['ttl'] = $app->functions->intval($parts[1]); switch ($resource_type) { - case 'mx': - case 'srv': - $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2)); - break; - case 'txt': - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); - if(substr($dns_rr[$r]['data'],0,1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],1); - if(substr($dns_rr[$r]['data'],-1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],0,-1); - break; - default: - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); + case 'mx': + case 'srv': + $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+2)); + break; + case 'txt': + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); + if(substr($dns_rr[$r]['data'], 0, 1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 1); + if(substr($dns_rr[$r]['data'], -1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 0, -1); + break; + default: + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); } - } + } // A 1.2.3.4 // MX 10 mail // TXT "v=spf1 a mx ptr -all" @@ -461,20 +461,20 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $dns_rr[$r]['name'] = $soa['name']; $dns_rr[$r]['ttl'] = $soa['ttl']; switch ($resource_type) { - case 'mx': - case 'srv': - $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+2)); - break; - case 'txt': - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); - if(substr($dns_rr[$r]['data'],0,1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],1); - if(substr($dns_rr[$r]['data'],-1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'],0,-1); - break; - default: - $dns_rr[$r]['aux'] = 0; - $dns_rr[$r]['data'] = implode(' ',array_slice($parts, $pkey+1)); + case 'mx': + case 'srv': + $dns_rr[$r]['aux'] = $app->functions->intval($parts[$pkey+1]); + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+2)); + break; + case 'txt': + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); + if(substr($dns_rr[$r]['data'], 0, 1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 1); + if(substr($dns_rr[$r]['data'], -1) == '"') $dns_rr[$r]['data'] = substr($dns_rr[$r]['data'], 0, -1); + break; + default: + $dns_rr[$r]['aux'] = 0; + $dns_rr[$r]['data'] = implode(' ', array_slice($parts, $pkey+1)); } } } @@ -486,7 +486,7 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' } $i++; } - + /* $i = 0; $r = 0; @@ -586,7 +586,7 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' if (!empty($mx[$r][$m])) $dns_rr[$r]['data'] = $mx[$r][$m]; } - + $dns_rr[$r]['aux'] = $mx[$r][0]; } else if (strtolower($dns_rr[$r]['type'])=='txt') @@ -618,11 +618,11 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $dns_rr[$r]['aux'] = 0; $r++; } - //print('
    ');
    -					//print_r($dns_rr);
    -					//print('
    '); - - + //print('
    ');
    +	//print_r($dns_rr);
    +	//print('
    '); + + // Insert the soa record $sys_userid = $_SESSION['s']['user']['userid']; $origin = $app->db->quote($soa['name']); @@ -641,7 +641,7 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `origin`, `ns`, `mbox`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `ttl`, `active`, `xfer`) VALUES ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$origin', '$ns', '$mbox', '$serial', '$refresh', '$retry', '$expire', '$minimum', '$ttl', 'Y', '$xfer')"; $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); - + // Insert the dns_rr records if(is_array($dns_rr) && $dns_soa_id > 0) { @@ -664,11 +664,11 @@ if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name' } -$app->tpl->setVar('msg',$msg); -$app->tpl->setVar('error',$error); +$app->tpl->setVar('msg', $msg); +$app->tpl->setVar('error', $error); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_mx_edit.php b/interface/web/dns/dns_mx_edit.php index 8ce9b872b..a839f70ff 100644 --- a/interface/web/dns/dns_mx_edit.php +++ b/interface/web/dns/dns_mx_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_mx.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,44 +95,44 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onInsert() { global $app, $conf; - + // Check if record is existing already $duplicate_mx = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ".$app->functions->intval($this->dataRecord["zone"])." AND name = '".$this->dataRecord["name"]."' AND type = '".$this->dataRecord["type"]."' AND data = '".$this->dataRecord["data"]."' AND ".$app->tform->getAuthSQL('r')); - + if(is_array($duplicate_mx) && !empty($duplicate_mx)) $app->error($app->tform->wordbook["duplicate_mx_record_txt"]); - + parent::onInsert(); } - + function onUpdate() { global $app, $conf; - + // Check if record is existing already $duplicate_mx = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ".$app->functions->intval($this->dataRecord["zone"])." AND name = '".$this->dataRecord["name"]."' AND type = '".$this->dataRecord["type"]."' AND data = '".$this->dataRecord["data"]."' AND id != ".$app->functions->intval($this->dataRecord["id"])." AND ".$app->tform->getAuthSQL('r')); - + if(is_array($duplicate_mx) && !empty($duplicate_mx)) $app->error($app->tform->wordbook["duplicate_mx_record_txt"]); - + parent::onUpdate(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -142,16 +142,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_ns_edit.php b/interface/web/dns/dns_ns_edit.php index 059c0e050..31df6ef33 100644 --- a/interface/web/dns/dns_ns_edit.php +++ b/interface/web/dns/dns_ns_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_ns.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,22 +95,22 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -120,16 +120,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_ptr_edit.php b/interface/web/dns/dns_ptr_edit.php index 8dc790e99..323d76c4c 100644 --- a/interface/web/dns/dns_ptr_edit.php +++ b/interface/web/dns/dns_ptr_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_ptr.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,22 +95,22 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -120,16 +120,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_rp_edit.php b/interface/web/dns/dns_rp_edit.php index 0e4eb0b6c..a4f81a046 100644 --- a/interface/web/dns/dns_rp_edit.php +++ b/interface/web/dns/dns_rp_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_rp.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,22 +95,22 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -120,16 +120,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_rr_del.php b/interface/web/dns/dns_rr_del.php index 46356e18d..a20c9c07d 100644 --- a/interface/web/dns/dns_rr_del.php +++ b/interface/web/dns/dns_rr_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/dns_a.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -52,16 +52,17 @@ class page_action extends tform_actions { function onAfterDelete() { global $app; $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($this->dataRecord["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; $page->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_slave_del.php b/interface/web/dns/dns_slave_del.php index a2bba0022..d3ca18fbc 100644 --- a/interface/web/dns/dns_slave_del.php +++ b/interface/web/dns/dns_slave_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/dns_slave.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -52,18 +52,19 @@ class page_action extends tform_actions { function onBeforeDelete() { global $app; $conf; - - if($app->tform->checkPerm($this->id,'d') == false) $app->error($app->lng('error_no_delete_permission')); - + + if($app->tform->checkPerm($this->id, 'd') == false) $app->error($app->lng('error_no_delete_permission')); + // Delete all records that belog to this zone. $records = $app->db->queryAllRecords("SELECT id FROM dns_slave WHERE zone = '".$app->functions->intval($this->id)."'"); foreach($records as $rec) { - $app->db->datalogDelete('dns_slave','id',$rec['id']); + $app->db->datalogDelete('dns_slave', 'id', $rec['id']); } } + } $page = new page_action; $page->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_slave_edit.php b/interface/web/dns/dns_slave_edit.php index 46e251a3b..a9688044f 100644 --- a/interface/web/dns/dns_slave_edit.php +++ b/interface/web/dns/dns_slave_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_slave.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,10 +49,10 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { if(!$app->tform->checkClientLimit('limit_dns_slave_zone')) { @@ -62,13 +62,13 @@ class page_action extends tform_actions { $app->error('Reseller: '.$app->tform->wordbook["limit_dns_slave_zone_txt"]); } } - + parent::onShowNew(); } - + function onShowEnd() { global $app, $conf; - + // If user is admin, we will allow him to select to whom this record belongs if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Domains of the user @@ -83,29 +83,29 @@ class page_action extends tform_actions { $client_select .= "\r\n"; } } - $app->tpl->setVar("client_group_id",$client_select); + $app->tpl->setVar("client_group_id", $client_select); } else if($app->auth->has_clients($_SESSION['s']['user']['userid'])) { - - // Get the limits of the client - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, sys_group.name, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - - // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY sys_group.name"; - $clients = $app->db->queryAllRecords($sql); - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']); - $client_select = ''; - //$tmp_data_record = $app->tform->getDataRecord($this->id); - if(is_array($clients)) { - foreach( $clients as $client) { - $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; - $client_select .= "\r\n"; + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT client.client_id, sys_group.name, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + // Fill the client select field + $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY sys_group.name"; + $clients = $app->db->queryAllRecords($sql); + $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']); + $client_select = ''; + //$tmp_data_record = $app->tform->getDataRecord($this->id); + if(is_array($clients)) { + foreach( $clients as $client) { + $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; + $client_select .= "\r\n"; + } } + $app->tpl->setVar("client_group_id", $client_select); + } - $app->tpl->setVar("client_group_id",$client_select); - - } - + if($this->id > 0) { //* we are editing a existing record $app->tpl->setVar("edit_disabled", 1); @@ -113,29 +113,29 @@ class page_action extends tform_actions { } else { $app->tpl->setVar("edit_disabled", 0); } - + parent::onShowEnd(); } - + function onSubmit() { global $app, $conf; - + if($_SESSION["s"]["user"]["typ"] != 'admin') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_slave_zone, default_slave_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // When the record is updated if($this->id > 0) { // restore the server ID if the user is not admin and record is edited $tmp = $app->db->queryOneRecord("SELECT server_id FROM dns_slave WHERE id = ".$app->functions->intval($this->id)); $this->dataRecord["server_id"] = $tmp["server_id"]; unset($tmp); - // When the record is inserted + // When the record is inserted } else { // set the server ID to the default dnsserver of the client $this->dataRecord["server_id"] = $client["default_slave_dnsserver"]; - + // Check if the user may add anoter secondary domain. if(!$app->tform->checkClientLimit('limit_dns_slave_zone')) { $app->error($app->tform->wordbook["limit_dns_slave_zone_txt"]); @@ -145,33 +145,33 @@ class page_action extends tform_actions { } } } - + //* Check if the zone name has a dot at the end - if(strlen($this->dataRecord["origin"]) > 0 && substr($this->dataRecord["origin"],-1,1) != '.') $this->dataRecord["origin"] .= '.'; - - //* Check if a primary zone with the same name already exists + if(strlen($this->dataRecord["origin"]) > 0 && substr($this->dataRecord["origin"], -1, 1) != '.') $this->dataRecord["origin"] .= '.'; + + //* Check if a primary zone with the same name already exists $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_soa WHERE origin = \"".$this->dataRecord["origin"]."\" AND server_id= \"".$this->dataRecord["server_id"]."\""); if($tmp["number"] > 0) { - $app->error($app->tform->wordbook["origin_error_unique"]); + $app->error($app->tform->wordbook["origin_error_unique"]); } parent::onSubmit(); } - + function onInsert() { global $app, $conf; - + // Check if record is existing already $duplicate_slave = $app->db->queryOneRecord("SELECT * FROM dns_slave WHERE origin = '".$this->dataRecord["origin"]."' AND server_id = ".$app->functions->intval($this->dataRecord["server_id"])." AND ".$app->tform->getAuthSQL('r')); - + if(is_array($duplicate_slave) && !empty($duplicate_slave)) $app->error($app->tform->wordbook["origin_error_unique"]); - + parent::onInsert(); } - + function onAfterInsert() { global $app, $conf; - + // make sure that the record belongs to the client group and not the admin group when a dmin inserts it if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); @@ -183,11 +183,11 @@ class page_action extends tform_actions { } } - + function onAfterUpdate() { global $app, $conf; - - $tmp = $app->db->diffrec($this->oldDataRecord,$app->tform->getDataRecord($this->id)); + + $tmp = $app->db->diffrec($this->oldDataRecord, $app->tform->getDataRecord($this->id)); // make sure that the record belongs to the client group and not the admin group when a dmin inserts it if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { @@ -198,7 +198,7 @@ class page_action extends tform_actions { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); $app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$this->id); } - + //** When the client group has changed, change also the owner of the record if the owner is not the admin user if($this->oldDataRecord["client_group_id"] != $this->dataRecord["client_group_id"] && $this->dataRecord["sys_userid"] != 1) { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); @@ -207,9 +207,9 @@ class page_action extends tform_actions { $app->db->query("UPDATE dns_slave SET sys_userid = ".$tmp["userid"]." WHERE id = ".$this->id); } } - + } - + } $page = new page_action; diff --git a/interface/web/dns/dns_slave_list.php b/interface/web/dns/dns_slave_list.php index fe78ca205..b277a86bf 100644 --- a/interface/web/dns/dns_slave_list.php +++ b/interface/web/dns/dns_slave_list.php @@ -1,6 +1,6 @@ listform_actions->SQLOrderBy = 'ORDER BY dns_slave.origin'; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_soa_del.php b/interface/web/dns/dns_soa_del.php index 82d680b0c..f9a06fcfb 100644 --- a/interface/web/dns/dns_soa_del.php +++ b/interface/web/dns/dns_soa_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/dns_soa.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -52,18 +52,19 @@ class page_action extends tform_actions { function onBeforeDelete() { global $app; $conf; - - if($app->tform->checkPerm($this->id,'d') == false) $app->error($app->lng('error_no_delete_permission')); - + + if($app->tform->checkPerm($this->id, 'd') == false) $app->error($app->lng('error_no_delete_permission')); + // Delete all records that belog to this zone. $records = $app->db->queryAllRecords("SELECT id FROM dns_rr WHERE zone = '".$app->functions->intval($this->id)."'"); foreach($records as $rec) { - $app->db->datalogDelete('dns_rr','id',$rec['id']); + $app->db->datalogDelete('dns_rr', 'id', $rec['id']); } } + } $page = new page_action; $page->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_soa_edit.php b/interface/web/dns/dns_soa_edit.php index 9f524e896..94ce065fa 100644 --- a/interface/web/dns/dns_soa_edit.php +++ b/interface/web/dns/dns_soa_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_soa.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,7 +49,7 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShow() { global $app; //* Reset the page number of the list form for the dns @@ -59,10 +59,10 @@ class page_action extends tform_actions { } parent::onShow(); } - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { if(!$app->tform->checkClientLimit('limit_dns_zone')) { @@ -72,13 +72,13 @@ class page_action extends tform_actions { $app->error('Reseller: '.$app->tform->wordbook["limit_dns_zone_txt"]); } } - + parent::onShowNew(); } - + function onShowEnd() { global $app, $conf; - + // If user is admin, we will allow him to select to whom this record belongs if($_SESSION["s"]["user"]["typ"] == 'admin') { // Getting Domains of the user @@ -93,29 +93,29 @@ class page_action extends tform_actions { $client_select .= "\r\n"; } } - $app->tpl->setVar("client_group_id",$client_select); + $app->tpl->setVar("client_group_id", $client_select); } else if($app->auth->has_clients($_SESSION['s']['user']['userid'])) { - - // Get the limits of the client - $client_group_id = $_SESSION["s"]["user"]["default_group"]; - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - - // Fill the client select field - $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY sys_group.name"; - $clients = $app->db->queryAllRecords($sql); - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']); - $client_select = ''; - //$tmp_data_record = $app->tform->getDataRecord($this->id); - if(is_array($clients)) { - foreach( $clients as $client) { - $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; - $client_select .= "\r\n"; + + // Get the limits of the client + $client_group_id = $_SESSION["s"]["user"]["default_group"]; + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + + // Fill the client select field + $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." ORDER BY sys_group.name"; + $clients = $app->db->queryAllRecords($sql); + $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$client['client_id']); + $client_select = ''; + //$tmp_data_record = $app->tform->getDataRecord($this->id); + if(is_array($clients)) { + foreach( $clients as $client) { + $selected = @(is_array($this->dataRecord) && ($client["groupid"] == $this->dataRecord['client_group_id'] || $client["groupid"] == $this->dataRecord['sys_groupid']))?'SELECTED':''; + $client_select .= "\r\n"; + } } + $app->tpl->setVar("client_group_id", $client_select); + } - $app->tpl->setVar("client_group_id",$client_select); - - } - + if($this->id > 0) { //* we are editing a existing record $app->tpl->setVar("edit_disabled", 1); @@ -123,29 +123,29 @@ class page_action extends tform_actions { } else { $app->tpl->setVar("edit_disabled", 0); } - + parent::onShowEnd(); } - + function onSubmit() { global $app, $conf; - + if($_SESSION["s"]["user"]["typ"] != 'admin') { // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_zone, default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // When the record is updated if($this->id > 0) { // restore the server ID if the user is not admin and record is edited $tmp = $app->db->queryOneRecord("SELECT server_id FROM dns_soa WHERE id = ".$app->functions->intval($this->id)); $this->dataRecord["server_id"] = $tmp["server_id"]; unset($tmp); - // When the record is inserted + // When the record is inserted } else { // set the server ID to the default dnsserver of the client $this->dataRecord["server_id"] = $client["default_dnsserver"]; - + // Check if the user may add another maildomain. if($client["limit_dns_zone"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_soa WHERE sys_groupid = $client_group_id"); @@ -155,39 +155,39 @@ class page_action extends tform_actions { } } } - + /* // Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); */ - - + + //* Check if soa, ns and mbox have a dot at the end - if(strlen($this->dataRecord["origin"]) > 0 && substr($this->dataRecord["origin"],-1,1) != '.') $this->dataRecord["origin"] .= '.'; - if(strlen($this->dataRecord["ns"]) > 0 && substr($this->dataRecord["ns"],-1,1) != '.') $this->dataRecord["ns"] .= '.'; - if(strlen($this->dataRecord["mbox"]) > 0 && substr($this->dataRecord["mbox"],-1,1) != '.') $this->dataRecord["mbox"] .= '.'; - + if(strlen($this->dataRecord["origin"]) > 0 && substr($this->dataRecord["origin"], -1, 1) != '.') $this->dataRecord["origin"] .= '.'; + if(strlen($this->dataRecord["ns"]) > 0 && substr($this->dataRecord["ns"], -1, 1) != '.') $this->dataRecord["ns"] .= '.'; + if(strlen($this->dataRecord["mbox"]) > 0 && substr($this->dataRecord["mbox"], -1, 1) != '.') $this->dataRecord["mbox"] .= '.'; + //* Replace @ in mbox - if(stristr($this->dataRecord["mbox"],'@')) { - $this->dataRecord["mbox"] = str_replace('@','.',$this->dataRecord["mbox"]); + if(stristr($this->dataRecord["mbox"], '@')) { + $this->dataRecord["mbox"] = str_replace('@', '.', $this->dataRecord["mbox"]); } - + $this->dataRecord["xfer"] = preg_replace('/\s+/', '', $this->dataRecord["xfer"]); $this->dataRecord["also_notify"] = preg_replace('/\s+/', '', $this->dataRecord["also_notify"]); - //* Check if a secondary zone with the same name already exists + //* Check if a secondary zone with the same name already exists $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_slave WHERE origin = \"".$this->dataRecord["origin"]."\" AND server_id = \"".$this->dataRecord["server_id"]."\""); if($tmp["number"] > 0) { - $app->error($app->tform->wordbook["origin_error_unique"]); - } + $app->error($app->tform->wordbook["origin_error_unique"]); + } parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + // make sure that the record belongs to the client group and not the admin group when a dmin inserts it if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); @@ -203,7 +203,7 @@ class page_action extends tform_actions { } } - + function onBeforeUpdate () { global $app, $conf; @@ -212,7 +212,7 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { //* We do not allow users to change a domain which has been created by the admin $rec = $app->db->queryOneRecord("SELECT origin from dns_soa WHERE id = ".$this->id); - if(isset($this->dataRecord["origin"]) && $rec['origin'] != $this->dataRecord["origin"] && $app->tform->checkPerm($this->id,'u')) { + if(isset($this->dataRecord["origin"]) && $rec['origin'] != $this->dataRecord["origin"] && $app->tform->checkPerm($this->id, 'u')) { //* Add a error message and switch back to old server $app->tform->errorMessage .= $app->lng('The Zone (soa) can not be changed. Please ask your Administrator if you want to change the Zone name.'); $this->dataRecord["origin"] = $rec['origin']; @@ -220,17 +220,17 @@ class page_action extends tform_actions { unset($rec); } } - + function onAfterUpdate() { global $app, $conf; - - $tmp = $app->db->diffrec($this->oldDataRecord,$app->tform->getDataRecord($this->id)); + + $tmp = $app->db->diffrec($this->oldDataRecord, $app->tform->getDataRecord($this->id)); if($tmp['diff_num'] > 0) { // Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ".$this->id); $app->db->query("UPDATE dns_soa SET serial = '".$app->validate_dns->increase_serial($soa["serial"])."' WHERE id = ".$this->id); } - + // make sure that the record belongs to the client group and not the admin group when a dmin inserts it if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); @@ -244,7 +244,7 @@ class page_action extends tform_actions { // And we want to update all rr records too, that belong to this record $app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id); } - + //** When the client group has changed, change also the owner of the record if the owner is not the admin user if($this->oldDataRecord["client_group_id"] != $this->dataRecord["client_group_id"] && $this->dataRecord["sys_userid"] != 1) { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); @@ -254,9 +254,9 @@ class page_action extends tform_actions { $app->db->query("UPDATE dns_rr SET sys_userid = ".$tmp["userid"]." WHERE zone = ".$this->id); } } - + } - + } $page = new page_action; diff --git a/interface/web/dns/dns_soa_list.php b/interface/web/dns/dns_soa_list.php index 27604fb54..da02729ff 100644 --- a/interface/web/dns/dns_soa_list.php +++ b/interface/web/dns/dns_soa_list.php @@ -1,6 +1,6 @@ listform_actions->SQLOrderBy = 'ORDER BY dns_soa.origin'; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_srv_edit.php b/interface/web/dns/dns_srv_edit.php index e41b5542b..a382e6178 100644 --- a/interface/web/dns/dns_srv_edit.php +++ b/interface/web/dns/dns_srv_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_srv.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -77,7 +77,7 @@ class page_action extends tform_actions { // Split the 3 parts of the SRV Record apart $split = explode(' ', $this->dataRecord['data']); - + $app->tpl->setVar('weight', $split[0]); $app->tpl->setVar('port', $split[1]); $app->tpl->setVar('target', $split[2]); @@ -151,6 +151,7 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_template_del.php b/interface/web/dns/dns_template_del.php index bfb343cbf..fee0900b9 100644 --- a/interface/web/dns/dns_template_del.php +++ b/interface/web/dns/dns_template_del.php @@ -39,8 +39,8 @@ $tform_def_file = "form/dns_template.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -55,4 +55,4 @@ class page_action extends tform_actions { $page = new page_action; $page->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_template_edit.php b/interface/web/dns/dns_template_edit.php index 5dda4dac1..1b63eaa14 100644 --- a/interface/web/dns/dns_template_edit.php +++ b/interface/web/dns/dns_template_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_template.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -51,10 +51,10 @@ $app->load('tform_actions'); if($_SESSION["s"]["user"]["typ"] != 'admin') die('Access denied for non admin users.'); class page_action extends tform_actions { - + } $page = new page_action; $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_template_list.php b/interface/web/dns/dns_template_list.php index acad5d37a..3fab001a0 100644 --- a/interface/web/dns/dns_template_list.php +++ b/interface/web/dns/dns_template_list.php @@ -1,6 +1,6 @@ listform_actions->SQLOrderBy = 'ORDER BY dns_template.name'; $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/dns_txt_edit.php b/interface/web/dns/dns_txt_edit.php index 2445f0321..2bacd3576 100644 --- a/interface/web/dns/dns_txt_edit.php +++ b/interface/web/dns/dns_txt_edit.php @@ -38,8 +38,8 @@ $tform_def_file = "form/dns_txt.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -49,17 +49,17 @@ $app->uses('tpl,tform,tform_actions,validate_dns'); $app->load('tform_actions'); class page_action extends tform_actions { - + function onShowNew() { global $app, $conf; - + // we will check only users, not admins if($_SESSION["s"]["user"]["typ"] == 'user') { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -68,25 +68,25 @@ class page_action extends tform_actions { } } } - + parent::onShowNew(); } - + function onSubmit() { global $app, $conf; - + // Get the parent soa record of the domain $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = '".$app->functions->intval($_POST["zone"])."' AND ".$app->tform->getAuthSQL('r')); // Check if Domain belongs to user if($soa["id"] != $_POST["zone"]) $app->tform->errorMessage .= $app->tform->wordbook["no_zone_perm"]; - + // Check the client limits, if user is not the admin if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT limit_dns_record FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // Check if the user may add another mailbox. if($this->id == 0 && $client["limit_dns_record"] >= 0) { $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM dns_rr WHERE sys_groupid = $client_group_id"); @@ -95,22 +95,22 @@ class page_action extends tform_actions { } } } // end if user is not admin - - + + // Set the server ID of the rr record to the same server ID as the parent record. $this->dataRecord["server_id"] = $soa["server_id"]; - + // Update the serial number and timestamp of the RR record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_rr WHERE id = ".$this->id); $this->dataRecord["serial"] = $app->validate_dns->increase_serial($soa["serial"]); $this->dataRecord["stamp"] = date('Y-m-d H:i:s'); - + parent::onSubmit(); } - + function onAfterInsert() { global $app, $conf; - + //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record $soa = $app->db->queryOneRecord("SELECT sys_groupid,serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $app->db->datalogUpdate('dns_rr', "sys_groupid = ".$soa['sys_groupid'], 'id', $this->id); @@ -120,16 +120,17 @@ class page_action extends tform_actions { $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } - + function onAfterUpdate() { global $app, $conf; - + //* Update the serial number of the SOA record $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = '".$app->functions->intval($this->dataRecord["zone"])."' AND ".$app->tform->getAuthSQL('r')); $soa_id = $app->functions->intval($_POST["zone"]); $serial = $app->validate_dns->increase_serial($soa["serial"]); $app->db->datalogUpdate('dns_soa', "serial = $serial", 'id', $soa_id); } + } $page = new page_action; diff --git a/interface/web/dns/dns_wizard.php b/interface/web/dns/dns_wizard.php index 10cfd9a75..d4b07f748 100644 --- a/interface/web/dns/dns_wizard.php +++ b/interface/web/dns/dns_wizard.php @@ -28,8 +28,8 @@ 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'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('dns'); @@ -38,7 +38,7 @@ $app->auth->check_module_permissions('dns'); // Loading the template $app->uses('tpl,validate_dns'); $app->tpl->newTemplate("form.tpl.htm"); -$app->tpl->setInclude('content_tpl','templates/dns_wizard.htm'); +$app->tpl->setInclude('content_tpl', 'templates/dns_wizard.htm'); $app->load_language_file('/web/dns/lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng'); // import variables @@ -66,11 +66,11 @@ foreach($records as $rec){ $n++; } unset($n); -$app->tpl->setVar("template_id_option",$template_id_option); +$app->tpl->setVar("template_id_option", $template_id_option); // If the user is administrator if($_SESSION['s']['user']['typ'] == 'admin') { - + // Load the list of servers $records = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 ORDER BY server_name"); $server_id_option = ''; @@ -78,8 +78,8 @@ if($_SESSION['s']['user']['typ'] == 'admin') { $checked = ($rec['server_id'] == $server_id)?' SELECTED':''; $server_id_option .= ''; } - $app->tpl->setVar("server_id",$server_id_option); - + $app->tpl->setVar("server_id", $server_id_option); + // load the list of clients $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.client_id > 0 ORDER BY sys_group.name"; $clients = $app->db->queryAllRecords($sql); @@ -92,16 +92,16 @@ if($_SESSION['s']['user']['typ'] == 'admin') { } } - $app->tpl->setVar("client_group_id",$client_select); + $app->tpl->setVar("client_group_id", $client_select); } if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { - + // Get the limits of the client $client_group_id = $_SESSION["s"]["user"]["default_group"]; $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname, sys_group.name FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - + // load the list of clients $sql = "SELECT sys_group.groupid, sys_group.name, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']; $clients = $app->db->queryAllRecords($sql); @@ -114,24 +114,24 @@ if ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSIO } } - $app->tpl->setVar("client_group_id",$client_select); + $app->tpl->setVar("client_group_id", $client_select); } $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = '$template_id'"); -$fields = explode(',',$template_record['fields']); +$fields = explode(',', $template_record['fields']); if(is_array($fields)) { foreach($fields as $field) { - $app->tpl->setVar($field."_VISIBLE",1); + $app->tpl->setVar($field."_VISIBLE", 1); $field = strtolower($field); - $app->tpl->setVar($field,$_POST[$field]); + $app->tpl->setVar($field, $_POST[$field]); } } if($_POST['create'] == 1) { - + $error = ''; - + // apply filters if(isset($_POST['domain']) && $_POST['domain'] != ''){ $_POST['domain'] = $app->functions->idn_encode($_POST['domain']); @@ -149,22 +149,22 @@ if($_POST['create'] == 1) { $_POST['email'] = $app->functions->idn_encode($_POST['email']); $_POST['email'] = strtolower($_POST['email']); } - - + + if(isset($_POST['domain']) && $_POST['domain'] == '') $error .= $app->lng('error_domain_empty').'
    '; - elseif(isset($_POST['domain']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,30}$/',$_POST['domain'])) $error .= $app->lng('error_domain_regex').'
    '; + elseif(isset($_POST['domain']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,30}$/', $_POST['domain'])) $error .= $app->lng('error_domain_regex').'
    '; if(isset($_POST['ip']) && $_POST['ip'] == '') $error .= $app->lng('error_ip_empty').'
    '; if(isset($_POST['ns1']) && $_POST['ns1'] == '') $error .= $app->lng('error_ns1_empty').'
    '; - elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/',$_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'
    '; + elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/', $_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'
    '; if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty').'
    '; - elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/',$_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'
    '; + elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,30}$/', $_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'
    '; if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'
    '; - elseif(isset($_POST['email']) && !preg_match('/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z0-9\-]{2,30}$/i',$_POST['email'])) $error .= $app->lng('error_email_regex').'
    '; - + elseif(isset($_POST['email']) && !preg_match('/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z0-9\-]{2,30}$/i', $_POST['email'])) $error .= $app->lng('error_email_regex').'
    '; + // make sure that the record belongs to the client group and not the admin group when admin inserts it if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($_POST['client_group_id'])) { $sys_groupid = $app->functions->intval($_POST['client_group_id']); @@ -173,11 +173,11 @@ if($_POST['create'] == 1) { } else { $sys_groupid = $_SESSION["s"]["user"]["default_group"]; } - + $tform_def_file = "form/dns_soa.tform.php"; $app->uses('tform'); $app->tform->loadFormDef($tform_def_file); - + if($_SESSION['s']['user']['typ'] != 'admin') { if(!$app->tform->checkClientLimit('limit_dns_zone')) { $error .= $app->tform->wordbook["limit_dns_zone_txt"]; @@ -186,31 +186,31 @@ if($_POST['create'] == 1) { $error .= $app->tform->wordbook["limit_dns_zone_txt"]; } } - - + + // replace template placeholders $tpl_content = $template_record['template']; - if($_POST['domain'] != '') $tpl_content = str_replace('{DOMAIN}',$_POST['domain'],$tpl_content); - if($_POST['ip'] != '') $tpl_content = str_replace('{IP}',$_POST['ip'],$tpl_content); - if($_POST['ns1'] != '') $tpl_content = str_replace('{NS1}',$_POST['ns1'],$tpl_content); - if($_POST['ns2'] != '') $tpl_content = str_replace('{NS2}',$_POST['ns2'],$tpl_content); - if($_POST['email'] != '') $tpl_content = str_replace('{EMAIL}',$_POST['email'],$tpl_content); - if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/',$_POST['domain'])) { - $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".$app->db->quote($_POST['domain'])."' AND dkim = 'y' AND ".$app->tform->getAuthSQL('r')); - if ($public_key!='') { - $dns_record=str_replace(array("\r\n", "\n", "\r","-----BEGIN PUBLIC KEY-----","-----END PUBLIC KEY-----"),'',$public_key['dkim_public']); - $tpl_content = str_replace('{DKIM}','TXT|default._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record,$tpl_content); - } - } - + if($_POST['domain'] != '') $tpl_content = str_replace('{DOMAIN}', $_POST['domain'], $tpl_content); + if($_POST['ip'] != '') $tpl_content = str_replace('{IP}', $_POST['ip'], $tpl_content); + if($_POST['ns1'] != '') $tpl_content = str_replace('{NS1}', $_POST['ns1'], $tpl_content); + if($_POST['ns2'] != '') $tpl_content = str_replace('{NS2}', $_POST['ns2'], $tpl_content); + if($_POST['email'] != '') $tpl_content = str_replace('{EMAIL}', $_POST['email'], $tpl_content); + if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/', $_POST['domain'])) { + $public_key=$app->db->queryOneRecord("SELECT dkim_public FROM mail_domain WHERE domain = '".$app->db->quote($_POST['domain'])."' AND dkim = 'y' AND ".$app->tform->getAuthSQL('r')); + if ($public_key!='') { + $dns_record=str_replace(array("\r\n", "\n", "\r", "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"), '', $public_key['dkim_public']); + $tpl_content = str_replace('{DKIM}', 'TXT|default._domainkey.'.$_POST['domain'].'.|v=DKIM1; t=s; p='.$dns_record, $tpl_content); + } + } + // Parse the template - $tpl_rows = explode("\n",$tpl_content); + $tpl_rows = explode("\n", $tpl_content); $section = ''; $vars = array(); $dns_rr = array(); foreach($tpl_rows as $row) { $row = trim($row); - if(substr($row,0,1) == '[') { + if(substr($row, 0, 1) == '[') { if($row == '[ZONE]') { $section = 'zone'; } elseif($row == '[DNS_RECORDS]') { @@ -222,14 +222,14 @@ if($_POST['create'] == 1) { if($row != '') { // Handle zone section if($section == 'zone') { - $parts = explode('=',$row); + $parts = explode('=', $row); $key = trim($parts[0]); $val = trim($parts[1]); if($key != '') $vars[$key] = $val; } // Handle DNS Record rows if($section == 'dns_records') { - $parts = explode('|',$row); + $parts = explode('|', $row); $dns_rr[] = array( 'name' => $app->db->quote($parts[1]), 'type' => $app->db->quote($parts[0]), @@ -240,9 +240,9 @@ if($_POST['create'] == 1) { } } } - + } // end foreach - + if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'
    '; if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'
    '; if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'
    '; @@ -251,13 +251,13 @@ if($_POST['create'] == 1) { if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'
    '; if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'
    '; if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'
    '; - + if($error == '') { // Insert the soa record $sys_userid = $_SESSION['s']['user']['userid']; $origin = $app->db->quote($vars['origin']); $ns = $app->db->quote($vars['ns']); - $mbox = $app->db->quote(str_replace('@','.',$vars['mbox'])); + $mbox = $app->db->quote(str_replace('@', '.', $vars['mbox'])); $refresh = $app->db->quote($vars['refresh']); $retry = $app->db->quote($vars['retry']); $expire = $app->db->quote($vars['expire']); @@ -267,35 +267,35 @@ if($_POST['create'] == 1) { $also_notify = $app->db->quote($vars['also_notify']); $update_acl = $app->db->quote($vars['update_acl']); $serial = $app->validate_dns->increase_serial(0); - - $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `origin`, `ns`, `mbox`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `ttl`, `active`, `xfer`, `also_notify`, `update_acl`) VALUES + + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `origin`, `ns`, `mbox`, `serial`, `refresh`, `retry`, `expire`, `minimum`, `ttl`, `active`, `xfer`, `also_notify`, `update_acl`) VALUES ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$origin', '$ns', '$mbox', '$serial', '$refresh', '$retry', '$expire', '$minimum', '$ttl', 'Y', '$xfer', '$also_notify', '$update_acl')"; $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); - + // Insert the dns_rr records if(is_array($dns_rr) && $dns_soa_id > 0) { foreach($dns_rr as $rr) { - $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES + $insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `zone`, `name`, `type`, `data`, `aux`, `ttl`, `active`) VALUES ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$dns_soa_id', '$rr[name]', '$rr[type]', '$rr[data]', '$rr[aux]', '$rr[ttl]', 'Y')"; $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); } } - + header("Location: dns_soa_list.php"); exit; - + } else { - $app->tpl->setVar("error",$error); + $app->tpl->setVar("error", $error); } - + } -$app->tpl->setVar("title",'DNS Wizard'); +$app->tpl->setVar("title", 'DNS Wizard'); $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dns_wizard.lng'; -include($lng_file); +include $lng_file; $app->tpl->setVar($wb); $app->tpl_defaults(); diff --git a/interface/web/dns/form/dns_a.tform.php b/interface/web/dns/form/dns_a.tform.php index d6e93ffb5..7d4d276e8 100644 --- a/interface/web/dns/form/dns_a.tform.php +++ b/interface/web/dns/form/dns_a.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS A"; -$form["description"] = ""; -$form["name"] = "dns_a"; -$form["action"] = "dns_a_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS A"; +$form["description"] = ""; +$form["name"] = "dns_a"; +$form["action"] = "dns_a_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,69 +52,69 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS A", - 'width' => 100, - 'template' => "templates/dns_a_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS A", + 'width' => 100, + 'template' => "templates/dns_a_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\a-zA-Z0-9\.\-\*]{0,64}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\a-zA-Z0-9\.\-\*]{0,64}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'A', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'A', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^([1-9]{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])\.(\d{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])\.(\d{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])\.(\d{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^([1-9]{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])\.(\d{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])\.(\d{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])\.(\d{1}|[1-9]\d|[1]\d\d|2[0-4]\d|25[0-5])$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -127,41 +127,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_aaaa.tform.php b/interface/web/dns/form/dns_aaaa.tform.php index d674913c2..c03423b8b 100644 --- a/interface/web/dns/form/dns_aaaa.tform.php +++ b/interface/web/dns/form/dns_aaaa.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS AAAA"; -$form["description"] = ""; -$form["name"] = "dns_aaaa"; -$form["action"] = "dns_aaaa_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS AAAA"; +$form["description"] = ""; +$form["name"] = "dns_aaaa"; +$form["action"] = "dns_aaaa_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,62 +52,62 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS AAAA", - 'width' => 100, - 'template' => "templates/dns_aaaa_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS AAAA", + 'width' => 100, + 'template' => "templates/dns_aaaa_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\*]{0,64}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\*]{0,64}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'AAAA', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'AAAA', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^\s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?\s*$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^\s*((([0-9A-Fa-f]{1,4}:){7}(([0-9A-Fa-f]{1,4})|:))|(([0-9A-Fa-f]{1,4}:){6}(:|((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})|(:[0-9A-Fa-f]{1,4})))|(([0-9A-Fa-f]{1,4}:){5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){4}(:[0-9A-Fa-f]{1,4}){0,1}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){3}(:[0-9A-Fa-f]{1,4}){0,2}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:){2}(:[0-9A-Fa-f]{1,4}){0,3}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(([0-9A-Fa-f]{1,4}:)(:[0-9A-Fa-f]{1,4}){0,4}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(:(:[0-9A-Fa-f]{1,4}){0,5}((:((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})?)|((:[0-9A-Fa-f]{1,4}){1,2})))|(((25[0-5]|2[0-4]\d|[01]?\d{1,2})(\.(25[0-5]|2[0-4]\d|[01]?\d{1,2})){3})))(%.+)?\s*$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -120,41 +120,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_alias.tform.php b/interface/web/dns/form/dns_alias.tform.php index b358b720c..b97889bb3 100644 --- a/interface/web/dns/form/dns_alias.tform.php +++ b/interface/web/dns/form/dns_alias.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS ALIAS"; -$form["description"] = ""; -$form["name"] = "dns_alias"; -$form["action"] = "dns_alias_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS ALIAS"; +$form["description"] = ""; +$form["name"] = "dns_alias"; +$form["action"] = "dns_alias_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,78 +52,78 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS ALIAS", - 'width' => 100, - 'template' => "templates/dns_alias_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS ALIAS", + 'width' => 100, + 'template' => "templates/dns_alias_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'name_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'name_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'ALIAS', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'ALIAS', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,255}$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,255}$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -136,41 +136,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_cname.tform.php b/interface/web/dns/form/dns_cname.tform.php index ccfef7368..b9d246c95 100644 --- a/interface/web/dns/form/dns_cname.tform.php +++ b/interface/web/dns/form/dns_cname.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS CNAME"; -$form["description"] = ""; -$form["name"] = "dns_cname"; -$form["action"] = "dns_cname_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS CNAME"; +$form["description"] = ""; +$form["name"] = "dns_cname"; +$form["action"] = "dns_cname_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,76 +52,76 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS CNAME", - 'width' => 100, - 'template' => "templates/dns_cname_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS CNAME", + 'width' => 100, + 'template' => "templates/dns_cname_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\*]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\*]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'CNAME', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'CNAME', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,255}$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,255}$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -134,41 +134,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_dkim.tform.php b/interface/web/dns/form/dns_dkim.tform.php index 71607c765..89ee8a002 100644 --- a/interface/web/dns/form/dns_dkim.tform.php +++ b/interface/web/dns/form/dns_dkim.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS DKIM Record"; -$form["description"] = ""; -$form["name"] = "dns_dkim"; -$form["action"] = "dns_dkim_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS DKIM Record"; +$form["description"] = ""; +$form["name"] = "dns_dkim"; +$form["action"] = "dns_dkim_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,100 +52,100 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS DKIM", - 'width' => 100, - 'template' => "templates/dns_dkim_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS DKIM", + 'width' => 100, + 'template' => "templates/dns_dkim_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'TXT', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'TXT', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); diff --git a/interface/web/dns/form/dns_hinfo.tform.php b/interface/web/dns/form/dns_hinfo.tform.php index 70971cf77..c64dea02d 100644 --- a/interface/web/dns/form/dns_hinfo.tform.php +++ b/interface/web/dns/form/dns_hinfo.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS hinfo"; -$form["description"] = ""; -$form["name"] = "dns_hinfo"; -$form["action"] = "dns_hinfo_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS hinfo"; +$form["description"] = ""; +$form["name"] = "dns_hinfo"; +$form["action"] = "dns_hinfo_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,68 +52,68 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS HINFO", - 'width' => 100, - 'template' => "templates/dns_hinfo_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS HINFO", + 'width' => 100, + 'template' => "templates/dns_hinfo_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'name_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,64}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'name_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,64}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'HINFO', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'HINFO', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -126,41 +126,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_mx.tform.php b/interface/web/dns/form/dns_mx.tform.php index a1f7b78b9..34268f9ef 100644 --- a/interface/web/dns/form/dns_mx.tform.php +++ b/interface/web/dns/form/dns_mx.tform.php @@ -35,16 +35,16 @@ global $app; -$form["title"] = "DNS mx"; -$form["description"] = ""; -$form["name"] = "dns_mx"; -$form["action"] = "dns_mx_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS mx"; +$form["description"] = ""; +$form["name"] = "dns_mx"; +$form["action"] = "dns_mx_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -53,123 +53,123 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS mx", - 'width' => 100, - 'template' => "templates/dns_mx_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS mx", + 'width' => 100, + 'template' => "templates/dns_mx_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\*]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\*]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'MX', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'MX', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,255}$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,255}$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), - + 'aux' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '10', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '10', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - + 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_ns.tform.php b/interface/web/dns/form/dns_ns.tform.php index 00a842f84..3eb39a927 100644 --- a/interface/web/dns/form/dns_ns.tform.php +++ b/interface/web/dns/form/dns_ns.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS ns"; -$form["description"] = ""; -$form["name"] = "dns_ns"; -$form["action"] = "dns_ns_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS ns"; +$form["description"] = ""; +$form["name"] = "dns_ns"; +$form["action"] = "dns_ns_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,76 +52,76 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS ns", - 'width' => 100, - 'template' => "templates/dns_ns_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS ns", + 'width' => 100, + 'template' => "templates/dns_ns_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'NS', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'NS', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,255}$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,255}$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -134,41 +134,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_ptr.tform.php b/interface/web/dns/form/dns_ptr.tform.php index 68ea83c54..3ba441b17 100644 --- a/interface/web/dns/form/dns_ptr.tform.php +++ b/interface/web/dns/form/dns_ptr.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS ptr"; -$form["description"] = ""; -$form["name"] = "dns_ptr"; -$form["action"] = "dns_ptr_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS ptr"; +$form["description"] = ""; +$form["name"] = "dns_ptr"; +$form["action"] = "dns_ptr_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,76 +52,76 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS ptr", - 'width' => 100, - 'template' => "templates/dns_ptr_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS ptr", + 'width' => 100, + 'template' => "templates/dns_ptr_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,256}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,256}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'PTR', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'PTR', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,256}$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,256}$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -134,41 +134,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_rp.tform.php b/interface/web/dns/form/dns_rp.tform.php index 5a7ff8314..86c43ed32 100644 --- a/interface/web/dns/form/dns_rp.tform.php +++ b/interface/web/dns/form/dns_rp.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS RP"; -$form["description"] = ""; -$form["name"] = "dns_rp"; -$form["action"] = "dns_rp_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS RP"; +$form["description"] = ""; +$form["name"] = "dns_rp"; +$form["action"] = "dns_rp_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,69 +52,69 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS RP", - 'width' => 100, - 'template' => "templates/dns_rp_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS RP", + 'width' => 100, + 'template' => "templates/dns_rp_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'RP', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'RP', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\s]{1,128}$/', - 'errmsg'=> 'data_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\s]{1,128}$/', + 'errmsg'=> 'data_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -127,41 +127,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_slave.tform.php b/interface/web/dns/form/dns_slave.tform.php index 0ff6a5e94..c5187317b 100644 --- a/interface/web/dns/form/dns_slave.tform.php +++ b/interface/web/dns/form/dns_slave.tform.php @@ -29,7 +29,7 @@ Hint: The ID field of the database table is not part of the datafield definition. The ID field must be always auto incement (int or bigint). - + Search: - searchable = 1 or searchable = 2 include the field in the search - searchable = 1: this field will be the title of the search result @@ -38,16 +38,16 @@ */ -$form["title"] = "Secondary DNS Zone"; -$form["description"] = ""; -$form["name"] = "dns_slave"; -$form["action"] = "dns_slave_edit.php"; -$form["db_table"] = "dns_slave"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns_slave"; -$form["list_default"] = "dns_slave_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "Secondary DNS Zone"; +$form["description"] = ""; +$form["name"] = "dns_slave"; +$form["action"] = "dns_slave_edit.php"; +$form["db_table"] = "dns_slave"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns_slave"; +$form["list_default"] = "dns_slave_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 @@ -56,85 +56,85 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns_slave'] = array ( - 'title' => "Secondary DNS Zone", - 'width' => 100, - 'template' => "templates/dns_slave_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Secondary DNS Zone", + 'width' => 100, + 'template' => "templates/dns_slave_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 AND {AUTHSQL} ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'server_id_error_empty'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 AND {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'server_id_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'origin' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'origin_error_empty'), - /* + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'origin_error_empty'), + /* 1 => array ( 'type' => 'UNIQUE', 'errmsg'=> 'origin_error_unique'), */ - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,10}[\.]{0,1}$/', - 'errmsg'=> 'origin_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,10}[\.]{0,1}$/', + 'errmsg'=> 'origin_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', 'searchable' => 1 ), 'ns' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[0-9\.]{1,255}$/', - 'errmsg'=> 'ns_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[0-9\.]{1,255}$/', + 'errmsg'=> 'ns_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', 'searchable' => 2 ), - 'xfer' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), + 'xfer' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); diff --git a/interface/web/dns/form/dns_soa.tform.php b/interface/web/dns/form/dns_soa.tform.php index ebc49cfce..fd41c87c9 100644 --- a/interface/web/dns/form/dns_soa.tform.php +++ b/interface/web/dns/form/dns_soa.tform.php @@ -29,7 +29,7 @@ Hint: The ID field of the database table is not part of the datafield definition. The ID field must be always auto incement (int or bigint). - + Search: - searchable = 1 or searchable = 2 include the field in the search - searchable = 1: this field will be the title of the search result @@ -39,16 +39,16 @@ */ global $app; -$form["title"] = "DNS Zone"; -$form["description"] = ""; -$form["name"] = "dns_soa"; -$form["action"] = "dns_soa_edit.php"; -$form["db_table"] = "dns_soa"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns_soa"; -$form["list_default"] = "dns_soa_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS Zone"; +$form["description"] = ""; +$form["name"] = "dns_soa"; +$form["action"] = "dns_soa_edit.php"; +$form["db_table"] = "dns_soa"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns_soa"; +$form["list_default"] = "dns_soa_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 @@ -57,235 +57,235 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns_soa'] = array ( - 'title' => "DNS Zone", - 'width' => 100, - 'template' => "templates/dns_soa_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS Zone", + 'width' => 100, + 'template' => "templates/dns_soa_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 AND {AUTHSQL} ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'server_id_error_empty'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE mirror_server_id = 0 AND dns_server = 1 AND {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'server_id_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'origin' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'origin_error_empty'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'origin_error_unique'), - 2 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/', - 'errmsg'=> 'origin_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'origin_error_empty'), + 1 => array ( 'type' => 'UNIQUE', + 'errmsg'=> 'origin_error_unique'), + 2 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,30}[\.]{0,1}$/', + 'errmsg'=> 'origin_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', 'searchable' => 1 ), 'ns' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{1,255}$/', - 'errmsg'=> 'ns_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{1,255}$/', + 'errmsg'=> 'ns_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', 'searchable' => 2 ), 'mbox' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'mbox_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[[a-zA-Z0-9\.\-\_]{0,255}\.$/', - 'errmsg'=> 'mbox_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'mbox_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[[a-zA-Z0-9\.\-\_]{0,255}\.$/', + 'errmsg'=> 'mbox_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255', 'searchable' => 2 ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'refresh' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'RANGE', - 'range' => '60:', - 'errmsg'=> 'refresh_range_error'), - ), - 'default' => '7200', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'RANGE', + 'range' => '60:', + 'errmsg'=> 'refresh_range_error'), + ), + 'default' => '7200', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'retry' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'RANGE', - 'range' => '60:', - 'errmsg'=> 'retry_range_error'), - ), - 'default' => '540', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'RANGE', + 'range' => '60:', + 'errmsg'=> 'retry_range_error'), + ), + 'default' => '540', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'expire' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'RANGE', - 'range' => '60:', - 'errmsg'=> 'expire_range_error'), - ), - 'default' => '604800', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'RANGE', + 'range' => '60:', + 'errmsg'=> 'expire_range_error'), + ), + 'default' => '604800', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'minimum' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'RANGE', - 'range' => '60:', - 'errmsg'=> 'minimum_range_error'), - ), - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'RANGE', + 'range' => '60:', + 'errmsg'=> 'minimum_range_error'), + ), + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'RANGE', - 'range' => '60:', - 'errmsg'=> 'ttl_range_error'), - ), - 'default' => '3600', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'RANGE', + 'range' => '60:', + 'errmsg'=> 'ttl_range_error'), + ), + 'default' => '3600', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'xfer' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISIP', - 'allowempty' => 'y', - 'separator' => ',', - 'errmsg'=> 'xfer_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISIP', + 'allowempty' => 'y', + 'separator' => ',', + 'errmsg'=> 'xfer_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'also_notify' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISIP', - 'allowempty' => 'y', - 'separator' => ',', - 'errmsg'=> 'also_notify_error_regex' - ), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISIP', + 'allowempty' => 'y', + 'separator' => ',', + 'errmsg'=> 'also_notify_error_regex' + ), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'update_acl' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); $form["tabs"]['dns_records'] = array ( - 'title' => "Records", - 'width' => 100, - 'template' => "templates/dns_records_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## - - ################################## - # ENDE Datatable fields - ################################## + 'title' => "Records", + 'width' => 100, + 'template' => "templates/dns_records_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# + + //################################# + // ENDE Datatable fields + //################################# ), 'plugins' => array ( - 'dns_records' => array ( - 'class' => 'plugin_listview', - 'options' => array( + 'dns_records' => array ( + 'class' => 'plugin_listview', + 'options' => array( 'listdef' => 'list/dns_a.list.php', 'sqlextwhere' => "zone = ".@$app->functions->intval(@$_REQUEST['id']), 'sql_order_by' => "ORDER BY type, name" ) - ) + ) ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_srv.tform.php b/interface/web/dns/form/dns_srv.tform.php index 736bbc920..b737bbd97 100644 --- a/interface/web/dns/form/dns_srv.tform.php +++ b/interface/web/dns/form/dns_srv.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS SRV"; -$form["description"] = ""; -$form["name"] = "dns_srv"; -$form["action"] = "dns_srv_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS SRV"; +$form["description"] = ""; +$form["name"] = "dns_srv"; +$form["action"] = "dns_srv_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,114 +52,114 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS SRV", - 'width' => 100, - 'template' => "templates/dns_srv_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS SRV", + 'width' => 100, + 'template' => "templates/dns_srv_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'SRV', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'SRV', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - 1 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{0,64}\s[\w\.\-]{0,64}\s[\w\.\-]{0,64}$/', - 'errmsg'=> 'srv_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + 1 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,64}\s[\w\.\-]{0,64}\s[\w\.\-]{0,64}$/', + 'errmsg'=> 'srv_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'aux' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '0', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '0', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/form/dns_template.tform.php b/interface/web/dns/form/dns_template.tform.php index 382271935..e209153f7 100644 --- a/interface/web/dns/form/dns_template.tform.php +++ b/interface/web/dns/form/dns_template.tform.php @@ -33,16 +33,16 @@ */ -$form["title"] = "DNS Wizard template"; -$form["description"] = ""; -$form["name"] = "dns_template"; -$form["action"] = "dns_template_edit.php"; -$form["db_table"] = "dns_template"; -$form["db_table_idx"] = "template_id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "template"; -$form["list_default"] = "dns_template_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS Wizard template"; +$form["description"] = ""; +$form["name"] = "dns_template"; +$form["action"] = "dns_template_edit.php"; +$form["db_table"] = "dns_template"; +$form["db_table_idx"] = "template_id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "template"; +$form["list_default"] = "dns_template_list.php"; +$form["auth"] = 'yes'; // yes / no $form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user $form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user @@ -51,53 +51,53 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['template'] = array ( - 'title' => "DNS Template", - 'width' => 100, - 'template' => "templates/dns_template_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS Template", + 'width' => 100, + 'template' => "templates/dns_template_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'name_error_empty'), - ), - 'default' => '', - 'value' => '', - 'width' => '40', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'name_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '40', + 'maxlength' => '255' ), 'fields' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOXARRAY', - 'default' => '', + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'default' => '', 'separator' => ',', - 'value' => array('DOMAIN' => 'Domain','IP' => 'IP Address','NS1' => 'NS 1','NS2' => 'NS 2','EMAIL' => 'Email', 'DKIM' => 'DKIM (use {DKIM}|0|3600 in your Template)'), - 'validators' => array ( 0 => array ('type' => 'CUSTOM', - 'class' => 'validate_dkim', - 'function' => 'check_template', - 'errmsg'=> 'dkim_domain_error'), - ), + 'value' => array('DOMAIN' => 'Domain', 'IP' => 'IP Address', 'NS1' => 'NS 1', 'NS2' => 'NS 2', 'EMAIL' => 'Email', 'DKIM' => 'DKIM (use {DKIM}|0|3600 in your Template)'), + 'validators' => array ( 0 => array ('type' => 'CUSTOM', + 'class' => 'validate_dkim', + 'function' => 'check_template', + 'errmsg'=> 'dkim_domain_error'), + ), ), 'template' => array ( - 'datatype' => 'TEXT', - 'formtype' => 'TEXTAREA', - 'default' => '', - 'value' => '', - 'cols' => '40', - 'rows' => '15' + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'default' => '', + 'value' => '', + 'cols' => '40', + 'rows' => '15' ), 'visible' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); diff --git a/interface/web/dns/form/dns_txt.tform.php b/interface/web/dns/form/dns_txt.tform.php index c59fa75e5..159629b20 100644 --- a/interface/web/dns/form/dns_txt.tform.php +++ b/interface/web/dns/form/dns_txt.tform.php @@ -34,16 +34,16 @@ */ global $app; -$form["title"] = "DNS TXT Record"; -$form["description"] = ""; -$form["name"] = "dns_txt"; -$form["action"] = "dns_txt_edit.php"; -$form["db_table"] = "dns_rr"; -$form["db_table_idx"] = "id"; -$form["db_history"] = "yes"; -$form["tab_default"] = "dns"; -$form["list_default"] = "dns_a_list.php"; -$form["auth"] = 'yes'; // yes / no +$form["title"] = "DNS TXT Record"; +$form["description"] = ""; +$form["name"] = "dns_txt"; +$form["action"] = "dns_txt_edit.php"; +$form["db_table"] = "dns_rr"; +$form["db_table_idx"] = "id"; +$form["db_history"] = "yes"; +$form["tab_default"] = "dns"; +$form["list_default"] = "dns_a_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 @@ -52,66 +52,66 @@ $form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, $form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete $form["tabs"]['dns'] = array ( - 'title' => "DNS TXT", - 'width' => 100, - 'template' => "templates/dns_txt_edit.htm", - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "DNS TXT", + 'width' => 100, + 'template' => "templates/dns_txt_edit.htm", + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'zone' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => @$app->functions->intval($_REQUEST["zone"]), - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => @$app->functions->intval($_REQUEST["zone"]), + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'name' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'filters' => array( 0 => array( 'event' => 'SAVE', - 'type' => 'IDNTOASCII'), - 1 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8'), - 2 => array( 'event' => 'SAVE', - 'type' => 'TOLOWER') - ), - 'validators' => array ( 0 => array ( 'type' => 'REGEX', - 'regex' => '/^[\w\.\-]{0,255}$/', - 'errmsg'=> 'name_error_regex'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'IDNTOASCII'), + 1 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8'), + 2 => array( 'event' => 'SAVE', + 'type' => 'TOLOWER') + ), + 'validators' => array ( 0 => array ( 'type' => 'REGEX', + 'regex' => '/^[\w\.\-]{0,255}$/', + 'errmsg'=> 'name_error_regex'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'type' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => 'TXT', - 'value' => '', - 'width' => '5', - 'maxlength' => '5' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'TXT', + 'value' => '', + 'width' => '5', + 'maxlength' => '5' ), 'data' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'data_error_empty'), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'data_error_empty'), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), /* 'aux' => array ( @@ -124,41 +124,41 @@ $form["tabs"]['dns'] = array ( ), */ 'ttl' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '86400', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '86400', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), 'active' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'CHECKBOX', - 'default' => 'Y', - 'value' => array(0 => 'N',1 => 'Y') + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'Y', + 'value' => array(0 => 'N', 1 => 'Y') ), 'stamp' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'serial' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => '', - 'value' => '', - 'width' => '10', - 'maxlength' => '10' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '10', + 'maxlength' => '10' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/lib/admin.conf.php b/interface/web/dns/lib/admin.conf.php index 67c94a574..acb6c3546 100644 --- a/interface/web/dns/lib/admin.conf.php +++ b/interface/web/dns/lib/admin.conf.php @@ -1,2 +1,2 @@ \ No newline at end of file +?> diff --git a/interface/web/dns/lib/module.conf.php b/interface/web/dns/lib/module.conf.php index 1af3a893d..83027c67d 100644 --- a/interface/web/dns/lib/module.conf.php +++ b/interface/web/dns/lib/module.conf.php @@ -1,33 +1,33 @@ "Add DNS Zone", - 'target' => 'content', - 'link' => 'dns/dns_wizard.php', - 'html_id' => 'dns_wizard'); +$items[] = array( 'title' => "Add DNS Zone", + 'target' => 'content', + 'link' => 'dns/dns_wizard.php', + 'html_id' => 'dns_wizard'); -$items[] = array( 'title' => "Import Zone File", - 'target' => 'content', - 'link' => 'dns/dns_import.php', - 'html_id' => 'dns_import'); +$items[] = array( 'title' => "Import Zone File", + 'target' => 'content', + 'link' => 'dns/dns_import.php', + 'html_id' => 'dns_import'); if($_SESSION["s"]["user"]["typ"] == 'admin') { - $items[] = array( 'title' => "Templates", - 'target' => 'content', - 'link' => 'dns/dns_template_list.php', - 'html_id' => 'dns_template_list'); + $items[] = array( 'title' => "Templates", + 'target' => 'content', + 'link' => 'dns/dns_template_list.php', + 'html_id' => 'dns_template_list'); } -$module["nav"][] = array( 'title' => 'DNS Wizard', - 'open' => 1, - 'items' => $items); +$module["nav"][] = array( 'title' => 'DNS Wizard', + 'open' => 1, + 'items' => $items); unset($items); @@ -37,10 +37,10 @@ unset($items); */ -$items[] = array( 'title' => "Zones", - 'target' => 'content', - 'link' => 'dns/dns_soa_list.php', - 'html_id' => 'dns_soa_list'); +$items[] = array( 'title' => "Zones", + 'target' => 'content', + 'link' => 'dns/dns_soa_list.php', + 'html_id' => 'dns_soa_list'); /* $items[] = array( 'title' => "A-Records", 'target' => 'content', @@ -49,20 +49,20 @@ $items[] = array( 'title' => "A-Records", */ -$module["nav"][] = array( 'title' => 'DNS', - 'open' => 1, - 'items' => $items); +$module["nav"][] = array( 'title' => 'DNS', + 'open' => 1, + 'items' => $items); unset($items); -$items[] = array( 'title' => "Secondary Zones", - 'target' => 'content', - 'link' => 'dns/dns_slave_list.php', - 'html_id' => 'dns_slave_list'); +$items[] = array( 'title' => "Secondary Zones", + 'target' => 'content', + 'link' => 'dns/dns_slave_list.php', + 'html_id' => 'dns_slave_list'); -$module["nav"][] = array( 'title' => 'Secondary DNS', - 'open' => 1, - 'items' => $items); +$module["nav"][] = array( 'title' => 'Secondary DNS', + 'open' => 1, + 'items' => $items); unset($items); @@ -70,4 +70,4 @@ unset($items); -?> \ No newline at end of file +?> diff --git a/interface/web/dns/lib/remote.conf.php b/interface/web/dns/lib/remote.conf.php index e14b5b7f5..dcabf9485 100644 --- a/interface/web/dns/lib/remote.conf.php +++ b/interface/web/dns/lib/remote.conf.php @@ -13,4 +13,4 @@ $function_list['dns_rp_get,dns_rp_add,dns_rp_update,dns_rp_delete'] = 'DNS rp fu $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'; -?> \ No newline at end of file +?> diff --git a/interface/web/dns/list/dns_a.list.php b/interface/web/dns/list/dns_a.list.php index 75076d017..3b47cf10c 100644 --- a/interface/web/dns/list/dns_a.list.php +++ b/interface/web/dns/list/dns_a.list.php @@ -13,34 +13,34 @@ // Name of the list -$liste["name"] = "dns_a"; +$liste["name"] = "dns_a"; // Database table -$liste["table"] = "dns_rr"; +$liste["table"] = "dns_rr"; // Index index field of the database table -$liste["table_idx"] = "id"; +$liste["table_idx"] = "id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "dns_a_list.php"; +$liste["file"] = "dns_a_list.php"; // Script file of the edit form -$liste["edit_file"] = "dns_a_edit.php"; +$liste["edit_file"] = "dns_a_edit.php"; // Script File of the delete script -$liste["delete_file"] = "dns_a_del.php"; +$liste["delete_file"] = "dns_a_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** @@ -48,91 +48,91 @@ $liste["auth"] = "yes"; *****************************************************/ -$liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('Y' => "
    Yes
    ",'N' => "
    No
    ")); - - -$liste["item"][] = array( 'field' => "server_id", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "zone", - 'datatype' => "VARCHAR", - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT id,origin FROM dns_soa WHERE {AUTHSQL} ORDER BY origin', - 'keyfield'=> 'id', - 'valuefield'=> 'origin' - ), - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "data", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "aux", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "ttl", - 'datatype' => "INTEGER", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "type", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('A'=>'A','AAAA' => 'AAAA','ALIAS'=>'ALIAS','CNAME'=>'CNAME','HINFO'=>'HINFO','MX'=>'MX','NS'=>'NS','PTR'=>'PTR','RP'=>'RP','SRV'=>'SRV','TXT'=>'TXT')); - - -?> \ No newline at end of file +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('Y' => "
    Yes
    ", 'N' => "
    No
    ")); + + +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', + 'keyfield'=> 'server_id', + 'valuefield'=> 'server_name' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "zone", + 'datatype' => "VARCHAR", + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT id,origin FROM dns_soa WHERE {AUTHSQL} ORDER BY origin', + 'keyfield'=> 'id', + 'valuefield'=> 'origin' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "data", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "aux", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "ttl", + 'datatype' => "INTEGER", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "type", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('A'=>'A', 'AAAA' => 'AAAA', 'ALIAS'=>'ALIAS', 'CNAME'=>'CNAME', 'HINFO'=>'HINFO', 'MX'=>'MX', 'NS'=>'NS', 'PTR'=>'PTR', 'RP'=>'RP', 'SRV'=>'SRV', 'TXT'=>'TXT')); + + +?> diff --git a/interface/web/dns/list/dns_slave.list.php b/interface/web/dns/list/dns_slave.list.php index f00d33baf..5a242de14 100644 --- a/interface/web/dns/list/dns_slave.list.php +++ b/interface/web/dns/list/dns_slave.list.php @@ -13,34 +13,34 @@ // Name of the list -$liste["name"] = "dns_slave"; +$liste["name"] = "dns_slave"; // Database table -$liste["table"] = "dns_slave"; +$liste["table"] = "dns_slave"; // Index index field of the database table -$liste["table_idx"] = "id"; +$liste["table_idx"] = "id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "dns_slave_list.php"; +$liste["file"] = "dns_slave_list.php"; // Script file of the edit form -$liste["edit_file"] = "dns_slave_edit.php"; +$liste["edit_file"] = "dns_slave_edit.php"; // Script File of the delete script -$liste["delete_file"] = "dns_slave_del.php"; +$liste["delete_file"] = "dns_slave_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** @@ -49,51 +49,51 @@ $liste["auth"] = "yes"; $liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('Y' => "
    Yes
    ",'N' => "
    No
    ")); - - -$liste["item"][] = array( 'field' => "server_id", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'datasource'=> array ( 'type' => 'CUSTOM', - 'class' => 'custom_datasource', - 'function' => 'slave_dns_servers' - ), - 'width' => "", - 'value' => ""); - -$liste["item"][] = array( 'field' => "origin", - 'datatype' => "VARCHAR", - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - - -$liste["item"][] = array( 'field' => "ns", - 'datatype' => "VARCHAR", - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -?> \ No newline at end of file + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('Y' => "
    Yes
    ", 'N' => "
    No
    ")); + + +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'datasource'=> array ( 'type' => 'CUSTOM', + 'class' => 'custom_datasource', + 'function' => 'slave_dns_servers' + ), + 'width' => "", + 'value' => ""); + +$liste["item"][] = array( 'field' => "origin", + 'datatype' => "VARCHAR", + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + + +$liste["item"][] = array( 'field' => "ns", + 'datatype' => "VARCHAR", + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +?> diff --git a/interface/web/dns/list/dns_soa.list.php b/interface/web/dns/list/dns_soa.list.php index 46ec9c9b8..e3b240a7c 100644 --- a/interface/web/dns/list/dns_soa.list.php +++ b/interface/web/dns/list/dns_soa.list.php @@ -13,34 +13,34 @@ // Name of the list -$liste["name"] = "dns_soa"; +$liste["name"] = "dns_soa"; // Database table -$liste["table"] = "dns_soa"; +$liste["table"] = "dns_soa"; // Index index field of the database table -$liste["table_idx"] = "id"; +$liste["table_idx"] = "id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "dns_soa_list.php"; +$liste["file"] = "dns_soa_list.php"; // Script file of the edit form -$liste["edit_file"] = "dns_soa_edit.php"; +$liste["edit_file"] = "dns_soa_edit.php"; // Script File of the delete script -$liste["delete_file"] = "dns_soa_del.php"; +$liste["delete_file"] = "dns_soa_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** @@ -48,66 +48,66 @@ $liste["auth"] = "yes"; *****************************************************/ -$liste["item"][] = array( 'field' => "active", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('Y' => "
    Yes
    ",'N' => "
    No
    ")); +$liste["item"][] = array( 'field' => "active", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('Y' => "
    Yes
    ", 'N' => "
    No
    ")); -$liste["item"][] = array( 'field' => "server_id", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'datasource' => array ( 'type' => 'CUSTOM', - 'class'=> 'custom_datasource', - 'function'=> 'dns_servers' - ), - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "server_id", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'dns_servers' + ), + 'width' => "", + 'value' => ""); -$liste["item"][] = array( 'field' => "origin", - 'datatype' => "VARCHAR", - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "origin", + 'datatype' => "VARCHAR", + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); -$liste["item"][] = array( 'field' => "ns", - 'datatype' => "VARCHAR", - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "ns", + 'datatype' => "VARCHAR", + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); -$liste["item"][] = array( 'field' => "mbox", - 'datatype' => "VARCHAR", - 'filters' => array( 0 => array( 'event' => 'SHOW', - 'type' => 'IDNTOUTF8') - ), - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); +$liste["item"][] = array( 'field' => "mbox", + 'datatype' => "VARCHAR", + 'filters' => array( 0 => array( 'event' => 'SHOW', + 'type' => 'IDNTOUTF8') + ), + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); @@ -117,4 +117,4 @@ $liste["item"][] = array( 'field' => "mbox", -?> \ No newline at end of file +?> diff --git a/interface/web/dns/list/dns_template.list.php b/interface/web/dns/list/dns_template.list.php index 58055fbb4..63302d956 100644 --- a/interface/web/dns/list/dns_template.list.php +++ b/interface/web/dns/list/dns_template.list.php @@ -13,34 +13,34 @@ // Name of the list -$liste["name"] = "dns_template"; +$liste["name"] = "dns_template"; // Database table -$liste["table"] = "dns_template"; +$liste["table"] = "dns_template"; // Index index field of the database table -$liste["table_idx"] = "template_id"; +$liste["table_idx"] = "template_id"; // Search Field Prefix -$liste["search_prefix"] = "search_"; +$liste["search_prefix"] = "search_"; // Records per page -$liste["records_per_page"] = "15"; +$liste["records_per_page"] = "15"; // Script File of the list -$liste["file"] = "dns_template_list.php"; +$liste["file"] = "dns_template_list.php"; // Script file of the edit form -$liste["edit_file"] = "dns_template_edit.php"; +$liste["edit_file"] = "dns_template_edit.php"; // Script File of the delete script -$liste["delete_file"] = "dns_template_del.php"; +$liste["delete_file"] = "dns_template_del.php"; // Paging Template -$liste["paging_tpl"] = "templates/paging.tpl.htm"; +$liste["paging_tpl"] = "templates/paging.tpl.htm"; // Enable auth -$liste["auth"] = "yes"; +$liste["auth"] = "yes"; /***************************************************** @@ -49,22 +49,22 @@ $liste["auth"] = "yes"; $liste["item"][] = array( 'field' => "visible", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'width' => "", - 'value' => array('Y' => "
    Yes
    ",'N' => "
    No
    ")); - - -$liste["item"][] = array( 'field' => "name", - 'datatype' => "VARCHAR", - 'formtype' => "TEXT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", - 'width' => "", - 'value' => ""); - -?> \ No newline at end of file + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('Y' => "
    Yes
    ", 'N' => "
    No
    ")); + + +$liste["item"][] = array( 'field' => "name", + 'datatype' => "VARCHAR", + 'formtype' => "TEXT", + 'op' => "like", + 'prefix' => "%", + 'suffix' => "%", + 'width' => "", + 'value' => ""); + +?> diff --git a/interface/web/help/faq_delete.php b/interface/web/help/faq_delete.php index 2e501d493..e8f362727 100644 --- a/interface/web/help/faq_delete.php +++ b/interface/web/help/faq_delete.php @@ -5,11 +5,11 @@ $list_def_file = 'list/faq_manage_questions_list.php'; $tform_def_file = 'form/faq.tform.php'; // Include the base libraries -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; // Check module permissions -if(!stristr($_SESSION['s']['user']['modules'],'help')) { +if(!stristr($_SESSION['s']['user']['modules'], 'help')) { header('Location: ../index.php'); die; } diff --git a/interface/web/help/faq_edit.php b/interface/web/help/faq_edit.php index 028c5112c..629bde88c 100644 --- a/interface/web/help/faq_edit.php +++ b/interface/web/help/faq_edit.php @@ -4,11 +4,11 @@ $tform_def_file = 'form/faq.tform.php'; // include the core configuration and application classes -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; // Check the module permissions and redirect if not allowed. -if(!stristr($_SESSION['s']['user']['modules'],'help')) { +if(!stristr($_SESSION['s']['user']['modules'], 'help')) { header('Location: ../index.php'); die; } diff --git a/interface/web/help/faq_list.php b/interface/web/help/faq_list.php index 79e9b6f63..2f48b4df3 100644 --- a/interface/web/help/faq_list.php +++ b/interface/web/help/faq_list.php @@ -1,13 +1,13 @@ uses('listform_actions'); // Optional limit $hf_section = 0; if(isset($_GET['hfs_id'])) - $hf_section = preg_replace("/[^0-9]/","",$_GET['hfs_id']); + $hf_section = preg_replace("/[^0-9]/", "", $_GET['hfs_id']); // if section id is not specified in the url, choose the first existing section if(!$hf_section) diff --git a/interface/web/help/faq_manage_questions_list.php b/interface/web/help/faq_manage_questions_list.php index ad34619ab..e72824458 100644 --- a/interface/web/help/faq_manage_questions_list.php +++ b/interface/web/help/faq_manage_questions_list.php @@ -1,6 +1,6 @@ auth->check_module_permissions('help'); $app->uses('listform_actions'); //* Optional limit -#$app->listform_actions->SQLExtWhere = "recipient_id = ".$_SESSION['s']['user']['userid']; +//$app->listform_actions->SQLExtWhere = "recipient_id = ".$_SESSION['s']['user']['userid']; //* Start the form rendering and action ahndling $app->listform_actions->onLoad(); diff --git a/interface/web/help/faq_sections_delete.php b/interface/web/help/faq_sections_delete.php index 9a47e9b6f..adcacf437 100644 --- a/interface/web/help/faq_sections_delete.php +++ b/interface/web/help/faq_sections_delete.php @@ -5,11 +5,11 @@ $list_def_file = 'list/faq_sections_list.php'; $tform_def_file = 'form/faq_sections.tform.php'; // Include the base libraries -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; // Check module permissions -if(!stristr($_SESSION['s']['user']['modules'],'help')) { +if(!stristr($_SESSION['s']['user']['modules'], 'help')) { header('Location: ../index.php'); die; } diff --git a/interface/web/help/faq_sections_edit.php b/interface/web/help/faq_sections_edit.php index 73d02800b..32f012346 100644 --- a/interface/web/help/faq_sections_edit.php +++ b/interface/web/help/faq_sections_edit.php @@ -4,11 +4,11 @@ $tform_def_file = 'form/faq_sections.tform.php'; // include the core configuration and application classes -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; // Check the module permissions and redirect if not allowed. -if(!stristr($_SESSION['s']['user']['modules'],'help')) { +if(!stristr($_SESSION['s']['user']['modules'], 'help')) { header('Location: ../index.php'); die; } diff --git a/interface/web/help/faq_sections_list.php b/interface/web/help/faq_sections_list.php index e6f997957..4acb4ae20 100644 --- a/interface/web/help/faq_sections_list.php +++ b/interface/web/help/faq_sections_list.php @@ -1,13 +1,13 @@ 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 +// 0 = default groupid of the user, > 0 id must match with groupid of current $form['auth_preset']['groupid'] = 0; // Permissions with the following codes: 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'] = 'r'; +$form['auth_preset']['perm_other'] = 'r'; // The form definition of the first tab. The name of the tab is called 'message'. We refer // to this name in the $form['tab_default'] setting above. $form['tabs']['message'] = array( - 'title' => 'FAQ', // Title of the Tab - 'width' => 100, // Tab width - 'template' => 'templates/faq_edit.htm', // Template file name - 'fields' => array( - - //*** BEGIN Datatable columns ********************************** - - 'hf_section' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT hfs_id,hfs_name FROM help_faq_sections', - 'keyfield' => 'hfs_id', - 'valuefield' => 'hfs_name' - ), - 'validators' => array ( 0 => array ( - 'type' => 'ISINT', - 'errmsg'=> 'recipient_id_is_not_integer'), - ), - 'value' => ($_SESSION['s']['user']['typ'] != 'admin')?array(1 => 'Administrator'):'' + 'title' => 'FAQ', // Title of the Tab + 'width' => 100, // Tab width + 'template' => 'templates/faq_edit.htm', // Template file name + 'fields' => array( + + //*** BEGIN Datatable columns ********************************** + + 'hf_section' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT hfs_id,hfs_name FROM help_faq_sections', + 'keyfield' => 'hfs_id', + 'valuefield' => 'hfs_name' + ), + 'validators' => array ( 0 => array ( + 'type' => 'ISINT', + 'errmsg'=> 'recipient_id_is_not_integer'), + ), + 'value' => ($_SESSION['s']['user']['typ'] != 'admin')?array(1 => 'Administrator'):'' ), - 'hf_question' => array( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array( 0 => array( 'type' => 'NOTEMPTY', - 'errmsg'=> 'subject_is_empty' - ), + 'hf_question' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array( 0 => array( 'type' => 'NOTEMPTY', + 'errmsg'=> 'subject_is_empty' + ), ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' - ), - - 'hf_answer' => array( - 'datatype' => 'TEXT', - 'formtype' => 'TEXTAREA', - 'validators' => array( 0 => array( 'type' => 'NOTEMPTY', - 'errmsg' => 'message_is_empty' - ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + + 'hf_answer' => array( + 'datatype' => 'TEXT', + 'formtype' => 'TEXTAREA', + 'validators' => array( 0 => array( 'type' => 'NOTEMPTY', + 'errmsg' => 'message_is_empty' ), - 'default' => '', - 'value' => '', - 'cols' => '30', - 'rows' => '10', - 'maxlength' => '255' - ), - - //*** END Datatable columns ********************************** + ), + 'default' => '', + 'value' => '', + 'cols' => '30', + 'rows' => '10', + 'maxlength' => '255' + ), + + //*** END Datatable columns ********************************** ) ); ?> diff --git a/interface/web/help/form/faq_sections.tform.php b/interface/web/help/form/faq_sections.tform.php index d849f27e8..1a1076876 100644 --- a/interface/web/help/form/faq_sections.tform.php +++ b/interface/web/help/form/faq_sections.tform.php @@ -1,72 +1,72 @@ 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 +// 0 = default groupid of the user, > 0 id must match with groupid of current $form['auth_preset']['groupid'] = 0; // Permissions with the following codes: 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'] = ''; +$form['auth_preset']['perm_other'] = ''; // The form definition of the first tab. The name of the tab is called 'message'. We refer // to this name in the $form['tab_default'] setting above. $form['tabs']['message'] = array( - 'title' => 'FAQ', // Title of the Tab - 'width' => 100, // Tab width - 'template' => 'templates/faq_sections_edit.htm', // Template file name - 'fields' => array( - - //*** BEGIN Datatable columns ********************************** - - 'hfs_name' => array( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators'=> array( 0 => array( 'type' => 'NOTEMPTY', - 'errmsg'=> 'subject_is_empty' - ), - ), - 'default' => '', - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'title' => 'FAQ', // Title of the Tab + 'width' => 100, // Tab width + 'template' => 'templates/faq_sections_edit.htm', // Template file name + 'fields' => array( + + //*** BEGIN Datatable columns ********************************** + + 'hfs_name' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators'=> array( 0 => array( 'type' => 'NOTEMPTY', + 'errmsg'=> 'subject_is_empty' + ), + ), + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), //*** END Datatable columns ********************************* ) diff --git a/interface/web/help/form/support_message.tform.php b/interface/web/help/form/support_message.tform.php index a8c0847a7..d982712c6 100644 --- a/interface/web/help/form/support_message.tform.php +++ b/interface/web/help/form/support_message.tform.php @@ -1,36 +1,36 @@ 0 id must match with id of current user @@ -45,12 +45,12 @@ $sm_default_recipient_id = ''; $sm_default_subject = ''; if(isset($_GET['reply'])) { - $sm_msg_id = preg_replace("/[^0-9]/","",$_GET['reply']); + $sm_msg_id = preg_replace("/[^0-9]/", "", $_GET['reply']); $res = $app->db->queryOneRecord("SELECT sender_id, subject FROM support_message WHERE support_message_id=$sm_msg_id"); if($res['sender_id']) { - $sm_default_recipient_id = $res['sender_id']; - $sm_default_subject = (preg_match("/^Re:/",$res['subject'])?"":"Re: ") . $res['subject']; + $sm_default_recipient_id = $res['sender_id']; + $sm_default_subject = (preg_match("/^Re:/", $res['subject'])?"":"Re: ") . $res['subject']; } } @@ -59,75 +59,75 @@ $authsql = $app->tform->getAuthSQL('r', 'client'); //* Begin of the form definition of the first tab. The name of the tab is called "message". We refer //* to this name in the $form["tab_default"] setting above. $form["tabs"]['message'] = array ( - 'title' => "Message", // Title of the Tab - 'width' => 100, // Tab width - 'template' => "templates/support_message_edit.htm", // Template file name - 'fields' => array ( - ################################## - # Begin Datatable fields - ################################## + 'title' => "Message", // Title of the Tab + 'width' => 100, // Tab width + 'template' => "templates/support_message_edit.htm", // Template file name + 'fields' => array ( + //################################# + // Begin Datatable fields + //################################# 'recipient_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => $sm_default_recipient_id, - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => "SELECT sys_user.userid, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_user, client WHERE sys_user.userid != 1 AND sys_user.client_id = client.client_id AND $authsql ORDER BY sys_user.username", - 'keyfield' => 'userid', - 'valuefield' => 'contactname' - ), - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'recipient_id_is_not_integer'), - ), - 'value' => ($_SESSION['s']['user']['typ'] != 'admin')?array(1 => 'Administrator'):'' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => $sm_default_recipient_id, + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT sys_user.userid, CONCAT(IF(client.company_name != '', CONCAT(client.company_name, ' :: '), ''), client.contact_name, ' (', client.username, IF(client.customer_no != '', CONCAT(', ', client.customer_no), ''), ')') as contactname FROM sys_user, client WHERE sys_user.userid != 1 AND sys_user.client_id = client.client_id AND $authsql ORDER BY sys_user.username", + 'keyfield' => 'userid', + 'valuefield' => 'contactname' + ), + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'recipient_id_is_not_integer'), + ), + 'value' => ($_SESSION['s']['user']['typ'] != 'admin')?array(1 => 'Administrator'):'' ), 'sender_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT userid,username FROM sys_user WHERE {AUTHSQL} ORDER BY username', - 'keyfield' => 'userid', - 'valuefield' => 'username' - ), - 'validators' => array ( 0 => array ( 'type' => 'ISINT', - 'errmsg'=> 'recipient_id_is_not_integer'), - ), - 'value' => '' + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT userid,username FROM sys_user WHERE {AUTHSQL} ORDER BY username', + 'keyfield' => 'userid', + 'valuefield' => 'username' + ), + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'recipient_id_is_not_integer'), + ), + 'value' => '' ), 'subject' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'subject_is_empty'), - ), - 'default' => $sm_default_subject, - 'value' => '', - 'width' => '30', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'subject_is_empty'), + ), + 'default' => $sm_default_subject, + 'value' => '', + 'width' => '30', + 'maxlength' => '255' ), 'message' => array ( - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXTAREA', - 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', - 'errmsg'=> 'message_is_empty'), - ), - 'default' => '', - 'value' => '', - 'cols' => '30', - 'rows' => '10', - 'maxlength' => '255' + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXTAREA', + 'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY', + 'errmsg'=> 'message_is_empty'), + ), + 'default' => '', + 'value' => '', + 'cols' => '30', + 'rows' => '10', + 'maxlength' => '255' ), 'tstamp' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'TEXT', - 'default' => time(), - 'value' => '', - 'width' => '30', - 'maxlength' => '30' + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'default' => time(), + 'value' => '', + 'width' => '30', + 'maxlength' => '30' ), - ################################## - # ENDE Datatable fields - ################################## + //################################# + // ENDE Datatable fields + //################################# ) ); diff --git a/interface/web/help/index.php b/interface/web/help/index.php index 93204bc52..5aa5f9cf6 100644 --- a/interface/web/help/index.php +++ b/interface/web/help/index.php @@ -13,4 +13,4 @@

     

    - \ No newline at end of file + diff --git a/interface/web/help/lib/admin.conf.php b/interface/web/help/lib/admin.conf.php index b0163e53c..62616b101 100644 --- a/interface/web/help/lib/admin.conf.php +++ b/interface/web/help/lib/admin.conf.php @@ -5,4 +5,4 @@ */ -?> \ No newline at end of file +?> diff --git a/interface/web/help/lib/module.conf.php b/interface/web/help/lib/module.conf.php index 0761a4cbf..bee099d1b 100644 --- a/interface/web/help/lib/module.conf.php +++ b/interface/web/help/lib/module.conf.php @@ -31,52 +31,52 @@ $items = array(); //* Add a menu item with the label 'Send message' $items[] = array( 'title' => 'Send message', - 'target' => 'content', - 'link' => 'help/support_message_edit.php', - 'html_id' => 'help_message_send'); + 'target' => 'content', + 'link' => 'help/support_message_edit.php', + 'html_id' => 'help_message_send'); //* Add a menu item with the label 'View messages' $items[] = array( 'title' => 'View messages', - 'target' => 'content', - 'link' => 'help/support_message_list.php', - 'html_id' => 'help_message_list'); + 'target' => 'content', + 'link' => 'help/support_message_list.php', + 'html_id' => 'help_message_list'); //* Add the menu items defined above to a menu section labeled 'Support' $module['nav'][] = array( 'title' => 'Support', - 'open' => 1, - 'items' => $items); + 'open' => 1, + 'items' => $items); //* the FAQ menu section $itemsfaq = array(); //* admin's tools if($_SESSION['s']['user']['typ'] == 'admin') { - $itemsfaq[] = array( 'title' => 'Manage Sections', - 'target' => 'content', - 'link' => 'help/faq_sections_list.php'); - $itemsfaq[] = array( 'title' => 'Manage Questions', - 'target' => 'content', - 'link' => 'help/faq_manage_questions_list.php'); - - $module['nav'][] = array( 'title' => 'FAQ', - 'open' => 1, - 'items' => $itemsfaq); + $itemsfaq[] = array( 'title' => 'Manage Sections', + 'target' => 'content', + 'link' => 'help/faq_sections_list.php'); + $itemsfaq[] = array( 'title' => 'Manage Questions', + 'target' => 'content', + 'link' => 'help/faq_manage_questions_list.php'); + + $module['nav'][] = array( 'title' => 'FAQ', + 'open' => 1, + 'items' => $itemsfaq); } else -{ //* the user + { //* the user $sql = "SELECT * FROM help_faq_sections"; $res = $app->db->queryAllRecords($sql); //* all the content sections if(is_array($res) && !empty($res)) { foreach($res as $v) { - $itemsfaq[] = array( 'title' => $v['hfs_name'], - 'target' => 'content', - 'link' => 'help/faq_list.php?hfs_id='.$v['hfs_id']); + $itemsfaq[] = array( 'title' => $v['hfs_name'], + 'target' => 'content', + 'link' => 'help/faq_list.php?hfs_id='.$v['hfs_id']); } // Display 'FAQ' menu only if there are sections - $module['nav'][] = array( 'title' => 'FAQ', - 'open' => 1, - 'items' => $itemsfaq); + $module['nav'][] = array( 'title' => 'FAQ', + 'open' => 1, + 'items' => $itemsfaq); } } //* -- end of the FAQ menu section @@ -84,23 +84,23 @@ else if($_SESSION['s']['user']['typ'] == 'admin') { -//* make sure that the items array is empty -$items = array(); + //* make sure that the items array is empty + $items = array(); -//* Add a menu item with the label 'Version' -$items[] = array( 'title' => 'Version', - 'target' => 'content', - 'link' => 'help/version.php', - 'html_id' => 'help_version' ); + //* Add a menu item with the label 'Version' + $items[] = array( 'title' => 'Version', + 'target' => 'content', + 'link' => 'help/version.php', + 'html_id' => 'help_version' ); -//* Add the menu items defined above to a menu section labeled 'Support' -$module['nav'][] = array( 'title' => 'About ISPConfig', - 'open' => 1, - 'items' => $items); + //* Add the menu items defined above to a menu section labeled 'Support' + $module['nav'][] = array( 'title' => 'About ISPConfig', + 'open' => 1, + 'items' => $items); } -?> \ No newline at end of file +?> diff --git a/interface/web/help/list/faq_list.php b/interface/web/help/list/faq_list.php index 0893e90ce..1f7e2bce8 100644 --- a/interface/web/help/list/faq_list.php +++ b/interface/web/help/list/faq_list.php @@ -10,7 +10,7 @@ $liste['table'] = 'help_faq'; $liste['table_idx'] = 'hf_id'; // Search Field Prefix -#$liste['search_prefix'] = 'search_'; +//$liste['search_prefix'] = 'search_'; // Records per page $liste['records_per_page']= 100; diff --git a/interface/web/help/list/faq_manage_questions_list.php b/interface/web/help/list/faq_manage_questions_list.php index 6bff574ef..aac10fa20 100644 --- a/interface/web/help/list/faq_manage_questions_list.php +++ b/interface/web/help/list/faq_manage_questions_list.php @@ -10,7 +10,7 @@ $liste['table'] = 'help_faq'; $liste['table_idx'] = 'hf_id'; // Search Field Prefix -#$liste['search_prefix'] = 'search_'; +//$liste['search_prefix'] = 'search_'; // Records per page $liste['records_per_page']= 30; @@ -32,16 +32,16 @@ $liste['auth'] = 'yes'; $liste["item"][] = array( 'field' => "hf_section", - 'datatype' => "VARCHAR", - 'formtype' => "SELECT", - 'op' => "=", - 'prefix' => "", - 'suffix' => "", - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT a.hf_section, b.hfs_name FROM help_faq a, help_faq_sections b WHERE (a.hf_section = b.hfs_id)', - 'keyfield'=> 'hf_section', - 'valuefield'=> 'hfs_name' - ), - 'width' => "", - 'value' => ""); + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => 'SELECT a.hf_section, b.hfs_name FROM help_faq a, help_faq_sections b WHERE (a.hf_section = b.hfs_id)', + 'keyfield'=> 'hf_section', + 'valuefield'=> 'hfs_name' + ), + 'width' => "", + 'value' => ""); ?> diff --git a/interface/web/help/list/faq_sections_list.php b/interface/web/help/list/faq_sections_list.php index 59e30e756..cfe391516 100644 --- a/interface/web/help/list/faq_sections_list.php +++ b/interface/web/help/list/faq_sections_list.php @@ -10,7 +10,7 @@ $liste['table'] = 'help_faq_sections'; $liste['table_idx'] = 'hfs_id'; // Search Field Prefix -#$liste['search_prefix'] = 'search_'; +//$liste['search_prefix'] = 'search_'; // Records per page $liste['records_per_page'] = 100; diff --git a/interface/web/help/list/support_message.list.php b/interface/web/help/list/support_message.list.php index 14749595f..1724c5489 100644 --- a/interface/web/help/list/support_message.list.php +++ b/interface/web/help/list/support_message.list.php @@ -1,71 +1,71 @@ 'sender_id', - 'datatype' => 'VARCHAR', - 'formtype' => 'SELECT', - 'op' => '=', - 'prefix' => '', - 'suffix' => '', - 'width' => '', - 'datasource'=> array ( 'type' => 'SQL', - 'querystring' => 'SELECT userid,username FROM sys_user WHERE {AUTHSQL} ORDER BY username', - 'keyfield' => 'userid', - 'valuefield' => 'username' - ), - 'value' => ''); - -$liste['item'][] = array( 'field' => 'subject', - 'datatype' => 'VARCHAR', - 'formtype' => 'TEXT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', - 'width' => '', - 'value' => ''); - -$liste['item'][] = array( 'field' => 'tstamp', - 'datatype' => 'DATETIMETSTAMP', - 'formtype' => 'TEXT', - 'op' => '=', - 'prefix' => '', - 'suffix' => '', - 'width' => '', - 'value' => ''); - - -?> \ No newline at end of file +$liste['item'][] = array( 'field' => 'sender_id', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', + 'width' => '', + 'datasource'=> array ( 'type' => 'SQL', + 'querystring' => 'SELECT userid,username FROM sys_user WHERE {AUTHSQL} ORDER BY username', + 'keyfield' => 'userid', + 'valuefield' => 'username' + ), + 'value' => ''); + +$liste['item'][] = array( 'field' => 'subject', + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => ''); + +$liste['item'][] = array( 'field' => 'tstamp', + 'datatype' => 'DATETIMETSTAMP', + 'formtype' => 'TEXT', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', + 'width' => '', + 'value' => ''); + + +?> diff --git a/interface/web/help/support_message_del.php b/interface/web/help/support_message_del.php index 63c23a0aa..6b66d8ef4 100644 --- a/interface/web/help/support_message_del.php +++ b/interface/web/help/support_message_del.php @@ -35,8 +35,8 @@ $list_def_file = 'list/support_message.list.php'; $tform_def_file = 'form/support_message.tform.php'; //* Include the base libraries -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('help'); @@ -45,4 +45,4 @@ $app->auth->check_module_permissions('help'); $app->uses('tform_actions'); $app->tform_actions->onDelete(); -?> \ No newline at end of file +?> diff --git a/interface/web/help/support_message_edit.php b/interface/web/help/support_message_edit.php index b1cbf2a83..a3b6fa5a7 100644 --- a/interface/web/help/support_message_edit.php +++ b/interface/web/help/support_message_edit.php @@ -4,8 +4,8 @@ $tform_def_file = 'form/support_message.tform.php'; //* include the basic application and configuration files -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('help'); @@ -19,18 +19,18 @@ class page_action extends tform_actions { //* Custom onSubmit Event handler function onSubmit() - { + { global $app, $conf; - + //* If the current user is not the admin user if($_SESSION['s']['user']['typ'] != 'admin') { //* Set the admin as recipient $this->dataRecord['recipient_id'] = 1; } - + //* Set the sender_id field to the ID of the current user $this->dataRecord['sender_id'] = $_SESSION['s']['user']['userid']; - + //* Get recipient email address if($this->dataRecord['recipient_id'] > 1){ $sql = "SELECT client.email FROM sys_user, client WHERE sys_user.userid = ".$this->dataRecord['recipient_id']." AND sys_user.client_id = client.client_id"; @@ -41,7 +41,7 @@ class page_action extends tform_actions { $system_config_mail_settings = $app->getconf->get_global_config('mail'); $recipient_email = $system_config_mail_settings['admin_mail']; } - + //* Get sender email address if($this->dataRecord['sender_id'] > 1){ $sql = "SELECT client.email FROM sys_user, client WHERE sys_user.userid = ".$this->dataRecord['sender_id']." AND sys_user.client_id = client.client_id"; @@ -52,7 +52,7 @@ class page_action extends tform_actions { $system_config_mail_settings = $app->getconf->get_global_config('mail'); $sender_email = $system_config_mail_settings['admin_mail']; } - + $email_regex = '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\.[a-z\-]{2,10}){0,1}$/i'; if(preg_match($email_regex, $sender_email, $match) && preg_match($email_regex, $recipient_email, $match)){ $subject = $app->tform->lng('support_request_subject_txt').': '.$this->dataRecord['subject']; @@ -64,7 +64,7 @@ class page_action extends tform_actions { $message .= "\n\n".$app->tform->lng('message_txt').": \"".$this->dataRecord['message']."\""; $message .= "\n\nISPConfig: ".($_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://').$_SERVER['HTTP_HOST']; $app->functions->mail($recipient_email, $subject, $message, $sender_email); - + //* Send confirmation email to sender if($this->dataRecord['sender_id'] == 1){ $confirmation_message = $app->tform->lng('answer_to_support_request_sent_txt'); @@ -77,47 +77,47 @@ class page_action extends tform_actions { } else { $app->tform->errorMessage .= $app->tform->lng("recipient_or_sender_email_address_not_valid_txt")."
    "; } - + //* call the onSubmit function of the parent class parent::onSubmit(); } - + //* Custom onShow Event handler - function onShow() - { + function onShow() + { global $app, $conf; - //* We do not want that messages get edited, so we switch to a + //* We do not want that messages get edited, so we switch to a //* read only template if a existing message is loaded if($this->id > 0) { $app->tform->formDef['tabs']['message']['template'] = 'templates/support_message_view.htm'; $record = $app->db->queryOneRecord("SELECT * FROM support_message WHERE support_message_id = ".$this->id); if ($record['tstamp'] > 0) { - // is value int? - if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record['tstamp'], $p)) { - $record['tstamp'] = date($app->lng('conf_format_datetime'), $record['tstamp']); - } else { - $record['tstamp'] = date($app->lng('conf_format_datetime'), strtotime($record['tstamp'])); - } - } + // is value int? + if (preg_match("/^[0-9]+[\.]?[0-9]*$/", $record['tstamp'], $p)) { + $record['tstamp'] = date($app->lng('conf_format_datetime'), $record['tstamp']); + } else { + $record['tstamp'] = date($app->lng('conf_format_datetime'), strtotime($record['tstamp'])); + } + } $app->tpl->setVar("date", $record['tstamp']); //die(print_r($this->dataRecord)); } - + //* call the onShow function of the parent class parent::onShow(); } - - function onAfterInsert() - { + + function onAfterInsert() + { global $app, $conf; - + if($_SESSION['s']['user']['typ'] == 'admin') { $app->db->query("UPDATE support_message SET sys_userid = ".$this->dataRecord['recipient_id']." WHERE support_message_id = ".$this->id); } - + } - + } //* Create the new page object @@ -126,4 +126,4 @@ $page = new page_action(); //* Start the page rendering and action handling $page->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/help/support_message_list.php b/interface/web/help/support_message_list.php index b2ac8c095..42db17de4 100644 --- a/interface/web/help/support_message_list.php +++ b/interface/web/help/support_message_list.php @@ -1,6 +1,6 @@ listform_actions->SQLExtWhere = "support_message.recipient_id = ".$_SESSIO //* Start the form rendering and action ahndling $app->listform_actions->onLoad(); -?> \ No newline at end of file +?> diff --git a/interface/web/help/version.php b/interface/web/help/version.php index dc0577e4a..4110c96ad 100644 --- a/interface/web/help/version.php +++ b/interface/web/help/version.php @@ -39,8 +39,8 @@ $tform_def_file = "form/user_settings.tform.php"; * End Form configuration ******************************************/ -require_once('../../lib/config.inc.php'); -require_once('../../lib/app.inc.php'); +require_once '../../lib/config.inc.php'; +require_once '../../lib/app.inc.php'; //* Check permissions for module $app->auth->check_module_permissions('help'); @@ -49,4 +49,4 @@ if($_SESSION['s']['user']['typ'] == 'admin') { echo '

     

     

    '.$app->lng('ISPConfig Version:').' '.ISPC_APP_VERSION.'

    '; } -?> \ No newline at end of file +?> diff --git a/interface/web/index.php b/interface/web/index.php index c0005bc56..8b448419a 100644 --- a/interface/web/index.php +++ b/interface/web/index.php @@ -28,8 +28,8 @@ 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'); +require_once '../lib/config.inc.php'; +require_once '../lib/app.inc.php'; if(!isset($_SESSION['s']['module']['name'])) $_SESSION['s']['module']['name'] = 'login'; @@ -41,37 +41,37 @@ $app->tpl->newTemplate('main.tpl.htm'); $app->uses('getconf'); $sys_config = $app->getconf->get_global_config('misc'); if($sys_config['tab_change_warning'] == 'y') { - $app->tpl->setVar('tabchange_warning_enabled', 'y'); - $app->tpl->setVar('global_tabchange_warning_txt', $app->lng('global_tabchange_warning_txt')); + $app->tpl->setVar('tabchange_warning_enabled', 'y'); + $app->tpl->setVar('global_tabchange_warning_txt', $app->lng('global_tabchange_warning_txt')); } else { - $app->tpl->setVar('tabchange_warning_enabled', 'n'); + $app->tpl->setVar('tabchange_warning_enabled', 'n'); } $app->tpl->setVar('tabchange_discard_enabled', $sys_config['tab_change_discard']); if($sys_config['tab_change_discard'] == 'y') { - $app->tpl->setVar('global_tabchange_discard_txt', $app->lng('global_tabchange_discard_txt')); + $app->tpl->setVar('global_tabchange_discard_txt', $app->lng('global_tabchange_discard_txt')); } if(isset($_SESSION['show_info_msg'])) { - $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); - unset($_SESSION['show_info_msg']); + $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); + unset($_SESSION['show_info_msg']); } if(isset($_SESSION['show_error_msg'])) { - $app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']); - unset($_SESSION['show_error_msg']); + $app->tpl->setVar('show_error_msg', $_SESSION['show_error_msg']); + unset($_SESSION['show_error_msg']); } // read js.d files $js_d = ISPC_WEB_PATH . '/js/js.d'; $js_d_files = array(); if(@is_dir($js_d)) { - $dir = opendir($js_d); - while($file = readdir($dir)) { - $filename = $js_d . '/' . $file; - if($file === '.' || $file === '..' || !is_file($filename)) continue; - if(substr($file, -3) !== '.js') continue; - $js_d_files[] = array('file' => $file); - } - closedir($dir); + $dir = opendir($js_d); + while($file = readdir($dir)) { + $filename = $js_d . '/' . $file; + if($file === '.' || $file === '..' || !is_file($filename)) continue; + if(substr($file, -3) !== '.js') continue; + $js_d_files[] = array('file' => $file); + } + closedir($dir); } $app->tpl->setLoop('js_d_includes', $js_d_files); @@ -79,4 +79,4 @@ unset($js_d_files); $app->tpl_defaults(); $app->tpl->pparse(); -?> \ No newline at end of file +?> diff --git a/interface/web/js/scrigo.js.php b/interface/web/js/scrigo.js.php index 33be65e01..3927b80f3 100644 --- a/interface/web/js/scrigo.js.php +++ b/interface/web/js/scrigo.js.php @@ -1,13 +1,13 @@ uses('ini_parser,getconf'); - $server_config_array = $app->getconf->get_global_config(); +session_start(); +include '../../lib/config.inc.php'; +header('Content-Type: text/javascript; charset=utf-8'); // the config file sets the content type header so we have to override it here! +require_once '../../lib/app.inc.php'; +$lang = (isset($_SESSION['s']['language']) && $_SESSION['s']['language'] != '')?$_SESSION['s']['language']:'en'; +include_once ISPC_ROOT_PATH.'/web/strengthmeter/lib/lang/'.$lang.'_strengthmeter.lng'; + +$app->uses('ini_parser,getconf'); +$server_config_array = $app->getconf->get_global_config(); ?> var pageFormChanged = false; var tabChangeWarningTxt = ''; @@ -22,10 +22,10 @@ var registeredHooks = new Array(); redirect = ''; function reportError(request) { - /* Error reporting is disabled by default as some browsers like safari - sometimes throw errors when a ajax request is delayed even if the + /* Error reporting is disabled by default as some browsers like safari + sometimes throw errors when a ajax request is delayed even if the ajax request worked. */ - + /*alert(request);*/ } @@ -54,7 +54,7 @@ function showLoadIndicator() { if($server_config_array['misc']['use_loadindicator'] == 'y'){ ?> requestsRunning += 1; - + if(requestsRunning < 2) { var indicator = jQuery('#ajaxloader'); if(indicator.length < 1) { @@ -64,7 +64,7 @@ if($server_config_array['misc']['use_loadindicator'] == 'y'){ var parent = jQuery('#content'); if(parent.length < 1) return; indicatorCompleted = false; - + var atx = parent.offset().left + 150; //((parent.outerWidth(true) - indicator.outerWidth(true)) / 2); var aty = parent.offset().top + 150; indicator.css( {'left': atx, 'top': aty } ).fadeIn('fast', function() { @@ -102,9 +102,9 @@ if($server_config_array['misc']['use_combobox'] == 'y'){ } function loadContentRefresh(pagename) { - + if(document.getElementById('refreshinterval').value > 0) { - var pageContentObject2 = jQuery.ajax({ type: "GET", + var pageContentObject2 = jQuery.ajax({ type: "GET", url: pagename, data: "refresh="+document.getElementById('refreshinterval').value, dataType: "html", @@ -127,8 +127,8 @@ function loadContentRefresh(pagename) { } function capp(module, redirect) { - var submitFormObj = jQuery.ajax({ type: "GET", - url: "capp.php", + var submitFormObj = jQuery.ajax({ type: "GET", + url: "capp.php", data: "mod="+module+((redirect != undefined) ? '&redirect='+redirect : ''), dataType: "html", beforeSend: function() { @@ -169,12 +169,12 @@ function submitLoginForm(formname) { passwordObj.focus(); return; } - + $('#dummy_username').val(userNameObj.value); $('#dummy_passwort').val(passwordObj.value); $('#dummy_login_form').submit(); - var submitFormObj = jQuery.ajax({ type: "POST", + var submitFormObj = jQuery.ajax({ type: "POST", url: "content.php", data: jQuery('#'+formname).serialize(), dataType: "html", @@ -211,11 +211,11 @@ function submitLoginForm(formname) { } document.getElementById('footer').innerHTML = 'Powered by ISPConfig'; */ - + } function submitForm(formname,target) { - var submitFormObj = jQuery.ajax({ type: "POST", + var submitFormObj = jQuery.ajax({ type: "POST", url: target, data: jQuery('#'+formname).serialize(), dataType: "html", @@ -253,7 +253,7 @@ function submitForm(formname,target) { function submitFormConfirm(formname,target,confirmation) { var successMessage = arguments[3]; if(window.confirm(confirmation)) { - var submitFormObj = jQuery.ajax({ type: "POST", + var submitFormObj = jQuery.ajax({ type: "POST", url: target, data: jQuery('#'+formname).serialize(), dataType: "html", @@ -284,10 +284,10 @@ function submitFormConfirm(formname,target,confirmation) { } } -function submitUploadForm(formname,target) { +function submitUploadForm(formname,target) { var handleResponse = function(loadedFrame) { var response, responseStr = loadedFrame.contentWindow.document.body.innerHTML; - + try { response = JSON.parse(responseStr); } catch(e) { @@ -303,9 +303,9 @@ function submitUploadForm(formname,target) { msg = msg+'
    '+errormsg+'
    '; } return msg; - + }; - + var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000); jQuery('body').after('