diff --git a/helper_scripts/recreate_webalizer_stats.php b/helper_scripts/recreate_webalizer_stats.php index fbaef38097d01009ac947755644fbf20f17803c0..5afcd9759a858aa6dccce93069a421c2be1c26e5 100644 --- a/helper_scripts/recreate_webalizer_stats.php +++ b/helper_scripts/recreate_webalizer_stats.php @@ -5,8 +5,8 @@ //###################################################################################################### -$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ".$conf["server_id"]; -$records = $app->db->queryAllRecords($sql); +$sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = ?"; +$records = $app->db->queryAllRecords($sql, $conf["server_id"]); foreach($records as $rec) { $domain = escapeshellcmd($rec["domain"]); $logdir = escapeshellcmd($rec["document_root"].'/log'); diff --git a/install/apps/metronome-init b/install/apps/metronome-init new file mode 100644 index 0000000000000000000000000000000000000000..78ba7ea14accccbc866cf1294c88f68f0821e8fc --- /dev/null +++ b/install/apps/metronome-init @@ -0,0 +1,75 @@ +#! /bin/sh +# +# metronome Start/stop metronome server +# + +### BEGIN INIT INFO +# Provides: metronome +# Required-Start: $remote_fs $network $named $time +# Required-Stop: $remote_fs $network $named $time +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts metronome server +# Description: Starts metronome server, an XMPP server written in Lua. +### END INIT INFO + +METRONOME=/usr/bin/metronomectl +PIDDIR=/var/run/metronome +NAME=metronome + +test -e $METRONOME || exit 0 + +start() +{ + mkdir $PIDDIR -p + chown metronome:metronome $PIDDIR + chmod 750 $PIDDIR + + $METRONOME start >> /dev/null +} + +stop() +{ + $METRONOME stop >> /dev/null +} + +reload() +{ + &METRONOME reload >> /dev/null +} + +restart() +{ + &METRONOME restart >> /dev/null +} + +case "$1" in + start) + echo -n "Starting Metronome..." + start & + ;; + stop) + echo -n "Stopping Metronome..." + stop & + ;; + reload) + echo -n "Reloading Metronome config..." + reload & + ;; + restart) + echo -n "Restarting Metronome..." + restart & + ;; + *) + echo "Usage: $0 {start|stop|reload|restart}" >&2 + exit 1 + ;; +esac + +if [ $? -eq 0 ]; then + echo . +else + echo " failed!" +fi + +exit 0 diff --git a/install/apps/metronome_libs/mod_auth_external/authenticate_isp.sh b/install/apps/metronome_libs/mod_auth_external/authenticate_isp.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5a0c8e6846b85087bcc6f3f1ba3ae764f1a7a3c --- /dev/null +++ b/install/apps/metronome_libs/mod_auth_external/authenticate_isp.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +IFS=":" +AUTH_OK=1 +AUTH_FAILED=0 +LOGFILE="/var/log/metronome/auth.log" +USELOG=true + +while read ACTION USER HOST PASS ; do + + [ $USELOG == true ] && { echo "Date: $(date) Action: $ACTION User: $USER Host: $HOST" >> $LOGFILE; } + + case $ACTION in + "auth") + if [ `/usr/bin/php /usr/lib/metronome/isp-modules/mod_auth_external/db_auth.php $USER $HOST $PASS 2>/dev/null` == 1 ] ; then + echo $AUTH_OK + [ $USELOG == true ] && { echo "AUTH OK" >> $LOGFILE; } + else + echo $AUTH_FAILED + [ $USELOG == true ] && { echo "AUTH FAILED" >> $LOGFILE; } + fi + ;; + "isuser") + if [ `/usr/bin/php /usr/lib/metronome/isp-modules/mod_auth_external/db_isuser.php $USER $HOST 2>/dev/null` == 1 ] ; then + echo $AUTH_OK + [ $USELOG == true ] && { echo "ISUSER OK" >> $LOGFILE; } + else + echo $AUTH_FAILED + [ $USELOG == true ] && { echo "ISUSER FAILED" >> $LOGFILE; } + fi + ;; + *) + echo $AUTH_FAILED + [ $USELOG == true ] && { echo "UNKNOWN ACTION GIVEN: $ACTION" >> $LOGFILE; } + ;; + esac + +done diff --git a/install/apps/metronome_libs/mod_auth_external/db_auth.php b/install/apps/metronome_libs/mod_auth_external/db_auth.php new file mode 100644 index 0000000000000000000000000000000000000000..3df135bc12a95c6773c5a8033f8b8117a3759981 --- /dev/null +++ b/install/apps/metronome_libs/mod_auth_external/db_auth.php @@ -0,0 +1,58 @@ +real_escape_string($arg_email); + $result = $db->query("SELECT jid, password FROM xmpp_user WHERE jid LIKE ? AND active='y' AND server_id=?", $dbmail, $isp_server_id); + result_false($result->num_rows != 1); + + $user = $result->fetch_object(); + + // check for domain autologin api key + $domain_key = 'f47kmm5Yh5hJzSws2KTS'; + + checkAuth($argv[1], $argv[2], $arg_password, $user->password, $domain_key); +}catch(Exception $ex){ + echo 0; + exit(); +} + +function result_false($cond = true){ + if(!$cond) return; + echo 0; + exit(); +} +function result_true(){ + echo 1; + exit(); +} +function checkAuth($user, $domain, $pw_arg, $pw_db, $domain_key){ + if(crypt($pw_arg, $pw_db) == $pw_db) + result_true(); + + if($domain_key){ + $datetime = new DateTime(); + $datetime->setTimezone(new DateTimeZone("UTC")); + for($t = $datetime->getTimestamp(); $t >= $datetime->getTimestamp()-30; $t--){ + $pw_api = md5($domain.'@'.$domain_key.'@'.$user.'@'.$t); + if($pw_api == $pw_arg) + result_true(); + } + } + result_false(); +} +?> \ No newline at end of file diff --git a/install/apps/metronome_libs/mod_auth_external/db_conf.inc.php b/install/apps/metronome_libs/mod_auth_external/db_conf.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..1aba63d6ea051ff4826312757b10af2a1c590525 --- /dev/null +++ b/install/apps/metronome_libs/mod_auth_external/db_conf.inc.php @@ -0,0 +1,6 @@ +real_escape_string($arg_email); + $result = $db->query("SELECT jid, password FROM xmpp_user WHERE jid LIKE ? AND active='y' AND server_id=?", $dbmail, $isp_server_id); + result_false($result->num_rows != 1); + result_true(); + +}catch(Exception $ex){ + echo 0; + exit(); +} + +function result_false($cond = true){ + if(!$cond) return; + echo 0; + exit(); +} +function result_true(){ + echo 1; + exit(); +} + +?> \ No newline at end of file diff --git a/install/apps/metronome_libs/mod_auth_external/mod_auth_external.lua b/install/apps/metronome_libs/mod_auth_external/mod_auth_external.lua new file mode 100644 index 0000000000000000000000000000000000000000..c86400610e2389b61b502b52b6b277fdad9419e7 --- /dev/null +++ b/install/apps/metronome_libs/mod_auth_external/mod_auth_external.lua @@ -0,0 +1,118 @@ +local nodeprep = require "util.encodings".stringprep.nodeprep; +local lpc = require "lpc"; + +local config = require "core.configmanager"; +local log = module._log; +local host = module.host; +local script_type = config.get(host, "external_auth_protocol") or "generic"; +assert(script_type == "ejabberd" or script_type == "generic"); +local command = config.get(host, "external_auth_command") or ""; +assert(type(command) == "string"); +assert(not host:find(":")); +local usermanager = require "core.usermanager"; +local jid_bare = require "util.jid".bare; +local new_sasl = require "util.sasl".new; + +local pid; +local readfile; +local writefile; + +local function send_query(text) + if pid and lpc.wait(pid,1) ~= nil then + log("debug","error, process died, force reopen"); + pid=nil; + end + if not pid then + log("debug", "Opening process " .. command); + pid, writefile, readfile = lpc.run(command); + end + if not pid then + log("debug", "Process failed to open"); + return nil; + end + + writefile:write(text); + writefile:flush(); + if script_type == "ejabberd" then + return readfile:read(4); + elseif script_type == "generic" then + return readfile:read(); + end +end + +function do_query(kind, username, password) + if not username then return nil, "not-acceptable"; end + username = nodeprep(username); + if not username then return nil, "jid-malformed"; end + + local query = (password and "%s:%s:%s:%s" or "%s:%s:%s"):format(kind, username, host, password); + local len = #query + if len > 1000 then return nil, "policy-violation"; end + + if script_type == "ejabberd" then + local lo = len % 256; + local hi = (len - lo) / 256; + query = string.char(hi, lo)..query; + end + if script_type == "generic" then + query = query..'\n'; + end + + local response = send_query(query); + if (script_type == "ejabberd" and response == "\0\2\0\0") or + (script_type == "generic" and response == "0") then + return nil, "not-authorized"; + elseif (script_type == "ejabberd" and response == "\0\2\0\1") or + (script_type == "generic" and response == "1") then + return true; + else + log("debug", "Nonsense back"); + return nil, "internal-server-error"; + end +end + +function new_external_provider(host) + local provider = { name = "external" }; + + function provider.test_password(username, password) + return do_query("auth", username, password); + end + + function provider.set_password(username, password) + return do_query("setpass", username, password); + end + + function provider.user_exists(username) + return do_query("isuser", username); + end + + function provider.create_user(username, password) return nil, "Account creation/modification not available."; end + + function provider.get_sasl_handler() + local testpass_authentication_profile = { + plain_test = function(sasl, username, password, realm) + return usermanager.test_password(username, realm, password), true; + end, + }; + return new_sasl(module.host, testpass_authentication_profile); + end + + function provider.is_admin(jid) + local admins = config.get(host, "admins"); + if admins ~= config.get("*", "admins") then + if type(admins) == "table" then + jid = jid_bare(jid); + for _,admin in ipairs(admins) do + if admin == jid then return true; end + end + elseif admins then + log("error", "Option 'admins' for host '%s' is not a table", host); + end + end + return usermanager.is_admin(jid); + end + + return provider; +end + +module:add_item("auth-provider", new_external_provider(host)); \ No newline at end of file diff --git a/install/apps/metronome_libs/mod_discoitems.lua b/install/apps/metronome_libs/mod_discoitems.lua new file mode 100644 index 0000000000000000000000000000000000000000..f05b9049073f540cef8686f4ed80579e9fa9ed28 --- /dev/null +++ b/install/apps/metronome_libs/mod_discoitems.lua @@ -0,0 +1,24 @@ +-- * Metronome IM * +-- +-- This file is part of the Metronome XMPP server and is released under the +-- ISC License, please see the LICENSE file in this source package for more +-- information about copyright and licensing. +-- +-- As per the sublicensing clause, this file is also MIT/X11 Licensed. +-- ** Copyright (c) 2009, Waqas Hussain + +local st = require "util.stanza"; + +local result_query = st.stanza("query", {xmlns = "http://jabber.org/protocol/disco#items"}); +for _, item in ipairs(module:get_option("disco_items") or {}) do + result_query:tag("item", {jid = item[1], name = item[2]}):up(); +end + +module:hook("iq/host/http://jabber.org/protocol/disco#items:query", function(event) + local stanza = event.stanza; + local query = stanza.tags[1]; + if stanza.attr.type == "get" and not query.attr.node then + event.origin.send(st.reply(stanza):add_child(result_query)); + return true; + end +end, 100); diff --git a/install/apps/metronome_libs/mod_webpresence/icons/status_away.png b/install/apps/metronome_libs/mod_webpresence/icons/status_away.png new file mode 100644 index 0000000000000000000000000000000000000000..0de5c6ab3d35e958b2c2c9fa9ee6e5876312b54b Binary files /dev/null and b/install/apps/metronome_libs/mod_webpresence/icons/status_away.png differ diff --git a/install/apps/metronome_libs/mod_webpresence/icons/status_chat.png b/install/apps/metronome_libs/mod_webpresence/icons/status_chat.png new file mode 100644 index 0000000000000000000000000000000000000000..324f40baf379ec677e4b7b9791f94298481d7e86 Binary files /dev/null and b/install/apps/metronome_libs/mod_webpresence/icons/status_chat.png differ diff --git a/install/apps/metronome_libs/mod_webpresence/icons/status_dnd.png b/install/apps/metronome_libs/mod_webpresence/icons/status_dnd.png new file mode 100644 index 0000000000000000000000000000000000000000..015f3da95dfe2a6c9dcdf414951c277104ae6b2e Binary files /dev/null and b/install/apps/metronome_libs/mod_webpresence/icons/status_dnd.png differ diff --git a/install/apps/metronome_libs/mod_webpresence/icons/status_offline.png b/install/apps/metronome_libs/mod_webpresence/icons/status_offline.png new file mode 100644 index 0000000000000000000000000000000000000000..12db2af7dd86308f5abed00e3930d7f961e1ecc3 Binary files /dev/null and b/install/apps/metronome_libs/mod_webpresence/icons/status_offline.png differ diff --git a/install/apps/metronome_libs/mod_webpresence/icons/status_online.png b/install/apps/metronome_libs/mod_webpresence/icons/status_online.png new file mode 100644 index 0000000000000000000000000000000000000000..fb257c3144736fd691d81ac82242f7d51f909679 Binary files /dev/null and b/install/apps/metronome_libs/mod_webpresence/icons/status_online.png differ diff --git a/install/apps/metronome_libs/mod_webpresence/icons/status_xa.png b/install/apps/metronome_libs/mod_webpresence/icons/status_xa.png new file mode 100644 index 0000000000000000000000000000000000000000..321d35b5a3f1c832669154c1bc8f4f000c42e761 Binary files /dev/null and b/install/apps/metronome_libs/mod_webpresence/icons/status_xa.png differ diff --git a/install/apps/metronome_libs/mod_webpresence/mod_webpresence.lua b/install/apps/metronome_libs/mod_webpresence/mod_webpresence.lua new file mode 100644 index 0000000000000000000000000000000000000000..c1de0e0d37eaecba6afb4244a12d6d4a5245912d --- /dev/null +++ b/install/apps/metronome_libs/mod_webpresence/mod_webpresence.lua @@ -0,0 +1,118 @@ +module:depends("http"); + +local jid_split = require "util.jid".prepped_split; +local b64 = require "util.encodings".base64.encode; +local sha1 = require "util.hashes".sha1; +local stanza = require "util.stanza".stanza; +local json = require "util.json".encode_ordered; + +local function require_resource(name) + local icon_path = module:get_option_string("presence_icons", "icons"); + local f, err = module:load_resource(icon_path.."/"..name); + if f then + return f:read("*a"); + end + module:log("warn", "Failed to open image file %s", icon_path..name); + return ""; +end + +local statuses = { online = {}, away = {}, xa = {}, dnd = {}, chat = {}, offline = {} }; + +local function handle_request(event, path) + local status, message; + local jid, type = path:match("([^/]+)/?(.*)$"); + if jid then + local user, host = jid_split(jid); + if host and not user then + user, host = host, event.request.headers.host; + if host then host = host:gsub(":%d+$", ""); end + end + if user and host then + local user_sessions = hosts[host] and hosts[host].sessions[user]; + if user_sessions then + status = user_sessions.top_resources[1]; + if status and status.presence then + message = status.presence:child_with_name("status"); + status = status.presence:child_with_name("show"); + if not status then + status = "online"; + else + status = status:get_text(); + end + if message then + message = message:get_text(); + end + end + end + end + end + status = status or "offline"; + + statuses[status].image = function() + return { status_code = 200, headers = { content_type = "image/png" }, + body = require_resource("status_"..status..".png") + }; + end; + statuses[status].html = function() + local jid_hash = sha1(jid, true); + return { status_code = 200, headers = { content_type = "text/html" }, + body = [[]].. + tostring( + stanza("html") + :tag("head") + :tag("title"):text("XMPP Status Page for "..jid):up():up() + :tag("body") + :tag("div", { id = jid_hash.."_status", class = "xmpp_status" }) + :tag("img", { id = jid_hash.."_img", class = "xmpp_status_image xmpp_status_"..status, + src = "data:image/png;base64,"..b64(require_resource("status_"..status..".png")) }):up() + :tag("span", { id = jid_hash.."_status_name", class = "xmpp_status_name" }) + :text("\194\160"..status):up() + :tag("span", { id = jid_hash.."_status_message", class = "xmpp_status_message" }) + :text(message and "\194\160"..message.."" or "") + ) + }; + end; + statuses[status].text = function() + return { status_code = 200, headers = { content_type = "text/plain" }, + body = status + }; + end; + statuses[status].message = function() + return { status_code = 200, headers = { content_type = "text/plain" }, + body = (message and message or "") + }; + end; + statuses[status].json = function() + return { status_code = 200, headers = { content_type = "application/json" }, + body = json({ + jid = jid, + show = status, + status = (message and message or "null") + }) + }; + end; + statuses[status].xml = function() + return { status_code = 200, headers = { content_type = "application/xml" }, + body = [[]].. + tostring( + stanza("result") + :tag("jid"):text(jid):up() + :tag("show"):text(status):up() + :tag("status"):text(message) + ) + }; + end + + if ((type == "") or (not statuses[status][type])) then + type = "image" + end; + + return statuses[status][type](); +end + +module:provides("http", { + default_path = "/status"; + route = { + ["GET /*"] = handle_request; + }; +}); diff --git a/install/dist/conf/centos70.conf.php b/install/dist/conf/centos70.conf.php index da5848c8cf5ae5caa4d9b20f9dd48c840b0d9806..8aa66ea0315b4f98558cd5d2bf6e6f86188efeff 100644 --- a/install/dist/conf/centos70.conf.php +++ b/install/dist/conf/centos70.conf.php @@ -171,9 +171,9 @@ $conf['powerdns']['init_script'] = 'pdns'; $conf['bind']['installed'] = false; // will be detected automatically during installation $conf['bind']['bind_user'] = 'named'; $conf['bind']['bind_group'] = 'named'; -$conf['bind']['bind_zonefiles_dir'] = '/var/named/chroot/var/named/'; -$conf['bind']['named_conf_path'] = '/var/named/chroot/etc/named.conf'; -$conf['bind']['named_conf_local_path'] = '/var/named/chroot/var/named/named.local'; +$conf['bind']['bind_zonefiles_dir'] = '/var/named'; +$conf['bind']['named_conf_path'] = '/etc/named.conf'; +$conf['bind']['named_conf_local_path'] = '/etc/named.conf.local'; $conf['bind']['init_script'] = 'named'; //* Jailkit diff --git a/install/dist/conf/debian40.conf.php b/install/dist/conf/debian40.conf.php index 3e9fe350065472b2d0a13613e2ad40ed8961c625..613c828d14906474fbda3a3b475508e5b8b2f997 100644 --- a/install/dist/conf/debian40.conf.php +++ b/install/dist/conf/debian40.conf.php @@ -183,7 +183,7 @@ $conf['jailkit']['installed'] = false; // will be detected automatically during $conf['jailkit']['config_dir'] = '/etc/jailkit'; $conf['jailkit']['jk_init'] = 'jk_init.ini'; $conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini'; -$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico'; +$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico /usr/bin/mysql /usr/bin/mysqldump /usr/bin/git /usr/bin/git-receive-pack /usr/bin/git-upload-pack /usr/bin/unzip /usr/bin/zip /bin/tar /bin/rm /usr/bin/patch'; $conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php'; //* Squid diff --git a/install/dist/conf/debian60.conf.php b/install/dist/conf/debian60.conf.php index a3819966b9dc640d42723450d3869f5905c64639..2c26dcb9cbb26ae89f1126ce15440471485b028a 100644 --- a/install/dist/conf/debian60.conf.php +++ b/install/dist/conf/debian60.conf.php @@ -183,7 +183,7 @@ $conf['jailkit']['installed'] = false; // will be detected automatically during $conf['jailkit']['config_dir'] = '/etc/jailkit'; $conf['jailkit']['jk_init'] = 'jk_init.ini'; $conf['jailkit']['jk_chrootsh'] = 'jk_chrootsh.ini'; -$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico'; +$conf['jailkit']['jailkit_chroot_app_programs'] = '/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico /usr/bin/mysql /usr/bin/mysqldump /usr/bin/git /usr/bin/git-receive-pack /usr/bin/git-upload-pack /usr/bin/unzip /usr/bin/zip /bin/tar /bin/rm /usr/bin/patch'; $conf['jailkit']['jailkit_chroot_cron_programs'] = '/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php'; //* Squid @@ -222,5 +222,9 @@ $conf['cron']['init_script'] = 'cron'; $conf['cron']['crontab_dir'] = '/etc/cron.d'; $conf['cron']['wget'] = '/usr/bin/wget'; +//* Metronome XMPP +$conf['xmpp']['installed'] = false; +$conf['xmpp']['init_script'] = 'metronome'; + ?> diff --git a/install/dist/lib/centos52.lib.php b/install/dist/lib/centos52.lib.php index 7d9b78caa55758375ab6b051514602971f24ae8a..911152804e9fb5bbcd10aa14c8c2443ee229aa8e 100644 --- a/install/dist/lib/centos52.lib.php +++ b/install/dist/lib/centos52.lib.php @@ -123,6 +123,7 @@ class installer extends installer_dist { $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); + chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); // Adding the amavisd commands to the postfix configuration diff --git a/install/dist/lib/centos53.lib.php b/install/dist/lib/centos53.lib.php index c7e11e50a3ddb4bed6befeeb9e335ca7e3bd1bb8..0ac99f266a4687390fe6c9e77a35f0e5b27ef3d7 100644 --- a/install/dist/lib/centos53.lib.php +++ b/install/dist/lib/centos53.lib.php @@ -124,6 +124,7 @@ class installer extends installer_dist { $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); + chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); // Adding the amavisd commands to the postfix configuration diff --git a/install/dist/lib/centos70.lib.php b/install/dist/lib/centos70.lib.php index 682833b70f77ee62469a5cbcd62eded1efae61b2..9cee55ff2d88dcf7a2db8df0e4e5111658ce963d 100644 --- a/install/dist/lib/centos70.lib.php +++ b/install/dist/lib/centos70.lib.php @@ -124,6 +124,7 @@ class installer extends installer_dist { $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); + chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); // Adding the amavisd commands to the postfix configuration diff --git a/install/dist/lib/debian60.lib.php b/install/dist/lib/debian60.lib.php index 584e6aa91c19753b89210ec25df19253acc96bd1..8c7f1bae48402fad02f6861919522da0e4f997a2 100644 --- a/install/dist/lib/debian60.lib.php +++ b/install/dist/lib/debian60.lib.php @@ -38,7 +38,7 @@ class installer extends installer_base { // check if virtual_transport must be changed if ($this->is_update) { - $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); + $tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); $ini_array = ini_to_array(stripslashes($tmp['config'])); // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() @@ -127,6 +127,7 @@ class installer extends installer_base { $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_port}', $conf['mysql']['port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); wf($config_dir.'/'.$configfile, $content); diff --git a/install/dist/lib/fedora.lib.php b/install/dist/lib/fedora.lib.php index 01fd96073b192db00d3faedf4e4888a0ca7a5e9c..f017ea544e90747c6f9e911edb19b09811ad1675 100644 --- a/install/dist/lib/fedora.lib.php +++ b/install/dist/lib/fedora.lib.php @@ -143,6 +143,9 @@ class installer_dist extends installer_base { //* mysql-virtual_sender.cf $this->process_postfix_config('mysql-virtual_sender.cf'); + //* mysql-virtual_sender_login_maps.cf + $this->process_postfix_config('mysql-virtual_sender_login_maps.cf'); + //* mysql-virtual_client.cf $this->process_postfix_config('mysql-virtual_client.cf'); @@ -152,6 +155,9 @@ class installer_dist extends installer_base { //* mysql-virtual_relayrecipientmaps.cf $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf'); + //* mysql-virtual_policy_greylist.cf + $this->process_postfix_config('mysql-virtual_policy_greylist.cf'); + //* postfix-dkim $full_file_name=$config_dir.'/tag_as_originating.re'; if(is_file($full_file_name)) { @@ -179,7 +185,7 @@ class installer_dist extends installer_base { if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); //* 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_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'])); unset($server_ini_rec); @@ -192,15 +198,28 @@ class installer_dist extends installer_base { } } unset($rbl_hosts); + + //* If Postgrey is installed, configure it + $greylisting = ''; + if($conf['postgrey']['installed'] == true) { + $greylisting = ', check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf'; + } + + $reject_sender_login_mismatch = ''; + if(isset($server_ini_array['mail']['reject_sender_login_mismatch']) && ($server_ini_array['mail']['reject_sender_login_mismatch'] == 'y')) { + $reject_sender_login_mismatch = ', reject_authenticated_sender_login_mismatch'; + } 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); - + '{rbl_list}' => $rbl_list, + '{greylisting}' => $greylisting, + '{reject_slm}' => $reject_sender_login_mismatch, + ); + $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 @@ -359,6 +378,7 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $content); wf("$config_dir/$configfile", $content); exec("chmod 660 $config_dir/$configfile"); @@ -385,7 +405,7 @@ class installer_dist extends installer_base { // check if virtual_transport must be changed if ($this->is_update) { - $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); + $tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); $ini_array = ini_to_array(stripslashes($tmp['config'])); // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() @@ -477,6 +497,7 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); wf("$config_dir/$configfile", $content); @@ -503,6 +524,7 @@ class installer_dist extends installer_base { $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); + chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); // Adding the amavisd commands to the postfix configuration @@ -633,6 +655,7 @@ class installer_dist extends installer_base { $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_port}', $conf["mysql"]["port"], $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); @@ -659,7 +682,7 @@ 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); + exec('chmod 2770 '.$content); } @@ -694,7 +717,7 @@ class installer_dist extends installer_base { $tpl = new tpl('apache_ispconfig.conf.master'); $tpl->setVar('apache_version',getapacheversion()); - $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + $records = $this->db->queryAllRecords("SELECT * FROM ?? WHERE server_id = ? AND virtualhost = 'y'", $conf['mysql']['master_database'] . '.server_ip', $conf['server_id']); $ip_addresses = array(); if(is_array($records) && count($records) > 0) { @@ -780,7 +803,7 @@ class installer_dist extends installer_base { 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() + public function configure_bastille_firewall() { global $conf; @@ -802,7 +825,7 @@ class installer_dist extends installer_base { $tcp_public_services = ''; $udp_public_services = ''; - $row = $this->db->queryOneRecord('SELECT * FROM '.$conf["mysql"]["database"].'.firewall WHERE server_id = '.intval($conf['server_id'])); + $row = $this->db->queryOneRecord('SELECT * FROM ?? WHERE server_id = ?', $conf["mysql"]["database"] . '.firewall', $conf['server_id']); if(trim($row["tcp_port"]) != '' || trim($row["udp_port"]) != ''){ $tcp_public_services = trim(str_replace(',', ' ', $row["tcp_port"])); @@ -813,7 +836,7 @@ class installer_dist extends installer_base { } 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'])); + if($row["tcp_port"] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ? WHERE server_id = ?", ',' . intval($conf['apache']['vhost_port']), $conf['server_id']); } $content = str_replace("{TCP_PUBLIC_SERVICES}", $tcp_public_services, $content); @@ -912,11 +935,13 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $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('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); @@ -937,11 +962,13 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $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('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); @@ -1013,13 +1040,11 @@ class installer_dist 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 = ?, web_server = ?, dns_server = ?, file_server = ?, db_server = ?, vserver_server = ? WHERE server_id = ?"; + $this->db->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); if($conf['mysql']['master_slave_setup'] == 'y') { - $this->dbmaster->query($sql); - $this->db->query($sql); - } else { - $this->db->query($sql); + $this->dbmaster->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); } // chown install dir to root and chmod 755 @@ -1309,7 +1334,12 @@ class installer_dist extends installer_base { // Add symlink for patch tool if(!is_link('/usr/local/bin/ispconfig_patch')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_patch /usr/local/bin/ispconfig_patch'); - + + // Change mode of a few files from amavisd + if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user', 0640); + if(is_file($conf['amavis']['config_dir'].'/50-user~')) chmod($conf['amavis']['config_dir'].'/50-user~', 0400); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf')) chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf~')) chmod($conf['amavis']['config_dir'].'/amavisd.conf~', 0400); } } diff --git a/install/dist/lib/gentoo.lib.php b/install/dist/lib/gentoo.lib.php index 6e463ec607c9e19542c0bde3fcd2751220a55ed5..6615dacc91f7d7c5fe5acfd0099b649f2f72a4bb 100644 --- a/install/dist/lib/gentoo.lib.php +++ b/install/dist/lib/gentoo.lib.php @@ -81,11 +81,40 @@ class installer extends installer_base } //* These postconf commands will be executed on installation and update + $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM ?? WHERE server_id = ?", $conf["mysql"]["database"].'.server', $conf['server_id']); + $server_ini_array = ini_to_array(stripslashes($server_ini_rec['config'])); + unset($server_ini_rec); + + //* 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'])); + foreach ($rbl_hosts as $key => $value) { + $rbl_list .= ", reject_rbl_client ". $value; + } + } + unset($rbl_hosts); + + //* If Postgrey is installed, configure it + $greylisting = ''; + if($conf['postgrey']['installed'] == true) { + $greylisting = ', check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf'; + } + + $reject_sender_login_mismatch = ''; + if(isset($server_ini_array['mail']['reject_sender_login_mismatch']) && ($server_ini_array['mail']['reject_sender_login_mismatch'] == 'y')) { + $reject_sender_login_mismatch = ', reject_authenticated_sender_login_mismatch'; + } + 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); + '{rbl_list}' => $rbl_list, + '{greylisting}' => $greylisting, + '{reject_slm}' => $reject_sender_login_mismatch, + ); $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); @@ -229,7 +258,7 @@ class installer extends installer_base // check if virtual_transport must be changed if ($this->is_update) { - $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); + $tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"].".server", $conf['server_id']); $ini_array = ini_to_array(stripslashes($tmp['config'])); // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() @@ -421,13 +450,13 @@ class installer extends installer_base global $conf; //* Create the database - if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['powerdns']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) { + if(!$this->db->query('CREATE DATABASE IF NOT EXISTS ?? DEFAULT CHARACTER SET ?', $conf['powerdns']['database'], $conf['mysql']['charset'])) { $this->error('Unable to create MySQL database: '.$conf['powerdns']['database'].'.'); } //* Create the ISPConfig database user in the local database - $query = 'GRANT ALL ON `'.$conf['powerdns']['database'].'` . * TO \''.$conf['mysql']['ispconfig_user'].'\'@\'localhost\';'; - if(!$this->db->query($query)) { + $query = 'GRANT ALL ON ??.* TO ?@?'; + if(!$this->db->query($query, $conf['powerdns']['database'], $conf['mysql']['ispconfig_user'], 'localhost')) { $this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage); } @@ -537,25 +566,10 @@ class installer extends installer_base //* 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) - { - 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); - */ - $tpl = new tpl('apache_ispconfig.conf.master'); $tpl->setVar('apache_version',getapacheversion()); - $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + $records = $this->db->queryAllRecords("SELECT * FROM ?? WHERE server_id = ? AND virtualhost = 'y'", $conf['mysql']['master_database'] . '.server_ip', $conf['server_id']); $ip_addresses = array(); if(is_array($records) && count($records) > 0) { @@ -820,6 +834,7 @@ class installer extends installer_base $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('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); @@ -904,13 +919,11 @@ class installer 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']); + $sql = "UPDATE `server` SET mail_server = ?, web_server = ?, dns_server = ?, file_server = ?, db_server = ?, vserver_server = ? WHERE server_id = ?"; + $this->db->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); if($conf['mysql']['master_slave_setup'] == 'y') { - $this->dbmaster->query($sql); - $this->db->query($sql); - } else { - $this->db->query($sql); + $this->dbmaster->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); } // chown install dir to root and chmod 755 @@ -1177,7 +1190,13 @@ class installer extends installer_base // Add symlink for patch tool if(!is_link('/usr/local/bin/ispconfig_patch')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_patch /usr/local/bin/ispconfig_patch'); - + + // Change mode of a few files from amavisd + if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user', 0640); + if(is_file($conf['amavis']['config_dir'].'/50-user~')) chmod($conf['amavis']['config_dir'].'/50-user~', 0400); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf')) chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf~')) chmod($conf['amavis']['config_dir'].'/amavisd.conf~', 0400); + } } diff --git a/install/dist/lib/opensuse.lib.php b/install/dist/lib/opensuse.lib.php index a278c90ccd4d5a0759fb9941b4a6879504c96c30..b452c2f2e1635a361946061a272dee9ab57f4c2e 100644 --- a/install/dist/lib/opensuse.lib.php +++ b/install/dist/lib/opensuse.lib.php @@ -159,6 +159,9 @@ class installer_dist extends installer_base { //* mysql-virtual_sender.cf $this->process_postfix_config('mysql-virtual_sender.cf'); + //* mysql-virtual_sender_login_maps.cf + $this->process_postfix_config('mysql-virtual_sender_login_maps.cf'); + //* mysql-virtual_client.cf $this->process_postfix_config('mysql-virtual_client.cf'); @@ -168,6 +171,9 @@ class installer_dist extends installer_base { //* mysql-virtual_relayrecipientmaps.cf $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf'); + //* mysql-virtual_policy_greylist.cf + $this->process_postfix_config('mysql-virtual_policy_greylist.cf'); + //* postfix-dkim $full_file_name=$config_dir.'/tag_as_originating.re'; if(is_file($full_file_name)) { @@ -209,7 +215,7 @@ class installer_dist extends installer_base { 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_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'])); unset($server_ini_rec); @@ -222,15 +228,28 @@ class installer_dist extends installer_base { } } unset($rbl_hosts); - unset($server_ini_array); - //* These postconf commands will be executed on installation and update + //* If Postgrey is installed, configure it + $greylisting = ''; + if($conf['postgrey']['installed'] == true) { + $greylisting = ', check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf'; + } + + $reject_sender_login_mismatch = ''; + if(isset($server_ini_array['mail']['reject_sender_login_mismatch']) && ($server_ini_array['mail']['reject_sender_login_mismatch'] == 'y')) { + $reject_sender_login_mismatch = ', reject_authenticated_sender_login_mismatch'; + } + 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); - + '{rbl_list}' => $rbl_list, + '{greylisting}' => $greylisting, + '{reject_slm}' => $reject_sender_login_mismatch, + ); + $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 @@ -414,6 +433,7 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $content); wf("$config_dir/$configfile", $content); exec("chmod 660 $config_dir/$configfile"); @@ -440,7 +460,7 @@ class installer_dist extends installer_base { // check if virtual_transport must be changed if ($this->is_update) { - $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); + $tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); $ini_array = ini_to_array(stripslashes($tmp['config'])); // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() @@ -526,6 +546,7 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); wf("$config_dir/$configfile", $content); @@ -551,6 +572,7 @@ class installer_dist extends installer_base { $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); + chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); // Adding the amavisd commands to the postfix configuration @@ -680,6 +702,7 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $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); @@ -726,7 +749,7 @@ class installer_dist extends installer_base { $tpl = new tpl('apache_ispconfig.conf.master'); $tpl->setVar('apache_version',getapacheversion()); - $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + $records = $this->db->queryAllRecords("SELECT * FROM ?? WHERE server_id = ? AND virtualhost = 'y'", $conf['mysql']['master_database'] . '.server_ip', $conf['server_id']); $ip_addresses = array(); if(is_array($records) && count($records) > 0) { @@ -854,7 +877,7 @@ class installer_dist extends installer_base { 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() + public function configure_bastille_firewall() { global $conf; @@ -876,7 +899,7 @@ class installer_dist extends installer_base { $tcp_public_services = ''; $udp_public_services = ''; - $row = $this->db->queryOneRecord('SELECT * FROM '.$conf["mysql"]["database"].'.firewall WHERE server_id = '.intval($conf['server_id'])); + $row = $this->db->queryOneRecord('SELECT * FROM ?? WHERE server_id = ?', $conf["mysql"]["database"] . '.firewall', $conf['server_id']); if(trim($row["tcp_port"]) != '' || trim($row["udp_port"]) != ''){ $tcp_public_services = trim(str_replace(',', ' ', $row["tcp_port"])); @@ -888,7 +911,7 @@ class installer_dist extends installer_base { 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'])); + if($row["tcp_port"] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ? WHERE server_id = ?", ',' . intval($conf['apache']['vhost_port']), $conf['server_id']); } $content = str_replace("{TCP_PUBLIC_SERVICES}", $tcp_public_services, $content); @@ -986,11 +1009,13 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $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('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); @@ -1011,11 +1036,13 @@ class installer_dist extends installer_base { $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_port}', $conf['mysql']['port'], $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('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); @@ -1086,13 +1113,11 @@ class installer_dist 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 = ?, web_server = ?, dns_server = ?, file_server = ?, db_server = ?, vserver_server = ? WHERE server_id = ?"; + $this->db->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); if($conf['mysql']['master_slave_setup'] == 'y') { - $this->dbmaster->query($sql); - $this->db->query($sql); - } else { - $this->db->query($sql); + $this->dbmaster->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); } // chown install dir to root and chmod 755 @@ -1382,8 +1407,12 @@ class installer_dist extends installer_base { // Add symlink for patch tool if(!is_link('/usr/local/bin/ispconfig_patch')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_patch /usr/local/bin/ispconfig_patch'); - - + + // Change mode of a few files from amavisd + if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user', 0640); + if(is_file($conf['amavis']['config_dir'].'/50-user~')) chmod($conf['amavis']['config_dir'].'/50-user~', 0400); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf')) chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf~')) chmod($conf['amavis']['config_dir'].'/amavisd.conf~', 0400); } } diff --git a/install/install.php b/install/install.php index 91759f22844f4859c8ef9e83700f9ad225d51022..8b320271c7434c57cb48a9a681101e14e440c168 100644 --- a/install/install.php +++ b/install/install.php @@ -171,8 +171,16 @@ $install_mode = $inst->simple_query('Installation mode', array('standard', 'expe //** Get the hostname $tmp_out = array(); exec('hostname -f', $tmp_out); -$conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', @$tmp_out[0],'hostname'); +$conf['hostname'] = @$tmp_out[0]; unset($tmp_out); +//** Prevent empty hostname +$check = false; +do { + $conf['hostname'] = $inst->free_query('Full qualified hostname (FQDN) of the server, eg server1.domain.tld ', $conf['hostname'], 'hostname'); + $conf['hostname']=trim($conf['hostname']); + $check = @($conf['hostname'] !== '')?true:false; + if(!$check) swriteln('Hostname may not be empty.'); +} while (!$check); // Check if the mysql functions are loaded in PHP if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Please ensure that the PHP MySQL module is loaded.'); @@ -181,6 +189,7 @@ if(!function_exists('mysql_connect')) die('No PHP MySQL functions available. Ple $finished = false; do { $tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host'],'mysql_hostname'); + $tmp_mysql_server_port = $inst->free_query('MySQL server port', $conf['mysql']['port'],'mysql_port'); $tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user'],'mysql_root_user'); $tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password'],'mysql_root_password'); $tmp_mysql_server_database = $inst->free_query('MySQL database to create', $conf['mysql']['database'],'mysql_database'); @@ -194,8 +203,9 @@ do { } //* Initialize the MySQL server connection - if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) { + if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, (int)$tmp_mysql_server_port)) { $conf['mysql']['host'] = $tmp_mysql_server_host; + $conf['mysql']['port'] = $tmp_mysql_server_port; $conf['mysql']['admin_user'] = $tmp_mysql_server_admin_user; $conf['mysql']['admin_password'] = $tmp_mysql_server_admin_password; $conf['mysql']['database'] = $tmp_mysql_server_database; @@ -218,140 +228,253 @@ include_once 'lib/mysql.lib.php'; $inst->db = new db(); //** Begin with standard or expert installation + +$conf['services']['mail'] = false; +$conf['services']['web'] = false; +$conf['services']['dns'] = false; +$conf['services']['file'] = false; +$conf['services']['db'] = true; +$conf['services']['vserver'] = false; +$conf['services']['firewall'] = false; +$conf['services']['proxy'] = false; +$conf['services']['xmpp'] = false; + 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'); - 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 Postgrey + $force = @($conf['postgrey']['installed']) ? true : $inst->force_configure_app('Postgrey'); + if($force) swriteln('Configuring Postgrey'); - //* Configure Mailman - if($conf['mailman']['installed'] == true) { - $inst->configure_mailman('install'); + //* Configure Postfix + $force = @($conf['postfix']['installed']) ? true : $inst->force_configure_app('Postfix'); + if($force) { + swriteln('Configuring Postfix'); + $inst->configure_postfix(); + $conf['services']['mail'] = true; } - //* Configure jailkit - swriteln('Configuring Jailkit'); - $inst->configure_jailkit(); + if($conf['services']['mail']) { - if($conf['dovecot']['installed'] == true) { + //* Configure Mailman + $force = @($conf['mailman']['installed']) ? true : $inst->force_configure_app('Mailman'); + if($force) { + swriteln('Configuring Mailman'); + $inst->configure_mailman(); + } + + //* Check for Dovecot and Courier + if(!$conf['dovecot']['installed'] && !$conf['courier']['installed']) { + $conf['dovecot']['installed'] = $inst->force_configure_app('Dovecot'); + $conf['courier']['installed'] = $inst->force_configure_app('Courier'); + } + //* Configure Mailserver - Dovecot or Courier + if($conf['dovecot']['installed'] && $conf['courier']['installed']) { + $mail_server_to_use = $inst->simple_query('Dovecot and Courier detected. Select server to use with ISPConfig:', array('dovecot', 'courier'), 'dovecot','mail_server'); + if($mail_server_to_use == 'dovecot'){ + $conf['courier']['installed'] = false; + } else { + $conf['dovecot']['installed'] = false; + } + } //* Configure Dovecot - swriteln('Configuring Dovecot'); - $inst->configure_dovecot(); - } else { - //* Configure saslauthd - swriteln('Configuring SASL'); - $inst->configure_saslauthd(); - - //* Configure PAM - swriteln('Configuring PAM'); - $inst->configure_pam(); - + if($conf['dovecot']['installed']) { + swriteln('Configuring Dovecot'); + $inst->configure_dovecot(); + } //* Configure Courier - swriteln('Configuring Courier'); - $inst->configure_courier(); - } + if($conf['courier']['installed']) { + swriteln('Configuring Courier'); + $inst->configure_courier(); + swriteln('Configuring SASL'); + $inst->configure_saslauthd(); + swriteln('Configuring PAM'); + $inst->configure_pam(); + } - //* Configure Spamasassin - swriteln('Configuring Spamassassin'); - $inst->configure_spamassassin(); + //* Configure Spamasassin + $force = @($conf['spamassassin']['installed']) ? true : $inst->force_configure_app('Spamassassin'); + if($force) { + swriteln('Configuring Spamassassin'); + $inst->configure_spamassassin(); + } + + //* Configure Amavis + $force = @($conf['amavis']['installed']) ? true : $inst->force_configure_app('Amavisd'); + if($force) { + swriteln('Configuring Amavisd'); + $inst->configure_amavis(); + } - //* Configure Amavis - if($conf['amavis']['installed'] == true) { - swriteln('Configuring Amavisd'); - $inst->configure_amavis(); - } + //* Configure Getmail + $force = @($conf['getmail']['installed']) ? true : $inst->force_configure_app('Getmail'); + if($force) { + swriteln('Configuring Getmail'); + $inst->configure_getmail(); + } - //* Configure Getmail - swriteln('Configuring Getmail'); - $inst->configure_getmail(); + } else swriteln('[ERROR] Postfix not installed - skipping Mail'); - //* Configure Pureftpd - swriteln('Configuring Pureftpd'); - $inst->configure_pureftpd(); - - //* Configure DNS - if($conf['powerdns']['installed'] == true) { + //* Check for DNS + if(!$conf['powerdns']['installed'] && !$conf['bind']['installed'] && !$conf['mydns']['installed']) { + $conf['powerdns']['installed'] = $inst->force_configure_app('PowerDNS'); + $conf['bind']['installed'] = $inst->force_configure_app('BIND'); + $conf['mydns']['installed'] = $inst->force_configure_app('MyDNS'); + } + //* Configure PowerDNS + if($conf['powerdns']['installed']) { swriteln('Configuring PowerDNS'); $inst->configure_powerdns(); - } elseif($conf['bind']['installed'] == true) { + $conf['services']['dns'] = true; + } + //* Configure Bind + if($conf['bind']['installed']) { swriteln('Configuring BIND'); $inst->configure_bind(); - } else { + $conf['services']['dns'] = true; + } + //* Configure MyDNS + if($conf['mydns']['installed']) { swriteln('Configuring MyDNS'); $inst->configure_mydns(); + $conf['services']['dns'] = true; + } + + //* Configure Jailkit + $force = @($conf['jailkit']['installed']) ? true : $inst->force_configure_app('Jailkit'); + if($force) { + swriteln('Configuring Jailkit'); + $inst->configure_jailkit(); + } + + //* Configure Pureftpd + $force = @($conf['pureftpd']['installed']) ? true : $inst->force_configure_app('pureftpd'); + if($force) { + swriteln('Configuring Pureftpd'); + $inst->configure_pureftpd(); + } + + //* Check for Web-Server + if(!$conf['apache']['installed'] && !$conf['nginx']['installed']) { + $conf['apache']['installed'] = $inst->force_configure_app('Apache'); + $conf['nginx']['installed'] = $inst->force_configure_app('nginx'); + } + + //* Configure Webserver - Apache or nginx + if($conf['apache']['installed'] && $conf['nginx']['installed']) { + $http_server_to_use = $inst->simple_query('Apache and nginx detected. Select server to use for ISPConfig:', array('apache', 'nginx'), 'apache','http_server'); + if($http_server_to_use == 'apache'){ + $conf['nginx']['installed'] = false; + } else { + $conf['apache']['installed'] = false; + } } //* Configure Apache - if($conf['apache']['installed'] == true){ + if($conf['apache']['installed']){ swriteln('Configuring Apache'); $inst->configure_apache(); + $conf['services']['web'] = true; + $conf['services']['file'] = true; + //* Configure Vlogger + $force = @($conf['vlogger']['installed']) ? true : $inst->force_configure_app('vlogger'); + if($force) { + swriteln('Configuring vlogger'); + $inst->configure_vlogger(); + } + //* Configure squid +/* + $force = @($conf['squid']['installed']) ? true : $inst->force_configure_app('squid'); + if($force) { + swriteln('Configuring Squid'); + $inst->configure_squid(); + $conf['services']['proxy'] = true; + } +*/ } //* Configure nginx - if($conf['nginx']['installed'] == true){ + if($conf['nginx']['installed']){ swriteln('Configuring nginx'); $inst->configure_nginx(); + $conf['services']['web'] = true; } - //** Configure Vlogger - swriteln('Configuring Vlogger'); - $inst->configure_vlogger(); - - //** Configure apps vhost - swriteln('Configuring Apps vhost'); - $inst->configure_apps_vhost(); + //* Configure XMPP + $force = @($conf['xmpp']['installed']) ? true : $inst->force_configure_app('Metronome XMPP Server'); + if($force) { + swriteln('Configuring Metronome XMPP Server'); + $inst->configure_xmpp(); + $conf['services']['xmpp'] = true; + } - //* Configure Firewall - if($conf['ufw']['installed'] == true) { - //* Configure Ubuntu Firewall - $conf['services']['firewall'] = true; + //* Check for Firewall + if(!$conf['ufw']['installed'] && !$conf['firewall']['installed']) { + $conf['ufw']['installed'] = $inst->force_configure_app('Ubuntu Firewall'); + $conf['firewall']['installed'] = $inst->force_configure_app('Bastille Firewall'); + } + //* Configure Firewall - Ubuntu or Bastille + if($conf['ufw']['installed'] && $conf['firewall']['installed']) { + $firewall_to_use = $inst->simple_query('Ubuntu and Bastille Firewall detected. Select firewall to use with ISPConfig:', array('bastille', 'ubuntu'), 'bastille','firewall_server'); + if($firewall_to_use == 'bastille'){ + $conf['ufw']['installed'] = false; + } else { + $conf['firewall']['installed'] = false; + } + } + //* Configure Ubuntu Firewall + if($conf['ufw']['installed']){ swriteln('Configuring Ubuntu Firewall'); $inst->configure_ufw_firewall(); - } else { - //* Configure Bastille Firewall $conf['services']['firewall'] = true; + } + //* Configure Bastille Firewall + if($conf['firewall']['installed']){ swriteln('Configuring Bastille Firewall'); $inst->configure_bastille_firewall(); + $conf['services']['firewall'] = true; } //* Configure Fail2ban - if($conf['fail2ban']['installed'] == true) { + $force = @($conf['fail2ban']['installed']) ? true : $inst->force_configure_app('Fail2ban'); + if($force) { swriteln('Configuring Fail2ban'); $inst->configure_fail2ban(); } - /* - if($conf['squid']['installed'] == true) { - $conf['services']['proxy'] = true; - swriteln('Configuring Squid'); - $inst->configure_squid(); - } else if($conf['nginx']['installed'] == true) { - $conf['services']['proxy'] = true; - swriteln('Configuring Nginx'); - $inst->configure_nginx(); + //* Configure OpenVZ + $force = @($conf['openvz']['installed']) ? true : $inst->force_configure_app('OpenVZ'); + if($force) { + $conf['services']['vserver'] = true; + swriteln('Configuring OpenVZ'); } - */ + + //** Configure apps vhost + swriteln('Configuring Apps vhost'); + $inst->configure_apps_vhost(); //* Configure ISPConfig swriteln('Installing ISPConfig'); //** Customize the port ISPConfig runs on $ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080','ispconfig_port'); + $conf['interface_password'] = $inst->free_query('Admin password', 'admin'); + if($conf['interface_password'] != 'admin') { + $check = false; + do { + unset($temp_password); + $temp_password = $inst->free_query('Re-enter admin password', ''); + $check = @($temp_password == $conf['interface_password'])?true:false; + if(!$check) swriteln('Passwords do not match.'); + } while (!$check); + } + unset($check); + unset($temp_password); 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); @@ -367,8 +490,10 @@ if($install_mode == 'standard') { $inst->configure_dbserver(); //* Configure ISPConfig - swriteln('Installing ISPConfig crontab'); - $inst->install_crontab(); + if($conf['cron']['installed']) { + swriteln('Installing ISPConfig crontab'); + $inst->install_crontab(); + } else swriteln('[ERROR] Cron not found'); swriteln('Restarting services ...'); if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1'); @@ -398,17 +523,9 @@ if($install_mode == 'standard') { //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'); + if($conf['xmpp']['installed'] == true && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['init_script'], 'restart').' &> /dev/null'); -} else { - - //* In expert mode, we select the services in the following steps, only db is always available - $conf['services']['mail'] = false; - $conf['services']['web'] = false; - $conf['services']['dns'] = false; - $conf['services']['db'] = true; - $conf['services']['firewall'] = false; - $conf['services']['proxy'] = false; - +} else { //* expert mode //** Get Server ID // $conf['server_id'] = $inst->free_query('Unique Numeric ID of the server','1'); @@ -420,13 +537,15 @@ if($install_mode == 'standard') { $finished = false; do { $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname'); + $tmp_mysql_server_port = $inst->free_query('MySQL master server port', $conf['mysql']['master_port'],'mysql_master_port'); $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user'); $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password'); $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'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)) { + if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, (int)$tmp_mysql_server_port)) { $conf['mysql']['master_host'] = $tmp_mysql_server_host; + $conf['mysql']['master_port'] = $tmp_mysql_server_port; $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; @@ -440,10 +559,8 @@ if($install_mode == 'standard') { // 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"]; + $inst->dbmaster->setDBData($conf['mysql']["master_host"], $conf['mysql']["master_admin_user"], $conf['mysql']["master_admin_password"]); + $inst->dbmaster->setDBName($conf['mysql']["master_database"]); } else { // the master DB is the same then the slave DB @@ -453,11 +570,17 @@ if($install_mode == 'standard') { //* Create the mysql database $inst->configure_database(); + //* Check for Web-Server + if($conf['apache']['installed'] != true && $conf['nginx']['installed'] != true) { + $conf['apache']['installed'] = $inst->force_configure_app('Apache'); + $conf['nginx']['installed'] = $inst->force_configure_app('nginx'); + } //* 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'); if($http_server_to_use == 'apache'){ $conf['nginx']['installed'] = false; + $conf['services']['file'] = true; } else { $conf['apache']['installed'] = false; } @@ -472,44 +595,73 @@ if($install_mode == 'standard') { $conf['services']['mail'] = true; + //* Configure Postgrey + $force = @($conf['postgrey']['installed']) ? true : $inst->force_configure_app('Postgrey'); + if($force) swriteln('Configuring Postgrey'); + //* Configure Postfix - swriteln('Configuring Postfix'); - $inst->configure_postfix(); + $force = @($conf['postfix']['installed']) ? true : $inst->force_configure_app('Postfix'); + if($force) { + swriteln('Configuring Postfix'); + $inst->configure_postfix(); + } //* Configure Mailman - swriteln('Configuring Mailman'); - $inst->configure_mailman(); + $force = @($conf['mailman']['installed']) ? true : $inst->force_configure_app('Mailman'); + if($force) { + swriteln('Configuring Mailman'); + $inst->configure_mailman(); + } - if($conf['dovecot']['installed'] == true) { - //* Configure dovecot + //* Check for Dovecot and Courier + if(!$conf['dovecot']['installed'] && !$conf['courier']['installed']) { + $conf['dovecot']['installed'] = $inst->force_configure_app('Dovecot'); + $conf['courier']['installed'] = $inst->force_configure_app('Courier'); + } + //* Configure Mailserver - Dovecot or Courier + if($conf['dovecot']['installed'] && $conf['courier']['installed']) { + $mail_server_to_use = $inst->simple_query('Dovecot and Courier detected. Select server to use with ISPConfig:', array('dovecot', 'courier'), 'dovecot','mail_server'); + if($mail_server_to_use == 'dovecot'){ + $conf['courier']['installed'] = false; + } else { + $conf['dovecot']['installed'] = false; + } + } + //* Configure Dovecot + if($conf['dovecot']['installed']) { swriteln('Configuring Dovecot'); $inst->configure_dovecot(); - } else { - - //* Configure saslauthd + } + //* Configure Courier + if($conf['courier']['installed']) { + swriteln('Configuring Courier'); + $inst->configure_courier(); swriteln('Configuring SASL'); $inst->configure_saslauthd(); - - //* Configure PAM swriteln('Configuring PAM'); $inst->configure_pam(); - - //* Configure courier - swriteln('Configuring Courier'); - $inst->configure_courier(); } //* Configure Spamasassin - swriteln('Configuring Spamassassin'); - $inst->configure_spamassassin(); - + $force = @($conf['spamassassin']['installed']) ? true : $inst->force_configure_app('Spamassassin'); + if($force) { + swriteln('Configuring Spamassassin'); + $inst->configure_spamassassin(); + } + //* Configure Amavis - swriteln('Configuring Amavisd'); - $inst->configure_amavis(); + $force = @($conf['amavis']['installed']) ? true : $inst->force_configure_app('Amavisd'); + if($force) { + swriteln('Configuring Amavisd'); + $inst->configure_amavis(); + } //* Configure Getmail - swriteln('Configuring Getmail'); - $inst->configure_getmail(); + $force = @($conf['getmail']['installed']) ? true : $inst->force_configure_app('Getmail'); + if($force) { + 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')); @@ -526,118 +678,122 @@ if($install_mode == 'standard') { 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','configure_jailkit') ) == 'y') { + //* Configure Jailkit + $force = @($conf['jailkit']['installed']) ? true : $inst->force_configure_app('Jailkit'); + if($force) { swriteln('Configuring Jailkit'); $inst->configure_jailkit(); } - //** Configure Pureftpd - if(strtolower($inst->simple_query('Configure FTP Server', array('y', 'n'), 'y','configure_ftp') ) == 'y') { + //* Configure Pureftpd + $force = @($conf['pureftpd']['installed']) ? true : $inst->force_configure_app('pureftpd'); + if($force) { 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','configure_dns')) == 'y') { $conf['services']['dns'] = true; - //* Configure DNS - if($conf['powerdns']['installed'] == true) { + + //* Check for DNS + if(!$conf['powerdns']['installed'] && !$conf['bind']['installed'] && !$conf['mydns']['installed']) { + $conf['powerdns']['installed'] = $inst->force_configure_app('PowerDNS'); + $conf['bind']['installed'] = $inst->force_configure_app('BIND'); + $conf['mydns']['installed'] = $inst->force_configure_app('MyDNS'); + } + //* Configure PowerDNS + if($conf['powerdns']['installed']) { swriteln('Configuring PowerDNS'); $inst->configure_powerdns(); - if($conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null'); - } elseif($conf['bind']['installed'] == true) { + $conf['services']['dns'] = true; + } + //* Configure Bind + if($conf['bind']['installed']) { swriteln('Configuring BIND'); $inst->configure_bind(); - if($conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null'); - } else { + $conf['services']['dns'] = true; + } + //* Configure MyDNS + if($conf['mydns']['installed']) { swriteln('Configuring MyDNS'); $inst->configure_mydns(); - if($conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null'); + $conf['services']['dns'] = true; } } - /* - //** Configure Squid - 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'); - $inst->configure_squid(); - if($conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script']))system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); - } else if($conf['nginx']['installed'] == true) { - $conf['services']['proxy'] = true; - swriteln('Configuring Nginx'); - $inst->configure_nginx(); - if($conf['nginx']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['nginx']['init_script']))system($conf['init_scripts'].'/'.$conf['nginx']['init_script'].' restart &> /dev/null'); - } - } - */ + if(strtolower($inst->simple_query('Configure Web Server', array('y', 'n'), 'y','configure_webserver')) == 'y') { + $conf['services']['web'] = true; - //** 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','configure_apache')) == 'y') { - $conf['services']['web'] = true; + //* Configure Apache + if($conf['apache']['installed']){ 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(); + $conf['services']['file'] = true; + //* Configure Vlogger + $force = @($conf['vlogger']['installed']) ? true : $inst->force_configure_app('vlogger'); + if($force) { + swriteln('Configuring vlogger'); + $inst->configure_vlogger(); + } + //* Configure squid +/* + $force = @($conf['squid']['installed']) ? true : $inst->force_configure_app('squid'); + if($force) { + swriteln('Configuring Squid'); + $inst->configure_squid(); + $conf['services']['proxy'] = true; + if($conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script']))system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null'); + } +*/ } - } - - //** 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','configure_nginx')) == 'y') { - $conf['services']['web'] = true; + //* Configure nginx + if($conf['nginx']['installed']){ 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($conf['openvz']['installed'] = true && strtolower($inst->simple_query('Enable Openvz-Server', array('y', 'n'), 'y','configure_openvz')) == 'y') + $conf['services']['vserver'] = true; + if(strtolower($inst->simple_query('Configure Firewall Server', array('y', 'n'), 'y','configure_firewall')) == 'y') { - //if($conf['bastille']['installed'] == true) { - //* Configure Bastille Firewall - $conf['services']['firewall'] = true; - swriteln('Configuring Bastille Firewall'); - $inst->configure_firewall(); - /*} elseif($conf['ufw']['installed'] == true) { - //* Configure Ubuntu Firewall - $conf['services']['firewall'] = true; + //* Check for Firewall + if(!$conf['ufw']['installed'] && !$conf['firewall']['installed']) { + $conf['ufw']['installed'] = $inst->force_configure_app('Ubuntu Firewall'); + $conf['firewall']['installed'] = $inst->force_configure_app('Bastille Firewall'); + } + //* Configure Firewall - Ubuntu or Bastille + if($conf['ufw']['installed'] && $conf['firewall']['installed']) { + $firewall_to_use = $inst->simple_query('Ubuntu and Bastille Firewall detected. Select firewall to use with ISPConfig:', array('bastille', 'ubuntu'), 'bastille','firewall_server'); + if($firewall_to_use == 'bastille'){ + $conf['ufw']['installed'] = false; + } else { + $conf['firewall']['installed'] = false; + } + } + //* Configure Ubuntu Firewall + if($conf['ufw']['installed']){ swriteln('Configuring Ubuntu Firewall'); $inst->configure_ufw_firewall(); - } else { - //* Configure Bastille Firewall $conf['services']['firewall'] = true; + } + //* Configure Bastille Firewall + if($conf['firewall']['installed']){ swriteln('Configuring Bastille Firewall'); $inst->configure_bastille_firewall(); + $conf['services']['firewall'] = true; } - */ } - //** Configure Firewall - /*if(strtolower($inst->simple_query('Configure Firewall Server',array('y','n'),'y')) == 'y') { - swriteln('Configuring Firewall'); - $inst->configure_firewall(); - }*/ + //* Configure XMPP + $force = @($conf['xmpp']['installed']) ? true : $inst->force_configure_app('Metronome XMPP Server'); + if($force) { + swriteln('Configuring Metronome XMPP Server'); + $inst->configure_xmpp(); + $conf['services']['xmpp'] = true; + } //** Configure ISPConfig :-) $install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y'; @@ -660,6 +816,18 @@ if($install_mode == 'standard') { //** Customise the port ISPConfig runs on $ispconfig_vhost_port = $inst->free_query('ISPConfig Port', '8080','ispconfig_port'); + $conf['interface_password'] = $inst->free_query('Admin password', 'admin'); + if($conf['interface_password'] != 'admin') { + $check = false; + do { + unset($temp_password); + $temp_password = $inst->free_query('Re-enter admin password', ''); + $check = @($temp_password == $conf['interface_password'])?true:false; + if(!$check) swriteln('Passwords do not match.'); + } while (!$check); + } + unset($check); + unset($temp_password); 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); @@ -694,6 +862,8 @@ if($install_mode == 'standard') { } //* << $install_mode / 'Standard' or Genius +$inst->create_mount_script(); + //* Create md5 filelist $md5_filename = '/usr/local/ispconfig/security/data/file_checksums_'.date('Y-m-d_h-i').'.md5'; exec('find /usr/local/ispconfig -type f -print0 | xargs -0 md5sum > '.$md5_filename); @@ -703,4 +873,4 @@ chmod($md5_filename,0700); echo "Installation completed.\n"; -?> +?> \ No newline at end of file diff --git a/install/lib/install.lib.php b/install/lib/install.lib.php index 9bd0e1d2bfdc69ef7aeddff9fd53506819b49500..f17b9827926763d531d1c0881b5f6138df7594a8 100644 --- a/install/lib/install.lib.php +++ b/install/lib/install.lib.php @@ -86,6 +86,9 @@ function get_distname() { $mainver = array_filter($mainver); $mainver = current($mainver).'.'.next($mainver); switch ($mainver){ + case "15.04": + $relname = "(Vivid Vervet)"; + break; case "14.10": $relname = "(Utopic Unicorn)"; break; @@ -178,6 +181,12 @@ function get_distname() { $distid = 'debian60'; $distbaseid = 'debian'; swriteln("Operating System: Debian 7.0 (Wheezy/Sid) or compatible\n"); + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '8') || substr(trim(file_get_contents('/etc/debian_version')),0,1) == '8') { + $distname = 'Debian'; + $distver = 'Jessie'; + $distid = 'debian60'; + $distbaseid = 'debian'; + swriteln("Operating System: Debian 8.0 (Jessie) or compatible\n"); } else { $distname = 'Debian'; $distver = 'Unknown'; diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 9137a41d1cdc617521e4b22773cb30b7b1821ac7..f867f04df8f1773d18190ede7889b0a75cb75a54 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -135,7 +135,8 @@ class installer_base { if(is_installed('mysql') || is_installed('mysqld')) $conf['mysql']['installed'] = true; if(is_installed('postfix')) $conf['postfix']['installed'] = true; - if(is_installed('mailman')) $conf['mailman']['installed'] = true; + if(is_installed('postgrey')) $conf['postgrey']['installed'] = true; + if(is_installed('mailman') || is_installed('mmsitepass')) $conf['mailman']['installed'] = true; if(is_installed('apache') || is_installed('apache2') || is_installed('httpd') || is_installed('httpd2')) $conf['apache']['installed'] = true; if(is_installed('getmail')) $conf['getmail']['installed'] = true; if(is_installed('courierlogger')) $conf['courier']['installed'] = true; @@ -153,11 +154,26 @@ class installer_base { if(is_installed('iptables') && is_installed('ufw')) $conf['ufw']['installed'] = true; if(is_installed('fail2ban-server')) $conf['fail2ban']['installed'] = true; if(is_installed('vzctl')) $conf['openvz']['installed'] = true; - if(is_dir("/etc/Bastille")) $conf['bastille']['installed'] = true; + if(is_installed('iptables') && is_installed('bastille-netfilter')) $conf['bastille']['installed'] = true; + if(is_installed('metronome') && is_installed('metronomectl')) $conf['xmpp']['installed'] = true; + if(is_installed('spamassassin')) $conf['spamassasin']['installed'] = true; + if(is_installed('vlogger')) $conf['vlogger']['installed'] = true; + if(is_installed('cron')) $conf['cron']['installed'] = true; if ($conf['services']['web'] && (($conf['apache']['installed'] && is_file($conf['apache']["vhost_conf_enabled_dir"]."/000-ispconfig.vhost")) || ($conf['nginx']['installed'] && is_file($conf['nginx']["vhost_conf_enabled_dir"]."/000-ispconfig.vhost")))) $this->ispconfig_interface_installed = true; } + public function force_configure_app($service) { + $force = false; + swriteln("[WARN] autodetect for $service failed"); + if(strtolower($this->simple_query("Force configure $service", array('y', 'n'), 'n') ) == 'y') { +// swriteln("Configure $service"); + $force = true; + } else swriteln("Skipping $service\n"); + return $force; + } + + /** Create the database for ISPConfig */ @@ -165,12 +181,12 @@ class installer_base { global $conf; //** Create the database - if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['mysql']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) { + if(!$this->db->query('CREATE DATABASE IF NOT EXISTS ?? DEFAULT CHARACTER SET ?', $conf['mysql']['database'], $conf['mysql']['charset'])) { $this->error('Unable to create MySQL database: '.$conf['mysql']['database'].'.'); } //* Set the database name in the DB library - $this->db->dbName = $conf['mysql']['database']; + $this->db->setDBName($conf['mysql']['database']); //* Load the database dump into the database, if database contains no tables $db_tables = $this->db->getTables(); @@ -190,8 +206,8 @@ class installer_base { } //* Load system.ini into the sys_ini table - $system_ini = $this->db->quote(rf('tpl/system.ini.master')); - $this->db->query("UPDATE sys_ini SET config = '$system_ini' WHERE sysini_id = 1"); + $system_ini = rf('tpl/system.ini.master'); + $this->db->query("UPDATE sys_ini SET config = ? WHERE sysini_id = 1", $system_ini); } } @@ -208,15 +224,13 @@ class installer_base { } // Delete ISPConfig user in the local database, in case that it exists - $this->db->query("DELETE FROM mysql.user WHERE User = '".$conf['mysql']['ispconfig_user']."' AND Host = '".$from_host."';"); - $this->db->query("DELETE FROM mysql.db WHERE Db = '".$conf['mysql']['database']."' AND Host = '".$from_host."';"); - $this->db->query('FLUSH PRIVILEGES;'); + $this->db->query("DELETE FROM mysql.user WHERE User = ? AND Host = ?", $conf['mysql']['ispconfig_user'], $from_host); + $this->db->query("DELETE FROM mysql.db WHERE Db = ? AND Host = ?", $conf['mysql']['database'], $from_host); + $this->db->query('FLUSH PRIVILEGES'); //* Create the ISPConfig database user in the local database - $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$conf['mysql']['database'].".* " - ."TO '".$conf['mysql']['ispconfig_user']."'@'".$from_host."' " - ."IDENTIFIED BY '".$conf['mysql']['ispconfig_password']."';"; - if(!$this->db->query($query)) { + $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON ?? TO ?@? IDENTIFIED BY ?'; + if(!$this->db->query($query, $conf['mysql']['database'] . ".*", $conf['mysql']['ispconfig_user'], $from_host, $conf['mysql']['ispconfig_password'])) { $this->error('Unable to create database user: '.$conf['mysql']['ispconfig_user'].' Error: '.$this->db->errorMessage); } @@ -224,7 +238,7 @@ class installer_base { $this->db->query('FLUSH PRIVILEGES;'); //* Set the database name in the DB library - $this->db->dbName = $conf['mysql']['database']; + $this->db->setDBName($conf['mysql']['database']); $tpl_ini_array = ini_to_array(rf('tpl/server.ini.master')); @@ -278,8 +292,7 @@ class installer_base { } $server_ini_content = array_to_ini($tpl_ini_array); - $server_ini_content = mysql_real_escape_string($server_ini_content); - + $mail_server_enabled = ($conf['services']['mail'])?1:0; $web_server_enabled = ($conf['services']['web'])?1:0; $dns_server_enabled = ($conf['services']['dns'])?1:0; @@ -307,14 +320,14 @@ class installer_base { if($conf['mysql']['master_slave_setup'] == 'y') { //* Insert the server record in master DB - $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version, $proxy_server_enabled, $firewall_server_enabled);"; - $this->dbmaster->query($sql); + $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES (1, 1, 'riud', 'riud', 'r', ?, ?, ?, ?, ?, ?, ?, ?, 0, 1, ?, ?, ?);"; + $this->dbmaster->query($sql, $conf['hostname'], $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $server_ini_content, $current_db_version, $proxy_server_enabled, $firewall_server_enabled); $conf['server_id'] = $this->dbmaster->insertID(); $conf['server_id'] = $conf['server_id']; //* Insert the same record in the local DB - $sql = "INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES ('".$conf['server_id']."',1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version, $proxy_server_enabled, $firewall_server_enabled);"; - $this->db->query($sql); + $sql = "INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES (?,1, 1, 'riud', 'riud', 'r', ?, ?, ?, ?, ?, ?, ?, 0, 1, ?, ?, ?);"; + $this->db->query($sql, $conf['server_id'], $conf['hostname'], $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $server_ini_content, $current_db_version, $proxy_server_enabled, $firewall_server_enabled); //* username for the ispconfig user $conf['mysql']['master_ispconfig_user'] = 'ispcsrv'.$conf['server_id']; @@ -323,8 +336,8 @@ class installer_base { } else { //* Insert the server, if its not a mster / slave setup - $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES (1, 1, 'riud', 'riud', 'r', '".$conf['hostname']."', '$mail_server_enabled', '$web_server_enabled', '$dns_server_enabled', '$file_server_enabled', '$db_server_enabled', '$vserver_server_enabled', '$server_ini_content', 0, 1, $current_db_version, $proxy_server_enabled, $firewall_server_enabled);"; - $this->db->query($sql); + $sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`, `dbversion`,`firewall_server`,`proxy_server`) VALUES (1, 1, 'riud', 'riud', 'r', ?, ?, ?, ?, ?, ?, ?, ?, 0, 1, ?, ?, ?);"; + $this->db->query($sql, $conf['hostname'], $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $server_ini_content, $current_db_version, $proxy_server_enabled, $firewall_server_enabled); $conf['server_id'] = $this->db->insertID(); $conf['server_id'] = $conf['server_id']; } @@ -386,141 +399,141 @@ class installer_base { * 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'] . "'"; + $query = "CREATE USER ?@? IDENTIFIED BY ?"; if ($verbose){ echo "\n\n" . $query ."\n"; } - $this->dbmaster->query($query); // ignore the error + $this->dbmaster->query($query, $value['user'], $host, $value['pwd']); // 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."' "; + $query = "REVOKE ALL PRIVILEGES, GRANT OPTION FROM ?@?"; if ($verbose){ echo "\n\n" . $query ."\n"; } - $this->dbmaster->query($query); // ignore the error + $this->dbmaster->query($query, $value['user'], $host); // ignore the error //* Create the ISPConfig database user in the remote database - $query = "GRANT SELECT ON ".$value['db'].".`server` TO '".$value['user']."'@'".$host."' "; + $query = "GRANT SELECT ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.server', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, INSERT ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.sys_log', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, UPDATE(`status`, `error`) ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.sys_datalog', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, UPDATE(`status`) ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.software_update_inst', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, UPDATE(`updated`) ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.server', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, UPDATE (`ssl_request`, `ssl_cert`, `ssl_action`, `ssl_key`) ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.web_domain', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.sys_group', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, UPDATE (`action_state`, `response`) ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.sys_remoteaction', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, INSERT , DELETE ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.monitor_data', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, INSERT, UPDATE ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.mail_traffic', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, INSERT, UPDATE ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.web_traffic', $value['user'], $host)) { $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, DELETE ON ".$value['db'].".`aps_instances` TO '".$value['user']."'@'".$host."' "; + $query = "GRANT SELECT, UPDATE, DELETE ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.aps_instances', $value['user'], $host)) { $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage); } - $query = "GRANT SELECT, DELETE ON ".$value['db'].".`aps_instances_settings` TO '".$value['user']."'@'".$host."' "; + $query = "GRANT SELECT, DELETE ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.aps_instances_settings', $value['user'], $host)) { $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."' "; + $query = "GRANT SELECT, INSERT, DELETE ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.web_backup', $value['user'], $host)) { $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'].".`mail_backup` TO '".$value['user']."'@'".$host."' "; + $query = "GRANT SELECT, INSERT, DELETE ON ?? TO ?@?"; if ($verbose){ echo $query ."\n"; } - if(!$this->dbmaster->query($query)) { + if(!$this->dbmaster->query($query, $value['db'] . '.mail_backup', $value['user'], $host)) { $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage); } } @@ -528,7 +541,7 @@ class installer_base { /* * It is all done. Relod the rights... */ - $this->dbmaster->query('FLUSH PRIVILEGES;'); + $this->dbmaster->query('FLUSH PRIVILEGES'); } } @@ -692,6 +705,9 @@ class installer_base { //* mysql-virtual_sender.cf $this->process_postfix_config('mysql-virtual_sender.cf'); + //* mysql-virtual_sender_login_maps.cf + $this->process_postfix_config('mysql-virtual_sender_login_maps.cf'); + //* mysql-virtual_client.cf $this->process_postfix_config('mysql-virtual_client.cf'); @@ -704,6 +720,9 @@ class installer_base { //* mysql-virtual_outgoing_bcc.cf $this->process_postfix_config('mysql-virtual_outgoing_bcc.cf'); + //* mysql-virtual_policy_greylist.cf + $this->process_postfix_config('mysql-virtual_policy_greylist.cf'); + //* postfix-dkim $full_file_name=$config_dir.'/tag_as_originating.re'; if(is_file($full_file_name)) copy($full_file_name, $full_file_name.'~'); @@ -727,7 +746,7 @@ class installer_base { if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); //* These postconf commands will be executed on installation and update - $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM `" . $this->db->quote($conf["mysql"]["database"]) . "`.`server` WHERE server_id = ".$conf['server_id']); + $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . '.server', $conf['server_id']); $server_ini_array = ini_to_array(stripslashes($server_ini_rec['config'])); unset($server_ini_rec); @@ -740,13 +759,27 @@ class installer_base { } } unset($rbl_hosts); - unset($server_ini_array); + //* If Postgrey is installed, configure it + $greylisting = ''; + if($conf['postgrey']['installed'] == true) { + $greylisting = ', check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf'; + } + + $reject_sender_login_mismatch = ''; + if(isset($server_ini_array['mail']['reject_sender_login_mismatch']) && ($server_ini_array['mail']['reject_sender_login_mismatch'] == 'y')) { + $reject_sender_login_mismatch = ', reject_authenticated_sender_login_mismatch'; + } + 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); + '{rbl_list}' => $rbl_list, + '{greylisting}' => $greylisting, + '{reject_slm}' => $reject_sender_login_mismatch, + ); $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); @@ -841,7 +874,7 @@ class installer_base { caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); } - + public function configure_saslauthd() { global $conf; @@ -852,12 +885,12 @@ class installer_base { unset($parts); unset($out); - if(version_compare($saslversion , '2.1.23') > 0) { - //* Configfile for saslauthd versions 2.1.24 and newer - $configfile = 'sasl_smtpd2.conf'; - } else { + if(version_compare($saslversion , '2.1.23', '<=')) { //* Configfile for saslauthd versions up to 2.1.23 $configfile = 'sasl_smtpd.conf'; + } else { + //* Configfile for saslauthd versions 2.1.24 and newer + $configfile = 'sasl_smtpd2.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~'); @@ -935,6 +968,7 @@ class installer_base { $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_port}', $conf['mysql']['port'], $content); wf($config_dir.'/'.$configfile, $content); chmod($config_dir.'/'.$configfile, 0660); @@ -961,7 +995,7 @@ class installer_base { // check if virtual_transport must be changed if ($this->is_update) { - $tmp = $this->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); + $tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); $ini_array = ini_to_array(stripslashes($tmp['config'])); // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() @@ -1019,22 +1053,22 @@ class installer_base { unset($tmp); //* Copy dovecot configuration file - if(version_compare($dovecot_version,2) >= 0) { + if(version_compare($dovecot_version,1, '<=')) { //* Dovecot 1.x + 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); + } + } else { //* Dovecot 2.x 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); } replaceLine($config_dir.'/'.$configfile, 'postmaster_address = postmaster@example.com', 'postmaster_address = postmaster@'.$conf['hostname'], 1, 0); - if(version_compare($dovecot_version,2.1) < 0) { + if(version_compare($dovecot_version, 2.1, '<')) { removeLine($config_dir.'/'.$configfile, 'ssl_protocols ='); } - } 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); - } } //* dovecot-sql.conf @@ -1048,6 +1082,7 @@ class installer_base { $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_port}', $conf['mysql']['port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); wf($config_dir.'/'.$configfile, $content); @@ -1066,7 +1101,7 @@ 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~')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user~', 0400); + if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user~')) chmod($conf['amavis']['config_dir'].'/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); @@ -1074,6 +1109,7 @@ class installer_base { $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); + chmod($conf['amavis']['config_dir'].'/conf.d/50-user', 0640); // TODO: chmod and chown on the config file @@ -1225,6 +1261,7 @@ class installer_base { $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_port}', $conf['mysql']['port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); wf($conf['mydns']['config_dir'].'/'.$configfile, $content); chmod($conf['mydns']['config_dir'].'/'.$configfile, 0600); @@ -1237,18 +1274,18 @@ class installer_base { global $conf; //* Create the database - if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$conf['powerdns']['database'].' DEFAULT CHARACTER SET '.$conf['mysql']['charset'])) { + if(!$this->db->query('CREATE DATABASE IF NOT EXISTS ?? DEFAULT CHARACTER SET ?', $conf['powerdns']['database'], $conf['mysql']['charset'])) { $this->error('Unable to create MySQL database: '.$conf['powerdns']['database'].'.'); } //* Create the ISPConfig database user in the local database - $query = "GRANT ALL ON `".$conf['powerdns']['database']."` . * TO '".$conf['mysql']['ispconfig_user']."'@'localhost';"; - if(!$this->db->query($query)) { + $query = "GRANT ALL ON ?? TO ?@'localhost'"; + if(!$this->db->query($query, $conf['powerdns']['database'] . '.*', $conf['mysql']['ispconfig_user'])) { $this->error('Unable to create user for powerdns database Error: '.$this->db->errorMessage); } //* Reload database privelages - $this->db->query('FLUSH PRIVILEGES;'); + $this->db->query('FLUSH PRIVILEGES'); //* load the powerdns databse dump if($conf['mysql']['admin_password'] == '') { @@ -1268,6 +1305,7 @@ class installer_base { $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); + $content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content); wf($conf['powerdns']['config_dir'].'/'.$configfile, $content); chmod($conf['powerdns']['config_dir'].'/'.$configfile, 0600); chown($conf['powerdns']['config_dir'].'/'.$configfile, 'root'); @@ -1287,15 +1325,135 @@ class installer_base { //* Create the slave subdirectory $content .= 'slave'; - if(!@is_dir($content)) mkdir($content, 0770, true); + if(!@is_dir($content)) mkdir($content, 2770, true); //* Chown the slave subdirectory to $conf['bind']['bind_user'] chown($content, $conf['bind']['bind_user']); chgrp($content, $conf['bind']['bind_group']); + chmod($content, 2770); } + public function configure_xmpp($options = '') { + global $conf; + + if($conf['xmpp']['installed'] == false) return; + //* Create the logging directory for xmpp server + if(!@is_dir('/var/log/metronome')) mkdir('/var/log/metronome', 0755, true); + chown('/var/log/metronome', 'metronome'); + if(!@is_dir('/var/run/metronome')) mkdir('/var/run/metronome', 0755, true); + chown('/var/run/metronome', 'metronome'); + if(!@is_dir('/var/lib/metronome')) mkdir('/var/lib/metronome', 0755, true); + chown('/var/lib/metronome', 'metronome'); + if(!@is_dir('/etc/metronome/hosts')) mkdir('/etc/metronome/hosts', 0755, true); + if(!@is_dir('/etc/metronome/status')) mkdir('/etc/metronome/status', 0755, true); + unlink('/etc/metronome/metronome.cfg.lua'); + + $row = $this->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $conf["server_id"]); + $server_name = $row["server_name"]; + + $tpl = new tpl('metronome_conf_main.master'); + wf('/etc/metronome/metronome.cfg.lua', $tpl->grab()); + unset($tpl); + + $tpl = new tpl('metronome_conf_global.master'); + $tpl->setVar('xmpp_admins',''); + wf('/etc/metronome/global.cfg.lua', $tpl->grab()); + unset($tpl); + + // Copy isp libs + if(!@is_dir('/usr/lib/metronome/isp-modules')) mkdir('/usr/lib/metronome/isp-modules', 0755, true); + caselog('cp -rf apps/metronome_libs/* /usr/lib/metronome/isp-modules/', __FILE__, __LINE__); + // Process db config + $full_file_name = '/usr/lib/metronome/isp-modules/mod_auth_external/db_conf.inc.php'; + $content = rf($full_file_name); + $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); + $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); + $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); + $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); + $content = str_replace('{server_id}', $conf['server_id'], $content); + wf($full_file_name, $content); + + if(!stristr($options, 'dont-create-certs')){ + // Create SSL Certificate for localhost + echo "writing new private key to 'localhost.key'\n-----\n"; + $ssl_country = $this->free_query('Country Name (2 letter code)', 'AU'); + $ssl_locality = $this->free_query('Locality Name (eg, city)', ''); + $ssl_organisation = $this->free_query('Organization Name (eg, company)', 'Internet Widgits Pty Ltd'); + $ssl_organisation_unit = $this->free_query('Organizational Unit Name (eg, section)', ''); + $ssl_domain = $this->free_query('Common Name (e.g. server FQDN or YOUR name)', $conf['hostname']); + $ssl_email = $this->free_query('Email Address', ''); + + $tpl = new tpl('metronome_conf_ssl.master'); + $tpl->setVar('ssl_country',$ssl_country); + $tpl->setVar('ssl_locality',$ssl_locality); + $tpl->setVar('ssl_organisation',$ssl_organisation); + $tpl->setVar('ssl_organisation_unit',$ssl_organisation_unit); + $tpl->setVar('domain',$ssl_domain); + $tpl->setVar('ssl_email',$ssl_email); + wf('/etc/metronome/certs/localhost.cnf', $tpl->grab()); + unset($tpl); + // Generate new key, csr and cert + exec("(cd /etc/metronome/certs && make localhost.key)"); + exec("(cd /etc/metronome/certs && make localhost.csr)"); + exec("(cd /etc/metronome/certs && make localhost.cert)"); + exec('chmod 0400 /etc/metronome/certs/localhost.key'); + exec('chown metronome /etc/metronome/certs/localhost.key'); + }else{ + echo "-----\n"; + echo "Metronome XMPP SSL server certificate is not renewed. Run the following command manual as root to recreate it:\n"; + echo "# (cd /etc/metronome/certs && make localhost.key && make localhost.csr && make localhost.cert && chmod 0400 localhost.key && chown metronome localhost.key)\n"; + echo "-----\n"; + } + + // Copy init script + caselog('cp -f apps/metronome-init /etc/init.d/metronome', __FILE__, __LINE__); + caselog('chmod u+x /etc/init.d/metronome', __FILE__, __LINE__); + caselog('update-rc.d metronome defaults', __FILE__, __LINE__); + + exec($this->getinitcommand('xmpp', 'restart')); + +/* +writing new private key to 'smtpd.key' +----- +You are about to be asked to enter information that will be incorporated +into your certificate request. +What you are about to enter is what is called a Distinguished Name or a DN. +There are quite a few fields but you can leave some blank +For some fields there will be a default value, +If you enter '.', the field will be left blank. +----- +Country Name (2 letter code) [AU]: +State or Province Name (full name) [Some-State]: +Locality Name (eg, city) []: +Organization Name (eg, company) [Internet Widgits Pty Ltd]: +Organizational Unit Name (eg, section) []: +Common Name (e.g. server FQDN or YOUR name) []: +Email Address []: + * */ + + /*// Dont just copy over the virtualhost template but add some custom settings + $tpl = new tpl('apache_apps.vhost.master'); + + $tpl->setVar('apps_vhost_port',$conf['web']['apps_vhost_port']); + $tpl->setVar('apps_vhost_dir',$conf['web']['website_basedir'].'/apps'); + $tpl->setVar('apps_vhost_basedir',$conf['web']['website_basedir']); + $tpl->setVar('apps_vhost_servername',$apps_vhost_servername); + $tpl->setVar('apache_version',getapacheversion()); + + + // 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) { + $tpl->setVar('vhost_port_listen','#'); + } else { + $tpl->setVar('vhost_port_listen',''); + } + + wf($vhost_conf_dir.'/apps.vhost', $tpl->grab()); + unset($tpl);*/ + } + public function configure_apache() { global $conf; @@ -1351,7 +1509,7 @@ class installer_base { $tpl = new tpl('apache_ispconfig.conf.master'); $tpl->setVar('apache_version',getapacheversion()); - $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + $records = $this->db->queryAllRecords("SELECT * FROM ?? WHERE server_id = ? AND virtualhost = 'y'", $conf['mysql']['master_database'] . '.server_ip', $conf['server_id']); $ip_addresses = array(); if(is_array($records) && count($records) > 0) { @@ -1434,36 +1592,6 @@ class installer_base { //* 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"); - - /* - $row = $this->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$conf["server_id"].""); - $ip_address = gethostbyname($row["server_name"]); - $server_name = $row["server_name"]; - - //setup proxy.conf - $configfile = 'proxy.conf'; - if(is_file($conf["nginx"]["config_dir"].'/'.$configfile)) copy($conf["nginx"]["config_dir"].'/'.$configfile,$conf["nginx"]["config_dir"].'/'.$configfile.'~'); - if(is_file($conf["nginx"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["nginx"]["config_dir"].'/'.$configfile.'~'); - $content = rf("tpl/nginx_".$configfile.".master"); - wf($conf["nginx"]["config_dir"].'/'.$configfile,$content); - exec('chmod 600 '.$conf["nginx"]["config_dir"].'/'.$configfile); - exec('chown root:root '.$conf["nginx"]["config_dir"].'/'.$configfile); - - //setup conf.d/cache.conf - $configfile = 'cache.conf'; - if(is_file($conf["nginx"]["config_dir"].'/conf.d/'.$configfile)) copy($conf["nginx"]["config_dir"].'/conf.d/'.$configfile,$conf["nginx"]["config_dir"].'/conf.d/'.$configfile.'~'); - if(is_file($conf["nginx"]["config_dir"].'/conf.d/'.$configfile.'~')) exec('chmod 400 '.$conf["nginx"]["config_dir"].'/conf.d/'.$configfile.'~'); - $content = rf("tpl/nginx_".$configfile.".master"); - wf($conf["nginx"]["config_dir"].'/conf.d/'.$configfile,$content); - exec('chmod 600 '.$conf["nginx"]["config_dir"].'/conf.d/'.$configfile); - exec('chown root:root '.$conf["nginx"]["config_dir"].'/conf.d/'.$configfile); - - //setup cache directories - mkdir('/var/cache/nginx/cache'); - exec('chown www-data:www-data /var/cache/nginx/cache'); - mkdir('/var/cache/nginx/temp'); - exec('chown www-data:www-data /var/cache/nginx/temp'); - */ } public function configure_fail2ban() { @@ -1473,7 +1601,7 @@ class installer_base { public function configure_squid() { global $conf; - $row = $this->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$conf["server_id"].""); + $row = $this->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $conf["server_id"]); $ip_address = gethostbyname($row["server_name"]); $server_name = $row["server_name"]; @@ -1520,7 +1648,7 @@ class installer_base { $tcp_public_services = ''; $udp_public_services = ''; - $row = $this->db->queryOneRecord('SELECT * FROM '.$conf["mysql"]["database"].'.firewall WHERE server_id = '.intval($conf['server_id'])); + $row = $this->db->queryOneRecord('SELECT * FROM ?? WHERE server_id = ?', $conf["mysql"]["database"] . '.firewall', $conf['server_id']); if(trim($row['tcp_port']) != '' || trim($row['udp_port']) != '') { $tcp_public_services = trim(str_replace(',', ' ', $row['tcp_port'])); @@ -1532,7 +1660,7 @@ class installer_base { 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'])); + if($row['tcp_port'] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ? WHERE server_id = ?", ',' . intval($conf['apache']['vhost_port']), $conf['server_id']); } $content = str_replace('{TCP_PUBLIC_SERVICES}', $tcp_public_services, $content); @@ -1843,11 +1971,13 @@ class installer_base { $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_port}', $conf['mysql']['port'], $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('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); @@ -1868,11 +1998,13 @@ class installer_base { $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_port}', $conf['mysql']['port'], $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('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); $content = str_replace('{server_id}', $conf['server_id'], $content); $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); @@ -1957,14 +2089,13 @@ class installer_base { $vserver_server_enabled = ($conf['openvz']['installed'])?1:0; $proxy_server_enabled = ($conf['services']['proxy'])?1:0; $firewall_server_enabled = ($conf['services']['firewall'])?1:0; + $xmpp_server_enabled = ($conf['services']['xmpp'])?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', proxy_server = '$proxy_server_enabled', firewall_server = '$firewall_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', proxy_server = '$proxy_server_enabled', firewall_server = '$firewall_server_enabled', xmpp_server = '.$xmpp_server_enabled.' WHERE server_id = ?"; + $this->db->query($sql, $conf['server_id']); if($conf['mysql']['master_slave_setup'] == 'y') { - $this->dbmaster->query($sql); - $this->db->query($sql); - } else { - $this->db->query($sql); + $this->dbmaster->query($sql, $conf['server_id']); } @@ -2079,6 +2210,11 @@ class installer_base { $command = "chmod +x $install_dir/server/scripts/*.sh"; caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); + if ($this->install_ispconfig_interface == true && isset($conf['interface_password']) && $conf['interface_password']!='admin') { + $sql = "UPDATE sys_user SET passwort = md5(?) WHERE username = 'admin';"; + $this->db->query($sql, $conf['interface_password']); + } + if($conf['apache']['installed'] == true && $this->install_ispconfig_interface == true){ //* Copy the ISPConfig vhost for the controlpanel $vhost_conf_dir = $conf['apache']['vhost_conf_dir']; @@ -2254,6 +2390,11 @@ class installer_base { // Add symlink for patch tool if(!is_link('/usr/local/bin/ispconfig_patch')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_patch /usr/local/bin/ispconfig_patch'); + // Change mode of a few files from amavisd + if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user', 0640); + if(is_file($conf['amavis']['config_dir'].'/50-user~')) chmod($conf['amavis']['config_dir'].'/50-user~', 0400); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf')) chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf~')) chmod($conf['amavis']['config_dir'].'/amavisd.conf~', 0400); } public function configure_dbserver() { @@ -2343,6 +2484,32 @@ class installer_base { } + public function create_mount_script(){ + global $app, $conf; + $mount_script = '/usr/local/ispconfig/server/scripts/backup_dir_mount.sh'; + $mount_command = ''; + + if(is_file($mount_script)) return; + if(is_file('/etc/rc.local')){ + $rc_local = file('/etc/rc.local'); + if(is_array($rc_local) && !empty($rc_local)){ + foreach($rc_local as $line){ + $line = trim($line); + if(substr($line, 0, 1) == '#') continue; + if(strpos($line, 'sshfs') !== false && strpos($line, '/var/backup') !== false){ + $mount_command = "#!/bin/sh\n\n"; + $mount_command .= $line."\n\n"; + file_put_contents($mount_script, $mount_command); + chmod($mount_script, 0755); + chown($mount_script, 'root'); + chgrp($mount_script, 'root'); + break; + } + } + } + } + } + // This function is called at the end of the update process and contains code to clean up parts of old ISPCONfig releases public function cleanup_ispconfig() { global $app,$conf; @@ -2355,7 +2522,11 @@ class installer_base { if(is_file('/usr/local/ispconfig/interface/lib/classes/db_firebird.inc.php')) unlink('/usr/local/ispconfig/interface/lib/classes/db_firebird.inc.php'); if(is_file('/usr/local/ispconfig/interface/lib/classes/form.inc.php')) unlink('/usr/local/ispconfig/interface/lib/classes/form.inc.php'); - + // Change mode of a few files from amavisd + if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user', 0640); + if(is_file($conf['amavis']['config_dir'].'/50-user~')) chmod($conf['amavis']['config_dir'].'/50-user~', 0400); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf')) chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); + if(is_file($conf['amavis']['config_dir'].'/amavisd.conf~')) chmod($conf['amavis']['config_dir'].'/amavisd.conf~', 0400); } @@ -2487,6 +2658,7 @@ class installer_base { $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_port}', $conf["mysql"]["port"], $tContents); return $tContents; diff --git a/install/lib/mysql.lib.php b/install/lib/mysql.lib.php index c5c2a83a68681ac18a7c3036307c6f0b4423fa49..c6078ca2bbc05a2ede69c76fb6edfe50f9fa416c 100644 --- a/install/lib/mysql.lib.php +++ b/install/lib/mysql.lib.php @@ -1,190 +1,499 @@ _iConnId) mysqli_close($this->_iConnId); + } + + private function do_connect() { global $conf; + + if($this->_iConnId) return true; $this->dbHost = $conf["mysql"]["host"]; - //$this->dbName = $conf["mysql"]["database"]; + $this->dbName = false;//$conf["mysql"]["database"]; $this->dbUser = $conf["mysql"]["admin_user"]; $this->dbPass = $conf["mysql"]["admin_password"]; $this->dbCharset = $conf["mysql"]["charset"]; - //$this->connect(); - } + $this->dbNewLink = false; + $this->dbClientFlags = null; + + $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass); + $try = 0; + while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) { + if($try > 0) sleep(1); + + $try++; + $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass); + } - // error handler - function updateError($location) - { - $this->errorNumber = mysqli_errno($this->linkId); - $this->errorMessage = mysqli_error($this->linkId); - $this->errorLocation = $location; - if($this->errorNumber && $this->show_error_messages) - { - echo '
'.$this->errorLocation.'
'.$this->errorMessage; - flush(); + if(!is_object($this->_iConnId) || mysqli_connect_error()) { + $this->_iConnId = null; + $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!'); + return false; + } + + if($this->dbName) $this->setDBName($this->dbName); + + $this->_setCharset(); + } + + public function setDBData($host, $user, $password) { + $this->dbHost = $host; + $this->dbUser = $user; + $this->dbPass = $password; + } + + public function setDBName($name) { + $this->dbName = $name; + if(!((bool)mysqli_query( $this->_iConnId, 'USE `' . $this->dbName . '`'))) { + $this->close(); + $this->_sqlerror('Datenbank nicht gefunden / Database not found'); + return false; } } + + public function close() { + if($this->_iConnId) mysqli_close($this->_iConnId); + $this->_iConnId = null; + } - function connect() - { - if(!$this->linkId) - { - $this->linkId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass); + /* This allows our private variables to be "read" out side of the class */ + public function __get($var) { + return isset($this->$var) ? $this->$var : NULL; + } - if(!$this->linkId) - { - $this->updateError('DB::connect()
mysqli_connect'); - return false; + public function _build_query_string($sQuery = '') { + $iArgs = func_num_args(); + if($iArgs > 1) { + $aArgs = func_get_args(); + + if($iArgs == 3 && $aArgs[1] === true && is_array($aArgs[2])) { + $aArgs = $aArgs[2]; + $iArgs = count($aArgs); + } else { + array_shift($aArgs); // delete the query string that is the first arg! + } + + $iPos = 0; + $iPos2 = 0; + foreach($aArgs as $sKey => $sValue) { + $iPos2 = strpos($sQuery, '??', $iPos2); + $iPos = strpos($sQuery, '?', $iPos); + + if($iPos === false && $iPos2 === false) break; + + if($iPos2 !== false && ($iPos === false || $iPos2 <= $iPos)) { + $sTxt = $this->escape($sValue); + + if(strpos($sTxt, '.') !== false) { + $sTxt = preg_replace('/^(.+)\.(.+)$/', '`$1`.`$2`', $sTxt); + $sTxt = str_replace('.`*`', '.*', $sTxt); + } else $sTxt = '`' . $sTxt . '`'; + + $sQuery = substr_replace($sQuery, $sTxt, $iPos2, 2); + $iPos2 += strlen($sTxt); + $iPos = $iPos2; + } else { + if(is_int($sValue) || is_float($sValue)) { + $sTxt = $sValue; + } elseif(is_string($sValue) && (strcmp($sValue, '#NULL#') == 0)) { + $sTxt = 'NULL'; + } elseif(is_array($sValue)) { + $sTxt = ''; + foreach($sValue as $sVal) $sTxt .= ',\'' . $this->escape($sVal) . '\''; + $sTxt = '(' . substr($sTxt, 1) . ')'; + if($sTxt == '()') $sTxt = '(0)'; + } else { + $sTxt = '\'' . $this->escape($sValue) . '\''; + } + + $sQuery = substr_replace($sQuery, $sTxt, $iPos, 1); + $iPos += strlen($sTxt); + $iPos2 = $iPos; + } } - $this->queryId = @mysqli_query($this->linkId, 'SET NAMES '.$this->dbCharset); } - return true; + + return $sQuery; } - function query($queryString) - { - if(!$this->connect()) - { + /**#@-*/ + + + /**#@+ + * @access private + */ + private function _setCharset() { + mysqli_query($this->_iConnId, 'SET NAMES '.$this->dbCharset); + mysqli_query($this->_iConnId, "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."'"); + } + + private function _query($sQuery = '') { + $this->do_connect(); + + if ($sQuery == '') { + $this->_sqlerror('Keine Anfrage angegeben / No query given'); return false; } - if($this->dbName != '') { - if(!mysqli_select_db($this->linkId, $this->dbName)) - { - $this->updateError('DB::connect()
mysqli_select_db'); - return false; + + $try = 0; + do { + $try++; + $ok = mysqli_ping($this->_iConnId); + if(!$ok) { + if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) { + if($this->errorNumber == '111') { + // server is not available + if($try > 9) { + $this->_sqlerror('DB::query -> error connecting'); + exit; + } + sleep(30); // additional seconds, please! + } + + if($try > 9) { + $this->_sqlerror('DB::query -> reconnect'); + return false; + } else { + sleep(($try > 7 ? 5 : 1)); + } + } else { + $this->_setCharset(); + $ok = true; + } } - } - $this->queryId = @mysqli_query($this->linkId, $queryString); - $this->updateError('DB::query('.$queryString.')
mysqli_query'); - if(!$this->queryId) - { + } while($ok == false); + + $aArgs = func_get_args(); + $sQuery = call_user_func_array(array(&$this, '_build_query_string'), $aArgs); + + $this->_iQueryId = mysqli_query($this->_iConnId, $sQuery); + if (!$this->_iQueryId) { + $this->_sqlerror('Falsche Anfrage / Wrong Query', false, 'SQL-Query = ' . $sQuery); return false; } - $this->currentRow = 0; - return $this->queryId; + + return is_bool($this->_iQueryId) ? $this->_iQueryId : new db_result($this->_iQueryId, $this->_iConnId); } - // returns all records in an array - function queryAllRecords($queryString) - { - if(!$this->query($queryString)) - { - return false; - } - $ret = array(); - while($line = $this->nextRecord()) - { - $ret[] = $line; + /**#@-*/ + + + + + + /** + * Executes a query + * + * Executes a given query string, has a variable amount of parameters: + * - 1 parameter + * executes the given query + * - 2 parameters + * executes the given query, replaces the first ? in the query with the second parameter + * - 3 parameters + * if the 2nd parameter is a boolean true, the 3rd parameter has to be an array containing all the replacements for every occuring ? in the query, otherwise the second parameter replaces the first ?, the third parameter replaces the second ? in the query + * - 4 or more parameters + * all ? in the query are replaced from left to right by the parameters 2 to x + * + * @access public + * @param string $sQuery query string + * @param mixed ... one or more parameters + * @return db_result the result object of the query + */ + + + public function query($sQuery = '') { + $aArgs = func_get_args(); + return call_user_func_array(array(&$this, '_query'), $aArgs); + } + + /** + * Execute a query and get first result array + * + * Executes a query and returns the first result row as an array + * This is like calling $result = $db->query(), $result->get(), $result->free() + * Use of this function @see query + * + * @access public + * @param string $sQuery query to execute + * @param ... further params (see query()) + * @return array result row or NULL if none found + */ + public function queryOneRecord($sQuery = '') { + if(!preg_match('/limit \d+\s*,\s*\d+$/i', $sQuery)) $sQuery .= ' LIMIT 0,1'; + + $aArgs = func_get_args(); + $oResult = call_user_func_array(array(&$this, 'query'), $aArgs); + if(!$oResult) return null; + + $aReturn = $oResult->get(); + $oResult->free(); + + return $aReturn; + } + + public function queryOne($sQuery = '') { + return call_user_func_array(array(&$this, 'queryOneRecord'), func_get_args()); + } + + public function query_one($sQuery = '') { + return call_user_func_array(array(&$this, 'queryOneRecord'), func_get_args()); + } + + /** + * Execute a query and return all rows + * + * Executes a query and returns all result rows in an array + * Use this with extreme care!!! Uses lots of memory on big result sets. + * + * @access public + * @param string $sQuery query to execute + * @param ... further params (see query()) + * @return array all the rows in the result set + */ + public function queryAllRecords($sQuery = '') { + $aArgs = func_get_args(); + $oResult = call_user_func_array(array(&$this, 'query'), $aArgs); + if(!$oResult) return array(); + + $aResults = array(); + while($aRow = $oResult->get()) { + $aResults[] = $aRow; } - return $ret; + $oResult->free(); + + return $aResults; } - // returns one record in an array - function queryOneRecord($queryString) - { - if(!$this->query($queryString) || $this->numRows() == 0) - { - return false; + public function queryAll($sQuery = '') { + return call_user_func_array(array(&$this, 'queryAllRecords'), func_get_args()); + } + + public function query_all($sQuery = '') { + return call_user_func_array(array(&$this, 'queryAllRecords'), func_get_args()); + } + + /** + * Execute a query and return all rows as simple array + * + * Executes a query and returns all result rows in an array with elements + * Only first column is returned Uses lots of memory on big result sets. + * + * @access public + * @param string $sQuery query to execute + * @param ... further params (see query()) + * @return array all the rows in the result set + */ + public function queryAllArray($sQuery = '') { + $aArgs = func_get_args(); + $oResult = call_user_func_array(array(&$this, 'query'), $aArgs); + if(!$oResult) return array(); + + $aResults = array(); + while($aRow = $oResult->get()) { + $aResults[] = reset($aRow); } - return $this->nextRecord(); + $oResult->free(); + + return $aResults; } - // returns the next record in an array - function nextRecord() - { - $this->record = mysqli_fetch_assoc($this->queryId); - $this->updateError('DB::nextRecord()
mysqli_fetch_array'); - if(!$this->record || !is_array($this->record)) - { - return false; + public function query_all_array($sQuery = '') { + return call_user_func_array(array(&$this, 'queryAllArray'), func_get_args()); + } + + + + /** + * Get id of last inserted row + * + * Gives you the id of the last inserted row in a table with an auto-increment primary key + * + * @access public + * @return int id of last inserted row or 0 if none + */ + public function insert_id() { + $iRes = mysqli_query($this->_iConnId, 'SELECT LAST_INSERT_ID() as `newid`'); + if(!is_object($iRes)) return false; + + $aReturn = mysqli_fetch_assoc($iRes); + mysqli_free_result($iRes); + + return $aReturn['newid']; + } + + + + /** + * get affected row count + * + * Gets the amount of rows affected by the previous query + * + * @access public + * @return int affected rows + */ + public function affected() { + if(!is_object($this->_iConnId)) return 0; + $iRows = mysqli_affected_rows($this->_iConnId); + if(!$iRows) $iRows = 0; + return $iRows; + } + + + + /** + * check if a utf8 string is valid + * + * @access public + * @param string $string the string to check + * @return bool true if it is valid utf8, false otherwise + */ + private function check_utf8($str) { + $len = strlen($str); + for($i = 0; $i < $len; $i++){ + $c = ord($str[$i]); + if ($c > 128) { + if (($c > 247)) return false; + elseif ($c > 239) $bytes = 4; + elseif ($c > 223) $bytes = 3; + elseif ($c > 191) $bytes = 2; + else return false; + if (($i + $bytes) > $len) return false; + while ($bytes > 1) { + $i++; + $b = ord($str[$i]); + if ($b < 128 || $b > 191) return false; + $bytes--; + } + } + } + return true; + } // end of check_utf8 + + /** + * Escape a string for usage in a query + * + * @access public + * @param string $sString query string to escape + * @return string escaped string + */ + public function escape($sString) { + if(!is_string($sString) && !is_numeric($sString)) { + $sString = ''; + } + + $cur_encoding = mb_detect_encoding($sString); + if($cur_encoding != "UTF-8") { + if($cur_encoding != 'ASCII') { + if($cur_encoding) $sString = mb_convert_encoding($sString, 'UTF-8', $cur_encoding); + else $sString = mb_convert_encoding($sString, 'UTF-8'); + } + } elseif(!$this->check_utf8($sString)) { + $sString = utf8_encode($sString); } - $this->currentRow++; - return $this->record; + + if($this->_iConnId) return mysqli_real_escape_string($this->_iConnId, $sString); + else return addslashes($sString); } - // returns number of rows returned by the last select query - function numRows() - { - return mysqli_num_rows($this->queryId); + /** + * + * + * @access private + */ + private function _sqlerror($sErrormsg = 'Unbekannter Fehler', $sAddMsg = '') { + global $conf; + + $mysql_error = (is_object($this->_iConnId) ? mysqli_error($this->_iConnId) : mysqli_connect_error()); + $mysql_errno = (is_object($this->_iConnId) ? mysqli_errno($this->_iConnId) : mysqli_connect_errno()); + + //$sAddMsg .= getDebugBacktrace(); + + if($this->show_error_messages && $conf['demo_mode'] === false) { + echo $sErrormsg . $sAddMsg; + } } - function affectedRows() - { - return mysqli_affected_rows($this->linkId); + public function affectedRows() { + return $this->affected(); } // returns mySQL insert id - function insertID() - { - return mysqli_insert_id($this->linkId); + public function insertID() { + return $this->insert_id(); } - // Check der variablen - // deprecated, now use quote - function check($formfield) - { - return $this->quote($formfield); - } - // Check der variablen - function quote($formfield) - { - return mysqli_real_escape_string($this->linkId, $formfield); + //* Function to quote strings + public function quote($formfield) { + return $this->escape($formfield); } - // Check der variablen - function unquote($formfield) - { + //* Function to unquotae strings + public function unquote($formfield) { return stripslashes($formfield); } - function toLower($record) { + public function toLower($record) { if(is_array($record)) { foreach($record as $key => $val) { $key = strtolower($key); @@ -194,7 +503,7 @@ class db return $out; } - + /* TODO: rewrite SQL */ function insert($tablename, $form, $debug = 0) { if(is_array($form)){ @@ -213,7 +522,8 @@ class db if($debug == 1) echo "mySQL Error Message: ".$this->errorMessage; } } - + + /* TODO: rewrite SQL */ function update($tablename, $form, $bedingung, $debug = 0) { @@ -230,218 +540,174 @@ class db } } - 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 - type => 42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob - typeValue => Wert z.B. bei Varchar - defaultValue => Default Wert - notNull => true | false - autoInc => true | false - option => unique | primary | index) - - - */ - - function createTable($table_name, $columns) { - $index = ""; - $sql = "CREATE TABLE $table_name ("; + $columns = array(action => add | alter | drop + name => Spaltenname + name_new => neuer Spaltenname, nur bei 'alter' belegt + type => 42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob + typeValue => Wert z.B. bei Varchar + defaultValue => Default Wert + notNull => true | false + autoInc => true | false + option => unique | primary | index) + + + */ + /* TODO: rewrite SQL */ + public function createTable($table_name, $columns) { + $index = ''; + $sql = "CREATE TABLE ?? ("; 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"]."' "; - } + $sql .= $col['name'].' '.$this->mapType($col['type'], $col['typeValue']).' '; - } 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'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' "; + if($col['notNull'] == true) { + $sql .= 'NOT NULL '; + } else { + $sql .= 'NULL '; } - if($col["autoInc"] == true) $sql .= "auto_increment "; - $sql.= ","; + 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['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); + $sql .= ')'; + /* TODO: secure parameters */ + $this->query($sql, $table_name); return true; } /* - $columns = array(action => add | alter | drop - name => Spaltenname - name_new => neuer Spaltenname, nur bei 'alter' belegt - type => 42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob - typeValue => Wert z.B. bei Varchar - defaultValue => Default Wert - notNull => true | false - autoInc => true | false - option => unique | primary | index) - - - */ - function alterTable($table_name, $columns) { - $index = ""; - $sql = "ALTER TABLE $table_name "; + $columns = array(action => add | alter | drop + name => Spaltenname + name_new => neuer Spaltenname, nur bei 'alter' belegt + type => 42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob + typeValue => Wert z.B. bei Varchar + defaultValue => Default Wert + notNull => true | false + autoInc => true | false + option => unique | primary | index) + + + */ + /* TODO: rewrite SQL */ + public function alterTable($table_name, $columns) { + $index = ''; + $sql = "ALTER TABLE ?? "; 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'] == '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 "; + if($col['action'] != 'drop') { + if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' "; + if($col['notNull'] == true) { + $sql .= 'NOT NULL '; } else { - $sql .= "NULL "; + $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.= ','; + // 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); - + /* TODO: secure parameters */ //die($sql); - $this->query($sql); + $this->query($sql, $table_name); return true; } - function dropTable($table_name) { + public function dropTable($table_name) { $this->check($table_name); - $sql = "DROP TABLE '". $table_name."'"; - return $this->query($sql); + $sql = "DROP TABLE ??"; + return $this->query($sql, $table_name); } // gibt Array mit Tabellennamen zur�ck - function getTables($database_name = '') { - - if($database_name == ''){ - $database_name = $this->dbName; - } - - $tables = $this->queryAllRecords("SHOW TABLES FROM `$database_name`"); - $tb_names = array(); - if(is_array($tables) && !empty($tables)){ - for($i = 0; $i < sizeof($tables); $i++){ - $tb_names[$i] = $tables[$i]['Tables_in_'.$database_name]; - } - } - - /* - $result = mysqli_query("SHOW TABLES FROM `$database_name`"); - $tb_names = array(); - for ($i = 0; $i < mysqli_num_rows($result); $i++) { - $tb_names[$i] = mysql_tablename($result, $i); - } - */ + public function getTables($database_name = '') { + if(!is_object($this->_iConnId)) return false; + if($database_name == '') $database_name = $this->dbName; + $tb_names = $this->queryAllArray("SHOW TABLES FROM ??", $database_name); 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 - type => 42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob - typeValue => Wert z.B. bei Varchar - defaultValue => Default Wert - notNull => true | false - autoInc => true | false - option => unique | primary | index) - - - */ - + $columns = array(action => add | alter | drop + name => Spaltenname + name_new => neuer Spaltenname, nur bei 'alter' belegt + type => 42go-Meta-Type: int16, int32, int64, double, char, varchar, text, blob + typeValue => Wert z.B. bei Varchar + defaultValue => Default Wert + notNull => true | false + autoInc => true | false + option => unique | primary | index) + + + */ + /* TODO: rewrite SQL */ function tableInfo($table_name) { global $go_api, $go_info; // Tabellenfelder einlesen - if($rows = $go_api->db->queryAllRecords("SHOW FIELDS FROM ".$table_name)){ + 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]; + $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; + $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; + $column['notNull'] = true; } - if($extra == 'auto_increment') $column["autoInc"] = 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")) { + 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); + $column['typeValue'] = substr($tmp_typeValue[1], 0, -1); } - if(stristr($type, "varchar")) { + if(stristr($type, 'varchar')) { $metaType = 'varchar'; $tmp_typeValue = explode('(', $type); - $column["typeValue"] = substr($tmp_typeValue[1], 0, -1); + $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'; + if(stristr($type, 'text')) $metaType = 'text'; + if(stristr($type, 'double')) $metaType = 'double'; + if(stristr($type, 'blob')) $metaType = 'blob'; - $column["type"] = $metaType; + $column['type'] = $metaType; $columns[] = $column; } @@ -452,7 +718,7 @@ class db } - function mapType($metaType, $typeValue) { + public function mapType($metaType, $typeValue) { global $go_api; $metaType = strtolower($metaType); switch ($metaType) { @@ -472,7 +738,7 @@ class db return 'char'; break; case 'varchar': - if($typeValue < 1) die("Datenbank Fehler: F�r diesen Datentyp ist eine L�ngenangabe notwendig."); + if($typeValue < 1) die('Database failure: Lenght required for these data types.'); return 'varchar('.$typeValue.')'; break; case 'text': @@ -486,4 +752,238 @@ class db } +/** + * database query result class + * + * @package pxFramework + * + */ +class db_result { + + /** + * + * + * @access private + */ + private $_iResId = null; + private $_iConnection = null; + + + + /** + * + * + * @access private + */ + public function db_result($iResId, $iConnection) { + $this->_iResId = $iResId; + $this->_iConnection = $iConnection; + } + + + + /** + * get count of result rows + * + * Returns the amount of rows in the result set + * + * @access public + * @return int amount of rows + */ + public function rows() { + if(!is_object($this->_iResId)) return 0; + $iRows = mysqli_num_rows($this->_iResId); + if(!$iRows) $iRows = 0; + return $iRows; + } + + + + /** + * Get number of affected rows + * + * Returns the amount of rows affected by the previous query + * + * @access public + * @return int amount of affected rows + */ + public function affected() { + if(!is_object($this->_iConnection)) return 0; + $iRows = mysqli_affected_rows($this->_iConnection); + if(!$iRows) $iRows = 0; + return $iRows; + } + + + + /** + * Frees the result set + * + * @access public + */ + public function free() { + if(!is_object($this->_iResId)) return; + + mysqli_free_result($this->_iResId); + return; + } + + + + /** + * Get a result row (associative) + * + * Returns the next row in the result set. To be used in a while loop like while($currow = $result->get()) { do something ... } + * + * @access public + * @return array result row + */ + public function get() { + $aItem = null; + + if(is_object($this->_iResId)) { + $aItem = mysqli_fetch_assoc($this->_iResId); + if(!$aItem) $aItem = null; + } + return $aItem; + } + + + + /** + * Get a result row (array with numeric index) + * + * @access public + * @return array result row + */ + public function getAsRow() { + $aItem = null; + + if(is_object($this->_iResId)) { + $aItem = mysqli_fetch_row($this->_iResId); + if(!$aItem) $aItem = null; + } + return $aItem; + } + +} + +/** + * database query result class + * + * emulates a db result set out of an array so you can use array results and db results the same way + * + * @package pxFramework + * @see db_result + * + * + */ +class fakedb_result { + + /** + * + * + * @access private + */ + private $aResultData = array(); + + /** + * + * + * @access private + */ + private $aLimitedData = array(); + + + + /** + * + * + * @access private + */ + public function fakedb_result($aData) { + $this->aResultData = $aData; + $this->aLimitedData = $aData; + reset($this->aLimitedData); + } + + + + /** + * get count of result rows + * + * Returns the amount of rows in the result set + * + * @access public + * @return int amount of rows + */ + // Gibt die Anzahl Zeilen zurück + public function rows() { + return count($this->aLimitedData); + } + + + + /** + * Frees the result set + * + * @access public + */ + // Gibt ein Ergebnisset frei + public function free() { + $this->aResultData = array(); + $this->aLimitedData = array(); + return; + } + + + + /** + * Get a result row (associative) + * + * Returns the next row in the result set. To be used in a while loop like while($currow = $result->get()) { do something ... } + * + * @access public + * @return array result row + */ + // Gibt eine Ergebniszeile zurück + public function get() { + $aItem = null; + + if(!is_array($this->aLimitedData)) return $aItem; + + if(list($vKey, $aItem) = each($this->aLimitedData)) { + if(!$aItem) $aItem = null; + } + return $aItem; + } + + + + /** + * Get a result row (array with numeric index) + * + * @access public + * @return array result row + */ + public function getAsRow() { + return $this->get(); + } + + + + /** + * Limit the result (like a LIMIT x,y in a SQL query) + * + * @access public + * @param int $iStart offset to start read + * @param int iLength amount of datasets to read + */ + public function limit_result($iStart, $iLength) { + $this->aLimitedData = array_slice($this->aResultData, $iStart, $iLength, true); + } + +} + + ?> diff --git a/install/lib/update.lib.php b/install/lib/update.lib.php index d2d11bf11e3e381683796139da54743f33e92777..1813a19a21e00e7184d24cba5be16f29f573ff92 100644 --- a/install/lib/update.lib.php +++ b/install/lib/update.lib.php @@ -124,7 +124,7 @@ function updateDbAndIni() { global $inst, $conf; //* Update $conf array with values from the server.ini that shall be preserved - $tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); + $tmp = $inst->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . '.server', $conf['server_id']); $ini_array = ini_to_array(stripslashes($tmp['config'])); $current_db_version = (isset($tmp['dbversion']))?intval($tmp['dbversion']):0; @@ -218,8 +218,8 @@ function updateDbAndIni() { } //* 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']); + $inst->db->query("UPDATE ?? SET dbversion = ? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $current_db_version, $conf['server_id']); + if($inst->db->dbHost != $inst->dbmaster->dbHost) $inst->dbmaster->query("UPDATE ?? SET dbversion = ? WHERE server_id = ?", $conf["mysql"]["master_database"] . ".server", $current_db_version, $conf['server_id']); //* If ISPConfig Version < 3.0.3, we will do a full db update @@ -228,7 +228,7 @@ function updateDbAndIni() { swriteln($inst->lng('Starting full database update.')); //** Delete the old database - if( !$inst->db->query('DROP DATABASE IF EXISTS '.$conf['mysql']['database']) ) { + if( !$inst->db->query('DROP DATABASE IF EXISTS ??', $conf['mysql']['database']) ) { $inst->error('Unable to drop MySQL database: '.$conf['mysql']['database'].'.'); } @@ -239,7 +239,7 @@ function updateDbAndIni() { $db_tables = $inst->db->getTables(); foreach($db_tables as $table) { - $inst->db->query("TRUNCATE $table"); + $inst->db->query("TRUNCATE ??", $table); } //** load old data back into database @@ -262,15 +262,15 @@ function updateDbAndIni() { } //* 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']); + $inst->db->query("UPDATE ?? SET dbversion = ? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $current_db_version, $conf['server_id']); + if($inst->db->dbHost != $inst->dbmaster->dbHost) $inst->dbmaster->query("UPDATE ?? SET dbversion = ? WHERE server_id = ?", $conf["mysql"]["master_database"] . ".server", $current_db_version, $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']) ) { + if( !$inst->db->query('DROP DATABASE IF EXISTS ??', $conf['powerdns']['database']) ) { $inst->error('Unable to drop MySQL database: '.$conf['powerdns']['database'].'.'); } @@ -288,7 +288,7 @@ function updateDbAndIni() { //** Update server ini - $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']); + $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); $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')); @@ -344,12 +344,12 @@ 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); + $sql = "UPDATE ?? SET config = ? WHERE server_id = ?"; + $inst->db->query($sql, $conf["mysql"]["database"] . ".server", $new_ini, $conf['server_id']); 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); + $sql = "UPDATE ?? SET config = ? WHERE server_id = ?"; + $inst->dbmaster->query($sql, $conf["mysql"]["master_database"].".server", $new_ini, $conf['server_id']); } unset($old_ini_array); unset($tpl_ini_array); @@ -357,7 +357,7 @@ function updateDbAndIni() { //** Update system ini - $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ".$conf["mysql"]["database"].".sys_ini WHERE sysini_id = 1"); + $tmp_server_rec = $inst->db->queryOneRecord("SELECT config FROM ?? WHERE sysini_id = 1", $conf["mysql"]["database"] . ".sys_ini"); $old_ini_array = ini_to_array(stripslashes($tmp_server_rec['config'])); unset($tmp_server_rec); $tpl_ini_array = ini_to_array(rf('tpl/system.ini.master')); @@ -372,11 +372,11 @@ function updateDbAndIni() { } $new_ini = array_to_ini($tpl_ini_array); - $tmp = $inst->db->queryOneRecord('SELECT count(sysini_id) as number FROM '.$conf["mysql"]["database"].'.sys_ini WHERE 1'); + $tmp = $inst->db->queryOneRecord('SELECT count(sysini_id) as number FROM ?? WHERE 1', $conf["mysql"]["database"] . '.sys_ini'); if($tmp['number'] == 0) { - $inst->db->query("INSERT INTO ".$conf["mysql"]["database"].".sys_ini (sysini_id, config) VALUES (1,'".mysql_real_escape_string($new_ini)."')"); + $inst->db->query("INSERT INTO ?? (sysini_id, config) VALUES (1,?)", $conf["mysql"]["database"] . ".sys_ini", $new_ini); } else { - $inst->db->query("UPDATE ".$conf["mysql"]["database"].".sys_ini SET config = '".mysql_real_escape_string($new_ini)."' WHERE sysini_id = 1"); + $inst->db->query("UPDATE ?? SET config = ? WHERE sysini_id = 1", $conf["mysql"]["database"] . ".sys_ini", $new_ini); } unset($old_ini_array); unset($tpl_ini_array); @@ -385,4 +385,24 @@ function updateDbAndIni() { +function setDefaultServers(){ + global $inst, $conf; + + // clients + $clients = $inst->db->queryAllRecords("SELECT * FROM ".$conf["mysql"]["database"].".client"); + if(is_array($clients) && !empty($clients)){ + foreach($clients as $client){ + // mailserver + if(trim($client['mail_servers']) == '') $inst->db->query("UPDATE ?? SET mail_servers = ? WHERE client_id = ?", $conf["mysql"]["database"].".client", trim($client['default_mailserver']), $client['client_id']); + // webserver + if(trim($client['web_servers']) == '') $inst->db->query("UPDATE ?? SET web_servers = ? WHERE client_id = ?", $conf["mysql"]["database"].".client", trim($client['default_webserver']), $client['client_id']); + // dns server + if(trim($client['dns_servers']) == '') $inst->db->query("UPDATE ?? SET dns_servers = ? WHERE client_id = ?", $conf["mysql"]["database"].".client", trim($client['default_dnsserver']), $client['client_id']); + // db server + if(trim($client['db_servers']) == '') $inst->db->query("UPDATE ?? SET db_servers = ? WHERE client_id = ?", $conf["mysql"]["database"].".client", trim($client['default_dbserver']), $client['client_id']); + } + } + +} + ?> diff --git a/install/sql/incremental/upd_0079.sql b/install/sql/incremental/upd_0079.sql new file mode 100644 index 0000000000000000000000000000000000000000..5dd0152753814e661bbeeff24a46c9245f9c54b6 --- /dev/null +++ b/install/sql/incremental/upd_0079.sql @@ -0,0 +1,2 @@ +ALTER TABLE `directive_snippets` ADD `customer_viewable` ENUM('n','y') NOT NULL DEFAULT 'n' AFTER `snippet`; +ALTER TABLE `web_domain` ADD `directive_snippets_id` int(11) unsigned NOT NULL default '0'; \ No newline at end of file diff --git a/install/sql/incremental/upd_0080.sql b/install/sql/incremental/upd_0080.sql new file mode 100644 index 0000000000000000000000000000000000000000..fcdcb622e32cb7cb4b5438e1107dd5c73d8fe3e2 --- /dev/null +++ b/install/sql/incremental/upd_0080.sql @@ -0,0 +1 @@ +ALTER TABLE `web_domain` ADD COLUMN `enable_spdy` ENUM('y','n') NULL DEFAULT 'n' AFTER `proxy_directives`; diff --git a/install/sql/incremental/upd_dev_collection.sql b/install/sql/incremental/upd_dev_collection.sql index e60ae0206e0db76cae81fcba78498a61049e05e9..1f8b21d26d3c0ebf080d25e012f4018caf16bd31 100644 --- a/install/sql/incremental/upd_dev_collection.sql +++ b/install/sql/incremental/upd_dev_collection.sql @@ -2,9 +2,148 @@ ALTER TABLE `mail_user` CHANGE `uid` `uid` int(11) NOT NULL DEFAULT '5000', CHANGE `gid` `gid` int(11) NOT NULL DEFAULT '5000'; +ALTER TABLE `mail_user` + ADD COLUMN `sender_cc` varchar(255) NOT NULL DEFAULT '' AFTER `cc`; + ALTER TABLE `client_template` ADD `default_mailserver` INT(11) NOT NULL DEFAULT 1; ALTER TABLE `client_template` ADD `default_webserver` INT(11) NOT NULL DEFAULT 1; ALTER TABLE `client_template` ADD `default_dnsserver` INT(11) NOT NULL DEFAULT 1; ALTER TABLE `client_template` ADD `default_slave_dnsserver` INT(11) NOT NULL DEFAULT 1; ALTER TABLE `client_template` ADD `default_dbserver` INT(11) NOT NULL DEFAULT 1; ALTER TABLE `client` ADD `contact_firstname` VARCHAR( 64 ) NOT NULL DEFAULT '' AFTER `gender`; + +UPDATE `dns_template` SET `fields` = 'DOMAIN,IP,NS1,NS2,EMAIL,DKIM' WHERE `dns_template`.`template_id` =1; +UPDATE `dns_template` SET `template` = '[ZONE] +origin={DOMAIN}. +ns={NS1}. +mbox={EMAIL}. +refresh=7200 +retry=540 +expire=604800 +minimum=3600 +ttl=3600 + +[DNS_RECORDS] +A|{DOMAIN}.|{IP}|0|3600 +A|www|{IP}|0|3600 +A|mail|{IP}|0|3600 +NS|{DOMAIN}.|{NS1}.|0|3600 +NS|{DOMAIN}.|{NS2}.|0|3600 +MX|{DOMAIN}.|mail.{DOMAIN}.|10|3600 +TXT|{DOMAIN}.|v=spf1 mx a ~all|0|3600' WHERE `dns_template`.`template_id` = 1; + +ALTER TABLE `mail_backup` CHANGE `filesize` `filesize` VARCHAR(20) NOT NULL DEFAULT ''; +ALTER TABLE `web_backup` CHANGE `filesize` `filesize` VARCHAR(20) NOT NULL DEFAULT ''; + +ALTER TABLE `sys_datalog` ADD INDEX `dbtable` (`dbtable` (25), `dbidx` (25)), ADD INDEX (`action`); +ALTER TABLE `mail_user` ADD `greylisting` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `postfix`; +ALTER TABLE `mail_user` ADD `maildir_format` varchar(255) NOT NULL default 'maildir' AFTER `maildir`; +ALTER TABLE `mail_forwarding` ADD `greylisting` ENUM( 'n', 'y' ) NOT NULL DEFAULT 'n' AFTER `active`; + +ALTER TABLE `openvz_ip` CHANGE `ip_address` `ip_address` VARCHAR(39) DEFAULT NULL; + +-- XMPP Support + +ALTER TABLE `server` ADD COLUMN `xmpp_server` tinyint(1) NOT NULL default '0' AFTER `firewall_server`; + +ALTER TABLE `client` + ADD COLUMN `default_xmppserver` int(11) unsigned NOT NULL DEFAULT '1', + ADD COLUMN `xmpp_servers` blob, + ADD COLUMN `limit_xmpp_domain` int(11) NOT NULL DEFAULT '-1', + ADD COLUMN `limit_xmpp_user` int(11) NOT NULL DEFAULT '-1', + ADD COLUMN `limit_xmpp_muc` ENUM( 'n', 'y' ) NOT NULL default 'n', + ADD COLUMN `limit_xmpp_anon` ENUM( 'n', 'y' ) NOT NULL default 'n', + ADD COLUMN `limit_xmpp_auth_options` varchar(255) NOT NULL DEFAULT 'plain,hashed,isp', + ADD COLUMN `limit_xmpp_vjud` ENUM( 'n', 'y' ) NOT NULL default 'n', + ADD COLUMN `limit_xmpp_proxy` ENUM( 'n', 'y' ) NOT NULL default 'n', + ADD COLUMN `limit_xmpp_status` ENUM( 'n', 'y' ) NOT NULL default 'n', + ADD COLUMN `limit_xmpp_pastebin` ENUM( 'n', 'y' ) NOT NULL default 'n', + ADD COLUMN `limit_xmpp_httparchive` ENUM( 'n', 'y' ) NOT NULL default 'n'; + + +CREATE TABLE `xmpp_domain` ( + `domain_id` int(11) unsigned NOT NULL auto_increment, + `sys_userid` int(11) unsigned NOT NULL default '0', + `sys_groupid` int(11) unsigned NOT NULL default '0', + `sys_perm_user` varchar(5) NOT NULL default '', + `sys_perm_group` varchar(5) NOT NULL default '', + `sys_perm_other` varchar(5) NOT NULL default '', + `server_id` int(11) unsigned NOT NULL default '0', + `domain` varchar(255) NOT NULL default '', + + `management_method` ENUM( 'normal', 'maildomain' ) NOT NULL default 'normal', + `public_registration` ENUM( 'n', 'y' ) NOT NULL default 'n', + `registration_url` varchar(255) NOT NULL DEFAULT '', + `registration_message` varchar(255) NOT NULL DEFAULT '', + `domain_admins` text, + + `use_pubsub` enum('n','y') NOT NULL DEFAULT 'n', + `use_proxy` enum('n','y') NOT NULL DEFAULT 'n', + `use_anon_host` enum('n','y') NOT NULL DEFAULT 'n', + + `use_vjud` enum('n','y') NOT NULL DEFAULT 'n', + `vjud_opt_mode` enum('in', 'out') NOT NULL DEFAULT 'in', + + `use_muc_host` enum('n','y') NOT NULL DEFAULT 'n', + `muc_name` varchar(30) NOT NULL DEFAULT '' + `muc_restrict_room_creation` enum('n', 'y', 'm') NOT NULL DEFAULT 'm', + `muc_admins` text, + `use_pastebin` enum('n','y') NOT NULL DEFAULT 'n', + `pastebin_expire_after` int(3) NOT NULL DEFAULT 48, + `pastebin_trigger` varchar(10) NOT NULL DEFAULT '!paste', + `use_http_archive` enum('n','y') NOT NULL DEFAULT 'n', + `http_archive_show_join` enum('n', 'y') NOT NULL DEFAULT 'n', + `http_archive_show_status` enum('n', 'y') NOT NULL DEFAULT 'n', + `use_status_host` enum('n','y') NOT NULL DEFAULT 'n', + + `ssl_state` varchar(255) NULL, + `ssl_locality` varchar(255) NULL, + `ssl_organisation` varchar(255) NULL, + `ssl_organisation_unit` varchar(255) NULL, + `ssl_country` varchar(255) NULL, + `ssl_email` varchar(255) NULL, + `ssl_request` mediumtext NULL, + `ssl_cert` mediumtext NULL, + `ssl_bundle` mediumtext NULL, + `ssl_key` mediumtext NULL, + `ssl_action` varchar(16) NULL, + + `active` enum('n','y') NOT NULL DEFAULT 'n', + PRIMARY KEY (`domain_id`), + KEY `server_id` (`server_id`,`domain`), + KEY `domain_active` (`domain`,`active`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- +-- Table structure for table `xmpp_user` +-- + +CREATE TABLE `xmpp_user` ( + `xmppuser_id` int(11) unsigned NOT NULL auto_increment, + `sys_userid` int(11) unsigned NOT NULL default '0', + `sys_groupid` int(11) unsigned NOT NULL default '0', + `sys_perm_user` varchar(5) NOT NULL default '', + `sys_perm_group` varchar(5) NOT NULL default '', + `sys_perm_other` varchar(5) NOT NULL default '', + `server_id` int(11) unsigned NOT NULL default '0', + `jid` varchar(255) NOT NULL default '', + `password` varchar(255) NOT NULL default '', + `active` enum('n','y') NOT NULL DEFAULT 'n', + PRIMARY KEY (`xmppuser_id`), + KEY `server_id` (`server_id`,`jid`), + KEY `jid_active` (`jid`,`active`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +UPDATE `dbispconfig`.`sys_ini` SET `default_logo` = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABBCAYAAACU5+uOAAAItUlEQVR42u1dCWwVVRStUJZCK6HsFNAgWpaCJkKICZKApKUFhURQpEnZF4EEUJZYEEpBIamgkQpUQBZRW7YCBqQsggsQEAgKLbIGCYsSCNqyQ8D76h18Hd/MvJk/n/bXc5KT+TNz79vPzNv+/2FhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAe++s0akTsRZxMnE6cGkKcxkwhPofaBPwWRzxxB/EO8UGI8xhxEGoV8EscY8qBKFRcgdoFAhXHC+VUHAbHo5aBQASyrZwL5DoxEjUNeBXI9XIuEMEE1DTgVSA3FA3qIDEtBLnTQiBDUNOAV4EUKhpURojmZQQEAjwKgSwK0bykWQgEU74ABAKBABAIBOIJffoNrkRsS0whDiMO5uNw4gBiSxvfGOJrbDtMOgr2JNa18HmZmETsopnGp4h9xdF0TcQRb8NEPkawTzv2qaWIoybnZYRUBoJD+difGAuBlCy0qsRM4mfERcTFfGygsBUF/xFxE/EQ8RixwIbi/j7il8R3iE8qwuxAXMJxuuFiTvNMYleb/E0gXiI+cOBaISTJrzLxcw2/+8Q5pjjfNNkM0RDILLadpbimw+bsc4DPkxRpuqkZ1orisoBAiguuhkUhPSvZRBA3u6gsK94g9jDFP9aHcAV3EKNNYX8i3RcNJ4M4nTiROJCYykIzbGZKvouk68vYbyS/cUbz+RrJZpzkO5Sv3eajaJhRDvUwg21nKK4VcF5WKPgFH6PZZw/7dJXC6S6lczunfbIQLpeDkZ+lJcoCAikuvChioaLBtfD4JHPiXSFKKexBPoa9Wwr3ael6skMZDGO7K3z+uOSb5OA7mu2KiOGmPH3ADVh8/sohnDS2S1NcG+uiO/kd+8RL146YRWzj359tb0Eg+gIpsHkjFNrQqiF3DZJABDtyuCP5/FuNRlHN8Ofz9nx+XLNR3jR1c4w8TSFGSmnr4FEgU7wKhI51jAeTpv+/ZQGBOAuEu1d/Ku6LV35t9rdigkUjHuMgkHPEecQsxdjjUx4zHbMI+10OdzqfZ2o0iiqSfzgPfMXnzZqN6iTbJ5jytMTU0E97FEhaAAJ5kc/PuJjQOCoIgegJpKbUl5b5vGaBT+A+vOgn5/JYIdFBIOs1wo1kIZl93+P70/h8oUZYFXkmKInPU9h3m2YeT8lvRilPyyWbi3xt4iMWSDc+P4lp3uAIRDxdryjui6dmuujXcr91IDcMmaJv31WISfTrLeJXCUT3yb1a4Ztmalyu61MaZG/XtD9tapRGnpZKNp2lNNZ3KZARAQgk3untBYEEPgbJ92FsIAax34v1AQ2B5Go2BlW60n0QyCC/BWISdJ5LgewWU8k86DdTzMyNh0BKVyAzfB5I93YQyBGeTlW9lQbwIle2Rdgzy7BAxJT6Hb6X6EIgTrznRSCiHli02cwcPor1pbkQiL5AKvOA+ZZPAtkfxFms3j4IZHAwBGJaRPxdjH00BSImJRqKOlEwjtjUo0Dm2pWla4HMzsyqQIxSMKI8C8RkL9YXuhDf5gqcw4NweaZJiGkh8UeLwi+Utkb4KZCrYszkVSDiQRDMN4hkf5DvZ2gKZJyLPJgFkmAjEDEF3EYSWzPeklO8Q8CLQGKJhQquK+eDdLFNZBJxFLEf8XUXFTbcYv2kRhAEIq+vGNO88zTTKVaRzxPrSSvPW11O8yZqCiROSnMsX0sP0ixWops1Hfbx/AaJIz5QcFc5n+ZVNcbxmoWtEsBNB4EU8Tgk32Gv1wneEybeWG1N8RoNbplmOo2neiyxE3/eoun7G9t31hGIqXuzl8/HB0kgxhvhD03/KoEIpIWFQPLK+UJhkWpgKLZP8IKhajNhJg8A7yt8/5K6QoFM8z5mc68Ph3VWM6wTbN+a+AR/vqThV13KYyMXAgmXps9FnK8GSSA17KaXFf7R3gUyd8H/TiBss9fngfQehzfMpkDLgxcS73J4k1y85WrxtTtOjZPuVZA2O55RhLfUId5XpI2UHwZDIHxtp7HtRrVL25SfhWy7z7VAMuYvipszd0FJcfxzHspdrMctGnGcZNPTZ4F0VszqyPSlPHm8JG9f2SDtgF3Nq/rnJZssyXeUdP0CN64c9l/FDfGyZNNNkaeVGmnMM+Vdtd19los8/2e7Ow/E70lxiG7pRmkn8AaeULlcoo4sBDLfKvL0nLUxablfX0hfmfuQ01avI65fUQYEkupRIJHcAMwbDWNNdmLgupV4zeMO3stcIZ1M4aYo4vZt0oO7Locd0ndGTEQofN+QxiZ22+y7W+RpgUb66vOU7232SZXupZqvaYT3Dfu8ZLrejtc47mvkJ9FoVEWKBmW7dyc7ZXD1Nb2TH3JVn5Tqa3r1repzY6/gwWeqhUCGO/XjWSTmjYYVLOzFoP0Z/qJTks033brxrtjmxCbGtK4ivEqKuH2fNuc0tDatIYgna4yGbz2eeTL8WhJbic2aDnmqqpm2KlLeK5vWn0pc0wirGvtUtBkzNdPKDzWe24oGdZX4CzGfWCD4U93GBQdqNSw4Uiny8K9h4buOhlU2scq+Q1G1i233k63hFwBPEfcS04l1FGJoynbH+fgz8ZKFQJLDAMDjk/psCPzw20XxE6mmdLd24d8KNQ14FciUEPl1xHvEhlK6W2j65aOWgUAEUpV4NEREstyDQNqjloFARVKL/xukrAvkGjGC09zGwfYKsQdqF/BTKMnEJcTtxC3EPAU3iic5cRkfjc/ZFvZuuZm4gXjOouG35LQ2Yfutkq/4pfpN/E9TDVCjQGkJqQExho+CjYlRPseRiQE3EIriaMZTw4K3mOJv23J8jme23RsEAMqqQJrb9PnnEbPEVpUAuJD4Mf/PoCqeONQCUJYFElGKf7ojpnqjUQtAWRdJaf1t2w8ofSAUBNKulATSEaUPhIpIRj9icbyFUgdCTSRTeR0i2HwfpQ0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQBnG392D9QU+JXhxAAAAAElFTkSuQmCC' WHERE `sys_ini`.`sysini_id` = 1; + +ALTER TABLE `directive_snippets` ADD `required_php_snippets` VARCHAR(255) NOT NULL DEFAULT '' AFTER `customer_viewable`; +ALTER TABLE `dns_rr` CHANGE `ttl` `ttl` INT(11) UNSIGNED NOT NULL DEFAULT '3600'; +ALTER TABLE `dns_soa` CHANGE `minimum` `minimum` INT(11) UNSIGNED NOT NULL DEFAULT '3600', CHANGE `ttl` `ttl` INT(11) UNSIGNED NOT NULL DEFAULT '3600'; +ALTER TABLE `client` CHANGE `web_php_options` `web_php_options` VARCHAR(255) NOT NULL DEFAULT 'no,fast-cgi,cgi,mod,suphp,php-fpm,hhvm'; + +ALTER TABLE openvz_template ADD COLUMN `features` varchar(255) DEFAULT NULL AFTER `capability`; +ALTER TABLE openvz_vm ADD COLUMN `features` TEXT DEFAULT NULL AFTER `capability`; +ALTER TABLE openvz_template ADD COLUMN `iptables` varchar(255) DEFAULT NULL AFTER `features`; +ALTER TABLE openvz_vm ADD COLUMN `iptables` TEXT DEFAULT NULL AFTER `features`; diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 3f65bfe32d78bbf3be2fb66f8cd62254c31ebf82..9d90b5e9ef5efa31a8e7ceb9655d03bf0d9159bf 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -184,12 +184,24 @@ CREATE TABLE `client` ( `limit_spamfilter_wblist` int(11) NOT NULL DEFAULT '0', `limit_spamfilter_user` int(11) NOT NULL DEFAULT '0', `limit_spamfilter_policy` int(11) NOT NULL DEFAULT '0', + `default_xmppserver` int(11) unsigned NOT NULL DEFAULT '1', + `xmpp_servers` blob, + `limit_xmpp_domain` int(11) NOT NULL DEFAULT '-1', + `limit_xmpp_user` int(11) NOT NULL DEFAULT '-1', + `limit_xmpp_muc` ENUM( 'n', 'y' ) NOT NULL default 'n', + `limit_xmpp_anon` ENUM( 'n', 'y' ) NOT NULL default 'n', + `limit_xmpp_auth_options` varchar(255) NOT NULL DEFAULT 'plain,hashed,isp', + `limit_xmpp_vjud` ENUM( 'n', 'y' ) NOT NULL default 'n', + `limit_xmpp_proxy` ENUM( 'n', 'y' ) NOT NULL default 'n', + `limit_xmpp_status` ENUM( 'n', 'y' ) NOT NULL default 'n', + `limit_xmpp_pastebin` ENUM( 'n', 'y' ) NOT NULL default 'n', + `limit_xmpp_httparchive` ENUM( 'n', 'y' ) NOT NULL default 'n', `default_webserver` int(11) unsigned NOT NULL DEFAULT '1', `web_servers` blob, `limit_web_ip` text, `limit_web_domain` int(11) NOT NULL DEFAULT '-1', `limit_web_quota` int(11) NOT NULL DEFAULT '-1', - `web_php_options` varchar(255) NOT NULL DEFAULT 'no,fast-cgi,cgi,mod,suphp,php-fpm', + `web_php_options` varchar(255) NOT NULL DEFAULT 'no,fast-cgi,cgi,mod,suphp,php-fpm,hhvm', `limit_cgi` enum('n','y') NOT NULL DEFAULT 'n', `limit_ssi` enum('n','y') NOT NULL DEFAULT 'n', `limit_perl` enum('n','y') NOT NULL DEFAULT 'n', @@ -429,6 +441,8 @@ CREATE TABLE IF NOT EXISTS `directive_snippets` ( `name` varchar(255) DEFAULT NULL, `type` varchar(255) DEFAULT NULL, `snippet` mediumtext, + `customer_viewable` ENUM('n','y') NOT NULL DEFAULT 'n', + `required_php_snippets` varchar(255) NOT NULL DEFAULT '', `active` enum('n','y') NOT NULL DEFAULT 'y', PRIMARY KEY (`directive_snippets_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -452,7 +466,7 @@ CREATE TABLE `dns_rr` ( `type` enum('A','AAAA','ALIAS','CNAME','HINFO','MX','NAPTR','NS','PTR','RP','SRV','TXT') default NULL, `data` TEXT NOT NULL DEFAULT '', `aux` int(11) unsigned NOT NULL default '0', - `ttl` int(11) unsigned NOT NULL default '86400', + `ttl` int(11) unsigned NOT NULL default '3600', `active` enum('N','Y') NOT NULL default 'Y', `stamp` timestamp NOT NULL default CURRENT_TIMESTAMP, `serial` int(10) unsigned default NULL, @@ -504,8 +518,8 @@ CREATE TABLE `dns_soa` ( `refresh` int(11) unsigned NOT NULL default '28800', `retry` int(11) unsigned NOT NULL default '7200', `expire` int(11) unsigned NOT NULL default '604800', - `minimum` int(11) unsigned NOT NULL default '86400', - `ttl` int(11) unsigned NOT NULL default '86400', + `minimum` int(11) unsigned NOT NULL default '3600', + `ttl` int(11) unsigned NOT NULL default '3600', `active` enum('N','Y') NOT NULL DEFAULT 'N', `xfer` varchar(255) NOT NULL DEFAULT '', `also_notify` varchar(255) default NULL, @@ -702,7 +716,7 @@ CREATE TABLE `mail_backup` ( `backup_mode` varchar(64) NOT NULL DEFAULT '', `tstamp` int(10) unsigned NOT NULL DEFAULT '0', `filename` varchar(255) NOT NULL DEFAULT '', - `filesize` VARCHAR(10) NOT NULL DEFAULT '', + `filesize` VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (`backup_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -901,6 +915,7 @@ CREATE TABLE `mail_user` ( `uid` int(11) NOT NULL default '5000', `gid` int(11) NOT NULL default '5000', `maildir` varchar(255) NOT NULL default '', + `maildir_format` varchar(255) NOT NULL default 'maildir', `quota` bigint(20) NOT NULL default '-1', `cc` varchar(255) NOT NULL default '', `sender_cc` varchar(255) NOT NULL default '', @@ -984,7 +999,7 @@ CREATE TABLE IF NOT EXISTS `openvz_ip` ( `sys_perm_group` varchar(5) DEFAULT NULL, `sys_perm_other` varchar(5) DEFAULT NULL, `server_id` int(11) NOT NULL DEFAULT '0', - `ip_address` varchar(15) DEFAULT NULL, + `ip_address` varchar(39) DEFAULT NULL, `vm_id` int(11) NOT NULL DEFAULT '0', `reserved` varchar(255) NOT NULL DEFAULT 'n', PRIMARY KEY (`ip_address_id`) @@ -1073,6 +1088,8 @@ CREATE TABLE IF NOT EXISTS `openvz_template` ( `nameserver` varchar(255) DEFAULT NULL, `create_dns` varchar(1) NOT NULL DEFAULT 'n', `capability` varchar(255) DEFAULT NULL, + `features` varchar(255) DEFAULT NULL, + `iptables` varchar(255) DEFAULT NULL, PRIMARY KEY (`template_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; @@ -1080,7 +1097,7 @@ CREATE TABLE IF NOT EXISTS `openvz_template` ( -- Dumping data for table `openvz_template` -- -INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:65536', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:131072', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', ''); +INSERT INTO `openvz_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `diskspace`, `traffic`, `bandwidth`, `ram`, `ram_burst`, `cpu_units`, `cpu_num`, `cpu_limit`, `io_priority`, `active`, `description`, `numproc`, `numtcpsock`, `numothersock`, `vmguarpages`, `kmemsize`, `tcpsndbuf`, `tcprcvbuf`, `othersockbuf`, `dgramrcvbuf`, `oomguarpages`, `privvmpages`, `lockedpages`, `shmpages`, `physpages`, `numfile`, `avnumproc`, `numflock`, `numpty`, `numsiginfo`, `dcachesize`, `numiptent`, `swappages`, `hostname`, `nameserver`, `create_dns`, `capability`, `features`, `iptables`) VALUES(1, 1, 1, 'riud', 'riud', '', 'small', 10, -1, -1, 256, 512, 1000, 4, 400, 4, 'y', '', '999999:999999', '7999992:7999992', '7999992:7999992', '65536:65536', '2147483646:2147483646', '214748160:396774400', '214748160:396774400', '214748160:396774400', '214748160:396774400', '65536:65536', '131072:131072', '999999:999999', '65536:65536', '0:2147483647', '23999976:23999976', '180:180', '999999:999999', '500000:500000', '999999:999999', '2147483646:2147483646', '999999:999999', '256000:256000', 'v{VEID}.test.tld', '8.8.8.8 8.8.4.4', 'n', '', '', ''); -- -------------------------------------------------------- @@ -1136,6 +1153,8 @@ CREATE TABLE IF NOT EXISTS `openvz_vm` ( `nameserver` varchar(255) NOT NULL DEFAULT '8.8.8.8 8.8.4.4', `create_dns` varchar(1) NOT NULL DEFAULT 'n', `capability` text, + `features` text, + `iptabless` text, `config` mediumtext, PRIMARY KEY (`vm_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; @@ -1200,6 +1219,7 @@ CREATE TABLE `server` ( `vserver_server` tinyint(1) NOT NULL default '0', `proxy_server` tinyint(1) NOT NULL default '0', `firewall_server` tinyint(1) NOT NULL default '0', + `xmpp_server` tinyint(1) NOT NULL default '0', `config` text, `updated` bigint(20) unsigned NOT NULL default '0', `mirror_server_id` int(11) unsigned NOT NULL default '0', @@ -1607,6 +1627,8 @@ CREATE TABLE `sys_group` ( CREATE TABLE `sys_ini` ( `sysini_id` int(11) unsigned NOT NULL auto_increment, `config` longtext, + `default_logo` text NOT NULL, + `custom_logo` text NOT NULL, PRIMARY KEY (`sysini_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -1745,7 +1767,7 @@ CREATE TABLE `web_backup` ( `backup_mode` varchar(64) NOT NULL DEFAULT '', `tstamp` int(10) unsigned NOT NULL DEFAULT '0', `filename` varchar(255) NOT NULL DEFAULT '', - `filesize` VARCHAR(10) NOT NULL DEFAULT '', + `filesize` VARCHAR(20) NOT NULL DEFAULT '', PRIMARY KEY (`backup_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -1876,10 +1898,12 @@ CREATE TABLE `web_domain` ( `traffic_quota_lock` enum('n','y') NOT NULL default 'n', `fastcgi_php_version` varchar(255) DEFAULT NULL, `proxy_directives` mediumtext, + `enable_spdy` ENUM('y','n') NULL DEFAULT 'n', `last_quota_notification` date NULL default NULL, `rewrite_rules` mediumtext, `added_date` date NOT NULL DEFAULT '0000-00-00', `added_by` varchar(255) DEFAULT NULL, + `directive_snippets_id` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`domain_id`), UNIQUE KEY `serverdomain` ( `server_id` , `ip_address`, `domain` ) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; @@ -1947,6 +1971,89 @@ CREATE TABLE `web_traffic` ( PRIMARY KEY (`hostname`,`traffic_date`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; +-- -------------------------------------------------------- + +-- +-- Table structure for table `xmpp_domain` +-- + +CREATE TABLE `xmpp_domain` ( + `domain_id` int(11) unsigned NOT NULL auto_increment, + `sys_userid` int(11) unsigned NOT NULL default '0', + `sys_groupid` int(11) unsigned NOT NULL default '0', + `sys_perm_user` varchar(5) NOT NULL default '', + `sys_perm_group` varchar(5) NOT NULL default '', + `sys_perm_other` varchar(5) NOT NULL default '', + `server_id` int(11) unsigned NOT NULL default '0', + `domain` varchar(255) NOT NULL default '', + + `management_method` ENUM( 'normal', 'maildomain' ) NOT NULL default 'normal', + `public_registration` ENUM( 'n', 'y' ) NOT NULL default 'n', + `registration_url` varchar(255) NOT NULL DEFAULT '', + `registration_message` varchar(255) NOT NULL DEFAULT '', + `domain_admins` text, + + `use_pubsub` enum('n','y') NOT NULL DEFAULT 'n', + `use_proxy` enum('n','y') NOT NULL DEFAULT 'n', + `use_anon_host` enum('n','y') NOT NULL DEFAULT 'n', + + `use_vjud` enum('n','y') NOT NULL DEFAULT 'n', + `vjud_opt_mode` enum('in', 'out') NOT NULL DEFAULT 'in', + + `use_muc_host` enum('n','y') NOT NULL DEFAULT 'n', + `muc_name` varchar(30) NOT NULL DEFAULT '', + `muc_restrict_room_creation` enum('n', 'y', 'm') NOT NULL DEFAULT 'm', + `muc_admins` text, + `use_pastebin` enum('n','y') NOT NULL DEFAULT 'n', + `pastebin_expire_after` int(3) NOT NULL DEFAULT 48, + `pastebin_trigger` varchar(10) NOT NULL DEFAULT '!paste', + `use_http_archive` enum('n','y') NOT NULL DEFAULT 'n', + `http_archive_show_join` enum('n', 'y') NOT NULL DEFAULT 'n', + `http_archive_show_status` enum('n', 'y') NOT NULL DEFAULT 'n', + `use_status_host` enum('n','y') NOT NULL DEFAULT 'n', + + `ssl_state` varchar(255) NULL, + `ssl_locality` varchar(255) NULL, + `ssl_organisation` varchar(255) NULL, + `ssl_organisation_unit` varchar(255) NULL, + `ssl_country` varchar(255) NULL, + `ssl_email` varchar(255) NULL, + `ssl_request` mediumtext NULL, + `ssl_cert` mediumtext NULL, + `ssl_bundle` mediumtext NULL, + `ssl_key` mediumtext NULL, + `ssl_action` varchar(16) NULL, + + `active` enum('n','y') NOT NULL DEFAULT 'n', + PRIMARY KEY (`domain_id`), + KEY `server_id` (`server_id`,`domain`), + KEY `domain_active` (`domain`,`active`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `xmpp_user` +-- + +CREATE TABLE `xmpp_user` ( + `xmppuser_id` int(11) unsigned NOT NULL auto_increment, + `sys_userid` int(11) unsigned NOT NULL default '0', + `sys_groupid` int(11) unsigned NOT NULL default '0', + `sys_perm_user` varchar(5) NOT NULL default '', + `sys_perm_group` varchar(5) NOT NULL default '', + `sys_perm_other` varchar(5) NOT NULL default '', + `server_id` int(11) unsigned NOT NULL default '0', + `jid` varchar(255) NOT NULL default '', + `password` varchar(255) NOT NULL default '', + `active` enum('n','y') NOT NULL DEFAULT 'n', + PRIMARY KEY (`xmppuser_id`), + KEY `server_id` (`server_id`,`jid`), + KEY `jid_active` (`jid`,`active`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + -- -------------------------------------------------------- -- -------------------------------------------------------- -- DB-DATA @@ -2215,7 +2322,8 @@ INSERT INTO `country` (`iso`, `name`, `printable_name`, `iso3`, `numcode`, `eu`) -- Dumping data for table `dns_template` -- -INSERT INTO `dns_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `name`, `fields`, `template`, `visible`) VALUES (1, 1, 1, 'riud', 'riud', '', 'Default', 'DOMAIN,IP,NS1,NS2,EMAIL', '[ZONE]\norigin={DOMAIN}.\nns={NS1}.\nmbox={EMAIL}.\nrefresh=7200\nretry=540\nexpire=604800\nminimum=86400\nttl=3600\n\n[DNS_RECORDS]\nA|{DOMAIN}.|{IP}|0|3600\nA|www|{IP}|0|3600\nA|mail|{IP}|0|3600\nNS|{DOMAIN}.|{NS1}.|0|3600\nNS|{DOMAIN}.|{NS2}.|0|3600\nMX|{DOMAIN}.|mail.{DOMAIN}.|10|3600', 'y'); +INSERT INTO `dns_template` (`template_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `name`, `fields`, `template`, `visible`) VALUES (1, 1, 1, 'riud', 'riud', '', 'Default', 'DOMAIN,IP,NS1,NS2,EMAIL,DKIM', '[ZONE]\norigin={DOMAIN}.\nns={NS1}.\nmbox={EMAIL}.\nrefresh=7200\nretry=540\nexpire=604800\nminimum=3600\nttl=3600\n\n[DNS_RECORDS]\nA|{DOMAIN}.|{IP}|0|3600\nA|www|{IP}|0|3600\nA|mail|{IP}|0|3600\nNS|{DOMAIN}.|{NS1}.|0|3600\nNS|{DOMAIN}.|{NS2}.|0|3600\nMX|{DOMAIN}.|mail.{DOMAIN}.|10|3600\nTXT|{DOMAIN}.|v=spf1 mx a ~all|0|3600', 'y'); + -- -------------------------------------------------------- @@ -2269,7 +2377,7 @@ INSERT INTO `sys_group` (`groupid`, `name`, `description`, `client_id`) VALUES ( -- Dumping data for table `sys_ini` -- -INSERT INTO `sys_ini` (`sysini_id`, `config`) VALUES (1, ''); +INSERT INTO `sys_ini` (`sysini_id`, `config`, `default_logo`, `custom_logo`) VALUES (1, '', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAABBCAYAAACU5+uOAAAItUlEQVR42u1dCWwVVRStUJZCK6HsFNAgWpaCJkKICZKApKUFhURQpEnZF4EEUJZYEEpBIamgkQpUQBZRW7YCBqQsggsQEAgKLbIGCYsSCNqyQ8D76h18Hd/MvJk/n/bXc5KT+TNz79vPzNv+/2FhAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAOAe++s0akTsRZxMnE6cGkKcxkwhPofaBPwWRzxxB/EO8UGI8xhxEGoV8EscY8qBKFRcgdoFAhXHC+VUHAbHo5aBQASyrZwL5DoxEjUNeBXI9XIuEMEE1DTgVSA3FA3qIDEtBLnTQiBDUNOAV4EUKhpURojmZQQEAjwKgSwK0bykWQgEU74ABAKBABAIBOIJffoNrkRsS0whDiMO5uNw4gBiSxvfGOJrbDtMOgr2JNa18HmZmETsopnGp4h9xdF0TcQRb8NEPkawTzv2qaWIoybnZYRUBoJD+difGAuBlCy0qsRM4mfERcTFfGygsBUF/xFxE/EQ8RixwIbi/j7il8R3iE8qwuxAXMJxuuFiTvNMYleb/E0gXiI+cOBaISTJrzLxcw2/+8Q5pjjfNNkM0RDILLadpbimw+bsc4DPkxRpuqkZ1orisoBAiguuhkUhPSvZRBA3u6gsK94g9jDFP9aHcAV3EKNNYX8i3RcNJ4M4nTiROJCYykIzbGZKvouk68vYbyS/cUbz+RrJZpzkO5Sv3eajaJhRDvUwg21nKK4VcF5WKPgFH6PZZw/7dJXC6S6lczunfbIQLpeDkZ+lJcoCAikuvChioaLBtfD4JHPiXSFKKexBPoa9Wwr3ael6skMZDGO7K3z+uOSb5OA7mu2KiOGmPH3ADVh8/sohnDS2S1NcG+uiO/kd+8RL146YRWzj359tb0Eg+gIpsHkjFNrQqiF3DZJABDtyuCP5/FuNRlHN8Ofz9nx+XLNR3jR1c4w8TSFGSmnr4FEgU7wKhI51jAeTpv+/ZQGBOAuEu1d/Ku6LV35t9rdigkUjHuMgkHPEecQsxdjjUx4zHbMI+10OdzqfZ2o0iiqSfzgPfMXnzZqN6iTbJ5jytMTU0E97FEhaAAJ5kc/PuJjQOCoIgegJpKbUl5b5vGaBT+A+vOgn5/JYIdFBIOs1wo1kIZl93+P70/h8oUZYFXkmKInPU9h3m2YeT8lvRilPyyWbi3xt4iMWSDc+P4lp3uAIRDxdryjui6dmuujXcr91IDcMmaJv31WISfTrLeJXCUT3yb1a4Ztmalyu61MaZG/XtD9tapRGnpZKNp2lNNZ3KZARAQgk3untBYEEPgbJ92FsIAax34v1AQ2B5Go2BlW60n0QyCC/BWISdJ5LgewWU8k86DdTzMyNh0BKVyAzfB5I93YQyBGeTlW9lQbwIle2Rdgzy7BAxJT6Hb6X6EIgTrznRSCiHli02cwcPor1pbkQiL5AKvOA+ZZPAtkfxFms3j4IZHAwBGJaRPxdjH00BSImJRqKOlEwjtjUo0Dm2pWla4HMzsyqQIxSMKI8C8RkL9YXuhDf5gqcw4NweaZJiGkh8UeLwi+Utkb4KZCrYszkVSDiQRDMN4hkf5DvZ2gKZJyLPJgFkmAjEDEF3EYSWzPeklO8Q8CLQGKJhQquK+eDdLFNZBJxFLEf8XUXFTbcYv2kRhAEIq+vGNO88zTTKVaRzxPrSSvPW11O8yZqCiROSnMsX0sP0ixWops1Hfbx/AaJIz5QcFc5n+ZVNcbxmoWtEsBNB4EU8Tgk32Gv1wneEybeWG1N8RoNbplmOo2neiyxE3/eoun7G9t31hGIqXuzl8/HB0kgxhvhD03/KoEIpIWFQPLK+UJhkWpgKLZP8IKhajNhJg8A7yt8/5K6QoFM8z5mc68Ph3VWM6wTbN+a+AR/vqThV13KYyMXAgmXps9FnK8GSSA17KaXFf7R3gUyd8H/TiBss9fngfQehzfMpkDLgxcS73J4k1y85WrxtTtOjZPuVZA2O55RhLfUId5XpI2UHwZDIHxtp7HtRrVL25SfhWy7z7VAMuYvipszd0FJcfxzHspdrMctGnGcZNPTZ4F0VszqyPSlPHm8JG9f2SDtgF3Nq/rnJZssyXeUdP0CN64c9l/FDfGyZNNNkaeVGmnMM+Vdtd19los8/2e7Ow/E70lxiG7pRmkn8AaeULlcoo4sBDLfKvL0nLUxablfX0hfmfuQ01avI65fUQYEkupRIJHcAMwbDWNNdmLgupV4zeMO3stcIZ1M4aYo4vZt0oO7Locd0ndGTEQofN+QxiZ22+y7W+RpgUb66vOU7232SZXupZqvaYT3Dfu8ZLrejtc47mvkJ9FoVEWKBmW7dyc7ZXD1Nb2TH3JVn5Tqa3r1repzY6/gwWeqhUCGO/XjWSTmjYYVLOzFoP0Z/qJTks033brxrtjmxCbGtK4ivEqKuH2fNuc0tDatIYgna4yGbz2eeTL8WhJbic2aDnmqqpm2KlLeK5vWn0pc0wirGvtUtBkzNdPKDzWe24oGdZX4CzGfWCD4U93GBQdqNSw4Uiny8K9h4buOhlU2scq+Q1G1i233k63hFwBPEfcS04l1FGJoynbH+fgz8ZKFQJLDAMDjk/psCPzw20XxE6mmdLd24d8KNQ14FciUEPl1xHvEhlK6W2j65aOWgUAEUpV4NEREstyDQNqjloFARVKL/xukrAvkGjGC09zGwfYKsQdqF/BTKMnEJcTtxC3EPAU3iic5cRkfjc/ZFvZuuZm4gXjOouG35LQ2Yfutkq/4pfpN/E9TDVCjQGkJqQExho+CjYlRPseRiQE3EIriaMZTw4K3mOJv23J8jme23RsEAMqqQJrb9PnnEbPEVpUAuJD4Mf/PoCqeONQCUJYFElGKf7ojpnqjUQtAWRdJaf1t2w8ofSAUBNKulATSEaUPhIpIRj9icbyFUgdCTSRTeR0i2HwfpQ0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQBnG392D9QU+JXhxAAAAAElFTkSuQmCC', ''); -- -------------------------------------------------------- diff --git a/install/tpl/apache_apps_fcgi_starter.master b/install/tpl/apache_apps_fcgi_starter.master index 8a26441e681dede416531c8e4f1d613bc95faf28..8ef1cbbc7624f06f48e1185d6987ec694a1e57de 100644 --- a/install/tpl/apache_apps_fcgi_starter.master +++ b/install/tpl/apache_apps_fcgi_starter.master @@ -3,4 +3,8 @@ PHPRC={fastcgi_phpini_path} export PHPRC export PHP_FCGI_MAX_REQUESTS=5000 export PHP_FCGI_CHILDREN=1 -exec {fastcgi_bin} -d magic_quotes_gpc=off \ No newline at end of file +exec {fastcgi_bin} -d \ + -d disable_classes= \ + -d disable_functions= \ + -d magic_quotes_gpc=off \ + -d open_basedir= diff --git a/install/tpl/apache_ispconfig_fcgi_starter.master b/install/tpl/apache_ispconfig_fcgi_starter.master index 240fcccd68c152edba3a4bc1d187ae89c6c843d7..ab7d13f2874ac7b5e74304586cc7d451ebb5729a 100644 --- a/install/tpl/apache_ispconfig_fcgi_starter.master +++ b/install/tpl/apache_ispconfig_fcgi_starter.master @@ -3,4 +3,9 @@ PHPRC={fastcgi_phpini_path} export PHPRC export PHP_FCGI_MAX_REQUESTS=5000 export PHP_FCGI_CHILDREN=1 -exec {fastcgi_bin} -d magic_quotes_gpc=off -d session.save_path=/usr/local/ispconfig/interface/temp \ No newline at end of file +exec {fastcgi_bin} \ + -d disable_classes= \ + -d disable_functions= \ + -d magic_quotes_gpc=off \ + -d open_basedir= \ + -d session.save_path=/usr/local/ispconfig/interface/temp diff --git a/install/tpl/authmysqlrc.master b/install/tpl/authmysqlrc.master index d44b4f2ab14bd7d6e8cc4e1cbd15a2584e14d909..ec4095d3fb9331cee554932a457bd7a3af2de73d 100644 --- a/install/tpl/authmysqlrc.master +++ b/install/tpl/authmysqlrc.master @@ -1,7 +1,7 @@ MYSQL_SERVER {mysql_server_host} MYSQL_USERNAME {mysql_server_ispconfig_user} MYSQL_PASSWORD {mysql_server_ispconfig_password} -MYSQL_PORT 0 +MYSQL_PORT {mysql_server_port} MYSQL_DATABASE {mysql_server_database} MYSQL_USER_TABLE mail_user MYSQL_CRYPT_PWFIELD password diff --git a/install/tpl/bastille-firewall.cfg.master b/install/tpl/bastille-firewall.cfg.master index 728a731dc115c1f45e79b85474a7e763563a74fd..408713d74631a8922bafc4348d8168bebf396a1c 100644 --- a/install/tpl/bastille-firewall.cfg.master +++ b/install/tpl/bastille-firewall.cfg.master @@ -75,7 +75,7 @@ DNS_SERVERS="{DNS_SERVERS}" # use the "\" continuation character (so Bastille can change the # values if it is run more than once) TRUSTED_IFACES="lo" # MINIMAL/SAFEST -PUBLIC_IFACES="eth+ ppp+ slip+ venet+ bond+" # SAFEST +PUBLIC_IFACES="eth+ ppp+ slip+ venet+ bond+ en+" # SAFEST INTERNAL_IFACES="" # SAFEST diff --git a/install/tpl/config.inc.php.master b/install/tpl/config.inc.php.master index e5fa2c425923d423e6b3a31fe3d38b0a2da8778c..02a7b2f65ccccde2db89cfcaac24e86307e88843 100644 --- a/install/tpl/config.inc.php.master +++ b/install/tpl/config.inc.php.master @@ -63,6 +63,7 @@ define('DEVSYSTEM', 0); //** Database $conf['db_type'] = 'mysql'; $conf['db_host'] = '{mysql_server_host}'; +$conf['db_port'] = '{mysql_server_port}'; $conf['db_database'] = '{mysql_server_database}'; $conf['db_user'] = '{mysql_server_ispconfig_user}'; $conf['db_password'] = '{mysql_server_ispconfig_password}'; @@ -72,6 +73,7 @@ $conf['db_client_flags'] = 0; define('DB_TYPE',$conf['db_type']); define('DB_HOST',$conf['db_host']); +define('DB_PORT',$conf['db_port']); define('DB_DATABASE',$conf['db_database']); define('DB_USER',$conf['db_user']); define('DB_PASSWORD',$conf['db_password']); @@ -81,6 +83,7 @@ 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_port'] = '{mysql_master_server_port}'; $conf['dbmaster_database'] = '{mysql_master_server_database}'; $conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}'; $conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}'; diff --git a/install/tpl/debian6_dovecot-sql.conf.master b/install/tpl/debian6_dovecot-sql.conf.master index 61f86c4cfa6f14dbb6dfa87069bb704337a071c1..30afc1877a96147427c521fc72ba496e9ce1b59a 100644 --- a/install/tpl/debian6_dovecot-sql.conf.master +++ b/install/tpl/debian6_dovecot-sql.conf.master @@ -10,11 +10,12 @@ # ); driver = mysql -connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} +connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} port={mysql_server_port} default_pass_scheme = CRYPT -password_query = SELECT password FROM mail_user WHERE (login = '%u' OR email = '%u') AND disable%Ls = 'n' AND server_id = '{server_id}' -user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' +# password-query with prefetch +password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' +user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' # The iterate_query is required for the doveadm command only and works only on dovecot 2 servers. # Do not enable it on Dovecot 1.x servers diff --git a/install/tpl/debian6_dovecot2.conf.master b/install/tpl/debian6_dovecot2.conf.master index 8da19d195f3c6c61fefd73273a45d8f9f54a5e46..ee77f4e20e0416e7638d2be6e306e920ea6340f9 100644 --- a/install/tpl/debian6_dovecot2.conf.master +++ b/install/tpl/debian6_dovecot2.conf.master @@ -7,10 +7,14 @@ mail_privileged_group = vmail ssl_cert = - #userdb prefetch { - #} + userdb prefetch { + } # User to use for the process. This user needs access to only user and # password databases, nothing else. Only shadow and pam authentication diff --git a/install/tpl/debian_dovecot2.conf.master b/install/tpl/debian_dovecot2.conf.master index 8b21f6a40aba3d719318809a7c3e2ae3b317032b..39cf60fbe4de972a87deb006aab7f092284710fb 100644 --- a/install/tpl/debian_dovecot2.conf.master +++ b/install/tpl/debian_dovecot2.conf.master @@ -8,10 +8,14 @@ postmaster_address = postmaster@example.com ssl_cert = - #userdb prefetch { - #} + userdb prefetch { + } # System users (NSS, /etc/passwd, or similiar). In many systems nowadays this # uses Name Service Switch, which is configured in /etc/nsswitch.conf. diff --git a/install/tpl/fedora_dovecot2.conf.master b/install/tpl/fedora_dovecot2.conf.master index 2b542f1da69458f7238a31c7b04d1f3a33accb6d..9fca31927487a45358dcc98bc259b1af61c04197 100644 --- a/install/tpl/fedora_dovecot2.conf.master +++ b/install/tpl/fedora_dovecot2.conf.master @@ -11,6 +11,9 @@ passdb { args = /etc/dovecot-sql.conf driver = sql } +userdb { + driver = prefetch +} userdb { args = /etc/dovecot-sql.conf driver = sql @@ -57,4 +60,4 @@ protocol lda { protocol lmtp { postmaster_address = webmaster@localhost mail_plugins = quota sieve -} \ No newline at end of file +} diff --git a/install/tpl/fedora_postfix.conf.master b/install/tpl/fedora_postfix.conf.master index 6a2c97ea9a339f69a0968654b9283f6764088e29..473bbceba8e319354fb7f87b1ebcafca184cc17c 100644 --- a/install/tpl/fedora_postfix.conf.master +++ b/install/tpl/fedora_postfix.conf.master @@ -9,7 +9,9 @@ sender_bcc_maps = proxy:mysql:{config_dir}/mysql-virtual_outgoing_bcc.cf smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes -smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:{config_dir}/mysql-virtual_recipient.cf{rbl_list} +smtpd_restriction_classes = greylisting +greylisting = check_policy_service inet:127.0.0.1:10023 +smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:{config_dir}/mysql-virtual_recipient.cf{rbl_list}{greylisting} smtpd_use_tls = yes smtpd_tls_security_level = may smtpd_tls_cert_file = {config_dir}/smtpd.cert @@ -17,8 +19,9 @@ smtpd_tls_key_file = {config_dir}/smtpd.key transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:{config_dir}/mysql-virtual_transports.cf relay_domains = mysql:{config_dir}/mysql-virtual_relaydomains.cf relay_recipient_maps = mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf -proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $sender_bcc_maps $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks -smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re +smtpd_sender_login_maps = proxy:mysql:{config_dir}/mysql-virtual_sender_login_maps.cf +proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $sender_bcc_maps $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps +smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re{reject_slm}, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re smtpd_client_restrictions = check_client_access mysql:{config_dir}/mysql-virtual_client.cf smtpd_client_message_rate_limit = 100 maildrop_destination_concurrency_limit = 1 @@ -33,3 +36,5 @@ smtp_tls_security_level = may smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3 smtpd_tls_protocols = !SSLv2,!SSLv3 smtp_tls_protocols = !SSLv2,!SSLv3 +smtpd_tls_exclude_ciphers = RC4, aNULL +smtp_tls_exclude_ciphers = RC4, aNULL diff --git a/install/tpl/gentoo_postfix.conf.master b/install/tpl/gentoo_postfix.conf.master index 8db67c4d9dc96d5a68b82fec3e0aeb4558a1b2db..f5730f7e9f90c9c60f0c31baa5db89e1bceab287 100644 --- a/install/tpl/gentoo_postfix.conf.master +++ b/install/tpl/gentoo_postfix.conf.master @@ -8,7 +8,9 @@ virtual_gid_maps = mysql:/etc/postfix/mysql-virtual_gids.cf smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes -smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:{config_dir}/mysql-virtual_recipient.cf{rbl_list} +smtpd_restriction_classes = greylisting +greylisting = check_policy_service inet:127.0.0.1:10023 +smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:{config_dir}/mysql-virtual_recipient.cf{rbl_list}{greylisting} smtpd_use_tls = yes smtpd_tls_security_level = may smtpd_tls_cert_file = {config_dir}/smtpd.cert @@ -16,8 +18,9 @@ smtpd_tls_key_file = {config_dir}/smtpd.key transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:{config_dir}/mysql-virtual_transports.cf relay_domains = mysql:{config_dir}/mysql-virtual_relaydomains.cf relay_recipient_maps = mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf -proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks -smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re +smtpd_sender_login_maps = proxy:mysql:{config_dir}/mysql-virtual_sender_login_maps.cf +proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps +smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re{reject_slm}, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re smtpd_client_restrictions = check_client_access mysql:{config_dir}/mysql-virtual_client.cf smtpd_client_message_rate_limit = 100 maildrop_destination_concurrency_limit = 1 @@ -32,3 +35,5 @@ smtp_tls_security_level = may smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3 smtpd_tls_protocols = !SSLv2,!SSLv3 smtp_tls_protocols = !SSLv2,!SSLv3 +smtpd_tls_exclude_ciphers = RC4, aNULL +smtp_tls_exclude_ciphers = RC4, aNULL diff --git a/install/tpl/metronome_conf_global.master b/install/tpl/metronome_conf_global.master new file mode 100644 index 0000000000000000000000000000000000000000..68f4c59b6b34badb6abb216eccbbbd053ac897f0 --- /dev/null +++ b/install/tpl/metronome_conf_global.master @@ -0,0 +1,65 @@ +pidfile = "/var/run/metronome/metronome.pid"; +metronome_max_files_soft = 200000; +metronome_max_files_hard = 300000; +plugin_paths = { + "/usr/lib/metronome/isp-modules", +}; +use_libevent = true; +log = { + debug = "/var/log/metronome/metronome.dbg", + info = "/var/log/metronome/metronome.log", + error = "/var/log/metronome/metronome.err", +}; +use_ipv6 = true; +http_ports = { + 5290, +}; +https_ports = { + 5291, +}; +pastebin_ports = { + 5292, +}; +bosh_ports = { + 5280, +}; +admins = { + {tmpl_var xmpp_admins} +}; +modules_enabled = { + "saslauth", + "tls", + "dialback", + "disco", + "discoitems", + "version", + "uptime", + "time", + "ping", + "admin_adhoc", + "admin_telnet", + "bosh", + "posix", + "announce", + "offline", + "webpresence", + "mam", + "stream_management", + "message_carbons" +}; +modules_disabled = { +}; +bosh_max_inactivity = 30; +consider_bosh_secure = true; +cross_domain_bosh = true; +allow_registration = false; +ssl = { + key = "/etc/metronome/certs/localhost.key", + certificate = "/etc/metronome/certs/localhost.cert", +}; +c2s_require_encryption = false; +s2s_secure = true; +s2s_insecure_domains = { + "gmail.com", +}; +authentication = "internal_plain"; diff --git a/install/tpl/metronome_conf_main.master b/install/tpl/metronome_conf_main.master new file mode 100644 index 0000000000000000000000000000000000000000..f9c8fbdd655f0771c277df692916f5e1ba78cf5e --- /dev/null +++ b/install/tpl/metronome_conf_main.master @@ -0,0 +1,3 @@ +Include "/etc/metronome/global.cfg.lua" +Include "/etc/metronome/hosts/*.lua" +Include "/etc/metronome/status/*.lua" diff --git a/install/tpl/metronome_conf_ssl.master b/install/tpl/metronome_conf_ssl.master new file mode 100644 index 0000000000000000000000000000000000000000..922dfd22a1ab6c4f726fcc4b0eb84cdd60f73ec4 --- /dev/null +++ b/install/tpl/metronome_conf_ssl.master @@ -0,0 +1,48 @@ +oid_section = new_oids + +[ new_oids ] + +# RFC 3920 section 5.1.1 defines this OID +xmppAddr = 1.3.6.1.5.5.7.8.5 + +# RFC 4985 defines this OID +SRVName = 1.3.6.1.5.5.7.8.7 + +[ req ] + +default_bits = 4096 +default_keyfile = {tmpl_var name='domain'}.key +distinguished_name = distinguished_name +req_extensions = v3_extensions +x509_extensions = v3_extensions + +# ask about the DN? +prompt = no + +[ distinguished_name ] + +commonName = {tmpl_var name='domain'} +countryName = {tmpl_var name='ssl_country'} +localityName = {tmpl_var name='ssl_locality'} +organizationName = {tmpl_var name='ssl_organisation'} +organizationalUnitName = {tmpl_var name='ssl_organisation_unit'} +emailAddress = {tmpl_var name='ssl_email'} + +[ v3_extensions ] + +# for certificate requests (req_extensions) +# and self-signed certificates (x509_extensions) + +basicConstraints = CA:FALSE +keyUsage = digitalSignature,keyEncipherment +extendedKeyUsage = serverAuth,clientAuth +subjectAltName = @subject_alternative_name + +[ subject_alternative_name ] + +# See http://tools.ietf.org/html/draft-ietf-xmpp-3920bis#section-13.7.1.2 for more info. + +DNS.0 = {tmpl_var name='domain'} +otherName.0 = xmppAddr;FORMAT:UTF8,UTF8:{tmpl_var name='domain'} +otherName.1 = SRVName;IA5STRING:_xmpp-client.{tmpl_var name='domain'} +otherName.2 = SRVName;IA5STRING:_xmpp-server.{tmpl_var name='domain'} \ No newline at end of file diff --git a/install/tpl/mydns.conf.master b/install/tpl/mydns.conf.master index 4af5a8efa906406a4ac3eaa85fd6dd593c7463b7..fbfac0201a78d99277dd5a5b6d33536036a8f394 100644 --- a/install/tpl/mydns.conf.master +++ b/install/tpl/mydns.conf.master @@ -18,6 +18,7 @@ db-host = {mysql_server_host} # SQL server hostname db-user = {mysql_server_ispconfig_user} # SQL server username db-password = {mysql_server_ispconfig_password} # SQL server password database = {mysql_server_database} # MyDNS database name +db-port = {mysql_server_port} # SQL server port # GENERAL OPTIONS diff --git a/install/tpl/mysql-virtual_outgoing_bcc.cf.master b/install/tpl/mysql-virtual_outgoing_bcc.cf.master new file mode 100644 index 0000000000000000000000000000000000000000..6ca154f3b9fefc2d55610a30ef13c158a826ae1d --- /dev/null +++ b/install/tpl/mysql-virtual_outgoing_bcc.cf.master @@ -0,0 +1,8 @@ +user = {mysql_server_ispconfig_user} +password = {mysql_server_ispconfig_password} +dbname = {mysql_server_database} +table = mail_user +select_field = sender_cc +where_field = email +additional_conditions = and postfix = 'y' and disabledeliver = 'n' and disablesmtp = 'n' +hosts = 127.0.0.1 \ No newline at end of file diff --git a/install/tpl/mysql-virtual_policy_greylist.cf.master b/install/tpl/mysql-virtual_policy_greylist.cf.master new file mode 100644 index 0000000000000000000000000000000000000000..8beb7c4509c505f189313e401718a76deccaa473 --- /dev/null +++ b/install/tpl/mysql-virtual_policy_greylist.cf.master @@ -0,0 +1,5 @@ +user = {mysql_server_ispconfig_user} +password = {mysql_server_ispconfig_password} +dbname = {mysql_server_database} +query = SELECT 'greylisting' FROM (SELECT greylisting, source AS email FROM mail_forwarding WHERE server_id = {server_id} UNION SELECT greylisting, email FROM mail_user WHERE server_id = {server_id}) addresses WHERE addresses.email='%s' AND addresses.greylisting='y' +hosts = {mysql_server_ip} \ No newline at end of file diff --git a/install/tpl/mysql-virtual_sender_login_maps.cf.master b/install/tpl/mysql-virtual_sender_login_maps.cf.master new file mode 100644 index 0000000000000000000000000000000000000000..ad2d758b081c576cd384fb14a75602e66a534075 --- /dev/null +++ b/install/tpl/mysql-virtual_sender_login_maps.cf.master @@ -0,0 +1,5 @@ +user = {mysql_server_ispconfig_user} +password = {mysql_server_ispconfig_password} +dbname = {mysql_server_database} +query = SELECT destination FROM mail_forwarding WHERE source = '%s' AND active = 'y' AND type = 'alias' AND server_id = {server_id} UNION SELECT email FROM mail_user WHERE email = '%s' AND disablesmtp = 'n' AND server_id = {server_id}; +hosts = {mysql_server_ip} \ No newline at end of file diff --git a/install/tpl/nginx_apps.vhost.master b/install/tpl/nginx_apps.vhost.master index 2c720b55a86b9582e88ebd3f2619e787dab533c1..57a78bca2a54c184624d3463a25480b4a64fa2ce 100644 --- a/install/tpl/nginx_apps.vhost.master +++ b/install/tpl/nginx_apps.vhost.master @@ -12,7 +12,7 @@ server { } # serve static files directly - location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { + location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { access_log off; } diff --git a/install/tpl/nginx_ispconfig.vhost.master b/install/tpl/nginx_ispconfig.vhost.master index 70d6a53b590e3b50ed5e9fa32f552e7cc33a6f65..528ee2cc6eb76ab19bb332f957e7d80aaebaf231 100644 --- a/install/tpl/nginx_ispconfig.vhost.master +++ b/install/tpl/nginx_ispconfig.vhost.master @@ -19,7 +19,7 @@ server { } # serve static files directly - location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { + location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ { access_log off; } diff --git a/install/tpl/opensuse_dovecot-sql.conf.master b/install/tpl/opensuse_dovecot-sql.conf.master index 57515afe872099e2652258d58730f8a388fb65fd..f9ffbf7c069cc58f723a1bca94e8bccd249b824b 100644 --- a/install/tpl/opensuse_dovecot-sql.conf.master +++ b/install/tpl/opensuse_dovecot-sql.conf.master @@ -130,11 +130,12 @@ # FROM users WHERE userid = '%u' driver = mysql -connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} +connect = host={mysql_server_host} dbname={mysql_server_database} user={mysql_server_ispconfig_user} password={mysql_server_ispconfig_password} port={mysql_server_port} default_pass_scheme = CRYPT -password_query = SELECT password FROM mail_user WHERE (login = '%u' OR email = '%u') AND disable%Ls = 'n' AND server_id = '{server_id}' -user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' +# password-query with prefetch +password_query = SELECT email as user, password, maildir as userdb_home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as userdb_mail, uid as userdb_uid, gid as userdb_gid, CONCAT('*:storage=', quota, 'B') AS userdb_quota_rule, CONCAT(maildir, '/.sieve') as userdb_sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' +user_query = SELECT email as user, maildir as home, CONCAT( maildir_format, ':', maildir, '/', IF(maildir_format='maildir','Maildir',maildir_format)) as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE (login = '%u' OR email = '%u') AND `disable%Ls` = 'n' AND server_id = '{server_id}' # The iterate_query is required for the doveadm command only and works only on dovecot 2 servers. # Do not enable it on Dovecot 1.x servers diff --git a/install/tpl/opensuse_dovecot.conf.master b/install/tpl/opensuse_dovecot.conf.master index eca13a6ec3d82727bd778ef8da5cbbd4cb1bde81..9d345fa911af48198caf1d322b32ca460d99be59 100644 --- a/install/tpl/opensuse_dovecot.conf.master +++ b/install/tpl/opensuse_dovecot.conf.master @@ -1033,8 +1033,8 @@ auth default { # This can be made to work with SQL and LDAP databases, see their example # configuration files for more information how to do it. # - #userdb prefetch { - #} + userdb prefetch { + } # System users (NSS, /etc/passwd, or similiar). In many systems nowadays this # uses Name Service Switch, which is configured in /etc/nsswitch.conf. diff --git a/install/tpl/opensuse_dovecot2.conf.master b/install/tpl/opensuse_dovecot2.conf.master index 8da19d195f3c6c61fefd73273a45d8f9f54a5e46..1b9d9dc1555935880984885001fc97a14949ff70 100644 --- a/install/tpl/opensuse_dovecot2.conf.master +++ b/install/tpl/opensuse_dovecot2.conf.master @@ -11,6 +11,9 @@ passdb { args = /etc/dovecot/dovecot-sql.conf driver = sql } +userdb { + driver = prefetch +} userdb { args = /etc/dovecot/dovecot-sql.conf driver = sql diff --git a/install/tpl/opensuse_postfix.conf.master b/install/tpl/opensuse_postfix.conf.master index 5afd78ef06886732b58d53457d053f675af39663..f018e23210ad517e3c2c2e824ee5be6f6fd87013 100644 --- a/install/tpl/opensuse_postfix.conf.master +++ b/install/tpl/opensuse_postfix.conf.master @@ -11,7 +11,9 @@ sender_bcc_maps = proxy:mysql:{config_dir}/mysql-virtual_outgoing_bcc.cf smtpd_sasl_auth_enable = yes broken_sasl_auth_clients = yes smtpd_sasl_authenticated_header = yes -smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:{config_dir}/mysql-virtual_recipient.cf{rbl_list} +smtpd_restriction_classes = greylisting +greylisting = check_policy_service inet:127.0.0.1:10023 +smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_recipient_access mysql:{config_dir}/mysql-virtual_recipient.cf{rbl_list}{greylisting} smtpd_use_tls = yes smtpd_tls_security_level = may smtpd_tls_cert_file = {config_dir}/smtpd.cert @@ -19,8 +21,9 @@ smtpd_tls_key_file = {config_dir}/smtpd.key transport_maps = hash:/var/lib/mailman/data/transport-mailman, proxy:mysql:{config_dir}/mysql-virtual_transports.cf relay_domains = mysql:{config_dir}/mysql-virtual_relaydomains.cf relay_recipient_maps = mysql:{config_dir}/mysql-virtual_relayrecipientmaps.cf -proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $sender_bcc_maps $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks -smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re +smtpd_sender_login_maps = proxy:mysql:{config_dir}/mysql-virtual_sender_login_maps.cf +proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $sender_bcc_maps $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $smtpd_sender_login_maps +smtpd_sender_restrictions = check_sender_access mysql:{config_dir}/mysql-virtual_sender.cf regexp:{config_dir}/tag_as_originating.re{reject_slm}, permit_mynetworks, check_sender_access regexp:{config_dir}/tag_as_foreign.re smtpd_client_restrictions = check_client_access mysql:{config_dir}/mysql-virtual_client.cf smtpd_client_message_rate_limit = 100 maildrop_destination_concurrency_limit = 1 @@ -35,3 +38,5 @@ smtp_tls_security_level = may smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3 smtpd_tls_protocols = !SSLv2,!SSLv3 smtp_tls_protocols = !SSLv2,!SSLv3 +smtpd_tls_exclude_ciphers = RC4, aNULL +smtp_tls_exclude_ciphers = RC4, aNULL diff --git a/install/tpl/pdns.local.master b/install/tpl/pdns.local.master index 3e29ec46fb19e90d24f28d56034e47d41d979603..eb4ab7145ae6e2a0cb7afb1a9c40ec3733bca187 100644 --- a/install/tpl/pdns.local.master +++ b/install/tpl/pdns.local.master @@ -7,6 +7,7 @@ gmysql-host={mysql_server_host} gmysql-user={mysql_server_ispconfig_user} gmysql-password={mysql_server_ispconfig_password} gmysql-dbname={powerdns_database} +gmysql-port={mysql_server_port} slave=yes master=yes diff --git a/install/tpl/php_fpm_pool.conf.master b/install/tpl/php_fpm_pool.conf.master index 9ff7ebc9426ece96b15e1613262db627cd70b72a..16e1241bb9d9474237173199714b1dfba2c2c202 100644 --- a/install/tpl/php_fpm_pool.conf.master +++ b/install/tpl/php_fpm_pool.conf.master @@ -16,6 +16,6 @@ pm.max_spare_servers = 5 chdir = / -; php_admin_value[open_basedir] = /usr/local/ispconfig/interface:/usr/share +; php_admin_value[open_basedir] = /usr/local/ispconfig/interface:/usr/local/ispconfig/security:/usr/share:/var/lib/roundcube:/etc/roundcube:/usr/share/roundcube php_admin_value[session.save_path] = /usr/local/ispconfig/interface/temp php_admin_flag[magic_quotes_gpc] = off \ No newline at end of file diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master index c563650c75467728ca2fd17a84fc9ab491d4deb4..ec7fac8af3ba30537ff341be74b9e99a2e2972e6 100644 --- a/install/tpl/server.ini.master +++ b/install/tpl/server.ini.master @@ -16,7 +16,7 @@ firewall=bastille loglevel=2 admin_notify_events=1 backup_dir=/var/backup -backup_dir_is_mount=n +backup_dir_is_mount=y backup_mode=rootgz backup_delete=y monit_url= @@ -77,6 +77,7 @@ apps_vhost_ip=_default_ apps_vhost_servername= php_open_basedir=[website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin htaccess_allow_override=All +enable_spdy=y awstats_conf_dir=/etc/awstats awstats_data_dir=/var/lib/awstats awstats_pl=/usr/lib/cgi-bin/awstats.pl @@ -85,6 +86,7 @@ php_ini_path_apache=/etc/php5/apache2/php.ini php_ini_path_cgi=/etc/php5/cgi/php.ini check_apache_config=y enable_sni=y +enable_spdy=n enable_ip_wildcard=y overtraffic_notify_admin=y overtraffic_notify_client=y @@ -127,7 +129,7 @@ fastcgi_config_syntax=1 [jailkit] jailkit_chroot_home=/home/[username] jailkit_chroot_app_sections=basicshell editors extendedshell netutils ssh sftp scp groups jk_lsh -jailkit_chroot_app_programs=/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico +jailkit_chroot_app_programs=/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico /usr/bin/mysql /usr/bin/mysqldump /usr/bin/git /usr/bin/git-receive-pack /usr/bin/git-upload-pack /usr/bin/unzip /usr/bin/zip /bin/tar /bin/rm /usr/bin/patch jailkit_chroot_cron_programs=/usr/bin/php /usr/bin/perl /usr/share/perl /usr/share/php [vlogger] @@ -144,3 +146,12 @@ do_not_try_rescue_httpd=n do_not_try_rescue_mysql=n do_not_try_rescue_mail=n +[xmpp] +xmpp_use_ispv6=n +xmpp_bosh_max_inactivity=30 +xmpp_server_admins=admin@service.com, superuser@service.com +xmpp_modules_enabled=saslauth, tls, dialback, disco, discoitems, version, uptime, time, ping, admin_adhoc, admin_telnet, bosh, posix, announce, offline, webpresence, mam, stream_management, message_carbons +xmpp_port_http=5290 +xmpp_port_https=5291 +xmpp_port_pastebin=5292 +xmpp_port_bosh=5280 diff --git a/install/tpl/system.ini.master b/install/tpl/system.ini.master index f1a1bc901cb92cde78684a013485dce4dad2c9a4..92ae518697a8a1938f5ae9219c2bd634da6d2945 100644 --- a/install/tpl/system.ini.master +++ b/install/tpl/system.ini.master @@ -8,6 +8,9 @@ [mail] enable_custom_login=n +mailbox_show_autoresponder_tab=y +mailbox_show_mail_filter_tab=y +mailbox_show_custom_rules_tab=y mailboxlist_webmail_link=y webmail_url=/webmail dkim_path=/var/lib/amavis/dkim @@ -23,9 +26,13 @@ webdavuser_prefix=[CLIENTNAME] dblist_phpmyadmin_link=y phpmyadmin_url=/phpmyadmin webftp_url= +vhost_subdomains=n +vhost_aliasdomains=n client_username_web_check_disabled=n +backups_include_into_web_quota=n reseller_can_use_options=n + [tools] [domains] diff --git a/install/uninstall.php b/install/uninstall.php index 56cf0eb58b7bee9fb4ffb4d6c54c57470f30b0e1..111f57466311f6c70f017a4654c192603fc3305c 100644 --- a/install/uninstall.php +++ b/install/uninstall.php @@ -60,14 +60,6 @@ if($do_uninstall == 'yes') { echo "\n\n>> Uninstalling ISPConfig 3... \n\n"; - // Delete the ISPConfig database - // $app->db->query("DROP DATABASE '".$conf["db_database"]."'"); - // $app->db->query("DELETE FROM mysql.user WHERE User = 'ispconfig'"); - -// exec("/etc/init.d/mysql stop"); -// exec("rm -rf /var/lib/mysql/".$conf["db_database"]); -// exec("/etc/init.d/mysql start"); - $link = mysql_connect($clientdb_host, $clientdb_user, $clientdb_password); if (!$link) { echo "Unable to connect to the database'.mysql_error($link)"; diff --git a/install/update.php b/install/update.php index 311c070dfc8d1f7ecafc60564893eb3ce888270c..97b28fdf54905b8b1147cbd8bb2080a92bb435db 100644 --- a/install/update.php +++ b/install/update.php @@ -247,13 +247,15 @@ if($conf['mysql']['master_slave_setup'] == 'y') { $finished = false; do { $tmp_mysql_server_host = $inst->free_query('MySQL master server hostname', $conf['mysql']['master_host'],'mysql_master_hostname'); + $tmp_mysql_server_port = $inst->free_query('MySQL master server port', $conf['mysql']['master_port'],'mysql_master_port'); $tmp_mysql_server_admin_user = $inst->free_query('MySQL master server root username', $conf['mysql']['master_admin_user'],'mysql_master_root_user'); $tmp_mysql_server_admin_password = $inst->free_query('MySQL master server root password', $conf['mysql']['master_admin_password'],'mysql_master_root_password'); $tmp_mysql_server_database = $inst->free_query('MySQL master server database name', $conf['mysql']['master_database'],'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)) { + if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password, (int)$tmp_mysql_server_port)) { $conf['mysql']['master_host'] = $tmp_mysql_server_host; + $conf['mysql']['master_port'] = $tmp_mysql_server_port; $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; @@ -267,10 +269,8 @@ if($conf['mysql']['master_slave_setup'] == 'y') { // 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"]; + $inst->dbmaster->setDBData($conf['mysql']["master_host"], $conf['mysql']["master_admin_user"], $conf['mysql']["master_admin_password"]); + $inst->dbmaster->setDBName($conf['mysql']["master_database"]); } else { $inst->dbmaster = $inst->db; } @@ -392,6 +392,11 @@ if($reconfigure_services_answer == 'yes') { $inst->configure_apps_vhost(); } + if($conf['services']['xmpp']) { + //** Configure Metronome XMPP + $inst->configure_xmpp('dont-create-certs'); + } + //* Configure DBServer swriteln('Configuring Database'); @@ -494,6 +499,10 @@ if($reconfigure_services_answer == 'yes') { if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null'); } + if($conf['services']['xmpp']) { + if($conf['xmpp']['installed'] == true && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['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['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null'); @@ -504,6 +513,11 @@ if($reconfigure_services_answer == 'yes') { } } +//* Set default servers +setDefaultServers(); + +$inst->create_mount_script(); + //* Create md5 filelist $md5_filename = '/usr/local/ispconfig/security/data/file_checksums_'.date('Y-m-d_h-i').'.md5'; exec('find /usr/local/ispconfig -type f -print0 | xargs -0 md5sum > '.$md5_filename); diff --git a/interface/lib/app.inc.php b/interface/lib/app.inc.php index 615e39087b8898ba1e62f70726f8ee6373980df0..949f1643cf1f12d78611adf0f027b3452ffa387e 100755 --- a/interface/lib/app.inc.php +++ b/interface/lib/app.inc.php @@ -70,6 +70,8 @@ class app { $this->uses('session'); $sess_timeout = $this->conf('interface', 'session_timeout'); + $cookie_domain = (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']); + $cookie_secure = ($_SERVER["HTTPS"] == 'on')?true:false; if($sess_timeout) { /* check if user wants to stay logged in */ if(isset($_POST['s_mod']) && isset($_POST['s_pg']) && $_POST['s_mod'] == 'login' && $_POST['s_pg'] == 'index' && isset($_POST['stay']) && $_POST['stay'] == '1') { @@ -79,19 +81,19 @@ class app { $tmp = $this->ini_parser->parse_ini_string(stripslashes($tmp['config'])); if(!isset($tmp['misc']['session_allow_endless']) || $tmp['misc']['session_allow_endless'] != 'y') { $this->session->set_timeout($sess_timeout); - session_set_cookie_params(3600 * 24 * 365); // cookie timeout is never updated, so it must not be short + session_set_cookie_params(3600 * 24 * 365,'/',$cookie_domain,$cookie_secure,true); // cookie timeout is never updated, so it must not be short } else { // we are doing login here, so we need to set the session data $this->session->set_permanent(true); - $this->session->set_timeout(365 * 24 * 3600); // one year - session_set_cookie_params(3600 * 24 * 365); // cookie timeout is never updated, so it must not be short + $this->session->set_timeout(365 * 24 * 3600,'/',$cookie_domain,$cookie_secure,true); // one year + session_set_cookie_params(3600 * 24 * 365,'/',$cookie_domain,$cookie_secure,true); // cookie timeout is never updated, so it must not be short } } else { $this->session->set_timeout($sess_timeout); - session_set_cookie_params(3600 * 24 * 365); // cookie timeout is never updated, so it must not be short + session_set_cookie_params(3600 * 24 * 365,'/',$cookie_domain,$cookie_secure,true); // cookie timeout is never updated, so it must not be short } } else { - session_set_cookie_params(0); // until browser is closed + session_set_cookie_params(0,'/',$cookie_domain,$cookie_secure,true); // until browser is closed } session_set_save_handler( array($this->session, 'open'), @@ -153,15 +155,15 @@ class app { public function conf($plugin, $key, $value = null) { if(is_null($value)) { - $tmpconf = $this->db->queryOneRecord("SELECT `value` FROM `sys_config` WHERE `group` = '" . $this->db->quote($plugin) . "' AND `name` = '" . $this->db->quote($key) . "'"); + $tmpconf = $this->db->queryOneRecord("SELECT `value` FROM `sys_config` WHERE `group` = ? AND `name` = ?", $plugin, $key); if($tmpconf) return $tmpconf['value']; else return null; } else { if($value === false) { - $this->db->query("DELETE FROM `sys_config` WHERE `group` = '" . $this->db->quote($plugin) . "' AND `name` = '" . $this->db->quote($key) . "'"); + $this->db->query("DELETE FROM `sys_config` WHERE `group` = ? AND `name` = ?", $plugin, $key); return null; } else { - $this->db->query("REPLACE INTO `sys_config` (`group`, `name`, `value`) VALUES ('" . $this->db->quote($plugin) . "', '" . $this->db->quote($key) . "', '" . $this->db->quote($value) . "')"); + $this->db->query("REPLACE INTO `sys_config` (`group`, `name`, `value`) VALUES (?, ?, ?)", $plugin, $key, $value); return $value; } } @@ -177,8 +179,8 @@ class app { $server_id = 0; $priority = $this->functions->intval($priority); $tstamp = time(); - $msg = $this->db->quote('[INTERFACE]: '.$msg); - $this->db->query("INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ($server_id,0,$priority,$tstamp,'$msg')"); + $msg = '[INTERFACE]: '.$msg; + $this->db->query("INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES (?, 0, ?, ?, ?)", $server_id, $priority,$tstamp,$msg); /* if (is_writable($this->_conf['log_file'])) { if (!$fp = fopen ($this->_conf['log_file'], 'a')) { diff --git a/interface/lib/classes/aps_crawler.inc.php b/interface/lib/classes/aps_crawler.inc.php index 7bb2650e09daf6cb87f627b2b2df23feaa58ac81..99db77bdbf7a822f188613d8aee255bdc55bd669 100644 --- a/interface/lib/classes/aps_crawler.inc.php +++ b/interface/lib/classes/aps_crawler.inc.php @@ -189,6 +189,8 @@ class ApsCrawler extends ApsBase curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0); curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1); curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($conn[$i], CURLOPT_SSL_VERIFYHOST, 1); + curl_setopt($conn[$i], CURLOPT_SSL_VERIFYPEER, false); curl_multi_add_handle($mh, $conn[$i]); } @@ -283,182 +285,182 @@ class ApsCrawler extends ApsBase $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); + try { + // 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); - //Find highest version - $app_version = "0.0.0"; - $entry_pos = 1; - for ($p = 1; ; $p++) { - $app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version'); - if (strlen($app_version_tmp) < 1) break; - if (version_compare($app_version_tmp, $app_version) >= 0) { - $app_version = $app_version_tmp; - $entry_pos = $p; + //Find highest version + $app_version = "0.0.0"; + $entry_pos = 1; + for ($p = 1; ; $p++) { + $app_version_tmp = parent::getXPathValue($sxe, 'entry[position()=' . $p . ']/a:version'); + if (strlen($app_version_tmp) < 1) break; + if (version_compare($app_version_tmp, $app_version) >= 0) { + $app_version = $app_version_tmp; + $entry_pos = $p; + } } - } - // 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'); - $app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name"); - $app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version"); - $app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release"); - - // Find out a (possibly) existing package version - $ex_ver = ''; - /* - 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)) { - foreach($existing_apps as $k => $v) { - if($v["Name"] == $app_name) $ex_ver = $v["CurrentVersion"]; + // 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'); + $app_name = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:name"); + $app_version = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:version"); + $app_release = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/a:release"); + + // Find out a (possibly) existing package version + $ex_ver = ''; + /* + 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)) { + foreach($existing_apps as $k => $v) { + 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"); - $app_dl = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@href"); - $app_filesize = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@length"); - $app_metafile = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/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) + $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"); + $app_dl = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@href"); + $app_filesize = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='aps']/@length"); + $app_metafile = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/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) { - $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->datalogUpdate('aps_packages', "package_status = ".PACKAGE_OUTDATED, 'id', $tmp['id']); - unset($tmp); - } + // 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); - // Create the local folder if not yet existing - if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true); + $tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE name = ? AND CONCAT(version, '-', CAST(`release` AS CHAR)) = ?", $app_name, $ex_ver); + $app->db->datalogUpdate('aps_packages', array("package_status" => PACKAGE_OUTDATED), 'id', $tmp['id']); + unset($tmp); + } - // 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); + // Create the local folder if not yet existing + if(!file_exists($local_intf_folder)) @mkdir($local_intf_folder, 0777, true); - // 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++; - } + // 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 package license - //$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href"); - $license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href"); - if($license != '') - { - $local_license = $local_intf_folder.'LICENSE'; - if(!file_exists($local_license) || filesize($local_license) == 0) + // 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' => basename($license), - 'url' => $license, + $apps_to_dl[] = array('name' => 'APP-META.xml', + 'url' => $app_metafile, 'filesize' => 0, - 'localtarget' => $local_license); + 'localtarget' => $local_metafile); + $apps_downloaded++; } - } - // Download package icon - //$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href"); - $icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href"); - if($icon != '') - { - $local_icon = $local_intf_folder.basename($icon); - if(!file_exists($local_icon) || filesize($local_icon) == 0) + // Download package license + //$license = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='eula']/@href"); + $license = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='eula']/@href"); + if($license != '') { - $apps_to_dl[] = array('name' => basename($icon), - 'url' => $icon, - 'filesize' => 0, - 'localtarget' => $local_icon); + $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 available screenshots - //$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true); - $screenshots = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='screenshot']", true); - if(!empty($screenshots)) - { - foreach($screenshots as $screen) + // Download package icon + //$icon = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='icon']/@href"); + $icon = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/link[@a:type='icon']/@href"); + if($icon != '') { - $local_screen = $local_intf_folder.basename($screen['href']); - if(!file_exists($local_screen) || filesize($local_screen) == 0) + $local_icon = $local_intf_folder.basename($icon); + if(!file_exists($local_icon) || filesize($local_icon) == 0) { - $apps_to_dl[] = array('name' => basename($screen['href']), - 'url' => $screen['href'], + $apps_to_dl[] = array('name' => basename($icon), + 'url' => $icon, 'filesize' => 0, - 'localtarget' => $local_screen); + 'localtarget' => $local_icon); + } + } + + // Download available screenshots + //$screenshots = parent::getXPathValue($sxe, "entry[position()=1]/link[@a:type='screenshot']", true); + $screenshots = parent::getXPathValue($sxe, "entry[position()=" . $entry_pos . "]/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); - } + 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'; + // 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++; + // 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++; + unset($sxe); + $apps_in_repo++; + } catch (Exception $e) { + // We dont want the crawler to fail on xml parse errors + $app->log($this->log_prefix.$e->getMessage(), LOGLEVEL_WARN); + //echo 'Caught exception: ', $e->getMessage(), "\n"; + } } } //var_dump($apps); + //echo print_r($apps_to_dl).'
-------------------
'; // For memory reasons, unset the current vendor and his apps unset($apps); @@ -531,14 +533,12 @@ class ApsCrawler extends ApsBase // 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;'); + $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']); + $tmp = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE path = ?", $todelete); + $app->db->datalogUpdate('aps_packages', array("package_status" => PACKAGE_ERROR_NOMETA), 'id', $tmp['id']); unset($tmp); } @@ -568,20 +568,17 @@ class ApsCrawler extends ApsBase //$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->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 - ('".$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.");"; - + $insert_data = array( + "path" => $pkg, + "name" => $pkg_name, + "category" => $pkg_category, + "version" => $pkg_version, + "release" => $pkg_release, + "package_url" => $pkg_url, + "package_status" => 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); @@ -611,12 +608,12 @@ class ApsCrawler extends ApsBase // 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 = ''"); + $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'); if($pkg_url != ''){ - $app->db->datalogUpdate('aps_packages', "package_url = '".$app->db->quote($pkg_url)."'", 'id', $incomplete_pkg['id']); + $app->db->datalogUpdate('aps_packages', array("package_url" => $pkg_url), 'id', $incomplete_pkg['id']); } } } diff --git a/interface/lib/classes/aps_guicontroller.inc.php b/interface/lib/classes/aps_guicontroller.inc.php index f6a0ff4e3d9a54d116c3457536652e7f53ffbfbf..db1c1487f77a5218867d11a82d8f02e165140662 100644 --- a/interface/lib/classes/aps_guicontroller.inc.php +++ b/interface/lib/classes/aps_guicontroller.inc.php @@ -100,7 +100,7 @@ class ApsGUIController extends ApsBase $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)."';"); + AND web_domain.domain = ?", $domain); if(!empty($customerdata)) $customerid = $customerdata['client_id']; return $customerid; @@ -122,14 +122,14 @@ class ApsGUIController extends ApsBase $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).");"); + WHERE name = 'main_domain' AND instance_id = ?)", $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).";"); + $app->db->query("DELETE FROM aps_instances WHERE id = ?", $instanceid); + $app->db->query("DELETE FROM aps_instances_settings WHERE instance_id = ?", $instanceid); } else $webserver_id = $websrv['server_id']; @@ -154,9 +154,9 @@ class ApsGUIController extends ApsBase $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).") + WHERE name = (SELECT name FROM aps_packages WHERE id = ?) AND package_status = 2 - ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC"); + ORDER BY REPLACE(version, '.', '')+0 DESC, `release` DESC", $id); if(!empty($result) && ($id != $result['id'])) return $result['id']; @@ -180,7 +180,7 @@ class ApsGUIController extends ApsBase '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).";"); + $result = $app->db->queryOneRecord("SELECT id FROM aps_packages WHERE ".$sql_ext." id = ?", $id); if(!$result) return false; return true; @@ -203,16 +203,132 @@ class ApsGUIController extends ApsBase 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).';'); + $params = array(); + $sql_ext = ''; + if(!$is_admin) { + $sql_ext = 'customer_id = ? AND '; + $params[] = $client_id; + } + $params[] = $id; + + $result = $app->db->queryOneRecord('SELECT id FROM aps_instances WHERE '.$sql_ext.' id = ?', true, $params); if(!$result) return false; return true; } - - + public function createDatabaseForPackageInstance(&$settings, $websrv) { + global $app; + + $app->uses('tools_sites'); + + $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) + $mysql_db_server_id = $app->functions->intval($websrv['server_id']); + $settings['main_database_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 = $app->functions->intval($client['default_dbserver']); + $dbserver_config = $web_config = $app->getconf->get_server_config($app->functions->intval($mysql_db_server_id), 'server'); + $settings['main_database_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']; + $settings['main_database_host'] = 'localhost'; + $mysql_db_remote_access = 'n'; + $mysql_db_remote_ips = '';*/ + } + } + + if (empty($settings['main_database_name'])) { + //* 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 = ?", $mysql_db_name); + if($tmp['number'] == 0) break; + } + $settings['main_database_name'] = $mysql_db_name; + } + if (empty($settings['main_database_login'])) { + //* Find a free db username for the app + for($n = 1; $n <= 1000; $n++) { + $mysql_db_user = ($dbuser_prefix != '' ? $dbuser_prefix.'aps'.$n : uniqid('aps')); + $tmp = $app->db->queryOneRecord("SELECT count(database_user_id) as number FROM web_database_user WHERE database_user = ?", $mysql_db_user); + if($tmp['number'] == 0) break; + } + $settings['main_database_login'] = $mysql_db_user; + } + + //* Create the mysql database user if not existing + $tmp = $app->db->queryOneRecord("SELECT database_user_id FROM web_database_user WHERE database_user = ?", $settings['main_database_login']); + if(!$tmp) { + $insert_data = array("sys_userid" => $websrv['sys_userid'], + "sys_groupid" => $websrv['sys_groupid'], + "sys_perm_user" => 'riud', + "sys_perm_group" => $websrv['sys_perm_group'], + "sys_perm_other" => '', + "server_id" => 0, + "database_user" => $settings['main_database_login'], + "database_user_prefix" => $dbuser_prefix, + "database_password" => "PASSWORD('" . $settings['main_database_password'] . "')" + ); + $mysql_db_user_id = $app->db->datalogInsert('web_database_user', $insert_data, 'database_user_id'); + } + else $mysql_db_user_id = $tmp['database_user_id']; + + //* Create the mysql database if not existing + $tmp = $app->db->queryOneRecord("SELECT count(database_id) as number FROM web_database WHERE database_name = ?", $settings['main_database_name']); + if($tmp['number'] == 0) { + $insert_data = array("sys_userid" => $websrv['sys_userid'], + "sys_groupid" => $websrv['sys_groupid'], + "sys_perm_user" => 'riud', + "sys_perm_group" => $websrv['sys_perm_group'], + "sys_perm_other" => '', + "server_id" => $mysql_db_server_id, + "parent_domain_id" => $websrv['domain_id'], + "type" => 'mysql', + "database_name" => $settings['main_database_name'], + "database_name_prefix" => $dbname_prefix, + "database_user_id" => $mysql_db_user_id, + "database_ro_user_id" => 0, + "database_charset" => '', + "remote_access" => $mysql_db_remote_access, + "remote_ips" => $mysql_db_remote_ips, + "backup_copies" => $websrv['backup_copies'], + "active" => 'y', + "backup_interval" => $websrv['backup_interval'] + ); + $app->db->datalogInsert('web_database', $insert_data, 'database_id'); + } + + return true; + } + /** * Creates a new database record for the package instance and * an install task @@ -227,7 +343,7 @@ class ApsGUIController extends ApsBase $app->uses('tools_sites'); $webserver_id = 0; - $websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$app->db->quote($settings['main_domain'])."';"); + $websrv = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = ?", $settings['main_domain']); if(!empty($websrv)) $webserver_id = $websrv['server_id']; $customerid = $this->getCustomerIDFromDomain($settings['main_domain']); @@ -240,176 +356,80 @@ class ApsGUIController extends ApsBase //* 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') { - $app->db->datalogUpdate('web_domain', "php = 'fast-cgi', suexec = 'y'", 'domain_id', $websrv['domain_id']); + $app->db->datalogUpdate('web_domain', array("php" => 'fast-cgi', "suexec" => 'y'), 'domain_id', $websrv['domain_id']); } } else { // nginx if($websrv['php'] != 'php-fpm' && $websrv['php'] != 'fast-cgi') { - $app->db->datalogUpdate('web_domain', "php = 'php-fpm'", 'domain_id', $websrv['domain_id']); + $app->db->datalogUpdate('web_domain', array("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).';'); + //* Create the MySQL database for the application if necessary + $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = ?', $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 = ".$app->functions->intval($websrv['server_id'])); - if($web_server['db_server'] == 1) { - // create database on "localhost" (webserver) - $mysql_db_server_id = $app->functions->intval($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 = ".$app->functions->intval($websrv['sys_groupid'])); - if(is_array($client) && $client['default_dbserver'] > 0 && $client['default_dbserver'] != $websrv['server_id']) { - $mysql_db_server_id = $app->functions->intval($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']; - $mysql_db_host = 'localhost'; - $mysql_db_remote_access = 'n'; - $mysql_db_remote_ips = '';*/ - } - } - - //* Find a free db name for the app - for($n = 1; $n <= 1000; $n++) { - $mysql_db_name = $app->db->quote(($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)."'"); - if($tmp['number'] == 0) break; - } - //* Find a free db username for the app - for($n = 1; $n <= 1000; $n++) { - $mysql_db_user = $app->db->quote(($dbuser_prefix != '' ? $dbuser_prefix.'aps'.$n : uniqid('aps'))); - $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`) - VALUES( ".$app->functions->intval($websrv['sys_userid']).", ".$app->functions->intval($websrv['sys_groupid']).", 'riud', '".$app->functions->intval($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`) - VALUES( ".$app->functions->intval($websrv['sys_userid']).", ".$app->functions->intval($websrv['sys_groupid']).", 'riud', '".$app->functions->intval($websrv['sys_perm_group'])."', '', $mysql_db_server_id, ".$app->functions->intval($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', ".$app->functions->intval($websrv['backup_copies']).", 'y', '".$app->functions->intval($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; - + // mysql-database-name is updated inside if not set already + if (!$this->createDatabaseForPackageInstance($settings, $websrv)) return false; } - + //* 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 (".$app->functions->intval($websrv['sys_userid']).", ".$app->functions->intval($websrv['sys_groupid']).", 'riud', '".$app->db->quote($websrv['sys_perm_group'])."', '', ".$app->db->quote($webserver_id).",".$app->db->quote($customerid).", ".$app->db->quote($packageid).", ".INSTANCE_PENDING.")"; + $insert_data = array( + "sys_userid" => $websrv['sys_userid'], + "sys_groupid" => $websrv['sys_groupid'], + "sys_perm_user" => 'riud', + "sys_perm_group" => $websrv['sys_perm_group'], + "sys_perm_other" => '', + "server_id" => $webserver_id, + "customer_id" => $customerid, + "package_id" => $packageid, + "instance_status" => INSTANCE_PENDING + ); $InstanceID = $app->db->datalogInsert('aps_instances', $insert_data, 'id'); //* Insert all package settings if(is_array($settings)) { foreach($settings as $key => $value) { - $insert_data = "(server_id, instance_id, name, value) VALUES (".$app->db->quote($webserver_id).",".$app->db->quote($InstanceID).", '".$app->db->quote($key)."', '".$app->db->quote($value)."')"; + $insert_data = array( + "server_id" => $webserver_id, + "instance_id" => $InstanceID, + "name" => $key, + "value" => $value + ); $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); + $app->db->datalogUpdate('aps_instances', array("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; - /* - $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); - - $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) + public function deleteInstance($instanceid, $keepdatabase = false) { 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); - */ + if (!$keepdatabase) { + $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 = ? LIMIT 0,1"; + $tmp = $app->db->queryOneRecord($sql, $instanceid); + 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` = ? OR `database_ro_user_id` = ?", $database_user, $database_user); + if($tmp['cnt'] < 1) $app->db->datalogDelete('web_database_user', 'database_user_id', $database_user); + } - $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 = ".$app->db->quote($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', array("instance_status" => INSTANCE_REMOVE), 'id', $instanceid); - $app->db->datalogUpdate('aps_instances', "instance_status = ".INSTANCE_INSTALL, 'id', $instanceid); } /** @@ -422,7 +442,7 @@ class ApsGUIController extends ApsBase { global $app; - $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = '.$app->db->quote($id).';'); + $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = ?', $id); // Load in meta file if existing and register its namespaces $metafile = $this->interface_pkg_dir.'/'.$pkg['path'].'/APP-META.xml'; @@ -544,7 +564,7 @@ class ApsGUIController extends ApsBase 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'])."';"); + WHERE domain = ?", $postinput['main_domain']); $new_path = $docroot['document_root']; if(substr($new_path, -1) != '/') $new_path .= '/'; $new_path .= $main_location; @@ -559,13 +579,13 @@ class ApsGUIController extends ApsBase $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)."';"); + AND i.customer_id = ?", $customerid); 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'])."';"); + WHERE domain = ?", $instance_domains[$i]['domain']); // Probably the domain settings were changed later, so make sure the doc_root // is not empty for further validation @@ -576,7 +596,7 @@ class ApsGUIController extends ApsBase $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'])."';"); + AND instance_id = ?", $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']; @@ -608,6 +628,10 @@ class ApsGUIController extends ApsBase if(isset($pkg_details['Requirements Database']) && $pkg_details['Requirements Database'] != '') { + if (isset($postinput['main_database_host'])) $input['main_database_host'] = $postinput['main_database_host']; + if (isset($postinput['main_database_name'])) $input['main_database_name'] = $postinput['main_database_name']; + if (isset($postinput['main_database_login'])) $input['main_database_login'] = $postinput['main_database_login']; + if(isset($postinput['main_database_password'])) { if($postinput['main_database_password'] == '') $error[] = $app->lng('error_no_database_pw'); @@ -705,7 +729,7 @@ class ApsGUIController extends ApsBase { global $app; - $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = '.$app->db->quote($id).';'); + $pkg = $app->db->queryOneRecord('SELECT * FROM aps_packages WHERE id = ?', $id); // Load in meta file if existing and register its namespaces $metafile = $this->interface_pkg_dir.'/'.$pkg['path'].'/APP-META.xml'; diff --git a/interface/lib/classes/auth.inc.php b/interface/lib/classes/auth.inc.php index 70c1722aedc9ff7b48226fa61d3f38cc0a6a105d..9640a4b3ede039267ccd8752b7898f52c89d9792 100644 --- a/interface/lib/classes/auth.inc.php +++ b/interface/lib/classes/auth.inc.php @@ -57,7 +57,7 @@ class auth { 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"); + $client = $app->db->queryOneRecord("SELECT client.limit_client FROM sys_user, client WHERE sys_user.userid = ? AND sys_user.client_id = client.client_id", $userid); if($client['limit_client'] != 0) { return true; } else { @@ -73,12 +73,12 @@ class auth { $groupid = $app->functions->intval($groupid); if($userid > 0 && $groupid > 0) { - $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid"); + $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = ?", $userid); $groups = explode(',', $user['groups']); if(!in_array($groupid, $groups)) $groups[] = $groupid; $groups_string = implode(',', $groups); - $sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET groups = ? WHERE userid = ?"; + $app->db->query($sql, $groups_string, $userid); return true; } else { return false; @@ -95,7 +95,7 @@ class auth { // simple query cache if($this->client_limits===null) - $this->client_limits = $app->db->queryOneRecord("SELECT client.* FROM sys_user, client WHERE sys_user.userid = $userid AND sys_user.client_id = client.client_id"); + $this->client_limits = $app->db->queryOneRecord("SELECT client.* FROM sys_user, client WHERE sys_user.userid = ? AND sys_user.client_id = client.client_id", $userid); // isn't client -> no limit if(!$this->client_limits) @@ -114,13 +114,13 @@ class auth { $groupid = $app->functions->intval($groupid); if($userid > 0 && $groupid > 0) { - $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = $userid"); + $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = ?", $userid); $groups = explode(',', $user['groups']); $key = array_search($groupid, $groups); unset($groups[$key]); $groups_string = implode(',', $groups); - $sql = "UPDATE sys_user SET groups = '$groups_string' WHERE userid = $userid"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET groups = ? WHERE userid = ?"; + $app->db->query($sql, $groups_string, $userid); return true; } else { return false; @@ -129,11 +129,32 @@ class auth { public function check_module_permissions($module) { // Check if the current user has the permissions to access this module + $module = trim(preg_replace('@\s+@', '', $module)); $user_modules = explode(',',$_SESSION["s"]["user"]["modules"]); - if(!in_array($module,$user_modules)) { - // echo "LOGIN_REDIRECT:/index.php"; - header("Location: /index.php"); - exit; + if(strpos($module, ',') !== false){ + $can_use_module = false; + $tmp_modules = explode(',', $module); + if(is_array($tmp_modules) && !empty($tmp_modules)){ + foreach($tmp_modules as $tmp_module){ + if($tmp_module != ''){ + if(in_array($tmp_module,$user_modules)) { + $can_use_module = true; + break; + } + } + } + } + if(!$can_use_module){ + // echo "LOGIN_REDIRECT:/index.php"; + header("Location: /index.php"); + exit; + } + } else { + if(!in_array($module,$user_modules)) { + // echo "LOGIN_REDIRECT:/index.php"; + header("Location: /index.php"); + exit; + } } } @@ -153,13 +174,44 @@ class auth { } - public function get_random_password($length = 8) { - $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + public function get_random_password($minLength = 8, $special = false) { + $minLength = $minLength || 10; + if($minLength < 8) $minLength = 8; + $maxLength = $minLength + 5; + $length = mt_rand($minLength, $maxLength); + + $alphachars = "abcdefghijklmnopqrstuvwxyz"; + $upperchars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + $numchars = "1234567890"; + $specialchars = "!@#_"; + + $num_special = 0; + if($special == true) { + $num_special = intval(mt_rand(0, round($length / 4))) + 1; + } + $numericlen = mt_rand(1, 2); + $alphalen = $length - $num_special - $numericlen; + $upperlen = intval($alphalen / 2); + $alphalen = $alphalen - $upperlen; $password = ''; - for ($n=0;$n<$length;$n++) { - $password.=$base64_alphabet[mt_rand(0, 63)]; + + for($i = 0; $i < $alphalen; $i++) { + $password .= substr($alphachars, mt_rand(0, strlen($alphachars) - 1), 1); } - return $password; + + for($i = 0; $i < $upperlen; $i++) { + $password .= substr($upperchars, mt_rand(0, strlen($upperchars) - 1), 1); + } + + for($i = 0; $i < $num_special; $i++) { + $password .= substr($specialchars, mt_rand(0, strlen($specialchars) - 1), 1); + } + + for($i = 0; $i < $numericlen; $i++) { + $password .= substr($numchars, mt_rand(0, strlen($numchars) - 1), 1); + } + + return str_shuffle($password); } public function crypt_password($cleartext_password) { diff --git a/interface/lib/classes/client_templates.inc.php b/interface/lib/classes/client_templates.inc.php index 993936b2cead67d8b1359ed5399c3933364eafcf..e3141d792ea83332e05b8eef160c7f97f76c0fdf 100644 --- a/interface/lib/classes/client_templates.inc.php +++ b/interface/lib/classes/client_templates.inc.php @@ -49,7 +49,7 @@ class client_templates { 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` = ' . $app->functions->intval($clientId)); + $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; @@ -61,24 +61,24 @@ class client_templates { 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 (' . $app->functions->intval($clientId) . ', ' . $app->functions->intval($tpl_id) . ')'); + $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 = ' . $app->functions->intval($clientId) . ' AND client_template_id = ' . $app->functions->intval($tpl_id) . ' LIMIT 1'); + $app->db->query('DELETE FROM `client_template_assigned` WHERE client_id = ? AND client_template_id = ? LIMIT 1', $clientId, $tpl_id); } } } } 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` = ' . $app->functions->intval($clientId)); + $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` = ' . $app->functions->intval($item['assigned_template_id'])); + $app->db->query('DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = ?', $item['assigned_template_id']); } } } @@ -86,7 +86,7 @@ class client_templates { 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 (' . $app->functions->intval($clientId) . ', ' . $app->functions->intval($item) . ')'); + $app->db->query('INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (?, ?)', $clientId, $item); } } } @@ -106,8 +106,8 @@ class client_templates { /* * Get the master-template for the client */ - $sql = "SELECT template_master, template_additional,limit_client FROM client WHERE client_id = " . $app->functions->intval($clientId); - $record = $app->db->queryOneRecord($sql); + $sql = "SELECT template_master, template_additional,limit_client FROM client WHERE client_id = ?"; + $record = $app->db->queryOneRecord($sql, $clientId); $masterTemplateId = $record['template_master']; $is_reseller = ($record['limit_client'] != 0)?true:false; @@ -115,15 +115,15 @@ class client_templates { // 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)); + $app->db->query('UPDATE `client` SET `template_additional` = \'\' WHERE `client_id` = ?', $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); + $sql = "SELECT * FROM client_template WHERE template_id = ?"; + $limits = $app->db->queryOneRecord($sql, $masterTemplateId); } 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 @@ -136,11 +136,11 @@ class client_templates { * if != -1) */ $addTpl = explode('/', $additionalTemplateStr); - $addTpls = $app->db->queryAllRecords('SELECT `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ' . $app->functions->intval($clientId)); + $addTpls = $app->db->queryAllRecords('SELECT `client_template_id` FROM `client_template_assigned` WHERE `client_id` = ?', $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); + $sql = "SELECT * FROM client_template WHERE template_id = ?"; + $addLimits = $app->db->queryOneRecord($sql, $item); $app->log('Template processing subtemplate ' . $item . ' for client ' . $clientId, LOGLEVEL_DEBUG); /* maybe the template is deleted in the meantime */ if (is_array($addLimits)){ @@ -232,6 +232,7 @@ class client_templates { * Write all back to the database */ $update = ''; + $update_values = array(); if(!$is_reseller) unset($limits['limit_client']); // Only Resellers may have limit_client set in template to ensure that we do not convert a client to reseller accidently. foreach($limits as $k => $v){ if (strpos($k, 'default') !== false and $v == 0) { @@ -239,13 +240,16 @@ class client_templates { } if ((strpos($k, 'limit') !== false or strpos($k, 'default') !== false or $k == 'ssh_chroot' or $k == 'web_php_options' or $k == 'force_suexec') && !is_array($v)){ if ($update != '') $update .= ', '; - $update .= '`' . $k . "`='" . $v . "'"; + $update .= '?? = ?'; + $update_values[] = $k; + $update_values[] = $v; } } + $update_values[] = $clientId; $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); + $sql = 'UPDATE client SET ' . $update . " WHERE client_id = ?"; + $app->db->query($sql, true, $update_values); } unset($form); } diff --git a/interface/lib/classes/custom_datasource.inc.php b/interface/lib/classes/custom_datasource.inc.php index 16036f599c3fe94803cabe98a3cfd3592f7de7dd..414de29dcc0bdc7a87d327b5f7d3c6da66a590b9 100644 --- a/interface/lib/classes/custom_datasource.inc.php +++ b/interface/lib/classes/custom_datasource.inc.php @@ -47,12 +47,12 @@ class custom_datasource { if($_SESSION["s"]["user"]["typ"] == 'user') { // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - $sql = "SELECT server_id,server_name FROM server WHERE server_id = ".$app->functions->intval($client['default_dnsserver']); + $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $sql = "SELECT server_id,server_name FROM server WHERE server_id = ?"; } else { $sql = "SELECT server_id,server_name FROM server WHERE dns_server = 1 ORDER BY server_name"; } - $records = $app->db->queryAllRecords($sql); + $records = $app->db->queryAllRecords($sql, $client['default_dnsserver']); $records_new = array(); if(is_array($records)) { foreach($records as $rec) { @@ -69,12 +69,12 @@ class custom_datasource { if($_SESSION["s"]["user"]["typ"] == 'user') { // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT default_slave_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - $sql = "SELECT server_id,server_name FROM server WHERE server_id = ".$app->functions->intval($client['default_slave_dnsserver']); + $client = $app->db->queryOneRecord("SELECT default_slave_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $sql = "SELECT server_id,server_name FROM server WHERE server_id = ?"; } else { $sql = "SELECT server_id,server_name FROM server WHERE dns_server = 1 ORDER BY server_name"; } - $records = $app->db->queryAllRecords($sql); + $records = $app->db->queryAllRecords($sql, $client['default_slave_dnsserver']); $records_new = array(); if(is_array($records)) { foreach($records as $rec) { @@ -99,7 +99,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 (".$app->db->quote($server_ids).") AND web_domain.server_id = server.server_id AND ".$app->tform->getAuthSQL('r', 'web_domain')." ORDER BY web_domain.domain"); + $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 ? AND web_domain.server_id = server.server_id AND ".$app->tform->getAuthSQL('r', 'web_domain')." ORDER BY web_domain.domain", $server_ids); $records_new = array(); if(is_array($records)) { @@ -159,22 +159,25 @@ class custom_datasource { if($_SESSION["s"]["user"]["typ"] == 'user') { // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $sql = "SELECT $server_type as server_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"; - $client = $app->db->queryOneRecord($sql); + $sql = "SELECT $server_type as server_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?"; + $client = $app->db->queryOneRecord($sql, $client_group_id); if($client['server_id'] > 0) { //* Select the default server for the client - $sql = "SELECT server_id,server_name FROM server WHERE server_id = ".$app->functions->intval($client['server_id']); + $sql = "SELECT server_id,server_name FROM server WHERE server_id = ?"; + $records = $app->db->queryAllRecords($sql, $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); - $sql = "SELECT server_id,server_name FROM server WHERE $field = 1 ORDER BY server_name"; + $sql = "SELECT server_id,server_name FROM server WHERE ?? = 1 ORDER BY server_name"; + $records = $app->db->queryAllRecords($sql, $field); } } 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"; + $sql = "SELECT server_id,server_name FROM server WHERE ?? = 1 ORDER BY server_name"; + $records = $app->db->queryAllRecords($sql, $field); } - $records = $app->db->queryAllRecords($sql); + $records_new = array(); if(is_array($records)) { foreach($records as $rec) { diff --git a/interface/lib/classes/db_mysql.inc.php b/interface/lib/classes/db_mysql.inc.php index c8d569b6bdd99a5852c716ba698b46c9b3ab4dd7..08a224f599ac313b7d03e09a4a8639c9762c26d2 100644 --- a/interface/lib/classes/db_mysql.inc.php +++ b/interface/lib/classes/db_mysql.inc.php @@ -36,6 +36,7 @@ class db extends mysqli private $_iConnId; private $dbHost = ''; // hostname of the MySQL server + private $dbPort = ''; // port of the MySQL server private $dbName = ''; // logical database name on that server private $dbUser = ''; // database authorized user private $dbPass = ''; // user's password @@ -54,7 +55,9 @@ class db extends mysqli 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 private $isConnected = false; // needed to know if we have a valid mysqli object from the constructor //// @@ -65,6 +68,7 @@ class db extends mysqli global $conf; if($prefix != '') $prefix .= '_'; $this->dbHost = $conf[$prefix.'db_host']; + $this->dbPort = $conf[$prefix.'db_port']; $this->dbName = $conf[$prefix.'db_database']; $this->dbUser = $conf[$prefix.'db_user']; $this->dbPass = $conf[$prefix.'db_password']; @@ -72,13 +76,13 @@ class db extends mysqli $this->dbNewLink = $conf[$prefix.'db_new_link']; $this->dbClientFlags = $conf[$prefix.'db_client_flags']; - $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass); + $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort); $try = 0; while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) { if($try > 0) sleep(1); $try++; - $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass); + $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort); } if(!is_object($this->_iConnId) || mysqli_connect_error()) { @@ -86,7 +90,7 @@ class db extends mysqli $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!'); return false; } - if(!((bool)mysqli_query( $this->_iConnId, "USE $this->dbName"))) { + if(!((bool)mysqli_query( $this->_iConnId, 'USE `' . $this->dbName . '`'))) { $this->close(); $this->_sqlerror('Datenbank nicht gefunden / Database not found'); return false; @@ -128,8 +132,10 @@ class db extends mysqli $sTxt = $this->escape($sValue); $sTxt = str_replace('`', '', $sTxt); - if(strpos($sTxt, '.') !== false) $sTxt = preg_replace('/^(.+)\.(.+)$/', '`$1`.`$2`', $sTxt); - else $sTxt = '`' . $sTxt . '`'; + if(strpos($sTxt, '.') !== false) { + $sTxt = preg_replace('/^(.+)\.(.+)$/', '`$1`.`$2`', $sTxt); + $sTxt = str_replace('.`*`', '.*', $sTxt); + } else $sTxt = '`' . $sTxt . '`'; $sQuery = substr_replace($sQuery, $sTxt, $iPos2, 2); $iPos2 += strlen($sTxt); @@ -137,13 +143,17 @@ class db extends mysqli } else { if(is_int($sValue) || is_float($sValue)) { $sTxt = $sValue; - } elseif(is_string($sValue) && (strcmp($sValue, '#NULL#') == 0)) { + } elseif(is_null($sValue) || (is_string($sValue) && (strcmp($sValue, '#NULL#') == 0))) { $sTxt = 'NULL'; } elseif(is_array($sValue)) { - $sTxt = ''; - foreach($sValue as $sVal) $sTxt .= ',\'' . $this->escape($sVal) . '\''; - $sTxt = '(' . substr($sTxt, 1) . ')'; - if($sTxt == '()') $sTxt = '(0)'; + if(isset($sValue['SQL'])) { + $sTxt = $sValue['SQL']; + } else { + $sTxt = ''; + foreach($sValue as $sVal) $sTxt .= ',\'' . $this->escape($sVal) . '\''; + $sTxt = '(' . substr($sTxt, 1) . ')'; + if($sTxt == '()') $sTxt = '(0)'; + } } else { $sTxt = '\'' . $this->escape($sValue) . '\''; } @@ -234,7 +244,7 @@ class db extends mysqli $try++; $ok = mysqli_ping($this->_iConnId); if(!$ok) { - if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) { + if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) { if($try > 4) { $this->_sqlerror('DB::query -> reconnect'); return false; @@ -252,7 +262,7 @@ class db extends mysqli $sQuery = call_user_func_array(array(&$this, '_build_query_string'), $aArgs); $this->securityScan($sQuery); - $this->_iQueryId = mysqli_query($this->_iConnId, $sQuery); + $this->_iQueryId = @mysqli_query($this->_iConnId, $sQuery); if (!$this->_iQueryId) { $this->_sqlerror('Falsche Anfrage / Wrong Query', false, 'SQL-Query = ' . $sQuery); return false; @@ -425,6 +435,34 @@ class db extends mysqli } + /** + * check if a utf8 string is valid + * + * @access public + * @param string $string the string to check + * @return bool true if it is valid utf8, false otherwise + */ + private function check_utf8($str) { + $len = strlen($str); + for($i = 0; $i < $len; $i++){ + $c = ord($str[$i]); + if ($c > 128) { + if (($c > 247)) return false; + elseif ($c > 239) $bytes = 4; + elseif ($c > 223) $bytes = 3; + elseif ($c > 191) $bytes = 2; + else return false; + if (($i + $bytes) > $len) return false; + while ($bytes > 1) { + $i++; + $b = ord($str[$i]); + if ($b < 128 || $b > 191) return false; + $bytes--; + } + } + } + return true; + } // end of check_utf8 /** * Escape a string for usage in a query @@ -442,16 +480,16 @@ class db extends mysqli $sString = ''; } - /*$cur_encoding = mb_detect_encoding($sString); + $cur_encoding = mb_detect_encoding($sString); if($cur_encoding != "UTF-8") { if($cur_encoding != 'ASCII') { - $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_WARN); + $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_INFO); if($cur_encoding) $sString = mb_convert_encoding($sString, 'UTF-8', $cur_encoding); else $sString = mb_convert_encoding($sString, 'UTF-8'); } - } elseif(!PXBase::check_utf8($sString)) { + } elseif(!$this->check_utf8($sString)) { $sString = utf8_encode($sString); - }*/ + } if($this->_iConnId) return mysqli_real_escape_string($this->_iConnId, $sString); else return addslashes($sString); @@ -467,6 +505,7 @@ class db extends mysqli $mysql_error = (is_object($this->_iConnId) ? mysqli_error($this->_iConnId) : mysqli_connect_error()); $mysql_errno = (is_object($this->_iConnId) ? mysqli_errno($this->_iConnId) : mysqli_connect_errno()); + $this->errorMessage = $mysql_error; //$sAddMsg .= getDebugBacktrace(); @@ -506,7 +545,27 @@ class db extends mysqli } return $out; } - + + public function insertFromArray($tablename, $data) { + if(!is_array($data)) return false; + + $k_query = ''; + $v_query = ''; + + $params = array($tablename); + $v_params = array(); + + foreach($data as $key => $value) { + $k_query .= ($k_query != '' ? ', ' : '') . '??'; + $v_query .= ($v_query != '' ? ', ' : '') . '?'; + $params[] = $key; + $v_params[] = $value; + } + + $query = 'INSERT INTO ?? (' . $k_query . ') VALUES (' . $v_query . ')'; + return $this->query($query, true, $params + $v_params); + } + public function diffrec($record_old, $record_new) { $diffrec_full = array(); $diff_num = 0; @@ -550,7 +609,6 @@ class db extends mysqli if(!preg_match('/^[a-zA-Z0-9\-\_\.]{1,64}$/',$db_table)) $app->error('Invalid table name '.$db_table); if(!preg_match('/^[a-zA-Z0-9\-\_]{1,64}$/',$primary_field)) $app->error('Invalid primary field '.$primary_field.' in table '.$db_table); - $primary_field = $this->quote($primary_field); $primary_id = intval($primary_id); if($force_update == true) { @@ -598,20 +656,27 @@ class db extends mysqli if(is_array($insert_data)) { $key_str = ''; $val_str = ''; + $params = array($tablename); + $v_params = array(); foreach($insert_data as $key => $val) { - $key_str .= "`".$key ."`,"; - $val_str .= "'".$this->escape($val)."',"; + $key_str .= '??,'; + $params[] = $key; + + $val_str .= '?,'; + $v_params[] = $val; } $key_str = substr($key_str, 0, -1); $val_str = substr($val_str, 0, -1); $insert_data_str = '('.$key_str.') VALUES ('.$val_str.')'; + $this->query("INSERT INTO ?? $insert_data_str", true, $params + $v_params); } else { + /* TODO: deprecate this method! */ $insert_data_str = $insert_data; + $this->query("INSERT INTO ?? $insert_data_str", $tablename); + $app->log("deprecated use of passing values to datalogInsert() - table " . $tablename, 1); } - /* TODO: reduce risk of insert_data_str! */ - + $old_rec = array(); - $this->query("INSERT INTO ?? $insert_data_str", $tablename); $index_value = $this->insertID(); $new_rec = $this->queryOneRecord("SELECT * FROM ?? WHERE ? = ?", $tablename, $index_field, $index_value); $this->datalogSave($tablename, 'INSERT', $index_field, $index_value, $old_rec, $new_rec); @@ -630,17 +695,24 @@ class db extends mysqli $old_rec = $this->queryOneRecord("SELECT * FROM ?? WHERE ?? = ?", $tablename, $index_field, $index_value); if(is_array($update_data)) { + $params = array($tablename); $update_data_str = ''; foreach($update_data as $key => $val) { - $update_data_str .= "`".$key ."` = '".$this->escape($val)."',"; + $update_data_str .= '?? = ?,'; + $params[] = $key; + $params[] = $val; } + $params[] = $index_field; + $params[] = $index_value; $update_data_str = substr($update_data_str, 0, -1); + $this->query("UPDATE ?? SET $update_data_str WHERE ?? = ?", true, $params); } else { + /* TODO: deprecate this method! */ $update_data_str = $update_data; + $this->query("UPDATE ?? SET $update_data_str WHERE ?? = ?", $tablename, $index_field, $index_value); + $app->log("deprecated use of passing values to datalogUpdate() - table " . $tablename, 1); } - /* TODO: reduce risk of update_data_str */ - $this->query("UPDATE ?? SET $update_data_str WHERE ?? = ?", $tablename, $index_field, $index_value); $new_rec = $this->queryOneRecord("SELECT * FROM ?? WHERE ?? = ?", $tablename, $index_field, $index_value); $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec, $force_update); diff --git a/interface/lib/classes/functions.inc.php b/interface/lib/classes/functions.inc.php index 2be5fb7df0bbd98c55bcf01a8ca87d5f863a3901..43eec67fc89467b4003fa6d712f88f480049e8e8 100644 --- a/interface/lib/classes/functions.inc.php +++ b/interface/lib/classes/functions.inc.php @@ -202,7 +202,7 @@ class functions { } $ips = array(); - $results = $app->db->queryAllRecords("SELECT ip_address AS ip, server_id FROM server_ip WHERE ip_type = '".$app->db->quote($type)."'"); + $results = $app->db->queryAllRecords("SELECT ip_address AS ip, server_id FROM server_ip WHERE ip_type = ?", $type); if(!empty($results) && is_array($results)){ foreach($results as $result){ if(preg_match($regex, $result['ip'])){ @@ -230,39 +230,6 @@ class functions { } } - /* - $results = $app->db->queryAllRecords("SELECT xfer FROM dns_slave WHERE xfer != ''"); - if(!empty($results) && is_array($results)){ - foreach($results as $result){ - $tmp_ips = explode(',', $result['xfer']); - foreach($tmp_ips as $tmp_ip){ - $tmp_ip = trim($tmp_ip); - if(preg_match($regex, $tmp_ip)) $ips[] = $tmp_ip; - } - } - } - $results = $app->db->queryAllRecords("SELECT xfer FROM dns_soa WHERE xfer != ''"); - if(!empty($results) && is_array($results)){ - foreach($results as $result){ - $tmp_ips = explode(',', $result['xfer']); - foreach($tmp_ips as $tmp_ip){ - $tmp_ip = trim($tmp_ip); - if(preg_match($regex, $tmp_ip)) $ips[] = $tmp_ip; - } - } - } - $results = $app->db->queryAllRecords("SELECT also_notify FROM dns_soa WHERE also_notify != ''"); - if(!empty($results) && is_array($results)){ - foreach($results as $result){ - $tmp_ips = explode(',', $result['also_notify']); - foreach($tmp_ips as $tmp_ip){ - $tmp_ip = trim($tmp_ip); - if(preg_match($regex, $tmp_ip)) $ips[] = $tmp_ip; - } - } - } - */ - $results = $app->db->queryAllRecords("SELECT remote_ips FROM web_database WHERE remote_ips != ''"); if(!empty($results) && is_array($results)){ foreach($results as $result){ @@ -413,6 +380,15 @@ class functions { return true; } + + public function getimagesizefromstring($string){ + if (!function_exists('getimagesizefromstring')) { + $uri = 'data://application/octet-stream;base64,' . base64_encode($string); + return getimagesize($uri); + } else { + return getimagesizefromstring($string); + } + } } diff --git a/interface/lib/classes/getconf.inc.php b/interface/lib/classes/getconf.inc.php index a246b1853c13d04339d1a6e1c6f04c0d9e99ab85..ef9e0702d212db0b3a773b4c5a0dc900af8e4153 100644 --- a/interface/lib/classes/getconf.inc.php +++ b/interface/lib/classes/getconf.inc.php @@ -39,7 +39,7 @@ class getconf { if(!isset($this->config[$server_id])) { $app->uses('ini_parser'); $server_id = $app->functions->intval($server_id); - $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id); + $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = ?', $server_id); $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config'])); } return ($section == '') ? $this->config[$server_id] : $this->config[$server_id][$section]; diff --git a/interface/lib/classes/listform.inc.php b/interface/lib/classes/listform.inc.php index 1b613a9a89977554c95efb484ac4e9b93fc52d9d..c8a9225a2f0e5468050074a1030c0b0bc1cf4840 100644 --- a/interface/lib/classes/listform.inc.php +++ b/interface/lib/classes/listform.inc.php @@ -246,6 +246,7 @@ class listform { return $this->pagingValues[$key]; } + /* TODO: maybe rewrite sql */ public function getPagingSQL($sql_where = '1') { global $app, $conf; @@ -283,7 +284,7 @@ class listform { 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"); + $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM ??".($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')." WHERE $sql_where", $table); $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); @@ -348,29 +349,33 @@ class listform { sort($show_pages); $show_pages = array_unique($show_pages); - + + $content = ''; + return $content; } @@ -478,7 +483,8 @@ class listform { } return $record; } - + + /* TODO: check double quoting of SQL */ public function encode($record) { global $app; diff --git a/interface/lib/classes/listform_actions.inc.php b/interface/lib/classes/listform_actions.inc.php index 0062d8e3ae6725eb8e3f3b912d6666f2f3dc2e85..3a3ac6e129a2624e8c3f41d434ce42413d484560 100644 --- a/interface/lib/classes/listform_actions.inc.php +++ b/interface/lib/classes/listform_actions.inc.php @@ -190,6 +190,7 @@ class listform_actions { return $rec; } + /* TODO: maybe rewrite SQL */ public function getQueryString($no_limit = false) { global $app; $sql_where = ''; diff --git a/interface/lib/classes/listform_tpl_generator.inc.php b/interface/lib/classes/listform_tpl_generator.inc.php index b8a26a73ae71bdd3a125895ba9e887e3daf046f0..0cb158bb39ee6666738b9c28d9bee673030ecd80 100644 --- a/interface/lib/classes/listform_tpl_generator.inc.php +++ b/interface/lib/classes/listform_tpl_generator.inc.php @@ -44,7 +44,7 @@ class listform_tpl_generator {
{tmpl_var name="toolsarea_head_txt"}
-
@@ -75,13 +75,13 @@ class listform_tpl_generator { foreach($listDef["item"] as $field) { $key = $field["field"]; if($field["formtype"] == 'SELECT') { - $html .= " \n"; + $html .= " \n"; } else { $html .= " \n"; } } - $html .= '
+ $html .= '
@@ -91,7 +91,7 @@ class listform_tpl_generator { foreach($listDef["item"] as $field) { $key = $field["field"]; - $html .= " {tmpl_var name=\"".$key."\"}\n"; + $html .= " {tmpl_var name=\"".$key."\"}\n"; } $html .= " diff --git a/interface/lib/classes/plugin_backuplist.inc.php b/interface/lib/classes/plugin_backuplist.inc.php index 9aebf77e9beb7b22a79a05a820ec9163f9128553..471560ab5ebd9f0285f48373809f17ffdeb1afaa 100644 --- a/interface/lib/classes/plugin_backuplist.inc.php +++ b/interface/lib/classes/plugin_backuplist.inc.php @@ -56,50 +56,42 @@ class plugin_backuplist extends plugin_base { $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); + $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)); + $get_domain = $app->db->queryOneRecord("SELECT domain_id FROM web_domain WHERE domain_id = ? AND ".$app->tform->getAuthSQL($check_perm), $domain_backup["parent_domain_id"]); 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); + $server_id = $this->form->dataRecord['server_id']; + $backup = $app->db->queryOneRecord("SELECT * FROM web_backup WHERE backup_id = ?", $backup_id); + if($backup['server_id'] > 0) $server_id = $backup['server_id']; + $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = ?"; + $tmp = $app->db->queryOneRecord($sql, $backup_id); 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); + "VALUES (?, UNIX_TIMESTAMP(), 'backup_download', ?, 'pending', '')"; + $app->db->query($sql, $server_id, $backup_id); } else { $error .= $wb['download_pending_txt']; } } if($_GET['backup_action'] == 'restore' && $backup_id > 0) { + $server_id = $this->form->dataRecord['server_id']; + $backup = $app->db->queryOneRecord("SELECT * FROM web_backup WHERE backup_id = ?", $backup_id); + if($backup['server_id'] > 0) $server_id = $backup['server_id']; $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); + "VALUES (?, UNIX_TIMESTAMP(), 'backup_restore', ?, 'pending', '')"; + $app->db->query($sql, $server_id, $backup_id); } else { $error .= $wb['restore_pending_txt']; } @@ -108,9 +100,18 @@ class plugin_backuplist extends plugin_base { } //* Get the data - $web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ".$app->functions->intval($this->form->id)); - $sql = "SELECT * FROM web_backup WHERE parent_domain_id = ".$app->functions->intval($this->form->id)." AND server_id = ".$app->functions->intval($web['server_id'])." ORDER BY tstamp DESC, backup_type ASC"; - $records = $app->db->queryAllRecords($sql); + $server_ids = array(); + $web = $app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE domain_id = ?", $this->form->id); + $databases = $app->db->queryAllRecords("SELECT server_id FROM web_database WHERE parent_domain_id = ?", $this->form->id); + if($app->functions->intval($web['server_id']) > 0) $server_ids[] = $app->functions->intval($web['server_id']); + if(is_array($databases) && !empty($databases)){ + foreach($databases as $database){ + if($app->functions->intval($database['server_id']) > 0) $server_ids[] = $app->functions->intval($database['server_id']); + } + } + $server_ids = array_unique($server_ids); + $sql = "SELECT * FROM web_backup WHERE parent_domain_id = ? AND server_id IN ? ORDER BY tstamp DESC, backup_type ASC"; + $records = $app->db->queryAllRecords($sql, $this->form->id, $server_ids); $bgcolor = "#FFFFFF"; if(is_array($records)) { @@ -122,6 +123,13 @@ class plugin_backuplist extends plugin_base { $rec['date'] = date($app->lng('conf_format_datetime'), $rec['tstamp']); $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])]; + + $rec['download_available'] = true; + if($rec['server_id'] != $web['server_id']) $rec['download_available'] = false; + + if($rec['filesize'] > 0){ + $rec['filesize'] = $app->functions->currency_format($rec['filesize']/(1024*1024), 'client').' MB'; + } $records_new[] = $rec; } diff --git a/interface/lib/classes/plugin_backuplist_mail.inc.php b/interface/lib/classes/plugin_backuplist_mail.inc.php index 5bef570d8d0c1b2f5ec351a0415275e933b5233c..901901a3ed62cc7642d472809ef99ee99aa132c5 100644 --- a/interface/lib/classes/plugin_backuplist_mail.inc.php +++ b/interface/lib/classes/plugin_backuplist_mail.inc.php @@ -39,6 +39,9 @@ class plugin_backuplist_mail extends plugin_base { function onShow() { global $app; + + $app->uses('functions'); + $listTpl = new tpl; $listTpl->newTemplate('templates/mail_user_backup_list.htm'); @@ -52,42 +55,15 @@ class plugin_backuplist_mail extends plugin_base { if(isset($_GET['backup_action'])) { $backup_id = $app->functions->intval($_GET['backup_id']); -/* - 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($_GET['backup_action'] == 'restore_mail' && $backup_id > 0) { + $sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_restore_mail' AND action_param = ?"; + $tmp = $app->db->queryOneRecord($sql, $backup_id); 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); + "VALUES (?, ? 'backup_restore_mail', ?, 'pending','')"; + $app->db->query($sql, $this->form->dataRecord['server_id'], time(), $backup_id); } else { $error .= $wb['restore_pending_txt']; } @@ -95,8 +71,8 @@ class plugin_backuplist_mail extends plugin_base { } //* Get the data - $sql = "SELECT * FROM mail_backup WHERE mailuser_id = ".$this->form->id." ORDER BY tstamp DESC"; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_backup WHERE mailuser_id = ? ORDER BY tstamp DESC"; + $records = $app->db->queryAllRecords($sql, $this->form->id); $bgcolor = "#FFFFFF"; if(is_array($records)) { foreach($records as $rec) { @@ -105,6 +81,7 @@ class plugin_backuplist_mail extends plugin_base { $rec["bgcolor"] = $bgcolor; $rec['date'] = date($app->lng('conf_format_datetime'),$rec['tstamp']); $rec['backup_type'] = $wb[('backup_type_'.$rec['backup_type'])]; + $rec['filesize'] = $app->functions->formatBytes($rec['filesize']); $records_new[] = $rec; } } diff --git a/interface/lib/classes/plugin_dbhistory.inc.php b/interface/lib/classes/plugin_dbhistory.inc.php index c6547311106ab330d4cee9975af6b18711f9b4b8..3ad5d42ec05c57a459047e6b342f59ff5979ae30 100644 --- a/interface/lib/classes/plugin_dbhistory.inc.php +++ b/interface/lib/classes/plugin_dbhistory.inc.php @@ -47,12 +47,13 @@ class plugin_dbhistory extends plugin_base { $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."'"; + $sql = "SELECT action, tstamp, user, data FROM sys_datalog WHERE dbtable = ? AND dbidx = ?"; + $records = $app->db->queryAllRecords($sql, $db_table, $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."'"; + $sql = "SELECT action, tstamp, user, data FROM sys_datalog WHERE user = ? AND dbtable = ? AND dbidx = ?"; + $records = $app->db->queryAllRecords($sql, $_SESSION["s"]["user"]["username"], $db_table, $db_table_idx.":".$primary_id); } - $records = $app->db->queryAllRecords($sql); if(is_array($records)) { $content .= ''; foreach($records as $rec) { diff --git a/interface/lib/classes/plugin_directive_snippets.inc.php b/interface/lib/classes/plugin_directive_snippets.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..dbc7d4887d1f71b2f3fcc0c0fd2c14813b1bee42 --- /dev/null +++ b/interface/lib/classes/plugin_directive_snippets.inc.php @@ -0,0 +1,72 @@ +newTemplate('templates/web_directive_snippets.htm'); + + //* Loading language file + $lng_file = "lib/lang/".$_SESSION["s"]["language"]."_web_directive_snippets.lng"; + + include $lng_file; + $listTpl->setVar($wb); + + $message = ''; + $error = ''; + + $server_type = $app->getconf->get_server_config($this->form->dataRecord['server_id'], 'web'); + $server_type = $server_type['server_type']; + $records = $app->db->queryAllRecords("SELECT directive_snippets_id, name FROM directive_snippets WHERE customer_viewable = 'y' AND type = ? ORDER BY name ASC", $server_type); + + for ($i = 0, $c = count($records); $i < $c; $i++) + { + $records[$i]['is_selected'] = false; + + if ($this->form->dataRecord['directive_snippets_id'] === $records[$i]['directive_snippets_id']) + $records[$i]['is_selected'] = true; + } + + $listTpl->setLoop('records', $records); + + $list_name = 'directive_snippets_list'; + $_SESSION["s"]["list"][$list_name]["parent_id"] = $this->form->id; + $_SESSION["s"]["list"][$list_name]["parent_name"] = $app->tform->formDef["name"]; + $_SESSION["s"]["list"][$list_name]["parent_tab"] = $_SESSION["s"]["form"]["tab"]; + $_SESSION["s"]["list"][$list_name]["parent_script"] = $app->tform->formDef["action"]; + $_SESSION["s"]["form"]["return_to"] = $list_name; + + return $listTpl->grab(); + } + + public function onUpdate() + { + global $app, $conf; + + if (isset($this->form->dataRecord['directive_snippets_id']) && $this->form->oldDataRecord['directive_snippets_id'] !== $this->form->dataRecord['directive_snippets_id']) { + $app->db->query('UPDATE web_domain SET directive_snippets_id = ? WHERE domain_id = ?', $this->form->dataRecord['directive_snippets_id'], $this->form->id); + } + } + + public function onInsert() + { + global $app, $conf; + + if (isset($this->form->dataRecord['directive_snippets_id'])) { + $app->db->query('UPDATE web_domain SET directive_snippets_id = ? WHERE domain_id = ?', $this->form->dataRecord['directive_snippets_id'], $this->form->id); + } + } + +} +?> \ 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 e7d576cd17a58c9af14ac3e4f7761ed4ea520bbb..bc764caefe0dbb144b53d6c87826bad5edb0a637 100644 --- a/interface/lib/classes/plugin_listview.inc.php +++ b/interface/lib/classes/plugin_listview.inc.php @@ -126,7 +126,7 @@ class plugin_listview extends plugin_base { // Get the data - $records = $app->db->queryAllRecords("SELECT * FROM ".$app->listform->listDef["table"]." WHERE $sql_where $sql_order_by $limit_sql"); + $records = $app->db->queryAllRecords("SELECT * FROM ?? WHERE $sql_where $sql_order_by $limit_sql", $app->listform->listDef["table"]); $bgcolor = "#FFFFFF"; if(is_array($records)) { @@ -174,6 +174,58 @@ class plugin_listview extends plugin_base { $_SESSION["s"]["form"]["return_to"] = $list_name; //die(print_r($_SESSION["s"]["list"][$list_name])); + // defaults + $listTpl->setVar('app_title', $app->_conf['app_title']); + if(isset($_SESSION['s']['user'])) { + $listTpl->setVar('app_version', $app->_conf['app_version']); + // get pending datalog changes + $datalog = $app->db->datalogStatus(); + $listTpl->setVar('datalog_changes_txt', $app->lng('datalog_changes_txt')); + $listTpl->setVar('datalog_changes_end_txt', $app->lng('datalog_changes_end_txt')); + $listTpl->setVar('datalog_changes_count', $datalog['count']); + $listTpl->setLoop('datalog_changes', $datalog['entries']); + } else { + $listTpl->setVar('app_version', ''); + } + $listTpl->setVar('app_link', $app->_conf['app_link']); + + $listTpl->setVar('app_logo', $app->_conf['logo']); + + $listTpl->setVar('phpsessid', session_id()); + + $listTpl->setVar('theme', $_SESSION['s']['theme']); + $listTpl->setVar('html_content_encoding', $app->_conf['html_content_encoding']); + + $listTpl->setVar('delete_confirmation', $app->lng('delete_confirmation')); + //print_r($_SESSION); + if(isset($_SESSION['s']['module']['name'])) { + $listTpl->setVar('app_module', $_SESSION['s']['module']['name']); + } + if(isset($_SESSION['s']['user']) && $_SESSION['s']['user']['typ'] == 'admin') { + $listTpl->setVar('is_admin', 1); + } + if(isset($_SESSION['s']['user']) && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { + $listTpl->setVar('is_reseller', 1); + } + /* Show username */ + if(isset($_SESSION['s']['user'])) { + $listTpl->setVar('cpuser', $_SESSION['s']['user']['username']); + $listTpl->setVar('logout_txt', $app->lng('logout_txt')); + /* Show search field only for normal users, not mail users */ + if(stristr($_SESSION['s']['user']['username'], '@')){ + $listTpl->setVar('usertype', 'mailuser'); + } else { + $listTpl->setVar('usertype', 'normaluser'); + } + } + + /* Global Search */ + $listTpl->setVar('globalsearch_resultslimit_of_txt', $app->lng('globalsearch_resultslimit_of_txt')); + $listTpl->setVar('globalsearch_resultslimit_results_txt', $app->lng('globalsearch_resultslimit_results_txt')); + $listTpl->setVar('globalsearch_noresults_text_txt', $app->lng('globalsearch_noresults_text_txt')); + $listTpl->setVar('globalsearch_noresults_limit_txt', $app->lng('globalsearch_noresults_limit_txt')); + $listTpl->setVar('globalsearch_searchfield_watermark_txt', $app->lng('globalsearch_searchfield_watermark_txt')); + return $listTpl->grab(); } diff --git a/interface/lib/classes/quota_lib.inc.php b/interface/lib/classes/quota_lib.inc.php index b9ef6aab26915141ecbc3acfad666d38377f6543..24a3ce3d0d65a867640dbe165d14cb57be56a820 100644 --- a/interface/lib/classes/quota_lib.inc.php +++ b/interface/lib/classes/quota_lib.inc.php @@ -14,7 +14,7 @@ class quota_lib { //print_r($monitor_data); // select all websites or websites belonging to client - $sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND type = 'vhost'".(($clientid != null)?" AND sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)":''), $app->functions->intval($client_id)); + $sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND type = 'vhost'".(($clientid != null)?" AND sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)":''), $clientid); //print_r($sites); if(is_array($sites) && !empty($sites)){ @@ -35,7 +35,13 @@ class quota_lib { 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]; - + + $sites[$i]['used_raw'] = $sites[$i]['used']; + $sites[$i]['soft_raw'] = $sites[$i]['soft']; + $sites[$i]['hard_raw'] = $sites[$i]['hard']; + $sites[$i]['files_raw'] = $sites[$i]['files']; + $sites[$i]['used_percentage'] = ($sites[$i]['soft'] > 0 && $sites[$i]['used'] > 0 ? round($sites[$i]['used'] * 100 / $sites[$i]['soft']) : 0); + if ($readable) { // colours $sites[$i]['display_colour'] = '#000000'; @@ -89,7 +95,68 @@ class quota_lib { return $sites; } - + + public function get_trafficquota_data($clientid = null, $lastdays = 0) { + global $app; + + $traffic_data = array(); + + // select vhosts (belonging to client) + if($clientid != null){ + $sql_where = " AND sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)"; + } + $sites = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE active = 'y' AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias')".$sql_where, $clientid); + + $hostnames = array(); + $traffic_data = array(); + + foreach ($sites as $site) { + $hostnames[] = $site['domain']; + $traffic_data[$site['domain']]['domain_id'] = $site['domain_id']; + } + + // fetch all traffic-data of selected vhosts + if (!empty($hostnames)) { + $tmp_year = date('Y'); + $tmp_month = date('m'); + // This Month + $tmp_recs = $app->db->queryAllRecords("SELECT hostname, SUM(traffic_bytes) as t FROM web_traffic WHERE YEAR(traffic_date) = ? AND MONTH(traffic_date) = ? AND hostname IN ? GROUP BY hostname", $tmp_year, $tmp_month, $hostnames); + foreach ($tmp_recs as $tmp_rec) { + $traffic_data[$tmp_rec['hostname']]['this_month'] = $tmp_rec['t']; + } + // This Year + $tmp_recs = $app->db->queryAllRecords("SELECT hostname, SUM(traffic_bytes) as t FROM web_traffic WHERE YEAR(traffic_date) = ? AND hostname IN ? GROUP BY hostname", $tmp_year, $hostnames); + foreach ($tmp_recs as $tmp_rec) { + $traffic_data[$tmp_rec['hostname']]['this_year'] = $tmp_rec['t']; + } + + $tmp_year = date('Y', mktime(0, 0, 0, date("m")-1, date("d"), date("Y"))); + $tmp_month = date('m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y"))); + // Last Month + $tmp_recs = $app->db->queryAllRecords("SELECT hostname, SUM(traffic_bytes) as t FROM web_traffic WHERE YEAR(traffic_date) = ? AND MONTH(traffic_date) = ? AND hostname IN ? GROUP BY hostname", $tmp_year, $tmp_month, $hostnames); + foreach ($tmp_recs as $tmp_rec) { + $traffic_data[$tmp_rec['hostname']]['last_month'] = $tmp_rec['t']; + } + + $tmp_year = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1)); + // Last Year + $tmp_recs = $app->db->queryAllRecords("SELECT hostname, SUM(traffic_bytes) as t FROM web_traffic WHERE YEAR(traffic_date) = ? AND hostname IN ? GROUP BY hostname", $tmp_year, $hostnames); + foreach ($tmp_recs as $tmp_rec) { + $traffic_data[$tmp_rec['hostname']]['last_year'] = $tmp_rec['t']; + } + + if (is_int($lastdays) && ($lastdays > 0)) { + // Last xx Days + $tmp_recs = $app->db->queryAllRecords("SELECT hostname, SUM(traffic_bytes) as t FROM web_traffic WHERE (traffic_date >= DATE_SUB(NOW(), INTERVAL ? DAY)) AND hostname IN ? GROUP BY hostname", $lastdays, $hostnames); + foreach ($tmp_recs as $tmp_rec) { + $traffic_data[$tmp_rec['hostname']]['lastdays'] = $tmp_rec['t']; + } + } + } + + return $traffic_data; + } + public function get_mailquota_data($clientid = null, $readable = true) { global $app; @@ -109,7 +176,7 @@ class quota_lib { //print_r($monitor_data); // select all email accounts or email accounts belonging to client - $emails = $app->db->queryAllRecords("SELECT * FROM mail_user".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : ''), $app->functions->intval($client_id)); + $emails = $app->db->queryAllRecords("SELECT * FROM mail_user".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : ''), $clientid); //print_r($emails); if(is_array($emails) && !empty($emails)){ @@ -120,6 +187,11 @@ class quota_lib { if (!is_numeric($emails[$i]['used'])) $emails[$i]['used']=$emails[$i]['used'][1]; + $emails[$i]['quota_raw'] = $emails[$i]['quota']; + $emails[$i]['used_raw'] = $emails[$i]['used']; + $emails[$i]['used_percentage'] = ($emails[$i]['quota'] > 0 && $emails[$i]['used'] > 0 ? round($emails[$i]['used'] * 100 / $emails[$i]['quota']) : 0); + + if ($readable) { // colours $emails[$i]['display_colour'] = '#000000'; @@ -149,4 +221,66 @@ class quota_lib { return $emails; } + + public function get_databasequota_data($clientid = null, $readable = true) { + global $app; + + $tmp_rec = $app->db->queryAllRecords("SELECT data from monitor_data WHERE type = 'database_size' ORDER BY created DESC"); + $monitor_data = array(); + if(is_array($tmp_rec)) { + foreach ($tmp_rec as $tmp_mon) { + $tmp_array = unserialize($app->db->unquote($tmp_mon['data'])); + if(is_array($tmp_array)) { + foreach($tmp_array as $key => $data) { + if(!isset($monitor_data[$data['database_name']]['size'])) $monitor_data[$data['database_name']]['size'] = $data['size']; + } + } + } + } + //print_r($monitor_data); + + // select all databases belonging to client + $databases = $app->db->queryAllRecords("SELECT * FROM web_database".(($clientid != null)? " WHERE sys_groupid = (SELECT default_group FROM sys_user WHERE client_id=?)" : ''), $clientid); + + //print_r($databases); + if(is_array($databases) && !empty($databases)){ + for($i=0;$i 0) && ($databases[$i]['used'] > 0)) ? round($databases[$i]['used'] * 100 / $databases[$i]['database_quota']) : 0; + + if ($readable) { + // colours + $databases[$i]['display_colour'] = '#000000'; + if($databases[$i]['database_quota'] > 0){ + $used_ratio = $databases[$i]['used']/$databases[$i]['database_quota']; + } else { + $used_ratio = 0; + } + if($used_ratio >= 0.8) $databases[$i]['display_colour'] = '#fd934f'; + if($used_ratio >= 1) $databases[$i]['display_colour'] = '#cc0000'; + + if($databases[$i]['database_quota'] == 0){ + $databases[$i]['database_quota'] = $app->lng('unlimited'); + } else { + $databases[$i]['database_quota'] = round($databases[$i]['database_quota'] / 1048576, 4).' MB'; + } + + + if($databases[$i]['used'] < 1544000) { + $databases[$i]['used'] = round($databases[$i]['used'] / 1024, 4).' KB'; + } else { + $databases[$i]['used'] = round($databases[$i]['used'] / 1048576, 4).' MB'; + } + } + } + } + + return $databases; + } + } \ No newline at end of file diff --git a/interface/lib/classes/remote.d/admin.inc.php b/interface/lib/classes/remote.d/admin.inc.php index ba966fe1aba371daaf03fcb19844fa1681f4b8c7..2541ca5c19f35bebd850e4a6f3435ea79bfd738c 100644 --- a/interface/lib/classes/remote.d/admin.inc.php +++ b/interface/lib/classes/remote.d/admin.inc.php @@ -60,7 +60,7 @@ class remoting_admin extends remoting { switch($key) { case 'sys_userid': // check if userid is valid - $check = $app->db->queryOneRecord('SELECT userid FROM sys_user WHERE userid = ' . $app->functions->intval($value)); + $check = $app->db->queryOneRecord('SELECT userid FROM sys_user WHERE userid = ?', $app->functions->intval($value)); if(!$check || !$check['userid']) { $this->server->fault('invalid parameters', $value . ' is no valid sys_userid.'); return false; @@ -69,7 +69,7 @@ class remoting_admin extends remoting { break; case 'sys_groupid': // check if groupid is valid - $check = $app->db->queryOneRecord('SELECT groupid FROM sys_group WHERE groupid = ' . $app->functions->intval($value)); + $check = $app->db->queryOneRecord('SELECT groupid FROM sys_group WHERE groupid = ?', $app->functions->intval($value)); if(!$check || !$check['groupid']) { $this->server->fault('invalid parameters', $value . ' is no valid sys_groupid.'); return false; diff --git a/interface/lib/classes/remote.d/aps.inc.php b/interface/lib/classes/remote.d/aps.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..b626f1b7abf6b21d7037b02b654a28af53495e9e --- /dev/null +++ b/interface/lib/classes/remote.d/aps.inc.php @@ -0,0 +1,318 @@ + +Copyright (c) Profi Webdesign Dominik Müller + +*/ + +class remoting_aps extends remoting { + //* Functions for APS + public function sites_aps_update_package_list($session_id) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_update_package')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->load('aps_crawler'); + $aps = new ApsCrawler($app, false); // true = Interface mode, false = Server mode + $aps->startCrawler(); + $aps->parseFolderToDB(); + $aps->fixURLs(); + + return true; + } + + public function sites_aps_available_packages_list($session_id, $params) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_available_packages_list')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->load('aps_base'); + + if (isset($params['all_packages']) && ($params['all_packages'] == true)) { + $where = '(aps_packages.package_status = '.PACKAGE_ENABLED.' OR aps_packages.package_status = '.PACKAGE_LOCKED.')'; + } + else { + $where = 'aps_packages.package_status = '.PACKAGE_ENABLED; + } + + $sql = 'SELECT * FROM aps_packages WHERE '.$where.' ORDER BY aps_packages.name, aps_packages.version'; + return $app->db->queryAllRecords($sql); + } + + public function sites_aps_get_package_details($session_id, $primary_id) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_get_package_details')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->load('aps_guicontroller'); + $gui = new ApsGUIController($app); + + // Package-ID Check + if (isset($primary_id)) + { + $newest_pkg_id = $gui->getNewestPackageID($pkg_id); + if($newest_pkg_id != 0) $primary_id = $newest_pkg_id; + } + + // Make sure an integer ID is given + if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag + $this->server->fault('package_error', 'The given Package ID is not valid.'); + return false; + } + + // Get package details + $details = $gui->getPackageDetails($primary_id); + if (isset($details['error'])) { + $this->server->fault('package_error', $details['error']); + return false; + } + + // encode all parts to ensure SOAP-XML-format + array_walk_recursive($details, function(&$item, &$key) { $item = utf8_encode($item); } ); + // Special handling for license-text because of too much problems with soap-transport + $details['License content'] = base64_encode($details['License content']); + + return $details; + } + + public function sites_aps_get_package_file($session_id, $primary_id, $filename) { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_get_package_file')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->load('aps_guicontroller'); + $gui = new ApsGUIController($app); + + // Package-ID Check + if (isset($primary_id)) + { + $newest_pkg_id = $gui->getNewestPackageID($pkg_id); + if($newest_pkg_id != 0) $primary_id = $newest_pkg_id; + } + + // Make sure an integer ID is given + if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag + $this->server->fault('package_error', 'The given Package ID is not valid.'); + return false; + } + + // Get package details + $details = $gui->getPackageDetails($primary_id); + if (isset($details['error'])) { + $this->server->fault('package_error', $details['error']); + return false; + } + + // find file in details + $found = false; + if (basename($details['Icon']) == $filename) $found = true; + if (!$found && isset($details['Screenshots']) && is_array($details['Screenshots'])) + foreach ($details['Screenshots'] as $screen) { if (basename($screen['ScreenPath']) == $filename) { $found = true; break; } } + + if (!$found) { + $this->server->fault('package_error', 'File not found in package.'); + return false; + } + + return base64_encode(file_get_contents(ISPC_ROOT_PATH.'/web/sites/aps_meta_packages/'.$details['path'].'/'.$filename)); + } + + public function sites_aps_get_package_settings($session_id, $primary_id) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_get_package_details')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->load('aps_guicontroller'); + $gui = new ApsGUIController($app); + + // Package-ID Check + if (isset($primary_id)) + { + $newest_pkg_id = $gui->getNewestPackageID($pkg_id); + if($newest_pkg_id != 0) $primary_id = $newest_pkg_id; + } + + // Make sure an integer ID is given + if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag + $this->server->fault('package_error', 'The given Package ID is not valid.'); + return false; + } + + // Get package settings + $settings = $gui->getPackageSettings($primary_id); + if (isset($settings['error'])) { + $this->server->fault('package_error', $settings['error']); + return false; + } + + // encode all parts to ensure SOAP-XML-format + array_walk_recursive($settings, function(&$item, &$key) { $item = utf8_encode($item); } ); + + return $settings; + } + + public function sites_aps_install_package($session_id, $primary_id, $params) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_install_package')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->load('aps_guicontroller'); + $gui = new ApsGUIController($app); + + // Package-ID Check + if (isset($primary_id)) + { + $newest_pkg_id = $gui->getNewestPackageID($primary_id); + if($newest_pkg_id != 0) $primary_id = $newest_pkg_id; + } + + // Make sure an integer ID is given + if (!isset($primary_id) || !$gui->isValidPackageID($primary_id, true)) {// always adminflag + $this->server->fault('package_error', 'The given Package ID is not valid.'); + return false; + } + + // Get package details + $details = $gui->getPackageDetails($primary_id); + if (isset($details['error'])) { + $this->server->fault('package_error', $details['error']); + return false; + } + $settings = $gui->getPackageSettings($primary_id); + if (isset($settings['error'])) { + $this->server->fault('package_error', $settings['error']); + return false; + } + + // Check given Site/VHostDomain + if (!isset($params['main_domain'])) { + $this->server->fault('invalid parameters', 'No valid domain given.'); + return false; + } + + $sql = "SELECT * FROM web_domain WHERE domain = ?"; + $domain = $app->db->queryOneRecord($sql, $params['main_domain']); + + if (!$domain) { + $this->server->fault('invalid parameters', 'No valid domain given.'); + return false; + } + + $domains = array($domain['domain']); // Simulate correct Domain-List + $result = $gui->validateInstallerInput($params, $details, $domains, $settings); + if(empty($result['error'])) + { + return $gui->createPackageInstance($result['input'], $primary_id); + } + + $this->server->fault('invalid parameters', implode('
', $result['error'])); + return false; + } + + public function sites_aps_instance_get($session_id, $primary_id) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_instance_get')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $sql = "SELECT * FROM aps_instances WHERE id = ?"; + $result = $app->db->queryOneRecord($sql, $app->functions->intval($primary_id)); + return $result; + } + + public function sites_aps_instance_settings_get($session_id, $primary_id) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_instance_get')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $sql = "SELECT * FROM aps_instances_settings WHERE instance_id = ?"; + $result = $app->db->queryAllRecords($sql, $app->functions->intval($primary_id)); + return $result; + } + + public function sites_aps_instance_delete($session_id, $primary_id, $params = array()) + { + global $app; + + if(!$this->checkPerm($session_id, 'sites_aps_instance_delete')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $app->load('aps_guicontroller'); + $gui = new ApsGUIController($app); + + // Check if Instance exists + $sql = "SELECT * FROM aps_instances WHERE id = ?"; + $result = $app->db->queryOneRecord($sql, $primary_id); + + if (!$result) { + $this->server->fault('instance_error', 'No valid instance id given.'); + return false; + } + + $gui->deleteInstance($primary_id, (isset($params['keep_database']) && ($params['keep_database'] === true))); + + return true; + } +} + +?> diff --git a/interface/lib/classes/remote.d/client.inc.php b/interface/lib/classes/remote.d/client.inc.php index d780ec8533d19411fd18804c7771f72ece851a77..cccc04f110baa654e789d89f3ba0014afcfa2051 100644 --- a/interface/lib/classes/remote.d/client.inc.php +++ b/interface/lib/classes/remote.d/client.inc.php @@ -65,7 +65,7 @@ class remoting_client extends remoting { 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']); + $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']; @@ -78,7 +78,7 @@ class remoting_client extends remoting { // 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']); + $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']; @@ -104,7 +104,7 @@ class remoting_client extends remoting { $sys_userid = $app->functions->intval($sys_userid); - $rec = $app->db->queryOneRecord("SELECT client_id FROM sys_user WHERE userid = ".$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']); } else { @@ -125,7 +125,7 @@ class remoting_client extends remoting { $client_id = $app->functions->intval($client_id); - $rec = $app->db->queryOneRecord("SELECT company_name,contact_name,gender,email,language FROM client WHERE client_id = ".$client_id); + $rec = $app->db->queryOneRecord("SELECT company_name,contact_name,gender,email,language FROM client WHERE client_id = ?", $client_id); if(is_array($rec)) { return $rec; @@ -145,7 +145,7 @@ class remoting_client extends remoting { $client_id = $app->functions->intval($client_id); - $rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$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']); } else { @@ -169,7 +169,7 @@ class remoting_client extends remoting { if($params['parent_client_id']) { // check if this one is reseller - $check = $app->db->queryOneRecord('SELECT `limit_client` FROM `client` WHERE `client_id` = ' . intval($params['parent_client_id'])); + $check = $app->db->queryOneRecord('SELECT `limit_client` FROM `client` WHERE `client_id` = ?', intval($params['parent_client_id'])); if($check['limit_client'] == 0) { $this->server->fault('Invalid reseller', 'Selected client is not a reseller.'); return false; @@ -208,7 +208,7 @@ class remoting_client extends remoting { if($params['parent_client_id']) { // check if this one is reseller - $check = $app->db->queryOneRecord('SELECT `limit_client` FROM `client` WHERE `client_id` = ' . intval($params['parent_client_id'])); + $check = $app->db->queryOneRecord('SELECT `limit_client` FROM `client` WHERE `client_id` = ?', intval($params['parent_client_id'])); if($check['limit_client'] == 0) { $this->server->fault('Invalid reseller', 'Selected client is not a reseller.'); return false; @@ -221,7 +221,7 @@ class remoting_client extends remoting { } // we need the previuos templates assigned here - $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $client_id); + $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']); @@ -258,8 +258,8 @@ class remoting_client extends remoting { } if(@is_numeric($client_id)) { - $sql = "SELECT * FROM `client_template_assigned` WHERE `client_id` = ".$client_id; - return $app->db->queryOneRecord($sql); + $sql = "SELECT * FROM `client_template_assigned` WHERE `client_id` = ?"; + return $app->db->queryOneRecord($sql, $client_id); } else { $this->server->fault('The ID must be an integer.'); return array(); @@ -270,10 +270,10 @@ class remoting_client extends remoting { global $app; $this->id = $client_id; - $this->dataRecord = $app->db->queryOneRecord('SELECT * FROM `client` WHERE `client_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); + $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']); @@ -297,13 +297,13 @@ class remoting_client extends remoting { 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); + $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); + $check = $app->db->queryOneRecord('SELECT `template_id` FROM `client_template` WHERE `template_id` = ?', $template_id); if(!$check) { $this->server->fault('Invalid template'); return false; @@ -312,8 +312,8 @@ class remoting_client extends remoting { // 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); + $sql = "INSERT INTO `client_template_assigned` (`client_id`, `client_template_id`) VALUES (?, ?)"; + $app->db->query($sql, $client_id, $template_id); $insert_id = $app->db->insertID(); $app->plugin->raiseEvent('client:client:on_after_update', $this); @@ -335,13 +335,13 @@ class remoting_client extends remoting { 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); + $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); + $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; @@ -350,8 +350,8 @@ class remoting_client extends remoting { // 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); + $sql = "DELETE FROM `client_template_assigned` WHERE `assigned_template_id` = ? AND `client_id` = ?"; + $app->db->query($sql, $template_id, $client_id); $affected_rows = $app->db->affectedRows(); $app->plugin->raiseEvent('client:client:on_after_update', $this); @@ -395,15 +395,15 @@ class remoting_client extends remoting { 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"); + $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']); //* delete the group of the client - $app->db->query("DELETE FROM sys_group WHERE client_id = $client_id"); + $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"); + $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'; @@ -413,7 +413,7 @@ class remoting_client extends remoting { 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); + $records = $app->db->queryAllRecords("SELECT * FROM $table WHERE sys_groupid = ?", $client_group_id); //* find the primary ID of the table $table_info = $app->db->tableInfo($table); $index_field = ''; @@ -428,11 +428,11 @@ class remoting_client extends remoting { $app->db->datalogDelete($table, $index_field, $rec[$index_field]); //* Delete traffic records that dont have a sys_groupid column if($table == 'web_domain') { - $app->db->query("DELETE FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."'"); + $app->db->query("DELETE FROM web_traffic WHERE hostname = ?", $rec['domain']); } //* Delete mail_traffic records that dont have a sys_groupid if($table == 'mail_user') { - $app->db->query("DELETE FROM mail_traffic WHERE mailuser_id = '".$app->db->quote($rec['mailuser_id'])."'"); + $app->db->query("DELETE FROM mail_traffic WHERE mailuser_id = ?", $rec['mailuser_id']); } } } @@ -468,8 +468,7 @@ class remoting_client extends remoting { 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."'"); + $rec = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE username = ?", $username); if (isset($rec)) { return $rec; } else { @@ -477,6 +476,27 @@ class remoting_client extends remoting { return false; } } + + public function client_get_by_customer_no($session_id, $customer_no) { + global $app; + if(!$this->checkPerm($session_id, 'client_get_by_customer_no')) { + throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + $customer_no = trim($customer_no); + if($customer_no == '') { + throw new SoapFault('permission_denied', 'There was no customer number specified.'); + return false; + } + $customer_no = $app->db->quote($customer_no); + $rec = $app->db->queryOneRecord("SELECT * FROM client WHERE customer_no = '".$customer_no."'"); + if (isset($rec)) { + return $rec; + } else { + throw new SoapFault('no_client_found', 'There is no user account for this customer number.'); + return false; + } + } /** * Get All client_id's from database @@ -517,13 +537,12 @@ class remoting_client extends remoting { return false; } $client_id = $app->functions->intval($client_id); - $client = $app->db->queryOneRecord("SELECT client_id FROM client WHERE client_id = ".$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); + $sql = "UPDATE client SET password = md5(?) WHERE client_id = ?"; + $app->db->query($sql, $new_password, $client_id); + $sql = "UPDATE sys_user SET passwort = md5(?) WHERE client_id = ?"; + $app->db->query($sql, $new_password, $client_id); return true; } else { throw new SoapFault('no_client_found', 'There is no user account for this client_id'); @@ -567,8 +586,8 @@ class remoting_client extends remoting { } //* Check failed logins - $sql = "SELECT * FROM `attempts_login` WHERE `ip`= '".$app->db->quote($remote_ip)."' AND `login_time` > (NOW() - INTERVAL 1 MINUTE) LIMIT 1"; - $alreadyfailed = $app->db->queryOneRecord($sql); + $sql = "SELECT * FROM `attempts_login` WHERE `ip`= ? AND `login_time` > (NOW() - INTERVAL 1 MINUTE) LIMIT 1"; + $alreadyfailed = $app->db->queryOneRecord($sql, $remote_ip); //* too many failedlogins if($alreadyfailed['times'] > 5) { @@ -582,8 +601,8 @@ class remoting_client extends remoting { if(strstr($username,'@')) { // Check against client table - $sql = "SELECT * FROM client WHERE email = '".$app->db->quote($username)."'"; - $user = $app->db->queryOneRecord($sql); + $sql = "SELECT * FROM client WHERE email = ?"; + $user = $app->db->queryOneRecord($sql, $username); if($user) { $saved_password = stripslashes($user['password']); @@ -614,8 +633,8 @@ class remoting_client extends remoting { } else { // Check against sys_user table - $sql = "SELECT * FROM sys_user WHERE username = '".$app->db->quote($username)."'"; - $user = $app->db->queryOneRecord($sql); + $sql = "SELECT * FROM sys_user WHERE username = ?"; + $user = $app->db->queryOneRecord($sql, $username); if($user) { $saved_password = stripslashes($user['passwort']); @@ -649,15 +668,14 @@ class remoting_client extends remoting { //* Log failed login attempts if($user === false) { - $time = time(); if(!$alreadyfailed['times'] ) { //* user login the first time wrong - $sql = "INSERT INTO `attempts_login` (`ip`, `times`, `login_time`) VALUES ('".$app->db->quote($remote_ip)."', 1, NOW())"; - $app->db->query($sql); + $sql = "INSERT INTO `attempts_login` (`ip`, `times`, `login_time`) VALUES (?, 1, NOW())"; + $app->db->query($sql, $remote_ip); } elseif($alreadyfailed['times'] >= 1) { //* update times wrong - $sql = "UPDATE `attempts_login` SET `times`=`times`+1, `login_time`=NOW() WHERE `login_time` >= '".$time."' LIMIT 1"; - $app->db->query($sql); + $sql = "UPDATE `attempts_login` SET `times`=`times`+1, `login_time`=NOW() WHERE `ip` = ? AND `login_time` > (NOW() - INTERVAL 1 MINUTE) ORDER BY `login_time` DESC LIMIT 1"; + $app->db->query($sql, $remote_ip); } } diff --git a/interface/lib/classes/remote.d/dns.inc.php b/interface/lib/classes/remote.d/dns.inc.php index 1e9526a12faf52db8bb00192e9655794021a886e..57f7040e28553377f1e34cf9b77dc178c557b98c 100644 --- a/interface/lib/classes/remote.d/dns.inc.php +++ b/interface/lib/classes/remote.d/dns.inc.php @@ -50,9 +50,9 @@ class remoting_dns extends remoting { return false; } - $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM client WHERE client_id = ".$app->functions->intval($client_id)); + $client = $app->db->queryOneRecord("SELECT default_dnsserver FROM client WHERE client_id = ?", $client_id); $server_id = $client["default_dnsserver"]; - $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = '$template_id'"); + $template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = ?", $template_id); $fields = explode(',', $template_record['fields']); $tform_def_file = "../../web/dns/form/dns_soa.tform.php"; $app->uses('tform'); @@ -95,11 +95,11 @@ class remoting_dns extends remoting { if($section == 'dns_records') { $parts = explode('|', $row); $dns_rr[] = array( - 'name' => $app->db->quote($parts[1]), - 'type' => $app->db->quote($parts[0]), - 'data' => $app->db->quote($parts[2]), - 'aux' => $app->db->quote($parts[3]), - 'ttl' => $app->db->quote($parts[4]) + 'name' => $parts[1], + 'type' => $parts[0], + 'data' => $parts[2], + 'aux' => $parts[3], + 'ttl' => $parts[4] ); } } @@ -117,30 +117,62 @@ class remoting_dns extends remoting { 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)); + $tmp = $app->db->queryOneRecord("SELECT userid,default_group FROM sys_user WHERE client_id = ?", $client_id); $sys_userid = $tmp['userid']; $sys_groupid = $tmp['default_group']; unset($tmp); - $origin = $app->db->quote($vars['origin']); - $ns = $app->db->quote($vars['ns']); - $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']); - $minimum = $app->db->quote($vars['minimum']); - $ttl = $app->db->quote($vars['ttl']); - $xfer = $app->db->quote($vars['xfer']); - $also_notify = $app->db->quote($vars['also_notify']); - $update_acl = $app->db->quote($vars['update_acl']); + $origin = $vars['origin']; + $ns = $vars['ns']; + $mbox = str_replace('@', '.', $vars['mbox']); + $refresh = $vars['refresh']; + $retry = $vars['retry']; + $expire = $vars['expire']; + $minimum = $vars['minimum']; + $ttl = $vars['ttl']; + $xfer = $vars['xfer']; + $also_notify = $vars['also_notify']; + $update_acl = $vars['update_acl']; $serial = $app->validate_dns->increase_serial(0); - $insert_data = "(`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')"; + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $sys_groupid, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $server_id, + "origin" => $origin, + "ns" => $ns, + "mbox" => $mbox, + "serial" => $serial, + "refresh" => $refresh, + "retry" => $retry, + "expire" => $expire, + "minimum" => $minimum, + "ttl" => $ttl, + "active" => 'Y', + "xfer" => $xfer, + "also_notify" => $also_notify, + "update_acl" => $update_acl + ); $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 - ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$dns_soa_id', '$rr[name]', '$rr[type]', '$rr[data]', '$rr[aux]', '$rr[ttl]', 'Y')"; + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $sys_groupid, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $server_id, + "zone" => $dns_soa_id, + "name" => $rr['name'], + "type" => $rr['type'], + "data" => $rr['data'], + "aux" => $rr['aux'], + "ttl" => $rr['ttl'], + "active" => 'Y' + ); $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); } } @@ -180,7 +212,7 @@ class remoting_dns extends remoting { return false; } - $rec = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin like '".$origin."%'"); + $rec = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin like ?", $origin."%"); if(isset($rec['id'])) { return $app->functions->intval($rec['id']); } else { @@ -764,8 +796,8 @@ class remoting_dns extends remoting { 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); + $sql = "SELECT id, origin FROM dns_soa d INNER JOIN sys_user s on(d.sys_groupid = s.default_group) WHERE client_id = ? AND server_id = ?"; + $result = $app->db->queryAllRecords($sql, $client_id, $server_id); return $result; } return false; @@ -785,8 +817,8 @@ class remoting_dns extends remoting { 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);; - $result = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM dns_rr WHERE zone = ?"; + $result = $app->db->queryAllRecords($sql, $zone_id); return $result; } @@ -809,8 +841,8 @@ class remoting_dns extends remoting { } else { $status = 'N'; } - $sql = "UPDATE dns_soa SET active = '$status' WHERE id = ".$app->functions->intval($primary_id); - $app->db->query($sql); + $sql = "UPDATE dns_soa SET active = ? WHERE id = ?"; + $app->db->query($sql, $status, $primary_id); $result = $app->db->affectedRows(); return $result; } else { diff --git a/interface/lib/classes/remote.d/domains.inc.php b/interface/lib/classes/remote.d/domains.inc.php index 9bba710023f6d311b7a18673ba731e072d957c11..33830335d8989990cd1c4f4613ab290679763184 100644 --- a/interface/lib/classes/remote.d/domains.inc.php +++ b/interface/lib/classes/remote.d/domains.inc.php @@ -86,8 +86,8 @@ class remoting_domains extends remoting { 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); + $sql = "SELECT domain_id, domain FROM domain WHERE sys_groupid = ?"; + $all = $app->db->queryAllRecords($sql, $group_id); return $all; } diff --git a/interface/lib/classes/remote.d/mail.inc.php b/interface/lib/classes/remote.d/mail.inc.php index e579fb67ff7dec16757f6547bb2b815443c19926..914777070b9ccc15746ad3bf055adab488f308e1 100644 --- a/interface/lib/classes/remote.d/mail.inc.php +++ b/interface/lib/classes/remote.d/mail.inc.php @@ -208,7 +208,7 @@ class remoting_mail extends remoting { //* Check if mail domain exists $email_parts = explode('@', $params['email']); - $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'"); + $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = ?", $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.'); return false; @@ -235,7 +235,7 @@ class remoting_mail extends remoting { //* Check if mail domain exists $email_parts = explode('@', $params['email']); - $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'"); + $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = ?", $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.'); return false; @@ -309,6 +309,73 @@ class remoting_mail extends remoting { // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this); return $affected_rows; } + + // Mail backup list function by Dominik Mller, info@profi-webdesign.net + public function mail_user_backup_list($session_id, $primary_id = null) + { + global $app; + + if(!$this->checkPerm($session_id, 'mail_user_backup')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + $params = array(); + if ($site_id != null) { + $params[] = $site_id; + $sql = "SELECT * FROM mail_backup WHERE parent_domain_id = ?"; + } + else { + $sql = "SELECT * FROM mail_backup"; + } + + $result = $app->db->queryAllRecords($sql, true, $params); + return $result; + } + + // Mail backup restore/download functions by Dominik Mller, info@profi-webdesign.net + public function mail_user_backup($session_id, $primary_id, $action_type) + { + global $app; + + if(!$this->checkPerm($session_id, 'mail_user_backup')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + //*Set variables + $backup_record = $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`=?", $primary_id); + $server_id = $backup_record['server_id']; + + //*Set default action state + $action_state = "pending"; + $tstamp = time(); + + //* Basic validation of variables + if ($server_id <= 0) { + $this->server->fault('invalid_backup_id', "Invalid or non existant backup_id $primary_id"); + return false; + } + + if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail') { + $this->server->fault('invalid_action', "Invalid action_type $action_type"); + return false; + } + + //* Validate instance + $instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`=? and `action_type`=? and `action_state`='pending'", $primary_id, $action_type); + if ($instance_record['action_id'] >= 1) { + $this->server->fault('duplicate_action', "There is already a pending $action_type action"); + return false; + } + + //* Save the record + if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) { + return true; + } else { + return false; + } + } //* Get alias details public function mail_alias_get($session_id, $primary_id) @@ -336,7 +403,7 @@ class remoting_mail extends remoting { } //* 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"])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = ?", $params["source"]); if($tmp['number'] > 0) { throw new SoapFault('duplicate', 'There is already a mailbox with this email address.'); } @@ -358,7 +425,7 @@ class remoting_mail extends remoting { } //* 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"])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = ?", $params["source"]); if($tmp['number'] > 0) { throw new SoapFault('duplicate', 'There is already a mailbox with this email address.'); } @@ -994,9 +1061,8 @@ class remoting_mail extends remoting { return false; } if (!empty($domain)) { - $domain = $app->db->quote($domain); - $sql = "SELECT * FROM mail_domain WHERE domain = '$domain'"; - $result = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_domain WHERE domain = ?"; + $result = $app->db->queryAllRecords($sql, $domain); return $result; } return false; @@ -1014,8 +1080,8 @@ class remoting_mail extends remoting { } else { $status = 'n'; } - $sql = "UPDATE mail_domain SET active = '$status' WHERE domain_id = ".$app->functions->intval($primary_id); - $app->db->query($sql); + $sql = "UPDATE mail_domain SET active = ? WHERE domain_id = ?"; + $app->db->query($sql, $status, $primary_id); $result = $app->db->affectedRows(); return $result; } else { diff --git a/interface/lib/classes/remote.d/openvz.inc.php b/interface/lib/classes/remote.d/openvz.inc.php index 4a087ccbc7e2d2c3df231d943869211fccbee439..c427a1f749e3f7eecf6e85cf00722eb155dda51f 100644 --- a/interface/lib/classes/remote.d/openvz.inc.php +++ b/interface/lib/classes/remote.d/openvz.inc.php @@ -159,7 +159,7 @@ class remoting_openvz extends remoting { $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"); + $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 = ? LIMIT 0,1", $server_id); } 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"); } @@ -229,9 +229,9 @@ class remoting_openvz extends remoting { 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); + $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client_id); + $sql = "SELECT * FROM openvz_vm WHERE sys_groupid = ?"; + $result = $app->db->queryAllRecords($sql, $tmp['groupid']); return $result; } return false; @@ -272,23 +272,23 @@ class remoting_openvz extends remoting { } // Verify if template and ostemplate exist - $tmp = $app->db->queryOneRecord("SELECT template_id FROM openvz_template WHERE template_id = $template_id"); + $tmp = $app->db->queryOneRecord("SELECT template_id FROM openvz_template WHERE template_id = ?", $template_id); if(!is_array($tmp)) { throw new SoapFault('template_id_error', 'Template does not exist.'); return false; } - $tmp = $app->db->queryOneRecord("SELECT ostemplate_id FROM openvz_ostemplate WHERE ostemplate_id = $ostemplate_id"); + $tmp = $app->db->queryOneRecord("SELECT ostemplate_id FROM openvz_ostemplate WHERE ostemplate_id = ?", $ostemplate_id); if(!is_array($tmp)) { 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"); + $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"); + $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 = ? LIMIT 0,1", $override_params['server_id']); } else { $vmip = $app->db->queryOneRecord("SELECT ip_address_id, server_id, ip_address FROM openvz_ip WHERE reserved = 'n' AND vm_id = 0 LIMIT 0,1"); } @@ -376,25 +376,18 @@ class remoting_openvz extends remoting { $action = 'openvz_start_vm'; $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'"); + WHERE server_id = ? + AND action_type = ? + AND action_param = ? + AND action_state = 'pending'", $vm['server_id'], $action, $vm['veid']); 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', ". - "''". - ")"; - $app->db->query($sql); + "VALUES (?, ?, ?, ?, 'pending', '')"; + $app->db->query($sql, (int)$vm['server_id'], time(), $action, $vm['veid']); } } @@ -425,25 +418,18 @@ class remoting_openvz extends remoting { $action = 'openvz_stop_vm'; $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'"); + WHERE server_id = ? + AND action_type = ? + AND action_param = ? + AND action_state = 'pending'", $vm['server_id'], $action, $vm['veid']); 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', ". - "''". - ")"; - $app->db->query($sql); + "VALUES (?, ?, ?, ?, 'pending', '')"; + $app->db->query($sql, (int)$vm['server_id'], time(), $action, $vm['veid']); } } @@ -474,25 +460,18 @@ class remoting_openvz extends remoting { $action = 'openvz_restart_vm'; $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'"); + WHERE server_id = ? + AND action_type = ? + AND action_param = ? + AND action_state = 'pending'", $vm['server_id'], $action, $vm['veid']); 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', ". - "''". - ")"; - $app->db->query($sql); + "VALUES (?, ?, ?, ?, 'pending', '')"; + $app->db->query($sql, (int)$vm['server_id'], time(), $action, $vm['veid']); } } diff --git a/interface/lib/classes/remote.d/server.inc.php b/interface/lib/classes/remote.d/server.inc.php index 403530207151242fcef101c6052e507227bf1144..eb4a8b9846641d44865d345fa889b09cd2d6ef37 100644 --- a/interface/lib/classes/remote.d/server.inc.php +++ b/interface/lib/classes/remote.d/server.inc.php @@ -55,8 +55,8 @@ class remoting_server extends remoting { 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); + $sql = "SELECT server_id FROM server_ip WHERE ip_address = ? LIMIT 1"; + $all = $app->db->queryAllRecords($sql, $ipaddress); return $all; } @@ -178,8 +178,8 @@ class remoting_server extends remoting { return false; } if (!empty($session_id) && !empty($server_name)) { - $sql = "SELECT server_id FROM server WHERE server_name = '$server_name' LIMIT 1 "; - $all = $app->db->queryAllRecords($sql); + $sql = "SELECT server_id FROM server WHERE server_name = ? LIMIT 1"; + $all = $app->db->queryAllRecords($sql, $server_name); return $all; } else { return false; @@ -200,8 +200,8 @@ class remoting_server extends remoting { return false; } if (!empty($session_id) && !empty($server_id)) { - $sql = "SELECT mail_server, web_server, dns_server, file_server, db_server, vserver_server, proxy_server, firewall_server FROM server WHERE server_id = '$server_id' LIMIT 1 "; - $all = $app->db->queryAllRecords($sql); + $sql = "SELECT mail_server, web_server, dns_server, file_server, db_server, vserver_server, proxy_server, firewall_server FROM server WHERE server_id = ? LIMIT 1 "; + $all = $app->db->queryAllRecords($sql, $server_id); return $all; } else { return false; diff --git a/interface/lib/classes/remote.d/sites.inc.php b/interface/lib/classes/remote.d/sites.inc.php index 98c5bf63283e683e2167855bcac05f819c63b721..ad3f2e3046f96e3e84c5d2ba75b15f7d767d08aa 100644 --- a/interface/lib/classes/remote.d/sites.inc.php +++ b/interface/lib/classes/remote.d/sites.inc.php @@ -102,7 +102,8 @@ class remoting_sites extends remoting { $app->remoting_lib->loadFormDef('../sites/form/database.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } - + + /* TODO: secure queries! */ //* Add a record public function sites_database_add($session_id, $client_id, $params) { @@ -114,7 +115,7 @@ class remoting_sites extends remoting { } //* 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"])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(database_id) as dbnum FROM web_database WHERE database_name = ? AND server_id = ?", $params['database_name'], $params["server_id"]); if($tmp['dbnum'] > 0) { throw new SoapFault('database_name_error_unique', 'There is already a database with that name on the same server.'); return false; @@ -135,7 +136,6 @@ class remoting_sites extends remoting { $sql_set = array(); if(isset($params['backup_interval'])) $sql_set[] = "backup_interval = '".$app->db->quote($params['backup_interval'])."'"; if(isset($params['backup_copies'])) $sql_set[] = "backup_copies = ".$app->functions->intval($params['backup_copies']); - //$app->db->query("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval); $this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$retval, $retval, $params); } @@ -169,7 +169,6 @@ class remoting_sites extends remoting { $sql_set = array(); if(isset($params['backup_interval'])) $sql_set[] = "backup_interval = '".$app->db->quote($params['backup_interval'])."'"; if(isset($params['backup_copies'])) $sql_set[] = "backup_copies = ".$app->functions->intval($params['backup_copies']); - //$app->db->query("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$primary_id); $this->updateQueryExecute("UPDATE web_database SET ".implode(', ', $sql_set)." WHERE database_id = ".$primary_id, $primary_id, $params); } @@ -239,7 +238,7 @@ class remoting_sites extends remoting { $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)."'"); + $records = $app->db->queryAllRecords("SELECT DISTINCT server_id FROM web_database WHERE database_user_id = ? UNION SELECT DISTINCT server_id FROM web_database WHERE database_ro_user_id = ?", $primary_id, $primary_id); foreach($records as $rec) { $tmp_rec = $new_rec; $tmp_rec['server_id'] = $rec['server_id']; @@ -265,14 +264,14 @@ class remoting_sites extends remoting { $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)."'"); + $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = ?", $primary_id); foreach($records as $rec) { - $app->db->datalogUpdate('web_database', 'database_user_id=NULL', 'database_id', $rec['database_id']); + $app->db->datalogUpdate('web_database', array('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)."'"); + $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_ro_user_id = ?", $primary_id); foreach($records as $rec) { - $app->db->datalogUpdate('web_database', 'database_ro_user_id=NULL', 'database_id', $rec['database_id']); + $app->db->datalogUpdate('web_database', array('database_ro_user_id' => null), 'database_id', $rec['database_id']); } return $affected_rows; @@ -336,7 +335,7 @@ class remoting_sites extends remoting { return false; } - $data = $app->db->queryOneRecord("SELECT server_id FROM ftp_user WHERE username = '".$app->db->quote($ftp_user)."'"); + $data = $app->db->queryOneRecord("SELECT server_id FROM ftp_user WHERE username = ?", $ftp_user); //file_put_contents('/tmp/test.txt', serialize($data)); if(!isset($data['server_id'])) return false; @@ -406,7 +405,7 @@ class remoting_sites extends remoting { return false; } $app->uses('remoting_lib'); - $app->remoting_lib->loadFormDef('../sites/form/web_domain.tform.php'); + $app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php'); return $app->remoting_lib->getDataRecord($primary_id); } @@ -420,7 +419,7 @@ class remoting_sites extends remoting { } 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)); + $rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client_id); $params['client_group_id'] = $rec['groupid']; } @@ -435,9 +434,9 @@ class remoting_sites extends remoting { 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_vhost_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); + $app->db->query("UPDATE web_domain SET `sys_userid` = '1' WHERE domain_id = ?", $domain_id); return $domain_id; } @@ -455,7 +454,7 @@ class remoting_sites extends remoting { 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_vhost_domain.tform.php', $client_id, $primary_id, $params); return $affected_rows; } @@ -466,7 +465,7 @@ class remoting_sites extends remoting { 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_vhost_domain.tform.php', $primary_id); return $affected_rows; } @@ -751,7 +750,7 @@ class remoting_sites extends remoting { } // 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)."'"); + $records = $app->db->queryAllRecords("SELECT web_folder_user_id FROM web_folder_user WHERE web_folder_id = ?", $primary_id); foreach($records as $rec) { $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']); @@ -865,11 +864,11 @@ class remoting_sites extends remoting { } else { $status = 'n'; } - $app->remoting_lib->loadFormDef('../sites/form/web_domain.tform.php'); + $app->remoting_lib->loadFormDef('../sites/form/web_vhost_domain.tform.php'); $params = $app->remoting_lib->getDataRecord($primary_id); $params['active'] = $status; - $affected_rows = $this->updateQuery('../sites/form/web_domain.tform.php', 0, $primary_id, $params); + $affected_rows = $this->updateQuery('../sites/form/web_vhost_domain.tform.php', 0, $primary_id, $params); return $affected_rows; } else { throw new SoapFault('status_undefined', 'The status is not available'); @@ -889,8 +888,8 @@ class remoting_sites extends remoting { 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"; - $all = $app->db->queryAllRecords($sql); + $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 = ?"; + $all = $app->db->queryAllRecords($sql, $client_id); return $all; } @@ -904,7 +903,7 @@ class remoting_sites extends remoting { return false; } - $result = $app->db->queryAllRecords("SELECT * FROM web_backup".(($site_id != null)?' WHERE parent_domain_id = ?':''), $app->functions->intval($site_id)); + $result = $app->db->queryAllRecords("SELECT * FROM web_backup".(($site_id != null)?' WHERE parent_domain_id = ?':''), $site_id); return $result; } @@ -966,6 +965,34 @@ class remoting_sites extends remoting { return $app->quota_lib->get_quota_data($client_id, false); } + public function trafficquota_get_by_user($session_id, $client_id, $lastdays = 0) + { + global $app; + $app->uses('quota_lib'); + + if(!$this->checkPerm($session_id, 'trafficquota_get_by_user')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + if ($client_id != null) + $client_id = $app->functions->intval($client_id); + + return $app->quota_lib->get_trafficquota_data($client_id, $lastdays); + } + + public function databasequota_get_by_user($session_id, $client_id) + { + global $app; + $app->uses('quota_lib'); + + if(!$this->checkPerm($session_id, 'databasequota_get_by_user')) { + $this->server->fault('permission_denied', 'You do not have the permissions to access this function.'); + return false; + } + + return $app->quota_lib->get_databasequota_data($client_id, false); + } + } diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php index f42d22b070c655daa835c69659e65b365c163a8e..204aebb15c08e7c33e7f86c0c992de474959009a 100644 --- a/interface/lib/classes/remoting.inc.php +++ b/interface/lib/classes/remoting.inc.php @@ -90,15 +90,12 @@ class remoting { } //* Delete old remoting sessions - $sql = "DELETE FROM remote_session WHERE tstamp < ".time(); + $sql = "DELETE FROM remote_session WHERE tstamp < UNIX_TIMSTAMP()"; $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); + $sql = "SELECT * FROM sys_user WHERE USERNAME = ?"; + $user = $app->db->queryOneRecord($sql, $username); if($user) { $saved_password = stripslashes($user['passwort']); @@ -127,7 +124,7 @@ class remoting { } // 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'])); + $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 = ?", $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; @@ -140,13 +137,12 @@ class remoting { $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); + .') VALUES (?, ?, ?, 1, $tstamp)'; + $app->db->query($sql, $remote_session,$remote_userid,$remote_functions,$tstamp); return $remote_session; } else { - $sql = "SELECT * FROM remote_user WHERE remote_username = '$username' and remote_password = md5('$password')"; - $remote_user = $app->db->queryOneRecord($sql); + $sql = "SELECT * FROM remote_user WHERE remote_username = ? and remote_password = md5(?)"; + $remote_user = $app->db->queryOneRecord($sql, $username, $password); if($remote_user['remote_userid'] > 0) { //* Create a remote user session //srand ((double)microtime()*1000000); @@ -155,9 +151,8 @@ class remoting { $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); + .') VALUES (?, ?, ?, ?)'; + $app->db->query($sql, $remote_session,$remote_userid,$remote_functions,$tstamp); return $remote_session; } else { throw new SoapFault('login_failed', 'The login failed. Username or password wrong.'); @@ -177,10 +172,8 @@ class remoting { return false; } - $session_id = $app->db->quote($session_id); - - $sql = "DELETE FROM remote_session WHERE remote_session = '$session_id'"; - if($app->db->query($sql) != false) { + $sql = "DELETE FROM remote_session WHERE remote_session = ?"; + if($app->db->query($sql, $session_id) != false) { return true; } else { return false; @@ -203,8 +196,8 @@ class remoting { $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'"); + $username = $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 @@ -238,7 +231,7 @@ class remoting { /* 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); + $app->db->query("UPDATE client SET created_at = UNIX_TIMSTAMP(), id_rsa = ?, ssh_rsa = ? WHERE client_id = ?", @file_get_contents('/tmp/id_rsa'), @file_get_contents('/tmp/id_rsa.pub'), $this->id); exec('rm -f /tmp/id_rsa /tmp/id_rsa.pub'); @@ -251,10 +244,10 @@ class remoting { $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); + $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); + $app->db->query("UPDATE client SET parent_client_id = ? WHERE client_id = ?", $reseller_id, $insert_id); } } @@ -347,6 +340,7 @@ class remoting { //* Get the SQL query $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); @@ -473,11 +467,8 @@ class remoting { 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); + $sql = "SELECT * FROM remote_session WHERE remote_session = ? AND tstamp >= UNIX_TIMSTAMP()"; + $session = $app->db->queryOneRecord($sql, $session_id); if($session['remote_userid'] > 0) { return $session; } else { diff --git a/interface/lib/classes/remoting_lib.inc.php b/interface/lib/classes/remoting_lib.inc.php index d85612b6473596d4b331c30e0ca5b5601066b038..9ee3ca547c2d11cf0e9b89f7cbaac4251435f071 100644 --- a/interface/lib/classes/remoting_lib.inc.php +++ b/interface/lib/classes/remoting_lib.inc.php @@ -110,7 +110,7 @@ class remoting_lib extends tform_base { 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); + $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; @@ -125,23 +125,11 @@ class remoting_lib extends tform_base { $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"); - 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"); + $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'; } @@ -186,12 +174,11 @@ class remoting_lib extends tform_base { /** * 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 = '') { + function encode($record, $tab = '', $dbencode = true) { $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! @@ -240,8 +227,8 @@ class remoting_lib extends tform_base { return parent::getDataRecord($primary_id); } elseif($primary_id == -1) { // Return a array with all records - $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape; - return $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM ??"; + return $app->db->queryAllRecords($sql, $this->formDef['db_table']); } else { throw new SoapFault('invalid_id', 'The ID has to be > 0 or -1.'); return array(); @@ -251,22 +238,23 @@ class remoting_lib extends tform_base { $sql_offset = 0; $sql_limit = 0; $sql_where = ''; + $params = array($this->formDef['db_table']); 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 "; + $sql_where .= "? like ? AND "; } else { - $sql_where .= "$key = '$val' AND "; + $sql_where .= "? = ? AND "; } + $params[] = $key; + $params[] = $val; } $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']); + $sql = "SELECT * FROM ?? 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); + return $app->db->queryAllRecords($sql, true, $params); } else { $this->errorMessage = 'The ID must be either an integer or an array.'; return array(); @@ -275,12 +263,12 @@ class remoting_lib extends tform_base { function ispconfig_sysuser_add($params, $insert_id){ global $conf, $app, $sql1; - $username = $app->db->quote($params["username"]); - $password = $app->db->quote($params["password"]); + $username = $params["username"]; + $password = $params["password"]; if(!isset($params['modules'])) { $modules = $conf['interface_modules_enabled']; } else { - $modules = $app->db->quote($params['modules']); + $modules = $params['modules']; } if(isset($params['limit_client']) && $params['limit_client'] > 0) { $modules .= ',client'; @@ -289,44 +277,51 @@ class remoting_lib extends tform_base { if(!isset($params['startmodule'])) { $startmodule = 'dashboard'; } else { - $startmodule = $app->db->quote($params["startmodule"]); + $startmodule = $params["startmodule"]; if(!preg_match('/'.$startmodule.'/', $modules)) { $_modules = explode(',', $modules); $startmodule=$_modules[0]; } } - $usertheme = $app->db->quote($params["usertheme"]); + $usertheme = $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'); + $language = $params["language"]; + $groupid = $app->db->datalogInsert('sys_group', array("name" => $username, "description" => "", "client_id" => $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); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + $app->db->query($sql1, $username,$password,$modules,$startmodule,$usertheme,$type,$active,$language,$groups,$groupid,$insert_id); } function ispconfig_sysuser_update($params, $client_id){ global $app; - $username = $app->db->quote($params["username"]); - $clear_password = $app->db->quote($params["password"]); + $username = $params["username"]; + $clear_password = $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); + $params = array($username); + if ($clear_password) { + $pwstring = ", passwort = ?"; + $params[] = $password; + } else { + $pwstring ="" ; + } + $params[] = $client_id; + $sql = "UPDATE sys_user set username = ? $pwstring WHERE client_id = ?"; + $app->db->query($sql, true, $params); } 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); + $sql = "DELETE FROM sys_user WHERE client_id = ?"; + $app->db->query($sql, $client_id); + $sql = "DELETE FROM sys_group WHERE client_id = ?"; + $app->db->query($sql, $client_id); } } diff --git a/interface/lib/classes/searchform.inc.php b/interface/lib/classes/searchform.inc.php index cfa8f283601324f93861de938454d8b5cc635279..0a290c1d699bcae630af474c76190d92f5ec1d42 100644 --- a/interface/lib/classes/searchform.inc.php +++ b/interface/lib/classes/searchform.inc.php @@ -177,7 +177,7 @@ class searchform { 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"); + $record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM ?? WHERE $sql_where", $table); $pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page); $vars['list_file'] = $this->listDef['file']; @@ -247,7 +247,7 @@ class searchform { $list_name = $this->listDef['name']; $settings = $_SESSION['search'][$list_name]; unset($settings['page']); - $data = $app->db->quote(serialize($settings)); + $data = serialize($settings); $userid = $_SESSION['s']['user']['userid']; $groupid = $_SESSION['s']['user']['default_group']; @@ -260,9 +260,8 @@ class searchform { $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')"; - $app->db->query($sql); + .')VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)'; + $app->db->query($sql, $userid, $groupid, $sys_perm_user, $sys_perm_group, $sys_perm_other, $module, $searchform, $title, $data); } public function decode($record) @@ -303,6 +302,7 @@ class searchform { return $record; } + /* TODO: check for double quoting mysql value */ public function encode($record) { global $app; diff --git a/interface/lib/classes/session.inc.php b/interface/lib/classes/session.inc.php index 8b3a7cffc4b530136d472cbe4b7510a5cfbc3df8..bef2a1037838b2c3253c771b3b5d280b21ad49b9 100644 --- a/interface/lib/classes/session.inc.php +++ b/interface/lib/classes/session.inc.php @@ -66,9 +66,9 @@ class session { function read ($session_id) { if($this->timeout > 0) { - $rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = '".$this->db->quote($session_id)."' AND (`permanent` = 'y' OR last_updated >= DATE_SUB(NOW(), INTERVAL " . intval($this->timeout) . " MINUTE))"); + $rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = ? AND (`permanent` = 'y' OR last_updated >= DATE_SUB(NOW(), INTERVAL ? MINUTE))", $session_id, $this->timeout); } else { - $rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = '".$this->db->quote($session_id)."'"); + $rec = $this->db->queryOneRecord("SELECT * FROM sys_session WHERE session_id = ?", $session_id); } if (is_array($rec)) { @@ -87,23 +87,18 @@ class session { // 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); - $this->db->query("UPDATE sys_session SET last_updated = NOW() WHERE session_id = '$session_id'"); + $this->db->query("UPDATE sys_session SET last_updated = NOW() WHERE session_id = ?", $session_id); return true; } if (@$this->session_array['session_id'] == '') { - $session_id = $this->db->quote($session_id); - $session_data = $this->db->quote($session_data); - $sql = "REPLACE INTO sys_session (session_id,date_created,last_updated,session_data,permanent) VALUES ('$session_id',NOW(),NOW(),'$session_data','" . ($this->permanent ? 'y' : 'n') . "')"; - $this->db->query($sql); + $sql = "REPLACE INTO sys_session (session_id,date_created,last_updated,session_data,permanent) VALUES (?,NOW(),NOW(),'$session_data',?)"; + $this->db->query($sql, $session_id, ($this->permanent ? 'y' : 'n')); } else { - $session_id = $this->db->quote($session_id); - $session_data = $this->db->quote($session_data); - $sql = "UPDATE sys_session SET last_updated = NOW(), session_data = '$session_data'" . ($this->permanent ? ", `permanent` = 'y'" : "") . " WHERE session_id = '$session_id'"; - $this->db->query($sql); + $sql = "UPDATE sys_session SET last_updated = NOW(), session_data = ?" . ($this->permanent ? ", `permanent` = 'y'" : "") . " WHERE session_id = ?"; + $this->db->query($sql, $session_data, $session_id); } @@ -112,25 +107,20 @@ class session { 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); + $sql = "DELETE FROM sys_session WHERE session_id = ?"; + $this->db->query($sql, $session_id); return true; } function gc ($max_lifetime) { - /*if($this->timeout > 0) { - $this->db->query("DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW(), INTERVAL " . intval($this->timeout) . " MINUTE)"); - } else {*/ - $sql = "DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW(), INTERVAL " . intval($max_lifetime) . " SECOND) AND `permanent` != 'y'"; - $this->db->query($sql); + $sql = "DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW(), INTERVAL ? SECOND) AND `permanent` != 'y'"; + $this->db->query($sql, intval($max_lifetime)); - /* delete very old even if they are permanent */ - $sql = "DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW(), INTERVAL 1 YEAR)"; - $this->db->query($sql); - //} + /* delete very old even if they are permanent */ + $sql = "DELETE FROM sys_session WHERE last_updated < DATE_SUB(NOW(), INTERVAL 1 YEAR)"; + $this->db->query($sql); return true; diff --git a/interface/lib/classes/sites_database_plugin.inc.php b/interface/lib/classes/sites_database_plugin.inc.php index bf53c61fadbc5d6494a99da32ff3943b7244ceff..89cb7ce9c278a649d610a2a8ef4891cafbb47ebd 100644 --- a/interface/lib/classes/sites_database_plugin.inc.php +++ b/interface/lib/classes/sites_database_plugin.inc.php @@ -40,15 +40,15 @@ class sites_database_plugin { 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"])); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $form_page->dataRecord["parent_domain_id"]); //* The Database user shall be owned by the same group then the website $sys_groupid = $app->functions->intval($web['sys_groupid']); - $backup_interval = $app->db->quote($web['backup_interval']); + $backup_interval = $web['backup_interval']; $backup_copies = $app->functions->intval($web['backup_copies']); - $sql = "UPDATE web_database SET sys_groupid = '$sys_groupid', backup_interval = '$backup_interval', backup_copies = '$backup_copies' WHERE database_id = ".$form_page->id; - $app->db->query($sql); + $sql = "UPDATE web_database SET sys_groupid = ?, backup_interval = ?, backup_copies = ? WHERE database_id = ?"; + $app->db->query($sql, $sys_groupid, $backup_interval, $backup_copies, $form_page->id); } } diff --git a/interface/lib/classes/tform.inc.php b/interface/lib/classes/tform.inc.php index 7912f537dc78bb762ba11650ab2cd7b3ad2638f9..1376d7ded94c90f13204dff3fce85346d1e6e4e0 100644 --- a/interface/lib/classes/tform.inc.php +++ b/interface/lib/classes/tform.inc.php @@ -79,8 +79,8 @@ class tform extends tform_base { $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)) { + $sql = "SELECT ?? FROM ?? WHERE ?? = ? AND ".$this->getAuthSQL($perm); + if($record = $app->db->queryOneRecord($sql, $this->formDef['db_table_idx'], $this->formDef['db_table'], $this->formDef['db_table_idx'], $record_id)) { return true; } else { return false; @@ -133,8 +133,8 @@ class tform extends tform_base { $escape = '`'; } - $sql = "SELECT sys_userid FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id; - $record = $app->db->queryOneRecord($sql); + $sql = "SELECT sys_userid FROM ?? WHERE ?? = ?"; + $record = $app->db->queryOneRecord($sql, $this->formDef['db_table'], $this->formDef['db_table_idx'], $primary_id); // 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"]) { @@ -161,18 +161,17 @@ class tform extends tform_base { global $app; $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 = $app->functions->intval($_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"); + $client = $app->db->queryOneRecord("SELECT ?? as number, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $limit_name, $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'); + $sql = "SELECT count(??) as number FROM ?? WHERE ".$this->getAuthSQL('u'); if($sql_where != '') $sql .= ' and '.$sql_where; - $tmp = $app->db->queryOneRecord($sql); + $tmp = $app->db->queryOneRecord($sql, $this->formDef['db_table_idx'], $this->formDef['db_table']); if($tmp["number"] >= $client["number"]) $check_passed = false; } @@ -183,30 +182,29 @@ class tform extends tform_base { global $app; $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 = $app->functions->intval($_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"); + $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']); + $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']); + $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.")"; + $sql = "SELECT count(??) as number FROM ?? WHERE (sys_groupid IN ? or sys_userid = ?)"; if($sql_where != '') $sql .= ' and '.$sql_where; - $tmp = $app->db->queryOneRecord($sql); + $tmp = $app->db->queryOneRecord($sql, $this->formDef['db_table_idx'], $this->formDef['db_table'], explode(',', $reseller_groups), $reseller_userid); if($tmp["number"] >= $reseller["number"]) $check_passed = false; } } @@ -257,9 +255,13 @@ class tform extends tform_base { if ($display_seconds === true) { $dselect[] = 'second'; } + + $tmp_dt = strtr($this->datetimeformat,array('d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy', 'y' => 'yy', 'H' => 'hh', 'h' => 'HH', 'i' => 'ii')) . ($display_seconds ? ':ss' : ''); $out = ''; - + + return ''; +/* foreach ($dselect as $dt_element) { $dt_options = array(); @@ -320,7 +322,7 @@ class tform extends tform_base { $selected_value = (int)floor(date('s', $_datetime)); break; } - + $out .= "' . str_repeat(' ', $dt_space); } - return $out; + return $out;*/ } } diff --git a/interface/lib/classes/tform_actions.inc.php b/interface/lib/classes/tform_actions.inc.php index dfc943c8822a33039ea0cd82cf7e4a65a171fc2d..f172fea1f4c5fceb824281c8e1b54ee7cc6b3446 100644 --- a/interface/lib/classes/tform_actions.inc.php +++ b/interface/lib/classes/tform_actions.inc.php @@ -82,7 +82,7 @@ class tform_actions { // check if the client is locked - he may not change anything, then. if(!$app->auth->is_admin()) { $client_group_id = $app->functions->intval($_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)); + $client = $app->db->queryOneRecord("SELECT client.locked FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); if(is_array($client) && $client['locked'] == 'y') { $app->tform->errorMessage .= $app->lng("client_you_are_locked")."
"; } @@ -311,7 +311,6 @@ class tform_actions { 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); $app->plugin->raiseEvent($_SESSION['s']['module']['name'].':'.$app->tform->formDef['name'].':'.'on_check_delete', $this); @@ -324,7 +323,7 @@ class tform_actions { $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"); + $app->db->query("DELETE FROM ?? WHERE ?? = ? LIMIT 1", $app->tform->formDef['db_table'], $app->tform->formDef['db_table_idx'], $this->id); // loading plugins @@ -379,11 +378,11 @@ class tform_actions { $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; + $sql = "SELECT * FROM ?? WHERE ?? = ?"; } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); + $sql = "SELECT * FROM ?? WHERE ?? = ? AND ".$app->tform->getAuthSQL('r'); } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); + if(!$record = $app->db->queryOneRecord($sql, $app->tform->formDef['db_table'], $app->tform->formDef['db_table_idx'], $this->id)) $app->error($app->lng('error_no_view_permission')); $record["datum"] = date("d.m.Y"); @@ -423,11 +422,11 @@ class tform_actions { $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; + $sql = "SELECT * FROM ?? WHERE ?? = ?"; } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); + $sql = "SELECT * FROM ?? WHERE ?? = ? AND ".$app->tform->getAuthSQL('r'); } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); + if(!$record = $app->db->queryOneRecord($sql, $app->tform->formDef['db_table'], $app->tform->formDef['db_table_idx'], $this->id)) $app->error($app->lng('error_no_view_permission')); $record["datum"] = date("d.m.Y"); $record["mailmessage"] = $_POST["message"]; @@ -459,11 +458,11 @@ class tform_actions { if($app->tform->formDef['auth'] == 'no') { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; + $sql = "SELECT * FROM ?? WHERE ?? = ?"; } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id." AND ".$app->tform->getAuthSQL('r'); + $sql = "SELECT * FROM ?? WHERE ?? = ? AND ".$app->tform->getAuthSQL('r'); } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); + if(!$record = $app->db->queryOneRecord($sql, $app->tform->formDef['db_table'], $app->tform->formDef['db_table_idx'], $this->id)) $app->error($app->lng('error_no_view_permission')); $record["datum"] = date("d.m.Y"); @@ -560,11 +559,11 @@ class tform_actions { // 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'); + $sql = "SELECT * FROM ?? WHERE ?? = ? AND ".$app->tform->getAuthSQL('r'); } else { - $sql = "SELECT * FROM ".$app->tform->formDef['db_table']." WHERE ".$app->tform->formDef['db_table_idx']." = ".$this->id; + $sql = "SELECT * FROM ?? WHERE ?? = ?"; } - if(!$record = $app->db->queryOneRecord($sql)) $app->error($app->lng('error_no_view_permission')); + if(!$record = $app->db->queryOneRecord($sql, $app->tform->formDef['db_table'], $app->tform->formDef['db_table_idx'], $this->id)) $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); diff --git a/interface/lib/classes/tform_base.inc.php b/interface/lib/classes/tform_base.inc.php index e27940d4f5c0270eaea15d4e5c02528cb9f1419a..749ea5c708abceb8f9e0a489b55730b8d7bdf022 100644 --- a/interface/lib/classes/tform_base.inc.php +++ b/interface/lib/classes/tform_base.inc.php @@ -98,6 +98,7 @@ class tform_base { var $errorMessage = ''; var $dateformat = "d.m.Y"; + var $datetimeformat = 'd.m.Y H:i'; var $formDef = array(); var $wordbook; var $module; @@ -153,6 +154,7 @@ class tform_base { $this->wordbook = $wb; $this->dateformat = $app->lng('conf_format_dateshort'); + $this->datetimeformat = $app->lng('conf_format_datetime'); return true; } @@ -347,7 +349,7 @@ class tform_base { 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"); + $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']); } } @@ -359,19 +361,19 @@ class tform_base { } 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"); + $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']); + $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']); + $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; @@ -708,13 +710,8 @@ class tform_base { 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']; + $new_record[$key] = $date_parts['year'].'-'.str_pad($date_parts['month'], 2, "0", STR_PAD_LEFT).'-'.str_pad($date_parts['day'], 2, "0", STR_PAD_LEFT); } 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); } @@ -724,8 +721,6 @@ class tform_base { 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]; @@ -735,7 +730,7 @@ class tform_base { break; case 'DATETIME': - if (is_array($record[$key])) + /*if (is_array($record[$key])) { $filtered_values = array_map(create_function('$item', 'return (int)$item;'), $record[$key]); extract($filtered_values, EXTR_PREFIX_ALL, '_dt'); @@ -743,7 +738,14 @@ class tform_base { 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) ); } - } + } else {*/ + if($record[$key] != '' && $record[$key] != '0000-00-00 00:00:00') { + $tmp = strtotime($record[$key]); + $new_record[$key] = date($this->datetimeformat, $tmp); + } else { + $new_record[$key] = '0000-00-00 00:00:00'; + } + /*}*/ break; } @@ -810,6 +812,9 @@ class tform_base { case 'IDNTOUTF8': $returnval = $app->functions->idn_decode($returnval); break; + case 'TRIM': + $returnval = trim($returnval); + break; default: $this->errorMessage .= "Unknown Filter: ".$filter['type']; break; @@ -853,7 +858,7 @@ class tform_base { 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)."'"); + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ?? WHERE ?? = ?", $this->formDef['db_table'], $field_name, $field_value); if($num_rec["number"] > 0) { $errmsg = $validator['errmsg']; if(isset($this->wordbook[$errmsg])) { @@ -863,7 +868,7 @@ class tform_base { } } } 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); + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ?? WHERE ?? = ? AND ?? != ?", $this->formDef['db_table'], $field_name, $field_value, $this->formDef['db_table_idx'], $this->primary_id); if($num_rec["number"] > 0) { $errmsg = $validator['errmsg']; if(isset($this->wordbook[$errmsg])) { @@ -1108,6 +1113,7 @@ class tform_base { * @param primary_id * @return record */ + /* TODO: check for double quoting */ protected function _getSQL($record, $tab, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '', $api = false) { global $app; @@ -1139,7 +1145,7 @@ class tform_base { $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`"); + $tmp = $app->db->queryOneRecord("SELECT PASSWORD(?) as `crypted`", stripslashes($record[$key])); $record[$key] = $tmp['crypted']; $sql_insert_val .= "'".$app->db->quote($record[$key])."', "; } else { @@ -1167,7 +1173,7 @@ class tform_base { $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`"); + $tmp = $app->db->queryOneRecord("SELECT PASSWORD(?) as `crypted`", stripslashes($record[$key])); $record[$key] = $tmp['crypted']; $sql_update .= "`$key` = '".$app->db->quote($record[$key])."', "; } else { @@ -1359,8 +1365,8 @@ class tform_base { 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); + $sql = "SELECT * FROM ?? WHERE ?? = ? AND ".$this->getAuthSQL('r', $this->formDef['db_table']); + return $app->db->queryOneRecord($sql, $this->formDef['db_table'], $this->formDef['db_table_idx'], $primary_id); } diff --git a/interface/lib/classes/tform_tpl_generator.inc.php b/interface/lib/classes/tform_tpl_generator.inc.php index 49fd274a898e67ff6d955b052ce0d679a89e0ad8..b759e5128f9fea3cff775c9ff55db204438a23ef 100644 --- a/interface/lib/classes/tform_tpl_generator.inc.php +++ b/interface/lib/classes/tform_tpl_generator.inc.php @@ -136,8 +136,8 @@ class tform_tpl_generator {
- - + +
diff --git a/interface/lib/classes/tools_monitor.inc.php b/interface/lib/classes/tools_monitor.inc.php index db8c91ec2a83eb4ee2e8dc2a6128fef8fcddf565..bd1a969d57457fee98709adf390ea4ab12b0e00f 100644 --- a/interface/lib/classes/tools_monitor.inc.php +++ b/interface/lib/classes/tools_monitor.inc.php @@ -33,7 +33,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'server_load' AND server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $data = unserialize($record['data']); @@ -80,7 +80,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'disk_usage' AND server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $data = unserialize($record['data']); @@ -91,16 +91,18 @@ class tools_monitor { $html = '
-
+
+ - - - - - - - - '; + + + + + + + + + '; foreach($data as $line) { $html .= ''; foreach ($line as $item) { @@ -108,7 +110,7 @@ class tools_monitor { } $html .= ''; } - $html .= '
'.$app->lng("monitor_diskusage_filesystem_txt").''.$app->lng("monitor_diskusage_type_txt").''.$app->lng("monitor_diskusage_size_txt").''.$app->lng("monitor_diskusage_used_txt").''.$app->lng("monitor_diskusage_available_txt").''.$app->lng("monitor_diskusage_usage_txt").''.$app->lng("monitor_diskusage_mounted_txt").'
'.$app->lng("monitor_diskusage_filesystem_txt").''.$app->lng("monitor_diskusage_type_txt").''.$app->lng("monitor_diskusage_size_txt").''.$app->lng("monitor_diskusage_used_txt").''.$app->lng("monitor_diskusage_available_txt").''.$app->lng("monitor_diskusage_usage_txt").''.$app->lng("monitor_diskusage_mounted_txt").'
'; + $html .= ''; $html .= '
'; } else { $html = '

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

'; @@ -121,28 +123,31 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'database_size' AND server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $data = unserialize($record['data']); //* format the data $html = '
- - - - - - '; +
'.$app->lng("monitor_database_name_txt").''.$app->lng("monitor_database_size_txt").''.$app->lng("monitor_database_client_txt").''.$app->lng("monitor_database_domain_txt").'
+ + + + + + '; foreach($data as $line) { $html .= ''; if ($line['size'] > 0) $line['size'] = $app->functions->formatBytes($line['size']); //* get the client - $line['client']=$app->db->queryOneRecord("SELECT client.username FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name='".$line['database_name']."'")['username']; + $tmp = $app->db->queryOneRecord("SELECT client.username FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name=?", $line['database_name']); + $line['client'] = $tmp['username']; //* get the domain - $line['domain']=$app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id=(SELECT parent_domain_id FROM web_database WHERE database_name='".$line['database_name']."')")['domain']; + $tmp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id=(SELECT parent_domain_id FROM web_database WHERE database_name=?", $line['database_name']); + $line['domain'] = $tmp['domain']; //* remove the sys_groupid from output unset($line['sys_groupid']); @@ -150,7 +155,7 @@ class tools_monitor { foreach ($line as $item) { $html .= ''; } - $html .= ''; + $html .= ''; } $html .= '
'.$app->lng("monitor_database_name_txt").''.$app->lng("monitor_database_size_txt").''.$app->lng("monitor_database_client_txt").''.$app->lng("monitor_database_domain_txt").'
' . $item . '
'; } else { @@ -163,7 +168,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mem_usage' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $data = unserialize($record['data']); @@ -174,7 +179,8 @@ class tools_monitor { $html = '
- '; +
+ '; foreach($data as $key => $value) { if ($key != '') { @@ -184,7 +190,7 @@ class tools_monitor { '; } } - $html .= '
'; + $html .= ''; $html .= '
'; } else { @@ -198,7 +204,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'cpu_info' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $data = unserialize($record['data']); @@ -209,7 +215,8 @@ class tools_monitor { $html = '
- '; +
+ '; foreach($data as $key => $value) { if ($key != '') { $html .= ' @@ -218,7 +225,7 @@ class tools_monitor { '; } } - $html .= '
'; + $html .= ''; $html .= '
'; } else { $html = '

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

'; @@ -231,7 +238,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'services' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $data = unserialize($record['data']); @@ -242,7 +249,8 @@ class tools_monitor { $html = '
- '; +
+ '; if($data['webserver'] != -1) { if($data['webserver'] == 1) { @@ -330,7 +338,7 @@ class tools_monitor { } - $html .= '
'; + $html .= ''; } else { $html = '

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

'; } @@ -343,7 +351,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'system_update' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $html = @@ -373,7 +381,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'openvz_beancounter' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $html = @@ -402,7 +410,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'raid_state' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $html = @@ -435,7 +443,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'rkhunter' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $html = @@ -466,7 +474,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_fail2ban' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $html = @@ -480,7 +488,7 @@ class tools_monitor { $data = unserialize($record['data']); if ($data == '') { $html .= '

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

'; } @@ -500,7 +508,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'log_mongodb' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $html = @@ -514,8 +522,7 @@ class tools_monitor { $data = unserialize($record['data']); if ($data == '') { $html .= '

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

'; } else { @@ -532,7 +539,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'iptables_rules' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $html = '
@@ -556,7 +563,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mailq' and server_id = ? ORDER BY created DESC", $_SESSION['monitor']['server_id']); if(isset($record['data'])) { $data = unserialize($record['data']); @@ -572,7 +579,7 @@ class tools_monitor { 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"); + $record = $app->db->queryOneRecord("SELECT created FROM monitor_data WHERE type = ? and server_id = ? ORDER BY created DESC", $type, $_SESSION['monitor']['server_id']); /* TODO: datetimeformat should be set somewhat other way */ $dateTimeFormat = $app->lng("monitor_settings_datetimeformat_txt"); diff --git a/interface/lib/classes/tools_sites.inc.php b/interface/lib/classes/tools_sites.inc.php index 3400c5b708097d837a6880881b1e4a064d9fdd5d..b2881f57cc7e28a96554b8f585d17873100035fe 100644 --- a/interface/lib/classes/tools_sites.inc.php +++ b/interface/lib/classes/tools_sites.inc.php @@ -87,7 +87,7 @@ class tools_sites { 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']); + $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']; @@ -96,7 +96,7 @@ class tools_sites { } } - $tmp = $app->db->queryOneRecord("SELECT name FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id)); + $tmp = $app->db->queryOneRecord("SELECT name FROM sys_group WHERE groupid = ?", $client_group_id); $clientName = $tmp['name']; if ($clientName == "") $clientName = 'default'; $clientName = $this->convertClientName($clientName); @@ -114,7 +114,7 @@ class tools_sites { 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']); + $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']; @@ -122,7 +122,7 @@ class tools_sites { return '[CLIENTID]'; } } - $tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id)); + $tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = ?", $client_group_id); $clientID = $tmp['client_id']; if ($clientID == '') $clientID = '0'; return $clientID; @@ -144,6 +144,7 @@ class tools_sites { return $res; } + /* TODO: rewrite SQL */ function getDomainModuleDomains($not_used_in_table = null, $selected_domain = null) { global $app; @@ -168,6 +169,7 @@ class tools_sites { return $app->db->queryAllRecords($sql, $not_used_in_table, $selected_domain); } + /* TODO: rewrite SQL */ function checkDomainModuleDomain($domain_id) { global $app; @@ -180,7 +182,8 @@ class tools_sites { if(!$domain || !$domain['domain_id']) return false; return $domain['domain']; } - + + /* TODO: rewrite SQL */ function getClientIdForDomain($domain_id) { global $app; diff --git a/interface/lib/classes/validate_client.inc.php b/interface/lib/classes/validate_client.inc.php index 0f90a5b3d1c5b706ffdc4f12ad35175df645b249..db55b04f187862eecd25593396597303f27c3aff 100644 --- a/interface/lib/classes/validate_client.inc.php +++ b/interface/lib/classes/validate_client.inc.php @@ -43,7 +43,7 @@ class validate_client { } if($client_id == 0) { - $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."'"); + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = ?", $field_value); if($num_rec["number"] > 0) { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { @@ -53,7 +53,7 @@ class validate_client { } } } else { - $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = '".$app->db->quote($field_value)."' AND client_id != ".$app->functions->intval($client_id)); + $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM sys_user WHERE username = ? AND client_id != ?", $field_value, $client_id); if($num_rec["number"] > 0) { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { @@ -108,20 +108,24 @@ class validate_client { switch ($field_name) { case 'web_servers': - $used_servers = $app->db->queryAllRecords('SELECT domain_id FROM web_domain INNER JOIN sys_user ON web_domain.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');'); + $used_servers = $app->db->queryAllRecords('SELECT domain_id FROM web_domain INNER JOIN sys_user ON web_domain.sys_userid = sys_user.userid WHERE client_id = ? AND server_id NOT IN ?', $client_id, $field_value); break; case 'dns_servers': - $used_servers = $app->db->queryAllRecords('SELECT id FROM dns_rr INNER JOIN sys_user ON dns_rr.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');'); + $used_servers = $app->db->queryAllRecords('SELECT id FROM dns_rr INNER JOIN sys_user ON dns_rr.sys_userid = sys_user.userid WHERE client_id = ? AND server_id NOT IN ?', $client_id, $field_value); break; case 'db_servers': - $used_servers = $app->db->queryAllRecords('SELECT database_id FROM web_database INNER JOIN sys_user ON web_database.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');'); + $used_servers = $app->db->queryAllRecords('SELECT database_id FROM web_database INNER JOIN sys_user ON web_database.sys_userid = sys_user.userid WHERE client_id = ? AND server_id NOT IN ?', $client_id, $field_value); break; case 'mail_servers': - $used_servers = $app->db->queryAllRecords('SELECT domain_id FROM mail_domain INNER JOIN sys_user ON mail_domain.sys_userid = sys_user.userid WHERE client_id = ' . $client_id . ' AND server_id NOT IN (' . implode(', ', $field_value) . ');'); + $used_servers = $app->db->queryAllRecords('SELECT domain_id FROM mail_domain INNER JOIN sys_user ON mail_domain.sys_userid = sys_user.userid WHERE client_id = ? AND server_id NOT IN ?', $client_id, $field_value); break; + + case 'xmpp_servers': + $used_servers = $app->db->queryAllRecords('SELECT domain_id FROM xmpp_domain INNER JOIN sys_user ON xmpp_domain.sys_userid = sys_user.userid WHERE client_id = ? AND server_id NOT IN ?', $client_id, $field_value); + break; } if ($used_servers === null || count($used_servers)) @@ -136,7 +140,87 @@ class validate_client { } } + function check_vat_id ($field_name, $field_value, $validator){ + global $app, $page; + + $vatid = trim($field_value); + if(isset($app->remoting_lib->primary_id)) { + $country = $app->remoting_lib->dataRecord['country']; + } else { + $country = $page->dataRecord['country']; + } + + // check if country is member of EU + $country_details = $app->db->queryOneRecord("SELECT * FROM country WHERE iso = ?", $country); + if($country_details['eu'] == 'y' && $vatid != ''){ + + $vatid = preg_replace('/\s+/', '', $vatid); + $vatid = str_replace(array('.', '-', ','), '', $vatid); + $cc = substr($vatid, 0, 2); + $vn = substr($vatid, 2); + + // Test if the country of the VAT-ID matches the country of the customer + if($country != ''){ + // Greece + if($country == 'GR') $country = 'EL'; + if(strtoupper($cc) != $country){ + $errmsg = $validator['errmsg']; + if(isset($app->tform->wordbook[$errmsg])) { + return $app->tform->wordbook[$errmsg]."
\r\n"; + } else { + return $errmsg."
\r\n"; + } + } + } + $client = new SoapClient("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"); + + if($client){ + $params = array('countryCode' => $cc, 'vatNumber' => $vn); + try{ + $r = $client->checkVat($params); + if($r->valid == true){ + } else { + $errmsg = $validator['errmsg']; + if(isset($app->tform->wordbook[$errmsg])) { + return $app->tform->wordbook[$errmsg]."
\r\n"; + } else { + return $errmsg."
\r\n"; + } + } + + // This foreach shows every single line of the returned information + /* + foreach($r as $k=>$prop){ + echo $k . ': ' . $prop; + } + */ + + } catch(SoapFault $e) { + //echo 'Error, see message: '.$e->faultstring; + switch ($e->faultstring) { + case 'INVALID_INPUT': + $errmsg = $validator['errmsg']; + if(isset($app->tform->wordbook[$errmsg])) { + return $app->tform->wordbook[$errmsg]."
\r\n"; + } else { + return $errmsg."
\r\n"; + } + break; + // the following cases shouldn't be the user's fault, so we return no error + case 'SERVICE_UNAVAILABLE': + case 'MS_UNAVAILABLE': + case 'TIMEOUT': + case 'SERVER_BUSY': + break; + } + } + } else { + // Connection to host not possible, europe.eu down? + // this shouldn't be the user's fault, so we return no error + } + } + } } diff --git a/interface/lib/classes/validate_dkim.inc.php b/interface/lib/classes/validate_dkim.inc.php index 71fd8c5454a847b1877cd9d74e81502538803851..5d7fb8f1e369a88930ca90379ee90be5af2cb203 100644 --- a/interface/lib/classes/validate_dkim.inc.php +++ b/interface/lib/classes/validate_dkim.inc.php @@ -62,8 +62,10 @@ class validate_dkim { */ function check_template($field_name, $field_value, $validator) { $dkim=false; - foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; } - if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']); + if(is_array($field_value) && !empty($field_value)){ + foreach($field_value as $field ) { if($field == 'DKIM') $dkim=true; } + if ($dkim && $field_value[0]!='DOMAIN') return $this->get_error($validator['errmsg']); + } } diff --git a/interface/lib/classes/validate_dns.inc.php b/interface/lib/classes/validate_dns.inc.php index 212c4d75dccd8aaf7b537f342b9a7465be22cf10..a6920e0b01d4f033326b148f425d34631d2cb9bb 100644 --- a/interface/lib/classes/validate_dns.inc.php +++ b/interface/lib/classes/validate_dns.inc.php @@ -104,7 +104,7 @@ class validate_dns { } if(substr($field, -1) == '.' && $area == 'Name'){ - $soa = $app->db->queryOneRecord("SELECT * FROM soa WHERE id = ".intval($zoneid)); + $soa = $app->db->queryOneRecord("SELECT * FROM soa WHERE id = ?", $zoneid); if(substr($field, (strlen($field) - strlen($soa['origin']))) != $soa['origin']) $error .= $desc." ".$app->tform->wordbook['error_out_of_zone']."
\r\n"; } diff --git a/interface/lib/classes/validate_domain.inc.php b/interface/lib/classes/validate_domain.inc.php index a072412584f51bb4a4d5b226c20009449df983c5..fde14b0010a2af2b825cc1fb2bb1fd3f66bd9e5d 100644 --- a/interface/lib/classes/validate_domain.inc.php +++ b/interface/lib/classes/validate_domain.inc.php @@ -88,8 +88,8 @@ class validate_domain { $app->uses('ini_parser,getconf'); $settings = $app->getconf->get_global_config('domains'); if ($settings['use_domain_module'] == 'y') { - $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($check_domain); - $domain_check = $app->db->queryOneRecord($sql); + $sql = "SELECT domain_id, domain FROM domain WHERE domain_id = ?"; + $domain_check = $app->db->queryOneRecord($sql, $check_domain); if(!$domain_check) return; $check_domain = $domain_check['domain']; } @@ -157,24 +157,31 @@ class validate_domain { if($domain['ip_address'] == '' || $domain['ipv6_address'] == ''){ if($domain['parent_domain_id'] > 0){ - $parent_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$app->functions->intval($domain['parent_domain_id'])); + $parent_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $domain['parent_domain_id']); + if(is_array($parent_domain) && !empty($parent_domain)){ + $domain['ip_address'] = $parent_domain['ip_address']; + $domain['ipv6_address'] = $parent_domain['ipv6_address']; + } } } // check if domain has alias/subdomains - if we move a web to another IP, make sure alias/subdomains are checked as well - $aliassubdomains = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$app->functions->intval($primary_id)." AND (type = 'alias' OR type = 'subdomain' OR type = 'vhostsubdomain')"); + $aliassubdomains = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ? AND (type = 'alias' OR type = 'subdomain' OR type = 'vhostsubdomain')", $primary_id); $additional_sql1 = ''; $additional_sql2 = ''; + $domain_params = array(); if(is_array($aliassubdomains) && !empty($aliassubdomains)){ foreach($aliassubdomains as $aliassubdomain){ - $additional_sql1 .= " OR d.domain = '".$app->db->quote($aliassubdomain['domain'])."'"; - $additional_sql2 .= " OR CONCAT(d.subdomain, '.', d.domain) = '".$app->db->quote($aliassubdomain['domain'])."'"; + $additional_sql1 .= " OR d.domain = ?"; + $additional_sql2 .= " OR CONCAT(d.subdomain, '.', d.domain) = ?"; + $domain_params[] = $aliassubdomain['domain']; } } - $qrystr = "SELECT d.domain_id, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ip_address, d.ip_address) as `ip_address`, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ipv6_address, d.ipv6_address) as `ipv6_address` FROM `web_domain` as d LEFT JOIN `web_domain` as p ON (p.domain_id = d.parent_domain_id) WHERE (d.domain = '" . $app->db->quote($domain_name) . "'" . $additional_sql1 . ") AND d.server_id = " . $app->functions->intval($domain['server_id']) . " AND d.domain_id != " . $app->functions->intval($primary_id) . ($primary_id ? " AND d.parent_domain_id != " . $app->functions->intval($primary_id) : ""); - $checks = $app->db->queryAllRecords($qrystr); + $qrystr = "SELECT d.domain_id, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ip_address, d.ip_address) as `ip_address`, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ipv6_address, d.ipv6_address) as `ipv6_address` FROM `web_domain` as d LEFT JOIN `web_domain` as p ON (p.domain_id = d.parent_domain_id) WHERE (d.domain = ?" . $additional_sql1 . ") AND d.server_id = ? AND d.domain_id != ?" . ($primary_id ? " AND d.parent_domain_id != ?" : ""); + $params = array($domain_name) + $domain_params + array($domain['server_id'], $primary_id, $primary_id); + $checks = $app->db->queryAllRecords($qrystr, true, $params); if(is_array($checks) && !empty($checks)){ foreach($checks as $check){ if($domain['ip_address'] == '*') return false; @@ -185,8 +192,9 @@ class validate_domain { } if($only_domain == false) { - $qrystr = "SELECT d.domain_id, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ip_address, d.ip_address) as `ip_address`, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ipv6_address, d.ipv6_address) as `ipv6_address` FROM `web_domain` as d LEFT JOIN `web_domain` as p ON (p.domain_id = d.parent_domain_id) WHERE (CONCAT(d.subdomain, '.', d.domain)= '" . $app->db->quote($domain_name) . "'" . $additional_sql2 . ") AND d.server_id = " . $app->functions->intval($domain['server_id']) . " AND d.domain_id != " . $app->functions->intval($primary_id) . ($primary_id ? " AND d.parent_domain_id != " . $app->functions->intval($primary_id) : ""); - $checks = $app->db->queryAllRecords($qrystr); + $qrystr = "SELECT d.domain_id, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ip_address, d.ip_address) as `ip_address`, IF(d.parent_domain_id != 0 AND p.domain_id IS NOT NULL, p.ipv6_address, d.ipv6_address) as `ipv6_address` FROM `web_domain` as d LEFT JOIN `web_domain` as p ON (p.domain_id = d.parent_domain_id) WHERE (CONCAT(d.subdomain, '.', d.domain)= ?" . $additional_sql2 . ") AND d.server_id = ? AND d.domain_id != ?" . ($primary_id ? " AND d.parent_domain_id != ?" : ""); + $params = array($domain_name) + $domain_params + array($domain['server_id'], $primary_id, $primary_id); + $checks = $app->db->queryAllRecords($qrystr, true, $params); if(is_array($checks) && !empty($checks)){ foreach($checks as $check){ if($domain['ip_address'] == '*') return false; @@ -207,7 +215,7 @@ class validate_domain { if($_SESSION["s"]["user"]["typ"] != 'admin') { // Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT limit_wildcard FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT limit_wildcard FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); if($client["limit_wildcard"] == 'y') return true; else return false; diff --git a/interface/lib/classes/validate_ftpuser.inc.php b/interface/lib/classes/validate_ftpuser.inc.php index 8e0663ecae9dc661df5051163a37a9b9d73a1bea..da8c100adcdb168287b97db8b81be580a36f6d13 100644 --- a/interface/lib/classes/validate_ftpuser.inc.php +++ b/interface/lib/classes/validate_ftpuser.inc.php @@ -50,7 +50,7 @@ class validate_ftpuser { if($primary_id > 0) { //* get parent_domain_id from website - $ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = '".$app->db->quote($primary_id)."'"); + $ftp_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM ftp_user WHERE ftp_user_id = ?", $primary_id); if(!is_array($ftp_data) || $ftp_data["parent_domain_id"] < 1) { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { @@ -66,7 +66,7 @@ class validate_ftpuser { $parent_domain_id = $app->functions->intval($app->remoting_lib->dataRecord['parent_domain_id']); } - $domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($parent_domain_id)."'"); + $domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = ?", $parent_domain_id); if(!is_array($domain_data) || $domain_data["domain_id"] < 1) { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { diff --git a/interface/lib/classes/validate_systemuser.inc.php b/interface/lib/classes/validate_systemuser.inc.php index 2cab1cf44464c563b7296230cd3af6682d906aa3..74824b72ca592ad3b4506fee29f1f219e6d798fd 100644 --- a/interface/lib/classes/validate_systemuser.inc.php +++ b/interface/lib/classes/validate_systemuser.inc.php @@ -95,7 +95,7 @@ class validate_systemuser { if($primary_id > 0) { //* get parent_domain_id from website - $shell_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM shell_user WHERE shell_user_id = '".$app->db->quote($primary_id)."'"); + $shell_data = $app->db->queryOneRecord("SELECT parent_domain_id FROM shell_user WHERE shell_user_id = ?", $primary_id); if(!is_array($shell_data) || $shell_data["parent_domain_id"] < 1) { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { @@ -111,7 +111,7 @@ class validate_systemuser { $parent_domain_id = $app->functions->intval($app->remoting_lib->dataRecord['parent_domain_id']); } - $domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = '".$app->db->quote($parent_domain_id)."'"); + $domain_data = $app->db->queryOneRecord("SELECT domain_id, document_root FROM web_domain WHERE domain_id = ?", $parent_domain_id); if(!is_array($domain_data) || $domain_data["domain_id"] < 1) { $errmsg = $validator['errmsg']; if(isset($app->tform->wordbook[$errmsg])) { diff --git a/interface/lib/config.inc.php b/interface/lib/config.inc.php index 7b5dacec2a1fcff5cabcb6bea1c5b48a7ccc6271..907f372871ec71a8c1ad34716a5de8f5b28ac14e 100644 --- a/interface/lib/config.inc.php +++ b/interface/lib/config.inc.php @@ -51,6 +51,7 @@ define('DEVSYSTEM', 0); //** Database $conf['db_type'] = 'mysql'; $conf['db_host'] = 'localhost'; +$conf['db_port'] = 3306; $conf['db_database'] = 'ispconfig3_305'; $conf['db_user'] = 'root'; $conf['db_password'] = ''; @@ -60,6 +61,7 @@ $conf['db_client_flags'] = 0; define('DB_TYPE', $conf['db_type']); define('DB_HOST', $conf['db_host']); +define('DB_PORT', $conf['db_port']); define('DB_DATABASE', $conf['db_database']); define('DB_USER', $conf['db_user']); define('DB_PASSWORD', $conf['db_password']); @@ -69,6 +71,7 @@ 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_port'] = '{mysql_master_server_port}'; $conf['dbmaster_database'] = '{mysql_master_server_database}'; $conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}'; $conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}'; diff --git a/interface/lib/lang/en.lng b/interface/lib/lang/en.lng index c89c97a7ccaed04036a54541fcb431b2ef608ce2..3c2bfafe2085347ca5236e38283981645a652c01 100644 --- a/interface/lib/lang/en.lng +++ b/interface/lib/lang/en.lng @@ -26,7 +26,7 @@ $wb['delete_txt'] = "Delete"; $wb['filter_txt'] = "Filter"; $wb['add_new_record_txt'] = "Add new record"; $wb['btn_save_txt'] = "Save"; -$wb['btn_cancel_txt'] = "Back"; +$wb['btn_cancel_txt'] = "Cancel"; $wb['top_menu_system'] = 'System'; $wb['top_menu_client'] = 'Client'; $wb['top_menu_email'] = 'Email'; diff --git a/interface/lib/plugins/dns_dns_slave_plugin.inc.php b/interface/lib/plugins/dns_dns_slave_plugin.inc.php index aa2e20f9ab4089e5833de379049ee22f416f24a3..8f49ce69d0bc4c855f60a927cc120a38dee8f7ac 100644 --- a/interface/lib/plugins/dns_dns_slave_plugin.inc.php +++ b/interface/lib/plugins/dns_dns_slave_plugin.inc.php @@ -30,19 +30,19 @@ class dns_dns_slave_plugin { // 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($page_form->dataRecord["client_group_id"])) { $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $app->db->query("UPDATE dns_slave SET sys_groupid = $client_group_id WHERE id = ".$page_form->id); + $app->db->query("UPDATE dns_slave SET sys_groupid = ? WHERE id = ?", $client_group_id, $page_form->id); } if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { $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 = ".$page_form->id); + $app->db->query("UPDATE dns_slave SET sys_groupid = ? WHERE id = ?", $client_group_id, $page_form->id); } //** When the client group has changed, change also the owner of the record if the owner is not the admin user if($page_form->oldDataRecord && $page_form->oldDataRecord["client_group_id"] != $page_form->dataRecord["client_group_id"] && $page_form->dataRecord["sys_userid"] != 1) { $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $tmp = $app->db->queryOneREcord("SELECT userid FROM sys_user WHERE default_group = ".$client_group_id); + $tmp = $app->db->queryOneREcord("SELECT userid FROM sys_user WHERE default_group = ?", $client_group_id); if($tmp["userid"] > 0) { - $app->db->query("UPDATE dns_slave SET sys_userid = ".$tmp["userid"]." WHERE id = ".$page_form->id); + $app->db->query("UPDATE dns_slave SET sys_userid = ? WHERE id = ?", $tmp["userid"], $page_form->id); } } } diff --git a/interface/lib/plugins/dns_dns_soa_plugin.inc.php b/interface/lib/plugins/dns_dns_soa_plugin.inc.php index 1cada0e932d59510d136542b8a3295933a434e37..8f047bef8b147c354cc400a082b4050a7b4befec 100644 --- a/interface/lib/plugins/dns_dns_soa_plugin.inc.php +++ b/interface/lib/plugins/dns_dns_soa_plugin.inc.php @@ -31,17 +31,17 @@ class dns_dns_soa_plugin { $tmp = $app->db->diffrec($page_form->oldDataRecord, $app->tform->getDataRecord($page_form->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 = ".$page_form->id); - $app->db->query("UPDATE dns_soa SET serial = '".$app->validate_dns->increase_serial($soa["serial"])."' WHERE id = ".$page_form->id); + $soa = $app->db->queryOneRecord("SELECT serial FROM dns_soa WHERE id = ?", $page_form->id); + $app->db->query("UPDATE dns_soa SET serial = ? WHERE id = ?", $app->validate_dns->increase_serial($soa["serial"]), $page_form->id); } //** When the client group has changed, change also the owner of the record if the owner is not the admin user if($page_form->oldDataRecord["client_group_id"] != $page_form->dataRecord["client_group_id"] && $page_form->dataRecord["sys_userid"] != 1) { $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $tmp = $app->db->queryOneREcord("SELECT userid FROM sys_user WHERE default_group = ".$client_group_id); + $tmp = $app->db->queryOneREcord("SELECT userid FROM sys_user WHERE default_group = ?", $client_group_id); if($tmp["userid"] > 0) { - $app->db->query("UPDATE dns_soa SET sys_userid = ".$tmp["userid"]." WHERE id = ".$page_form->id); - $app->db->query("UPDATE dns_rr SET sys_userid = ".$tmp["userid"]." WHERE zone = ".$page_form->id); + $app->db->query("UPDATE dns_soa SET sys_userid = ? WHERE id = ?", $tmp["userid"], $page_form->id); + $app->db->query("UPDATE dns_rr SET sys_userid = ? WHERE zone = ?", $tmp["userid"], $page_form->id); } } } @@ -49,15 +49,15 @@ class dns_dns_soa_plugin { // 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($page_form->dataRecord["client_group_id"])) { $client_group_id = $app->functions->intval($page_form->dataRecord["client_group_id"]); - $app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$page_form->id); + $app->db->query("UPDATE dns_soa SET sys_groupid = ?, sys_perm_group = 'ru' WHERE id = ?", $client_group_id, $page_form->id); // 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 = ".$page_form->id); + $app->db->query("UPDATE dns_rr SET sys_groupid = ? WHERE zone = ?", $client_group_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 dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$page_form->id); + $app->db->query("UPDATE dns_soa SET sys_groupid = ?, sys_perm_group = 'riud' WHERE id = ?", $client_group_id, $page_form->id); // 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 = ".$page_form->id); + $app->db->query("UPDATE dns_rr SET sys_groupid = ? WHERE zone = ?", $client_group_id, $page_form->id); } } diff --git a/interface/lib/plugins/mail_mail_domain_plugin.inc.php b/interface/lib/plugins/mail_mail_domain_plugin.inc.php index 13f6009ee58d62a84aaf6cc4de54b9c48a5ca4e3..90b1ac15b95033a431d6c75932392eaec0f8652a 100644 --- a/interface/lib/plugins/mail_mail_domain_plugin.inc.php +++ b/interface/lib/plugins/mail_mail_domain_plugin.inc.php @@ -31,23 +31,29 @@ class mail_mail_domain_plugin { // 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"]); - $updates = "sys_groupid = $client_group_id, sys_perm_group = 'ru'"; + $updates = "sys_groupid = ?, sys_perm_group = 'ru'"; + $update_params = array($client_group_id); if ($event_name == 'mail:mail_domain:on_after_update') { - $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id"); + $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = ?", $client_group_id); $client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1; - $updates = "sys_userid = $client_user_id, $updates"; + $updates .= ", sys_userid = ?"; + $update_params[] = $client_user_id; } - $app->db->query("UPDATE mail_domain SET $updates WHERE domain_id = ".$page_form->id); + $update_params[] = $page_form->id; + $app->db->query("UPDATE mail_domain SET " . $updates . " WHERE domain_id = ?", true, $update_params); } 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"]); $updates = "sys_groupid = $client_group_id, sys_perm_group = 'riud'"; + $update_params = array($client_group_id); if ($event_name == 'mail:mail_domain:on_after_update') { - $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $client_group_id"); + $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = ?", $client_group_id); $client_user_id = ($tmp['userid'] > 0)?$tmp['userid']:1; - $updates = "sys_userid = $client_user_id, $updates"; + $updates .= ", sys_userid = ?"; + $update_params[] = $client_user_id; } - $app->db->query("UPDATE mail_domain SET $updates WHERE domain_id = ".$page_form->id); + $update_params[] = $page_form->id; + $app->db->query("UPDATE mail_domain SET " . $updates . " WHERE domain_id = ?", true, $update_params); } //** If the domain name or owner has been changed, change the domain and owner in all mailbox records @@ -57,9 +63,9 @@ class mail_mail_domain_plugin { $mail_config = $app->getconf->get_server_config($page_form->dataRecord["server_id"], 'mail'); //* Update the mailboxes - $mailusers = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE email like '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'"); + $mailusers = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE email like ?", "%@" . $page_form->oldDataRecord['domain']); $sys_groupid = $app->functions->intval((isset($page_form->dataRecord['client_group_id']))?$page_form->dataRecord['client_group_id']:$page_form->oldDataRecord['sys_groupid']); - $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $sys_groupid"); + $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = ?", $sys_groupid); $client_user_id = $app->functions->intval(($tmp['userid'] > 0)?$tmp['userid']:1); if(is_array($mailusers)) { foreach($mailusers as $rec) { @@ -67,46 +73,45 @@ class mail_mail_domain_plugin { $mail_parts = explode("@", $rec['email']); $maildir = str_replace("[domain]", $page_form->dataRecord['domain'], $mail_config["maildir_path"]); $maildir = str_replace("[localpart]", $mail_parts[0], $maildir); - $maildir = $app->db->quote($maildir); - $email = $app->db->quote($mail_parts[0].'@'.$page_form->dataRecord['domain']); - $app->db->datalogUpdate('mail_user', "maildir = '$maildir', email = '$email', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'mailuser_id', $rec['mailuser_id']); + $email = $mail_parts[0].'@'.$page_form->dataRecord['domain']; + $app->db->datalogUpdate('mail_user', array("maildir" => $maildir, "email" => $email, "sys_userid" => $client_user_id, "sys_groupid" => $sys_groupid), 'mailuser_id', $rec['mailuser_id']); } } //* Update the aliases - $forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source like '%@".$app->db->quote($page_form->oldDataRecord['domain'])."' OR destination like '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'"); + $forwardings = $app->db->queryAllRecords("SELECT * FROM mail_forwarding WHERE source LIKE ? OR destination LIKE ?", "%@" . $page_form->oldDataRecord['domain'], "%@" . $page_form->oldDataRecord['domain']); if(is_array($forwardings)) { foreach($forwardings as $rec) { - $destination = $app->db->quote(str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['destination'])); - $source = $app->db->quote(str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['source'])); - $app->db->datalogUpdate('mail_forwarding', "source = '$source', destination = '$destination', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'forwarding_id', $rec['forwarding_id']); + $destination = str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['destination']); + $source = str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['source']); + $app->db->datalogUpdate('mail_forwarding', array("source" => $source, "destination" => $destination, "sys_userid" => $client_user_id, "sys_groupid" => $sys_groupid), 'forwarding_id', $rec['forwarding_id']); } } //* Update the mailinglist - $mailing_lists = $app->db->queryAllRecords("SELECT mailinglist_id FROM mail_mailinglist WHERE domain = '".$app->db->quote($page_form->oldDataRecord['domain'])."'"); + $mailing_lists = $app->db->queryAllRecords("SELECT mailinglist_id FROM mail_mailinglist WHERE domain = ?", $page_form->oldDataRecord['domain']); if(is_array($mailing_lists)) { foreach($mailing_lists as $rec) { - $app->db->datalogUpdate('mail_mailinglist', "sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'mailinglist_id', $rec['mailinglist_id']); + $app->db->datalogUpdate('mail_mailinglist', array("sys_userid" => $client_user_id, "sys_groupid" => $sys_groupid), 'mailinglist_id', $rec['mailinglist_id']); } } //* Update the mailget records - $mail_gets = $app->db->queryAllRecords("SELECT mailget_id, destination FROM mail_get WHERE destination LIKE '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'"); + $mail_gets = $app->db->queryAllRecords("SELECT mailget_id, destination FROM mail_get WHERE destination LIKE ?", "%@" . $page_form->oldDataRecord['domain']); if(is_array($mail_gets)) { foreach($mail_gets as $rec) { - $destination = $app->db->quote(str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['destination'])); - $app->db->datalogUpdate('mail_get', "destination = '$destination', sys_userid = $client_user_id, sys_groupid = '$sys_groupid'", 'mailget_id', $rec['mailget_id']); + $destination = str_replace($page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $rec['destination']); + $app->db->datalogUpdate('mail_get', array("destination" => $destination, "sys_userid" => $client_user_id, "sys_groupid" => $sys_groupid), 'mailget_id', $rec['mailget_id']); } } if ($page_form->oldDataRecord["domain"] != $page_form->dataRecord['domain']) { //* Delete the old spamfilter record - $tmp = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = '@".$app->db->quote($page_form->oldDataRecord["domain"])."'"); + $tmp = $app->db->queryOneRecord("SELECT id FROM spamfilter_users WHERE email = ?", "@" . $page_form->oldDataRecord["domain"]); $app->db->datalogDelete('spamfilter_users', 'id', $tmp["id"]); unset($tmp); } - $app->db->query("UPDATE spamfilter_users SET email=REPLACE(email, '".$app->db->quote($page_form->oldDataRecord['domain'])."', '".$app->db->quote($page_form->dataRecord['domain'])."'), sys_userid = $client_user_id, sys_groupid = $sys_groupid WHERE email LIKE '%@".$app->db->quote($page_form->oldDataRecord['domain'])."'"); + $app->db->query("UPDATE spamfilter_users SET email=REPLACE(email, ?, ?), sys_userid = ?, sys_groupid = ? WHERE email LIKE ?", $page_form->oldDataRecord['domain'], $page_form->dataRecord['domain'], $client_user_id, $sys_groupid, "%@" . $page_form->oldDataRecord['domain']); } // end if domain name changed } diff --git a/interface/lib/plugins/mail_user_filter_plugin.inc.php b/interface/lib/plugins/mail_user_filter_plugin.inc.php index 8faeab5e83aad6c63b01df88cc35689d36583099..e831789a6bd980b27123fbca2c74fe6962d13add 100644 --- a/interface/lib/plugins/mail_user_filter_plugin.inc.php +++ b/interface/lib/plugins/mail_user_filter_plugin.inc.php @@ -61,7 +61,7 @@ class mail_user_filter_plugin { 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"]); + $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']); $out = ''; @@ -86,8 +86,7 @@ class mail_user_filter_plugin { $out = $new_rule . $out; } - $out = $app->db->quote($out); - $app->db->datalogUpdate('mail_user', "custom_mailfilter = '$out'", 'mailuser_id', $page_form->dataRecord["mailuser_id"]); + $app->db->datalogUpdate('mail_user', array("custom_mailfilter" => $out), 'mailuser_id', $page_form->dataRecord["mailuser_id"]); } @@ -95,7 +94,7 @@ class mail_user_filter_plugin { 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"]); + $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']); $out = ''; @@ -111,8 +110,7 @@ class mail_user_filter_plugin { } } - $out = $app->db->quote($out); - $app->db->datalogUpdate('mail_user', "custom_mailfilter = '$out'", 'mailuser_id', $page_form->dataRecord["mailuser_id"]); + $app->db->datalogUpdate('mail_user', array("custom_mailfilter" => $out), 'mailuser_id', $page_form->dataRecord["mailuser_id"]); } @@ -124,7 +122,7 @@ class mail_user_filter_plugin { 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"])); + $mailuser_rec = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE mailuser_id = ?", $page_form->dataRecord["mailuser_id"]); $mail_config = $app->getconf->get_server_config($app->functions->intval($mailuser_rec["server_id"]), 'mail'); if($mail_config['mail_filter_syntax'] == 'sieve') { @@ -137,41 +135,69 @@ class mail_user_filter_plugin { $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( - array( - '"', - '\\[', - '\\]' - ), - array( - '\\"', - '\\\\[', - '\\\\]' - ), $searchterm); - - if($page_form->dataRecord["op"] == 'contains') { - $content .= ".*".$searchterm; - } elseif ($page_form->dataRecord["op"] == 'is') { - $content .= "^".$searchterm."$"; - } elseif ($page_form->dataRecord["op"] == 'begins') { - $content .= "^".$searchterm.".*"; - } elseif ($page_form->dataRecord["op"] == 'ends') { - $content .= ".*".$searchterm."$"; + + if($page_form->dataRecord["op"] == 'domain') { + $content .= 'if address :domain :is "'.strtolower($page_form->dataRecord["source"]).'" "'.$page_form->dataRecord["searchterm"].'" {'."\n"; + } elseif ($page_form->dataRecord["op"] == 'localpart') { + $content .= 'if address :localpart :is "'.strtolower($page_form->dataRecord["source"]).'" "'.$page_form->dataRecord["searchterm"].'" {'."\n"; + } elseif ($page_form->dataRecord["source"] == 'Size') { + if(substr(trim($page_form->dataRecord["searchterm"]),-1) == 'k' || substr(trim($page_form->dataRecord["searchterm"]),-1) == 'K') { + $unit = 'k'; + } else { + $unit = 'm'; + } + $content .= 'if size :over '.intval($page_form->dataRecord["searchterm"]).$unit.' {'."\n"; + } else { + + if($page_form->dataRecord["source"] == 'Header') { + $parts = explode(':',trim($page_form->dataRecord["searchterm"])); + $page_form->dataRecord["source"] = trim($parts[0]); + unset($parts[0]); + $page_form->dataRecord["searchterm"] = trim(implode(':',$parts)); + unset($parts); + } + + $content .= 'if header :regex ["'.strtolower($page_form->dataRecord["source"]).'"] ["'; + + $searchterm = preg_quote($page_form->dataRecord["searchterm"]); + $searchterm = str_replace( + array( + '"', + '\\[', + '\\]' + ), + array( + '\\"', + '\\\\[', + '\\\\]' + ), $searchterm); + + if($page_form->dataRecord["op"] == 'contains') { + $content .= ".*".$searchterm; + } elseif ($page_form->dataRecord["op"] == 'is') { + $content .= "^".$searchterm."$"; + } elseif ($page_form->dataRecord["op"] == 'begins') { + $content .= " ".$searchterm.""; + } elseif ($page_form->dataRecord["op"] == 'ends') { + $content .= ".*".$searchterm."$"; + } + + $content .= '"] {'."\n"; } - $content .= '"] {'."\n"; - if($page_form->dataRecord["action"] == 'move') { - $content .= ' fileinto "'.$page_form->dataRecord["target"].'";' . "\n"; + $content .= ' fileinto "'.$page_form->dataRecord["target"].'";' . "\n stop;\n"; + } elseif ($page_form->dataRecord["action"] == 'keep') { + $content .= " keep;\n"; + } elseif ($page_form->dataRecord["action"] == 'stop') { + $content .= " stop;\n"; + } elseif ($page_form->dataRecord["action"] == 'reject') { + $content .= ' reject "'.$page_form->dataRecord["target"].'"; stop;\n\n'; } else { - $content .= " discard;\n"; + $content .= " discard;\n stop;\n"; } - $content .= " stop;\n}\n"; + $content .= "}\n"; $content .= '### END FILTER_ID:'.$page_form->id."\n"; 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 1a880a1b10a0cd4d67cdc9861dbf917839b01c96..754c249ab9959208beba689b4b9a50971ae2b119 100644 --- a/interface/lib/plugins/sites_web_database_user_plugin.inc.php +++ b/interface/lib/plugins/sites_web_database_user_plugin.inc.php @@ -31,13 +31,12 @@ class sites_web_database_user_plugin { // 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); + $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'ru' WHERE database_user_id = ?", $client_group_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 sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_group_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); } } diff --git a/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php b/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php index d063fbbecfc5c4ed3dd41f8d311205a551a60c29..aeb5623996009f08e3650628c4e0c871b5b50007 100644 --- a/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php +++ b/interface/lib/plugins/sites_web_vhost_domain_plugin.inc.php @@ -51,11 +51,11 @@ class sites_web_vhost_domain_plugin { // 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); + $app->db->query("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_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); + $app->db->query("UPDATE web_domain SET sys_groupid = ?, sys_perm_group = 'riud' WHERE domain_id = ?", $client_group_id, $page_form->id); } // Get configuration for the web system $app->uses("getconf"); @@ -73,15 +73,15 @@ class sites_web_vhost_domain_plugin { // get the ID of the client if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) { $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = $client_group_id"); + $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"]); } elseif (isset($page_form->dataRecord["client_group_id"])) { $client_group_id = $page_form->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 = $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"]); } else { $client_group_id = $page_form->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 = $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"]); } @@ -89,81 +89,81 @@ class sites_web_vhost_domain_plugin { $client_user_id = $app->functions->intval(($tmp['userid'] > 0)?$tmp['userid']:1); // 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); + $system_user = 'web'.$page_form->id; + $system_group = '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); if($event_name == 'sites:web_vhost_domain:on_after_update') { if(($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) && isset($page_form->dataRecord["client_group_id"]) && $page_form->dataRecord["client_group_id"] != $page_form->oldDataRecord["sys_groupid"]) { - $sql = "UPDATE web_domain SET system_user = '$system_user', system_group = '$system_group', document_root = '$document_root' WHERE domain_id = ".$page_form->id; - $app->db->query($sql); + $sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ? WHERE domain_id = ?"; + $app->db->query($sql, $system_user, $system_group, $document_root, $page_form->id); // Update the FTP user(s) too - $records = $app->db->queryAllRecords("SELECT ftp_user_id FROM ftp_user WHERE parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT ftp_user_id FROM ftp_user WHERE parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('ftp_user', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."', uid = '$system_user', gid = '$system_group', dir = '$document_root'", 'ftp_user_id', $app->functions->intval($rec['ftp_user_id'])); + $app->db->datalogUpdate('ftp_user', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid'], "uid" => $system_user, "gid" => $system_group, "dir" => $document_root), 'ftp_user_id', $app->functions->intval($rec['ftp_user_id'])); } unset($records); unset($rec); // Update the webdav user(s) too - $records = $app->db->queryAllRecords("SELECT webdav_user_id FROM webdav_user WHERE parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT webdav_user_id FROM webdav_user WHERE parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('webdav_user', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'webdav_user_id', $app->functions->intval($rec['webdav_user_id'])); + $app->db->datalogUpdate('webdav_user', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid']), 'webdav_user_id', $app->functions->intval($rec['webdav_user_id'])); } unset($records); unset($rec); // Update the web folder(s) too - $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT web_folder_id FROM web_folder WHERE parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('web_folder', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'web_folder_id', $app->functions->intval($rec['web_folder_id'])); + $app->db->datalogUpdate('web_folder', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid']), 'web_folder_id', $app->functions->intval($rec['web_folder_id'])); } unset($records); unset($rec); //* Update all web folder users - $records = $app->db->queryAllRecords("SELECT web_folder_user.web_folder_user_id FROM web_folder_user, web_folder WHERE web_folder_user.web_folder_id = web_folder.web_folder_id AND web_folder.parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT web_folder_user.web_folder_user_id FROM web_folder_user, web_folder WHERE web_folder_user.web_folder_id = web_folder.web_folder_id AND web_folder.parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('web_folder_user', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'web_folder_user_id', $app->functions->intval($rec['web_folder_user_id'])); + $app->db->datalogUpdate('web_folder_user', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid']), 'web_folder_user_id', $app->functions->intval($rec['web_folder_user_id'])); } unset($records); unset($rec); // Update the Shell user(s) too - $records = $app->db->queryAllRecords("SELECT shell_user_id FROM shell_user WHERE parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT shell_user_id FROM shell_user WHERE parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('shell_user', "sys_userid = '".$web_rec['sys_userid']."', sys_groupid = '".$web_rec['sys_groupid']."', puser = '$system_user', pgroup = '$system_group', dir = '$document_root'", 'shell_user_id', $app->functions->intval($rec['shell_user_id'])); + $app->db->datalogUpdate('shell_user', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid'], "puser" => $system_user, "pgroup" => $system_group, "dir" => $document_root), 'shell_user_id', $app->functions->intval($rec['shell_user_id'])); } unset($records); unset($rec); // Update the cron(s) too - $records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT id FROM cron WHERE parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('cron', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'id', $app->functions->intval($rec['id'])); + $app->db->datalogUpdate('cron', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid']), 'id', $app->functions->intval($rec['id'])); } unset($records); unset($rec); //* Update all subdomains and alias domains - $records = $app->db->queryAllRecords("SELECT domain_id, `domain`, `type`, `web_folder` FROM web_domain WHERE parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT domain_id, `domain`, `type`, `web_folder` FROM web_domain WHERE parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $update_columns = "sys_userid = '".$web_rec['sys_userid']."', sys_groupid = '".$web_rec['sys_groupid']."'"; + $update_columns = array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid']); if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') { $php_open_basedir = str_replace("[website_path]/web", $document_root.'/'.$rec['web_folder'], $web_config["php_open_basedir"]); $php_open_basedir = str_replace("[website_domain]/web", $rec['domain'].'/'.$rec['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]", $rec['domain'], $php_open_basedir)); + $php_open_basedir = str_replace("[website_domain]", $rec['domain'], $php_open_basedir); - $update_columns .= ", document_root = '".$document_root."', `php_open_basedir` = '".$php_open_basedir."'"; + $update_columns["document_root"] = $document_root; + $update_columns["php_open_basedir"] = $php_open_basedir; } $app->db->datalogUpdate('web_domain', $update_columns, 'domain_id', $rec['domain_id']); } @@ -171,24 +171,24 @@ class sites_web_vhost_domain_plugin { unset($rec); //* Update all databases - $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('web_database', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'database_id', $app->functions->intval($rec['database_id'])); + $app->db->datalogUpdate('web_database', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid']), 'database_id', $app->functions->intval($rec['database_id'])); } //* Update all database users - $records = $app->db->queryAllRecords("SELECT web_database_user.database_user_id FROM web_database_user, web_database WHERE web_database_user.database_user_id IN (web_database.database_user_id, web_database.database_ro_user_id) AND web_database.parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT web_database_user.database_user_id FROM web_database_user, web_database WHERE web_database_user.database_user_id IN (web_database.database_user_id, web_database.database_ro_user_id) AND web_database.parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('web_database_user', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."'", 'database_user_id', $app->functions->intval($rec['database_user_id'])); + $app->db->datalogUpdate('web_database_user', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid']), 'database_user_id', $app->functions->intval($rec['database_user_id'])); } unset($records); unset($rec); // Update APS instances - $records = $app->db->queryAllRecords("SELECT instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = '".$app->db->quote($page_form->oldDataRecord["domain"])."'"); + $records = $app->db->queryAllRecords("SELECT instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = ?", $page_form->oldDataRecord["domain"]); if(is_array($records) && !empty($records)){ foreach($records as $rec){ - $app->db->datalogUpdate('aps_instances', "sys_userid = '".$app->functions->intval($web_rec['sys_userid'])."', sys_groupid = '".$app->functions->intval($web_rec['sys_groupid'])."', customer_id = '".$app->functions->intval($client_id)."'", 'id', $rec['instance_id']); + $app->db->datalogUpdate('aps_instances', array("sys_userid" => $web_rec['sys_userid'], "sys_groupid" => $web_rec['sys_groupid'], "customer_id" => $client_id), 'id', $rec['instance_id']); } } unset($records); @@ -198,22 +198,20 @@ class sites_web_vhost_domain_plugin { //* If the domain name has been changed, we will have to change all subdomains + APS instances if(!empty($page_form->dataRecord["domain"]) && !empty($page_form->oldDataRecord["domain"]) && $page_form->dataRecord["domain"] != $page_form->oldDataRecord["domain"]) { - $records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE (type = 'subdomain' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND domain LIKE '%.".$app->db->quote($page_form->oldDataRecord["domain"])."'"); + $records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE (type = 'subdomain' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND domain LIKE ?", "%." . $page_form->oldDataRecord["domain"]); foreach($records as $rec) { - $subdomain = $app->db->quote(str_replace($page_form->oldDataRecord["domain"], $page_form->dataRecord["domain"], $rec['domain'])); - $app->db->datalogUpdate('web_domain', "domain = '".$subdomain."'", 'domain_id', $rec['domain_id']); + $subdomain = str_replace($page_form->oldDataRecord["domain"], $page_form->dataRecord["domain"], $rec['domain']); + $app->db->datalogUpdate('web_domain', array("domain" => $subdomain), 'domain_id', $rec['domain_id']); } unset($records); unset($rec); unset($subdomain); // Update APS instances - $records = $app->db->queryAllRecords("SELECT id, instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = '".$app->db->quote($page_form->oldDataRecord["domain"])."'"); + $records = $app->db->queryAllRecords("SELECT id, instance_id FROM aps_instances_settings WHERE name = 'main_domain' AND value = ?", $page_form->oldDataRecord["domain"]); if(is_array($records) && !empty($records)){ foreach($records as $rec){ - $app->db->datalogUpdate('aps_instances_settings', "value = '".$app->db->quote($page_form->dataRecord["domain"])."'", 'id', $rec['id']); - // Reinstall of package needed? - //$app->db->datalogUpdate('aps_instances', "instance_status = '1'", 'id', $rec['instance_id']); + $app->db->datalogUpdate('aps_instances_settings', array("value" => $page_form->dataRecord["domain"]), 'id', $rec['id']); } } unset($records); @@ -222,35 +220,35 @@ class sites_web_vhost_domain_plugin { //* Set allow_override if empty if($web_rec['allow_override'] == '') { - $sql = "UPDATE web_domain SET allow_override = '".$app->db->quote($web_config["htaccess_allow_override"])."' WHERE domain_id = ".$page_form->id; - $app->db->query($sql); + $sql = "UPDATE web_domain SET allow_override = ? WHERE domain_id = ?"; + $app->db->query($sql, $web_config["htaccess_allow_override"], $page_form->id); } //* Set php_open_basedir if empty or domain or client has been changed if(empty($web_rec['php_open_basedir']) || (!empty($page_form->dataRecord["domain"]) && !empty($page_form->oldDataRecord["domain"]) && $page_form->dataRecord["domain"] != $page_form->oldDataRecord["domain"])) { $php_open_basedir = $web_rec['php_open_basedir']; - $php_open_basedir = $app->db->quote(str_replace($page_form->oldDataRecord['domain'], $web_rec['domain'], $php_open_basedir)); - $sql = "UPDATE web_domain SET php_open_basedir = '$php_open_basedir' WHERE domain_id = ".$page_form->id; - $app->db->query($sql); + $php_open_basedir = str_replace($page_form->oldDataRecord['domain'], $web_rec['domain'], $php_open_basedir); + $sql = "UPDATE web_domain SET php_open_basedir = ? WHERE domain_id = ?"; + $app->db->query($sql, $php_open_basedir, $page_form->id); } if(empty($web_rec['php_open_basedir']) || (isset($page_form->dataRecord["client_group_id"]) && $page_form->dataRecord["client_group_id"] != $page_form->oldDataRecord["sys_groupid"])) { - $document_root = $app->db->quote(str_replace("[client_id]", $client_id, $document_root)); + $document_root = str_replace("[client_id]", $client_id, $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]", $web_rec['domain'], $php_open_basedir)); - $sql = "UPDATE web_domain SET php_open_basedir = '$php_open_basedir' WHERE domain_id = ".$page_form->id; - $app->db->query($sql); + $php_open_basedir = str_replace("[website_domain]", $web_rec['domain'], $php_open_basedir); + $sql = "UPDATE web_domain SET php_open_basedir = ? WHERE domain_id = ?"; + $app->db->query($sql, $php_open_basedir, $page_form->id); } //* Change database backup options when web backup options have been changed if(isset($page_form->dataRecord['backup_interval']) && ($page_form->dataRecord['backup_interval'] != $page_form->oldDataRecord['backup_interval'] || $page_form->dataRecord['backup_copies'] != $page_form->oldDataRecord['backup_copies'])) { //* Update all databases - $backup_interval = $app->db->quote($page_form->dataRecord['backup_interval']); + $backup_interval = $page_form->dataRecord['backup_interval']; $backup_copies = $app->functions->intval($page_form->dataRecord['backup_copies']); $records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE parent_domain_id = ".$page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('web_database', "backup_interval = '$backup_interval', backup_copies = '$backup_copies'", 'database_id', $rec['database_id']); + $app->db->datalogUpdate('web_database', array("backup_interval" => $backup_interval, "backup_copies" => $backup_copies), 'database_id', $rec['database_id']); } unset($records); unset($rec); @@ -260,36 +258,36 @@ class sites_web_vhost_domain_plugin { //* Change vhost subdomain and alias ip/ipv6 if domain ip/ipv6 has changed if(isset($page_form->dataRecord['ip_address']) && ($page_form->dataRecord['ip_address'] != $page_form->oldDataRecord['ip_address'] || $page_form->dataRecord['ipv6_address'] != $page_form->oldDataRecord['ipv6_address'])) { - $records = $app->db->queryAllRecords("SELECT domain_id FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ".$page_form->id); + $records = $app->db->queryAllRecords("SELECT domain_id FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ?", $page_form->id); foreach($records as $rec) { - $app->db->datalogUpdate('web_domain', "ip_address = '".$app->db->quote($web_rec['ip_address'])."', ipv6_address = '".$app->db->quote($web_rec['ipv6_address'])."'", 'domain_id', $rec['domain_id']); + $app->db->datalogUpdate('web_domain', array("ip_address" => $web_rec['ip_address'], "ipv6_address" => $web_rec['ipv6_address']), 'domain_id', $rec['domain_id']); } unset($records); unset($rec); } } else { $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); + $php_open_basedir = str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir); + $htaccess_allow_override = $web_config["htaccess_allow_override"]; + + $sql = "UPDATE web_domain SET system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ?"; + $app->db->query($sql, $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $page_form->id); } } else { if(isset($page_form->dataRecord["parent_domain_id"]) && $page_form->dataRecord["parent_domain_id"] != $page_form->oldDataRecord["parent_domain_id"]) { - $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = '" . $app->functions->intval($page_form->dataRecord['parent_domain_id']) . "'"); + $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = ?", $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']); + $system_user = $parent_domain['system_user']; + $system_group = $parent_domain['system_group']; + $document_root = $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)); - $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); + $php_open_basedir = str_replace("[website_domain]", $page_form->dataRecord['domain'], $php_open_basedir); + $htaccess_allow_override = $parent_domain['allow_override']; + $sql = "UPDATE web_domain SET sys_groupid = ?,system_user = ?, system_group = ?, document_root = ?, allow_override = ?, php_open_basedir = ? WHERE domain_id = ?"; + $app->db->query($sql, $parent_domain['sys_groupid'], $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $page_form->id); } } } diff --git a/interface/lib/plugins/vm_openvz_plugin.inc.php b/interface/lib/plugins/vm_openvz_plugin.inc.php index fd442055623c273d166ba5094f88b76e44c8f222..73cc9cda86fd3e2be17a351ccda7fff974e4cf08 100644 --- a/interface/lib/plugins/vm_openvz_plugin.inc.php +++ b/interface/lib/plugins/vm_openvz_plugin.inc.php @@ -41,24 +41,24 @@ class vm_openvz_plugin { // 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"])) { $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); + $app->db->query("UPDATE openvz_vm SET sys_groupid = ? WHERE vm_id = ?", $client_group_id, $this->id); } if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { $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); + $app->db->query("UPDATE openvz_vm SET sys_groupid = ? WHERE vm_id = ?", $client_group_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); + $app->db->query("UPDATE openvz_vm SET veid = ? WHERE vm_id = ?", $veid, $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 = '".$app->db->quote($this->dataRecord['ip_address'])."'"); + $app->db->query("UPDATE openvz_ip SET vm_id = ? WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']); // Create the OpenVZ config file and store it in config field $this->makeOpenVZConfig(); @@ -82,11 +82,11 @@ class vm_openvz_plugin { // 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"])) { $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); + $app->db->query("UPDATE openvz_vm SET sys_groupid = ? WHERE vm_id = ?", $client_group_id, $this->id); } if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) { $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); + $app->db->query("UPDATE openvz_vm SET sys_groupid = ? WHERE vm_id = ?", $client_group_id, $this->id); } if(isset($this->dataRecord["ostemplate_id"]) && $this->oldDataRecord["ostemplate_id"] != $this->dataRecord["ostemplate_id"]) { @@ -94,7 +94,7 @@ class vm_openvz_plugin { } // Set the IP address - if(isset($this->dataRecord['ip_address'])) $app->db->query("UPDATE openvz_ip SET vm_id = ".$this->id." WHERE ip_address = '".$app->db->quote($this->dataRecord['ip_address'])."'"); + if(isset($this->dataRecord['ip_address'])) $app->db->query("UPDATE openvz_ip SET vm_id = ? WHERE ip_address = ?", $this->id, $this->dataRecord['ip_address']); // Create the OpenVZ config file and store it in config field $this->makeOpenVZConfig(); @@ -111,8 +111,8 @@ class vm_openvz_plugin { global $app, $conf; //* Free the IP address - $tmp = $app->db->queryOneRecord("SELECT ip_address_id FROM openvz_ip WHERE vm_id = ".$app->functions->intval($page_form->id)); - $app->db->datalogUpdate('openvz_ip', 'vm_id = 0', 'ip_address_id', $tmp['ip_address_id']); + $tmp = $app->db->queryOneRecord("SELECT ip_address_id FROM openvz_ip WHERE vm_id = ?", $page_form->id); + $app->db->datalogUpdate('openvz_ip', array('vm_id' => 0), 'ip_address_id', $tmp['ip_address_id']); unset($tmp); } @@ -120,29 +120,31 @@ class vm_openvz_plugin { private function applyTemplate() { global $app, $conf; - $tpl = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ".$app->functions->intval($this->dataRecord["template_id"])); + $tpl = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ?", $this->dataRecord["template_id"]); $sql = "UPDATE openvz_vm SET "; - $sql .= "diskspace = '".$app->db->quote($tpl['diskspace'])."', "; - $sql .= "ram = '".$app->db->quote($tpl['ram'])."', "; - $sql .= "ram_burst = '".$app->db->quote($tpl['ram_burst'])."', "; - $sql .= "cpu_units = '".$app->db->quote($tpl['cpu_units'])."', "; - $sql .= "cpu_num = '".$app->db->quote($tpl['cpu_num'])."', "; - $sql .= "cpu_limit = '".$app->db->quote($tpl['cpu_limit'])."', "; - $sql .= "io_priority = '".$app->db->quote($tpl['io_priority'])."', "; - $sql .= "nameserver = '".$app->db->quote($tpl['nameserver'])."', "; - $sql .= "create_dns = '".$app->db->quote($tpl['create_dns'])."', "; - $sql .= "capability = '".$app->db->quote($tpl['capability'])."' "; - $sql .= "WHERE vm_id = ".$app->functions->intval($this->id); - $app->db->query($sql); + $sql .= "diskspace = ?, "; + $sql .= "ram = ?, "; + $sql .= "ram_burst = ?, "; + $sql .= "cpu_units = ?, "; + $sql .= "cpu_num = ?, "; + $sql .= "cpu_limit = ?, "; + $sql .= "io_priority = ?, "; + $sql .= "nameserver = ?, "; + $sql .= "create_dns = ?, "; + $sql .= "capability = ?, "; + $sql .= "features = ?, "; + $sql .= "iptables = ? "; + $sql .= "WHERE vm_id = ?"; + $app->db->query($sql, $tpl['diskspace'], $tpl['ram'], $tpl['ram_burst'], $tpl['cpu_units'], $tpl['cpu_num'], $tpl['cpu_limit'], $tpl['io_priority'], $tpl['nameserver'], $tpl['create_dns'], $tpl['capability'], $tpl['features'], $tpl['iptables'], $this->id); } private function makeOpenVZConfig() { global $app, $conf; - $vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ".$app->functions->intval($this->id)); - $vm_template = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ".$app->functions->intval($vm['template_id'])); + $vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ?",$app->functions->intval($this->id)); + $vm_template = $app->db->queryOneRecord("SELECT * FROM openvz_template WHERE template_id = ?",$app->functions->intval($vm['template_id'])); $burst_ram = $vm['ram_burst']*256; $guar_ram = $vm['ram']*256; @@ -193,13 +195,15 @@ class vm_openvz_plugin { $tpl->setVar('ip_address', $vm['ip_address']); $tpl->setVar('nameserver', $vm['nameserver']); $tpl->setVar('capability', $vm['capability']); + $tpl->setVar('features', $vm['features']); + $tpl->setVar('iptables', $vm['iptables']); - $tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ".$app->functions->intval($vm['ostemplate_id'])); + $tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ?", $app->functions->intval($vm['ostemplate_id'])); $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 = ".$app->functions->intval($this->id)); + $openvz_config = $tpl->grab(); + $app->db->query("UPDATE openvz_vm SET config = ? WHERE vm_id = ?", $openvz_config, $app->functions->intval($this->id)); unset($tpl); @@ -208,23 +212,23 @@ class vm_openvz_plugin { private function createDNS() { global $app, $conf; - $vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ".$app->functions->intval($this->id)); + $vm = $app->db->queryOneRecord("SELECT * FROM openvz_vm WHERE vm_id = ?", $app->functions->intval($this->id)); if($vm['create_dns'] != 'y') return; $full_hostname = str_replace('{VEID}', $vm['veid'], $vm['hostname']); $hostname_parts = explode('.', $full_hostname); - $hostname = $app->db->quote($hostname_parts[0]); + $hostname = $hostname_parts[0]; unset($hostname_parts[0]); - $zone = $app->db->quote((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 = '".$app->db->quote($zone).".'"); - $rr_rec = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = '".$app->functions->intval($zone_rec['id'])."' AND name = '".$app->db->quote($hostname)."'"); + $zone_rec = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin = ?", $zone); + $rr_rec = $app->db->queryOneRecord("SELECT * FROM dns_rr WHERE zone = ? AND name = ?", $zone_rec['id'], $hostname); if($zone_rec['id'] > 0) { - $ip_address = $app->db->quote($vm['ip_address']); + $ip_address = $vm['ip_address']; $sys_userid = $app->functions->intval($zone_rec['sys_userid']); $sys_groupid = $app->functions->intval($zone_rec['sys_groupid']); $server_id = $app->functions->intval($zone_rec['server_id']); @@ -232,12 +236,25 @@ class vm_openvz_plugin { if($rr_rec['id'] > 0) { $app->uses('validate_dns'); - $app->db->datalogUpdate('dns_rr', "data = '$ip_address'", 'id', $app->functions->intval($rr_rec['id'])); + $app->db->datalogUpdate('dns_rr', array("data" => $ip_address), 'id', $app->functions->intval($rr_rec['id'])); $serial = $app->validate_dns->increase_serial($zone_rec['serial']); - $app->db->datalogUpdate('dns_soa', "serial = '$serial'", 'id', $app->functions->intval($zone_rec['id'])); + $app->db->datalogUpdate('dns_soa', array("serial" => $serial), 'id', $app->functions->intval($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 - ('$sys_userid', '$sys_groupid', 'riud', 'riud', '', '$server_id', '$dns_soa_id', '$hostname', 'A', '$ip_address', '0', '3600', 'Y')"; + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $sys_groupid, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $server_id, + "zone" => $dns_soa_id, + "name" => $hostname, + "type" => 'A', + "data" => $ip_address, + "aux" => '0', + "ttl" => '3600', + "active" => 'Y' + ); $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); } diff --git a/interface/web/admin/firewall_edit.php b/interface/web/admin/firewall_edit.php index 6c29f766d100d03f548d815f26ffdd6c4956bd37..4dd26afbf6759aa1a001fd773e6fa851c72ba3b1 100644 --- a/interface/web/admin/firewall_edit.php +++ b/interface/web/admin/firewall_edit.php @@ -56,7 +56,7 @@ class page_action extends tform_actions { //* 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'])) { - $rec = $app->db->queryOneRecord("SELECT server_id from firewall WHERE firewall_id = ".$this->id); + $rec = $app->db->queryOneRecord("SELECT server_id from firewall WHERE firewall_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.'); diff --git a/interface/web/admin/form/directive_snippets.tform.php b/interface/web/admin/form/directive_snippets.tform.php index 2af05af6c3e2824a57d62dd116fd1a2e07dac890..0c2502c6c4a4c1ef4b5a8cceaa5bd295ba6e0894 100644 --- a/interface/web/admin/form/directive_snippets.tform.php +++ b/interface/web/admin/form/directive_snippets.tform.php @@ -93,12 +93,29 @@ $form["tabs"]['directive_snippets'] = array ( 'maxlength' => '255', 'searchable' => 2 ), + 'customer_viewable' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), 'active' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', 'default' => 'y', 'value' => array(0 => 'n', 1 => 'y') ), + 'required_php_snippets' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOXARRAY', + 'default' => '', + 'datasource' => array ( 'type' => 'SQL', + 'querystring' => "SELECT directive_snippets_id,name FROM directive_snippets WHERE type = 'php' AND active = 'y'ORDER BY name", + 'keyfield' => 'directive_snippets_id', + 'valuefield' => 'name' + ), + 'separator' => ',', + ), //################################# // ENDE Datatable fields //################################# diff --git a/interface/web/admin/form/server.tform.php b/interface/web/admin/form/server.tform.php index a2eac6c3b758e5e6ffe1c993f167d3104fd2be05..1bf079e1b0bb08791cdddb7f70b9797e5720e504 100644 --- a/interface/web/admin/form/server.tform.php +++ b/interface/web/admin/form/server.tform.php @@ -102,6 +102,12 @@ $form["tabs"]['services'] = array ( 'default' => '0', 'value' => array(0 => 0, 1 => 1) ), + 'xmpp_server' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'default' => '0', + 'value' => array(0 => 0, 1 => 1) + ), 'mirror_server_id' => array ( 'datatype' => 'INTEGER', 'formtype' => 'TEXT', diff --git a/interface/web/admin/form/server_config.tform.php b/interface/web/admin/form/server_config.tform.php index aa9adc54327d6a32e3b0b5f8ca42e8b7ffd9bca7..a03636af4dbb045619effc8b0112ca9808b43b56 100644 --- a/interface/web/admin/form/server_config.tform.php +++ b/interface/web/admin/form/server_config.tform.php @@ -182,7 +182,7 @@ $form["tabs"]['server'] = array( 'backup_dir_is_mount' => array( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', - 'default' => 'n', + 'default' => 'y', 'value' => array(0 => 'n', 1 => 'y') ), 'backup_mode' => array( @@ -295,6 +295,12 @@ $form["tabs"]['mail'] = array( 'width' => '40', 'maxlength' => '255' ), + 'maildir_format' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'default' => '20', + 'value' => array('maildir' => 'Maildir', 'mdbox' => 'mdbox') + ), 'homedir_path' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -320,8 +326,8 @@ $form["tabs"]['mail'] = array( 'dkim_strength' => array( 'datatype' => 'INTEGER', 'formtype' => 'SELECT', - 'default' => '1024', - 'value' => array('1024' => 'normal (1024)', '2048' => 'strong (2048)', '4096' => 'very strong (4096)') + 'default' => '2048', + 'value' => array('1024' => 'weak (1024)', '2048' => 'normal (2048)', '4096' => 'strong (4096)') ), 'relayhost_password' => array( 'datatype' => 'VARCHAR', @@ -434,6 +440,12 @@ $form["tabs"]['mail'] = array( 'width' => '40', 'maxlength' => '255' ), + 'reject_sender_login_mismatch' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), 'mailbox_size_limit' => array( 'datatype' => 'INTEGER', 'formtype' => 'TEXT', @@ -604,14 +616,12 @@ $form["tabs"]['web'] = array( 'width' => '40', 'maxlength' => '255' ), - /* -'vhost_rewrite_v6' => array ( -'datatype' => 'VARCHAR', -'formtype' => 'CHECKBOX', -'default' => 'n', -'value' => array(0 => 'n',1 => 'y') -), -*/ + 'vhost_rewrite_v6' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n',1 => 'y') + ), 'vhost_conf_dir' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -993,7 +1003,7 @@ $form["tabs"]['web'] = array( 'datatype' => 'VARCHAR', 'formtype' => 'SELECT', 'default' => 'fast-cgi', - 'value' => array('no' => 'disabled_txt', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM'), + 'value' => array('no' => 'disabled_txt', 'fast-cgi' => 'Fast-CGI', 'cgi' => 'CGI', 'mod' => 'Mod-PHP', 'suphp' => 'SuPHP', 'php-fpm' => 'PHP-FPM', 'hhvm' => 'HHVM'), 'searchable' => 2 ), 'nginx_cgi_socket' => array( @@ -1021,6 +1031,15 @@ $form["tabs"]['web'] = array( 'width' => '40', 'maxlength' => '255' ), + 'enable_spdy' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'y', + 'value' => array ( + 0 => 'n', + 1 => 'y' + ) + ), 'apps_vhost_port' => array( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', @@ -1309,6 +1328,86 @@ $form["tabs"]['fastcgi'] = array( ); +$form["tabs"]['xmpp'] = array( + 'title' => "XMPP", + 'width' => 80, + 'template' => "templates/server_config_xmpp_edit.htm", + 'fields' => array( + //################################# + // Begin Datatable fields + //################################# + 'xmpp_use_ipv6' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'xmpp_bosh_max_inactivity' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '30', + 'validators' => array(0 => array('type' => 'ISINT', + 'errmsg' => 'ip_address_error_wrong'), + array('type'=>'RANGE', 'range'=>'15:360', 'errmsg' => 'xmpp_bosh_timeout_range_wrong') + ), + 'value' => '', + 'width' => '15' + ), + + 'xmpp_server_admins' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => 'admin@service.com, superuser@service.com', + 'value' => '', + 'width' => '15' + ), + + 'xmpp_modules_enabled' => array( + 'datatype' => 'TEXT', + 'formtype' => 'TEXT', + 'default' => "saslauth, tls, dialback, disco, discoitems, version, uptime, time, ping, admin_adhoc, admin_telnet, bosh, posix, announce, offline, webpresence, mam, stream_management, message_carbons", + 'value' => '', + 'separator' => "," + ), + + 'xmpp_port_http' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '5290', + 'validators' => array(0 => array('type' => 'ISINT')), + 'value' => '5290', + 'width' => '15' + ), + 'xmpp_port_https' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '5291', + 'validators' => array(0 => array('type' => 'ISINT')), + 'value' => '5291', + 'width' => '15' + ), + 'xmpp_port_pastebin' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '5292', + 'validators' => array(0 => array('type' => 'ISINT')), + 'value' => '5292', + 'width' => '15' + ), + 'xmpp_port_bosh' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '5280', + 'validators' => array(0 => array('type' => 'ISINT')), + 'value' => '5280', + 'width' => '15' + ), + //################################# + // ENDE Datatable fields + //################################# + ) +); + $form["tabs"]['jailkit'] = array( 'title' => "Jailkit", 'width' => 80, diff --git a/interface/web/admin/form/system_config.tform.php b/interface/web/admin/form/system_config.tform.php index 28aa42b7284080d45969d8a6379d2a962a034a5c..fabc180b04c11ca14641aefc485680b12922c4d6 100644 --- a/interface/web/admin/form/system_config.tform.php +++ b/interface/web/admin/form/system_config.tform.php @@ -166,6 +166,12 @@ $form["tabs"]['sites'] = array ( 'default' => 'n', 'value' => array(0 => 'n', 1 => 'y') ), + 'backups_include_into_web_quota' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), 'reseller_can_use_options' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'CHECKBOX', diff --git a/interface/web/admin/form/users.tform.php b/interface/web/admin/form/users.tform.php index 9ee2970df51bac402529b9c794579918bf678bf9..6a23559f1273b5113bb0165a3862905b5ab3b582 100644 --- a/interface/web/admin/form/users.tform.php +++ b/interface/web/admin/form/users.tform.php @@ -260,6 +260,19 @@ $form['tabs']['users'] = array ( 'maxlength' => '2', 'rows' => '', 'cols' => '' + ), + 'lost_password_function' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'CHECKBOX', + 'regex' => '', + 'errmsg' => '', + 'default' => 1, + 'value' => array(0 => 0, 1 => 1), + 'separator' => '', + 'width' => '30', + 'maxlength' => '255', + 'rows' => '', + 'cols' => '' ) //################################# // ENDE Datenbankfelder diff --git a/interface/web/admin/lib/lang/ar_server_config.lng b/interface/web/admin/lib/lang/ar_server_config.lng index f42dbc9e5cf61e7c3f0b620c0c9da5ace10eae04..b03eaebfddf06d8348f899b30c7bd4ed7163f18b 100644 --- a/interface/web/admin/lib/lang/ar_server_config.lng +++ b/interface/web/admin/lib/lang/ar_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Module'; $wb['maildir_path_txt'] = 'Maildir Path'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir Path'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost User'; $wb['relayhost_password_txt'] = 'Relayhost Password'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mailbox Size Limit'; $wb['message_size_limit_txt'] = 'Message Size Limit'; $wb['ip_address_txt'] = 'IP Address'; diff --git a/interface/web/admin/lib/lang/ar_system_config.lng b/interface/web/admin/lib/lang/ar_system_config.lng index 766c55b0adb693eacef12abcfb534ed7c63ef264..61f7a791c69d0f0a5d3e76b331f6eaacfc203d60 100644 --- a/interface/web/admin/lib/lang/ar_system_config.lng +++ b/interface/web/admin/lib/lang/ar_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/bg_server_config.lng b/interface/web/admin/lib/lang/bg_server_config.lng index e6f6e03c6825bf57abe405f79c0a4cfee0823607..10fbc0b3dd0cc4498e55ac0be52cb07b7b3d0249 100644 --- a/interface/web/admin/lib/lang/bg_server_config.lng +++ b/interface/web/admin/lib/lang/bg_server_config.lng @@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Модул'; $wb['maildir_path_txt'] = 'Maildir Path'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir Path'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -30,6 +31,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost User'; $wb['relayhost_password_txt'] = 'Relayhost Password'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mailbox Size Limit'; $wb['message_size_limit_txt'] = 'Message Size Limit'; $wb['ip_address_txt'] = 'IP адрес'; diff --git a/interface/web/admin/lib/lang/bg_system_config.lng b/interface/web/admin/lib/lang/bg_system_config.lng index cde9ab74c04c641ac7e7dcb9b4d365ace814ffc3..a88c2cec3a2e8b6ec09c3dd3a2de4a8506d90367 100644 --- a/interface/web/admin/lib/lang/bg_system_config.lng +++ b/interface/web/admin/lib/lang/bg_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/br_server_config.lng b/interface/web/admin/lib/lang/br_server_config.lng index 14e59facd0eff7db07d2e1038e453e18d9da258b..8946db17631e0cad672e6b6692040a4a10fe572f 100644 --- a/interface/web/admin/lib/lang/br_server_config.lng +++ b/interface/web/admin/lib/lang/br_server_config.lng @@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI: Requisições máximas'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Módulo'; $wb['maildir_path_txt'] = 'Caminho do diretório Maildir'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Caminho do diretório Home'; $wb['mailuser_uid_txt'] = 'UID usuário de email'; $wb['mailuser_gid_txt'] = 'GID usuário de email'; @@ -31,6 +32,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Host Relay'; $wb['relayhost_user_txt'] = 'Usuário do Host Relay'; $wb['relayhost_password_txt'] = 'Senha do Host Relay'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Tamanho máximo da Caixa Postal'; $wb['message_size_limit_txt'] = 'Tamanho máximo de mensagem'; $wb['ip_address_txt'] = 'Endereço IP'; diff --git a/interface/web/admin/lib/lang/br_system_config.lng b/interface/web/admin/lib/lang/br_system_config.lng index c0caf050bd581c4d291094088f3f865ba39e24c8..2a7201882971d0d2c99b38e9905caeaa48bf5424 100644 --- a/interface/web/admin/lib/lang/br_system_config.lng +++ b/interface/web/admin/lib/lang/br_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/cz_server_config.lng b/interface/web/admin/lib/lang/cz_server_config.lng index a1edf0d395e8c4f8f8faced94aa906b4965d0231..c5a3dbc4f3a1aa0cac361b75cdd8721791f8e489 100644 --- a/interface/web/admin/lib/lang/cz_server_config.lng +++ b/interface/web/admin/lib/lang/cz_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. požadavků'; $wb['fastcgi_bin_txt'] = 'FastCGI cesta k binarnímu balíčku'; $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Cesta k mail adresáři'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Cesta k domácímu adresáři'; $wb['mailuser_uid_txt'] = 'Mail uživatel UID'; $wb['mailuser_gid_txt'] = 'Mail uživatel GID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost uživatel'; $wb['relayhost_password_txt'] = 'Relayhost heslo'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Limit velikosti mailboxu'; $wb['message_size_limit_txt'] = 'Limit velikosti zprávy'; $wb['ip_address_txt'] = 'IP adresa'; diff --git a/interface/web/admin/lib/lang/cz_system_config.lng b/interface/web/admin/lib/lang/cz_system_config.lng index 13a202f5e9a2aea2da9ec906537aaf0c5f87d44a..ec1fae36f51b01224317e03231e3778231d9584d 100644 --- a/interface/web/admin/lib/lang/cz_system_config.lng +++ b/interface/web/admin/lib/lang/cz_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Použití jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Použití indikátoru zatížení'; $wb['f5_to_reload_js_txt'] = 'Pokud vypnete tuto volbu, zřejmě budete muset používat klávesu F5, aby internetový prohlížeč znovu načetl JavaScript knihovny nebo budete muset ručně vyprázdňovat mezipaměť (cache) vašeho internetového prohlížeče.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show Autoresponder tab in Mailbox detail'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show Mail Filter tab in Mailbox detail'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show Custom Rules tab in Mailbox detail'; diff --git a/interface/web/admin/lib/lang/de_directive_snippets.lng b/interface/web/admin/lib/lang/de_directive_snippets.lng index 18ce2d51b2f59be271a9c71035c1a49febb6fe9f..83a6b3c5f78b724124a29978bc0b48eb98b784f7 100644 --- a/interface/web/admin/lib/lang/de_directive_snippets.lng +++ b/interface/web/admin/lib/lang/de_directive_snippets.lng @@ -7,4 +7,5 @@ $wb['active_txt'] = 'Aktiv'; $wb['directive_snippets_name_empty'] = 'Bitte geben Sie einen Namen für den Schnipsel an.'; $wb['directive_snippets_name_error_unique'] = 'Es existiert schon ein Direktiven-Schnipsel mit diesem Namen.'; $wb['variables_txt'] = 'Variablen'; +$wb['customer_viewable_txt'] = 'Sichtbar für Kunden'; ?> diff --git a/interface/web/admin/lib/lang/de_directive_snippets_list.lng b/interface/web/admin/lib/lang/de_directive_snippets_list.lng index a19d5e8da49033c984604fb8b4875d5d8313a045..469489cd30f1dd1c3ba98d3b494e89227b2dce63 100644 --- a/interface/web/admin/lib/lang/de_directive_snippets_list.lng +++ b/interface/web/admin/lib/lang/de_directive_snippets_list.lng @@ -4,4 +4,5 @@ $wb['active_txt'] = 'Aktiv'; $wb['name_txt'] = 'Name des Schnipsels'; $wb['type_txt'] = 'Typ'; $wb['add_new_record_txt'] = 'Direktiven Schnipsel hinzufügen'; +$wb['customer_viewable_txt'] = 'Sichtbar für Kunden'; ?> diff --git a/interface/web/admin/lib/lang/de_server_config.lng b/interface/web/admin/lib/lang/de_server_config.lng index 9afd35cb12104a578f94235d54dd6cdf1628af5c..336cea82d9921c4617ef2366a471523978f81852 100644 --- a/interface/web/admin/lib/lang/de_server_config.lng +++ b/interface/web/admin/lib/lang/de_server_config.lng @@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Anfragen'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Maildir Pfad'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir Pfad'; $wb['dkim_path_txt'] = 'DKIM Pfad'; $wb['mailuser_uid_txt'] = 'Mailbenutzer UID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid Mapping kann nur um $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost Benutzer'; $wb['relayhost_password_txt'] = 'Relayhost Passwort'; +$wb['reject_sender_login_mismatch_txt'] = 'Zurückweisen von Mails, wenn Sender nicht gleich Login'; $wb['mailbox_size_limit_txt'] = 'E-Mailkonto Beschränkung'; $wb['message_size_limit_txt'] = 'E-Mailgrößen Beschränkung'; $wb['ip_address_txt'] = 'IP Adresse'; @@ -256,4 +258,11 @@ $wb['cron_init_script_error_regex'] = 'Invalid cron init script.'; $wb['crontab_dir_error_regex'] = 'Invalid crontab directory.'; $wb['cron_wget_error_regex'] = 'Invalid cron wget path.'; $wb['network_filesystem_txt'] = 'Netzwerk-Dateisystem'; +$wb['overquota_db_notify_admin_txt'] = 'Datenbank-Quota-Warnungen an den Administrator senden'; +$wb['overquota_db_notify_client_txt'] = 'Datenbank-Quota-Warnungen an den Kunden senden'; +$wb['php_ini_check_minutes_txt'] = 'Prüfe php.ini alle X Minuten auf Änderungen'; +$wb['php_ini_check_minutes_error_empty'] = 'Bitte geben Sie einen Wert an, wie oft die php.ini auf Änderungen geprüft werden soll.'; +$wb['php_ini_check_minutes_info_txt'] = '0 = keine Prüfung'; +$wb['php_handler_txt'] = 'Standard-PHP-Handler'; +$wb['enable_spdy_txt'] = 'Stellt SPDY zur Verfügung'; ?> diff --git a/interface/web/admin/lib/lang/de_system_config.lng b/interface/web/admin/lib/lang/de_system_config.lng index b0f612ac970463f7468e0a06f7e4e9fa54cea722..862fb569fe926f839b47d3657a5f60d5935aaa09 100644 --- a/interface/web/admin/lib/lang/de_system_config.lng +++ b/interface/web/admin/lib/lang/de_system_config.lng @@ -48,6 +48,7 @@ $wb['use_loadindicator_txt'] = 'Laden Grafik anzeigen'; $wb['f5_to_reload_js_txt'] = 'Wenn Sie den Wert ändern, müssen Sie F5 drücken, damit der Browser die JavaScript Bibliotheken neu lädt, oder Ihren Browser Cache leeren.'; $wb['phpmyadmin_url_error_regex'] = 'Falsche phpMyAdmin URL'; $wb['client_username_web_check_disabled_txt'] = 'Deaktiviere die Kunden Benutzernamen Überprüfung für den Begriff web.'; +$wb['backups_include_into_web_quota_txt'] = 'Backups in Web Quota hinzuzählen.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Zeige Autoresponder Reiter in E-Mail Kontodetails'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Zeige E-Mail Filter Reiter in E-Mail Kontodetails'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Zeige Benutzerregel Reiter in E-Mail Kontodetails'; diff --git a/interface/web/admin/lib/lang/de_users.lng b/interface/web/admin/lib/lang/de_users.lng index da26db30fc035192cf15524453260aeb0bea22b0..db37a605bc984ed6a708e6bc8802d979a397d3c8 100644 --- a/interface/web/admin/lib/lang/de_users.lng +++ b/interface/web/admin/lib/lang/de_users.lng @@ -31,4 +31,5 @@ $wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.'; $wb['password_match_txt'] = 'Die Passwörter stimmen überein.'; $wb['username_error_collision'] = 'Der Benutzername darf nicht web oder web gefolgt von einer Zahl sein.'; $wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin'; +$wb['lost_password_function_txt'] = 'Passwort vergessen Funktion steht zur Verfügung'; ?> diff --git a/interface/web/admin/lib/lang/el_server_config.lng b/interface/web/admin/lib/lang/el_server_config.lng index 560e2b809077d8d08bf64d3c97e37b6d099a1836..ca7cf2b26ed6c7de16bf58391712f47d5ca3c9a9 100644 --- a/interface/web/admin/lib/lang/el_server_config.lng +++ b/interface/web/admin/lib/lang/el_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'Όριο πλήθους αιτήσεων Fast $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Άρθρωμα'; $wb['maildir_path_txt'] = 'Διαδρομή Maildir'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Διαδρομή Homedir'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Χρήστης Relayhost'; $wb['relayhost_password_txt'] = 'Συνθηματικό Relayhost'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Όριο χώρου θυρίδας'; $wb['message_size_limit_txt'] = 'Μήνυμα ορίου χώρου'; $wb['ip_address_txt'] = 'Διεύθυνση IP'; diff --git a/interface/web/admin/lib/lang/el_system_config.lng b/interface/web/admin/lib/lang/el_system_config.lng index fa2cfeeae70e4be1a66fc821c8758e54986400a9..aa97d1e28b590d54a9396f9d5835eae531107606 100644 --- a/interface/web/admin/lib/lang/el_system_config.lng +++ b/interface/web/admin/lib/lang/el_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Χρήση jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Χρήση Load Indicator (ενδεικτή φόρτωσης)'; $wb['f5_to_reload_js_txt'] = 'Αν το αλλάξετε, ίσως πρέπει να πατήσετε το F5 για να κάνετε τον φυλλομετρητη να ξαναφορτώσει τις βιβλιοθήκες JavaScript ή να αδείασετε την cache του φυλλομετρητή.'; $wb['client_username_web_check_disabled_txt'] = 'Απενεργοποίηση ελέγχου στο όνομα χρήστη για την λέξη \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Εμφάνιση της καρτέλας Αυτόματης Απάντησης στις λεπτομέρειες του λογαριασμού mail'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Εμφάνιση της καρτέλας Φίλτρα mail στις λεπτομέρειες του λογαριασμού mail'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Εμφάνιση της καρτέλας Προσαρμοσμένοι Κανόνες στις λεπτομέρειες του λογαριασμού mail'; diff --git a/interface/web/admin/lib/lang/en_directive_snippets.lng b/interface/web/admin/lib/lang/en_directive_snippets.lng index 9d9b0ae8ee4b91485835dc9e66d45e6e1a57a665..e8733cd9480b545a3722fff93453d82520d5c6ce 100644 --- a/interface/web/admin/lib/lang/en_directive_snippets.lng +++ b/interface/web/admin/lib/lang/en_directive_snippets.lng @@ -7,4 +7,5 @@ $wb["active_txt"] = 'Active'; $wb["directive_snippets_name_empty"] = 'Please specify a name for the snippet.'; $wb["directive_snippets_name_error_unique"] = 'There is already a directive snippet with this name.'; $wb['variables_txt'] = 'Variables'; +$wb['customer_viewable_txt'] = 'Customer viewable'; ?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_directive_snippets_list.lng b/interface/web/admin/lib/lang/en_directive_snippets_list.lng index 702e7e250480306e6f717010d84662c0e03d41e1..7a4db54ea422270ce4b0456d3d4f9958ca65cfa9 100644 --- a/interface/web/admin/lib/lang/en_directive_snippets_list.lng +++ b/interface/web/admin/lib/lang/en_directive_snippets_list.lng @@ -4,4 +4,5 @@ $wb["active_txt"] = 'Active'; $wb["name_txt"] = 'Name of Snippet'; $wb["type_txt"] = 'Type'; $wb["add_new_record_txt"] = 'Add Directive Snippet'; +$wb['customer_viewable_txt'] = 'Customer viewable'; ?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_server.lng b/interface/web/admin/lib/lang/en_server.lng index 4130201b7ce0ce0b45e11a4657dfe8ed3d65b649..1f36bc718ef1402b752c9f0d9326ae68cb35fb60 100644 --- a/interface/web/admin/lib/lang/en_server.lng +++ b/interface/web/admin/lib/lang/en_server.lng @@ -12,4 +12,6 @@ $wb["firewall_server_txt"] = 'Firewall-Server'; $wb["active_txt"] = 'Active'; $wb["mirror_server_id_txt"] = 'Is mirror of Server'; $wb["- None -"] = '- None -'; +// New for XMPP +$wb['xmpp_server_txt'] = 'XMPP Server'; ?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_server_config.lng b/interface/web/admin/lib/lang/en_server_config.lng index dde50a0613d800c4e1e53e4202cc2e5ab1366d95..2628abf292c72ddaa0bd18e3ab20f859e64098b2 100644 --- a/interface/web/admin/lib/lang/en_server_config.lng +++ b/interface/web/admin/lib/lang/en_server_config.lng @@ -29,6 +29,7 @@ $wb["fastcgi_max_requests_txt"] = 'FastCGI max. Requests'; $wb["fastcgi_bin_txt"] = 'FastCGI Bin'; $wb["module_txt"] = 'Module'; $wb["maildir_path_txt"] = 'Maildir Path'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb["homedir_path_txt"] = 'Homedir Path'; $wb["dkim_path_txt"] = 'DKIM Path'; $wb["mailuser_uid_txt"] = 'Mailuser UID'; @@ -43,6 +44,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb["relayhost_txt"] = 'Relayhost'; $wb["relayhost_user_txt"] = 'Relayhost User'; $wb["relayhost_password_txt"] = 'Relayhost Password'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb["mailbox_size_limit_txt"] = 'Mailbox Size Limit'; $wb["message_size_limit_txt"] = 'Message Size Limit'; $wb["ip_address_txt"] = 'IP Address'; @@ -205,7 +207,7 @@ $wb['backup_delete_txt'] = 'Delete backups on domain/website delete'; $wb["overquota_db_notify_admin_txt"] = 'Send DB quota warnings to admin'; $wb["overquota_db_notify_client_txt"] = 'Send DB quota warnings to client'; $wb['monitor_system_updates_txt'] = 'Check for Linux updates'; -$wb['php_handler_txt'] = "PHP Handler"; +$wb['php_handler_txt'] = "Default PHP Handler"; $wb['disabled_txt'] = 'Disabled'; $wb['dkim_strength_txt'] = 'DKIM strength'; $wb['monitor_system_updates_txt'] = 'Check for Linux updates'; @@ -260,4 +262,22 @@ $wb['cron_init_script_error_regex'] = 'Invalid cron init script.'; $wb['crontab_dir_error_regex'] = 'Invalid crontab directory.'; $wb['cron_wget_error_regex'] = 'Invalid cron wget path.'; $wb['network_filesystem_txt'] = 'Network Filesystem'; +$wb['php_ini_check_minutes_txt'] = 'Check php.ini every X minutes for changes'; +$wb['php_ini_check_minutes_error_empty'] = 'Please specify a value how often php.ini should be checked for changes.'; +$wb['php_ini_check_minutes_info_txt'] = '0 = no check'; +$wb['enable_spdy_txt'] = 'Makes SPDY available'; + +// New for XMPP +$wb['xmpp_server_txt'] = 'XMPP Server'; +$wb['xmpp_use_ipv6_txt'] = 'Use IPv6'; +$wb['xmpp_bosh_max_inactivity_txt'] = 'Max. BOSH inactivity time'; +$wb['xmpp_bosh_timeout_range_wrong'] = 'Please enter a bosh timeout range between 15 - 360'; +$wb['xmpp_module_saslauth'] = 'saslauth'; +$wb['xmpp_server_admins_txt'] = 'Server Admins (JIDs)'; +$wb['xmpp_modules_enabled_txt'] = 'Serverwide enabled plugins (one per line)'; +$wb['xmpp_ports_txt'] = 'Component ports'; +$wb['xmpp_port_http_txt'] = 'HTTP'; +$wb['xmpp_port_https_txt'] = 'HTTPS'; +$wb['xmpp_port_pastebin_txt'] = 'Pastebin'; +$wb['xmpp_port_bosh_txt'] = 'BOSH'; ?> diff --git a/interface/web/admin/lib/lang/en_server_list.lng b/interface/web/admin/lib/lang/en_server_list.lng index 164468e700bb699c24e823da7f3626e58d5257ed..89a81fa43b06af831857246ace6ed47bd1460b06 100644 --- a/interface/web/admin/lib/lang/en_server_list.lng +++ b/interface/web/admin/lib/lang/en_server_list.lng @@ -10,4 +10,6 @@ $wb["vserver_server_txt"] = 'VServer'; $wb["proxy_server_txt"] = 'Proxy'; $wb["firewall_server_txt"] = 'Firewall'; $wb["add_new_record_txt"] = 'Add new Server'; +// New for XMPP +$wb['xmpp_server_txt'] = 'XMPP'; ?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_system_config.lng b/interface/web/admin/lib/lang/en_system_config.lng index 3fa210f07d32d8ca3375463feca37927a989c265..f446bb3ed7aa6c2d6c67517b4f494e5efe098332 100644 --- a/interface/web/admin/lib/lang/en_system_config.lng +++ b/interface/web/admin/lib/lang/en_system_config.lng @@ -51,6 +51,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/en_users.lng b/interface/web/admin/lib/lang/en_users.lng index 09b8ac3057382b237c0d5a9b17ad0225989f49ef..9c57f1db8bbbb4bf5acf4f5216a452252e880c47 100644 --- a/interface/web/admin/lib/lang/en_users.lng +++ b/interface/web/admin/lib/lang/en_users.lng @@ -31,4 +31,5 @@ $wb['password_mismatch_txt'] = 'The passwords do not match.'; $wb['password_match_txt'] = 'The passwords do match.'; $wb['username_error_collision'] = 'The username may not be web or web plus a number."'; $wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin'; +$wb['lost_password_function_txt'] = 'Forgot password function is available'; ?> diff --git a/interface/web/admin/lib/lang/es_server_config.lng b/interface/web/admin/lib/lang/es_server_config.lng index 83010f9113e903de7b6fde0efcc9d0a6d5230930..1c91d0dd6d68028433b77db8b2a79da72f5d0944 100644 --- a/interface/web/admin/lib/lang/es_server_config.lng +++ b/interface/web/admin/lib/lang/es_server_config.lng @@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'Peticiones máximas de FastCGI'; $wb['fastcgi_bin_txt'] = 'Binario de FastCGI'; $wb['module_txt'] = 'Módulo'; $wb['maildir_path_txt'] = 'Ruta de buzones'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Ruta base de correo'; $wb['mailuser_uid_txt'] = 'UID del usuario de correo'; $wb['mailuser_gid_txt'] = 'GID del usuario de correo'; @@ -30,6 +31,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Servidor de retransmisión'; $wb['relayhost_user_txt'] = 'Usuario de retransmisión'; $wb['relayhost_password_txt'] = 'Contraseña de retramisión'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Límite de tamaño del buzón'; $wb['message_size_limit_txt'] = 'Límite de tamaño del mensaje'; $wb['ip_address_txt'] = 'Dirección IP'; diff --git a/interface/web/admin/lib/lang/es_system_config.lng b/interface/web/admin/lib/lang/es_system_config.lng index 41e61bf0c668e6b85f30739679a4426155304836..e51736b7fee90c22ce0600e681e3177e1b09ea79 100644 --- a/interface/web/admin/lib/lang/es_system_config.lng +++ b/interface/web/admin/lib/lang/es_system_config.lng @@ -46,6 +46,7 @@ $wb['use_combobox_txt'] = 'Usar Combobox de jQuery UI'; $wb['use_loadindicator_txt'] = 'Usar indicador de carga'; $wb['f5_to_reload_js_txt'] = 'Si cambias esto, podrías tener que pulsar F5 para que tu navegador recargue las librerías JavaScript o vacíar la caché del navegador.'; $wb['client_username_web_check_disabled_txt'] = "Desactivar comprobación de la palabra 'web' en el nombre de cliente."; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Mostrar pestaña autoresponder en los detalles de la cuenta de correo'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Mostrar pestaña filtro de correo en los detalles de la cuenta de correo'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Mostrar pestaña filtros personalizados en los detalles de la cuenta de correo'; diff --git a/interface/web/admin/lib/lang/fi_server_config.lng b/interface/web/admin/lib/lang/fi_server_config.lng index 4b77dd73a6790a0f38b38fc5110b57c309089d15..8ece953fe87473ca6a122c41146fd9fe86873593 100755 --- a/interface/web/admin/lib/lang/fi_server_config.lng +++ b/interface/web/admin/lib/lang/fi_server_config.lng @@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI-pyyntöraja'; $wb['fastcgi_bin_txt'] = 'FastCGI-binääri'; $wb['module_txt'] = 'Ohjelmaosio'; $wb['maildir_path_txt'] = 'Postilaatikon hakemistopolku'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Kotikansion hakemistopolku'; $wb['mailuser_uid_txt'] = 'Käyttäjätunnus'; $wb['mailuser_gid_txt'] = 'Käyttäjäryhmä'; @@ -30,6 +31,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Edelleenlähetyspalvelin'; $wb['relayhost_user_txt'] = 'Edelleenlähetyspalvelimen käyttäjätunnus'; $wb['relayhost_password_txt'] = 'Edelleenlähetyspalvelimen salasana'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Postilaatikon koko'; $wb['message_size_limit_txt'] = 'Viestien enimmäiskoko'; $wb['ip_address_txt'] = 'IP-osoite'; diff --git a/interface/web/admin/lib/lang/fi_system_config.lng b/interface/web/admin/lib/lang/fi_system_config.lng index 7d840b58d2377be5a2aa0379c195e1eb55d26735..6e1239e51ed45bc39d4e97b132c0d7061207c4dd 100755 --- a/interface/web/admin/lib/lang/fi_system_config.lng +++ b/interface/web/admin/lib/lang/fi_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/fr_server_config.lng b/interface/web/admin/lib/lang/fr_server_config.lng index a7a71a5efb9eb8aac1d87168acdd8496853d81f4..d566538a5c46b7facb9e49137b2c4ba73853f37e 100644 --- a/interface/web/admin/lib/lang/fr_server_config.lng +++ b/interface/web/admin/lib/lang/fr_server_config.lng @@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'Nombre maximal de requês FastCGI'; $wb['fastcgi_bin_txt'] = 'Exétable FastCGI'; $wb['module_txt'] = 'Module'; $wb['maildir_path_txt'] = 'Chemin Maildir'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Chemin Homedir'; $wb['mailuser_uid_txt'] = 'UID de l\'utilisateur mail'; $wb['mailuser_gid_txt'] = 'GID de l\'utilisateur mail'; @@ -25,6 +26,7 @@ $wb['mailuser_group_txt'] = 'Groupe de l\'utilisateur mail'; $wb['relayhost_txt'] = 'Hôde relais'; $wb['relayhost_user_txt'] = 'Utilisateur du relais'; $wb['relayhost_password_txt'] = 'Mot de passe du relais'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Taille maximale de la boite mail'; $wb['message_size_limit_txt'] = 'Taille maximale des messages'; $wb['ip_address_txt'] = 'Adresse IP'; diff --git a/interface/web/admin/lib/lang/fr_system_config.lng b/interface/web/admin/lib/lang/fr_system_config.lng index b6db6d72ffcf4f8ed054b32431da96ac1068d408..1fb0643fce20db56db49fe9ed7b65e06db29ea27 100644 --- a/interface/web/admin/lib/lang/fr_system_config.lng +++ b/interface/web/admin/lib/lang/fr_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/hr_server_config.lng b/interface/web/admin/lib/lang/hr_server_config.lng index 2ebcae6bb793954731a2b671dffc8267338a9fe8..4a73d3f63a262f388b7dc8ae7d0775d2c6dee57c 100644 --- a/interface/web/admin/lib/lang/hr_server_config.lng +++ b/interface/web/admin/lib/lang/hr_server_config.lng @@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'Maks. broj FastCGI zahtjeva'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Put do Maildir-a'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Put do početne stranice'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -31,6 +32,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost korisnik'; $wb['relayhost_password_txt'] = 'Relayhost šifra'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Dozvoljena veličina mailboxa'; $wb['message_size_limit_txt'] = 'Dozvoljena veličina emaila'; $wb['ip_address_txt'] = 'IP adresa'; diff --git a/interface/web/admin/lib/lang/hr_system_config.lng b/interface/web/admin/lib/lang/hr_system_config.lng index fe9b89f85f8f7abc0b63c018818ecb4cad2a6f55..3827e3a5ba732c4d11d3e1b94ad281f168c854f2 100644 --- a/interface/web/admin/lib/lang/hr_system_config.lng +++ b/interface/web/admin/lib/lang/hr_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/hu_server_config.lng b/interface/web/admin/lib/lang/hu_server_config.lng index ecbef137e40c7419534f1338cd8412b360fab7ff..b29b74413dd9cb48f2c375780d718eea0b2f35f0 100644 --- a/interface/web/admin/lib/lang/hu_server_config.lng +++ b/interface/web/admin/lib/lang/hu_server_config.lng @@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Maildir Path'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir Path'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -30,6 +31,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost User'; $wb['relayhost_password_txt'] = 'Relayhost Password'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mailbox Size Limit'; $wb['message_size_limit_txt'] = 'Message Size Limit'; $wb['ip_address_txt'] = 'IP Address'; diff --git a/interface/web/admin/lib/lang/hu_system_config.lng b/interface/web/admin/lib/lang/hu_system_config.lng index d6d6224fe386853e7a6e739c0eaae64ca145ad82..37ca447bf8cecfe9b0e6e32f751528b70c23362b 100644 --- a/interface/web/admin/lib/lang/hu_system_config.lng +++ b/interface/web/admin/lib/lang/hu_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/id_server_config.lng b/interface/web/admin/lib/lang/id_server_config.lng index f9a26e2b1cfadca55ad01003b9517153fcd9b0fe..930a58cbf77b74dcaf18f6f37be2580051d28783 100644 --- a/interface/web/admin/lib/lang/id_server_config.lng +++ b/interface/web/admin/lib/lang/id_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'Maks. Request FastCGI'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Path Direktori Mail'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Path Direktori Home'; $wb['mailuser_uid_txt'] = 'UID Pengguna Mail'; $wb['mailuser_gid_txt'] = 'GID Pengguna Mail'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Pengguna Relayhost'; $wb['relayhost_password_txt'] = 'Kata Sandi Relayhost'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Batasan Ukuran Mailbox'; $wb['message_size_limit_txt'] = 'Batasan Ukuran Pesan'; $wb['ip_address_txt'] = 'Alamat IP'; diff --git a/interface/web/admin/lib/lang/id_system_config.lng b/interface/web/admin/lib/lang/id_system_config.lng index 7baf01798ba5b89ca6cdb3938d94305da3ed3070..d4f262573db50ce6e0afa931b2ac6c5f0bf316bf 100644 --- a/interface/web/admin/lib/lang/id_system_config.lng +++ b/interface/web/admin/lib/lang/id_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/it_server_config.lng b/interface/web/admin/lib/lang/it_server_config.lng index 52913e30939db91f54b004a74d0ebbeb8e1ca361..cba103ff83efa4c759d66dce0e7226c1aa68b650 100644 --- a/interface/web/admin/lib/lang/it_server_config.lng +++ b/interface/web/admin/lib/lang/it_server_config.lng @@ -16,6 +16,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Module'; $wb['maildir_path_txt'] = 'Maildir Path'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir Path'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -29,6 +30,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost User'; $wb['relayhost_password_txt'] = 'Relayhost Password'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mailbox Size Limit'; $wb['message_size_limit_txt'] = 'Message Size Limit'; $wb['ip_address_txt'] = 'Indirizzo IP'; diff --git a/interface/web/admin/lib/lang/it_system_config.lng b/interface/web/admin/lib/lang/it_system_config.lng index 9f151ca9ec8a6f7f87a0fbb38309593f51bde31b..9d00c8d75a43e0d0ab13f5e43cb1224994329bae 100644 --- a/interface/web/admin/lib/lang/it_system_config.lng +++ b/interface/web/admin/lib/lang/it_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/ja_server_config.lng b/interface/web/admin/lib/lang/ja_server_config.lng index 0823ff0c2d5b8954c520817dcfd95de36a89835d..37fb09ac5d5b968106fa30915905c3ed16ea65ee 100644 --- a/interface/web/admin/lib/lang/ja_server_config.lng +++ b/interface/web/admin/lib/lang/ja_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI 最大リクエスト数'; $wb['fastcgi_bin_txt'] = 'FastCGI実行ファイル'; $wb['module_txt'] = 'モジュール'; $wb['maildir_path_txt'] = 'メールディレクトリ'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'ホームディレクトリ'; $wb['mailuser_uid_txt'] = 'メールユーザーのUID'; $wb['mailuser_gid_txt'] = 'メールユーザーのGID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'リレーホスト'; $wb['relayhost_user_txt'] = 'リレーホストユーザー'; $wb['relayhost_password_txt'] = 'リレーホストパスワード'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'メールボックスのサイズ'; $wb['message_size_limit_txt'] = 'メッセージの最大サイズ'; $wb['ip_address_txt'] = 'IPアドレス'; diff --git a/interface/web/admin/lib/lang/ja_system_config.lng b/interface/web/admin/lib/lang/ja_system_config.lng index 7800e3f8e46d53014b56555df3e8832b3f68b7ad..e81768d8750b1dc7ac78ca9d5a7baa87a6733f22 100644 --- a/interface/web/admin/lib/lang/ja_system_config.lng +++ b/interface/web/admin/lib/lang/ja_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/nl_server_config.lng b/interface/web/admin/lib/lang/nl_server_config.lng index 5027cc39d7fad190820c9537281cba8c32839f23..44eea44022391b7ef440f55b376359cbb0631b9f 100644 --- a/interface/web/admin/lib/lang/nl_server_config.lng +++ b/interface/web/admin/lib/lang/nl_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. gequests'; $wb['fastcgi_bin_txt'] = 'FastCGI bin'; $wb['module_txt'] = 'Module'; $wb['maildir_path_txt'] = 'Maildir pad'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir pad'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost gebruiker'; $wb['relayhost_password_txt'] = 'Relayhost wachtwoord'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mailbox grootte limiet'; $wb['message_size_limit_txt'] = 'Message grootte limiet'; $wb['ip_address_txt'] = 'IP adres'; diff --git a/interface/web/admin/lib/lang/nl_system_config.lng b/interface/web/admin/lib/lang/nl_system_config.lng index 07d5bffbf30d07992e770da16bbae74d946d5472..6f1a6fb514e828508635eed3d6e1276e6c22e714 100644 --- a/interface/web/admin/lib/lang/nl_system_config.lng +++ b/interface/web/admin/lib/lang/nl_system_config.lng @@ -51,6 +51,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/pl_server_config.lng b/interface/web/admin/lib/lang/pl_server_config.lng index 64f41d203c930a9edee4420f3753a156a9b1cd7f..5e17c41c53150e74d9c4df497319fd4ef7256b3c 100644 --- a/interface/web/admin/lib/lang/pl_server_config.lng +++ b/interface/web/admin/lib/lang/pl_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'Maksymalna ilość zadań FastCGI'; $wb['fastcgi_bin_txt'] = 'Kosz FastCGI'; $wb['module_txt'] = 'Moduł'; $wb['maildir_path_txt'] = 'Adres poczty e-mail'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Bazowy adres poczty e-mail'; $wb['mailuser_uid_txt'] = 'UID użytkownika e-mail'; $wb['mailuser_gid_txt'] = 'GID użytkownika e-mail'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Adres Relayhost'; $wb['relayhost_user_txt'] = 'Użytkownik Relayhost'; $wb['relayhost_password_txt'] = 'Hasło Relayhost'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Maksymalna wielkość skrzynki pocztowej'; $wb['message_size_limit_txt'] = 'Maksymalna wielkość wiadomości'; $wb['ip_address_txt'] = 'Adres IP'; diff --git a/interface/web/admin/lib/lang/pl_system_config.lng b/interface/web/admin/lib/lang/pl_system_config.lng index 792fb899277b23f249a744072fc8928f866920ba..402390688fc55f57c1ec047bdf1757eb91d111d0 100644 --- a/interface/web/admin/lib/lang/pl_system_config.lng +++ b/interface/web/admin/lib/lang/pl_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Użyj jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Użyj wskaźnika ładowania'; $wb['f5_to_reload_js_txt'] = 'Jeżeli zmienisz to, możesz potrzebować wcisnąć F5 lub wyczyścić cache aby przeglądarka przeładowała biblioteki JavaScript.'; $wb['client_username_web_check_disabled_txt'] = 'Wyłącz sprawdzanie nazwy klienta w poszukiwaniu słowa -web-.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Pokaż zakładkę autorespondera w szczegółach konta email.'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Pokaż zakładkę filtra email w szczegółach konta email.'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Pokaż zakładkę własnych filtrów email w szczegółach konta email.'; diff --git a/interface/web/admin/lib/lang/pt_server_config.lng b/interface/web/admin/lib/lang/pt_server_config.lng index 5315bf94753c0ff3fb5e0272fcba1c9726c1a595..adf708552fa2a1f5aa107cdaed7132dfef614bbc 100644 --- a/interface/web/admin/lib/lang/pt_server_config.lng +++ b/interface/web/admin/lib/lang/pt_server_config.lng @@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI: Requisições máximas'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Módulo'; $wb['maildir_path_txt'] = 'Pasta do Maildir'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Pasta Home'; $wb['mailuser_uid_txt'] = 'UID utilizador de email'; $wb['mailuser_gid_txt'] = 'GID utilizador de email'; @@ -31,6 +32,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Host Relay'; $wb['relayhost_user_txt'] = 'Utilizador do Host Relay'; $wb['relayhost_password_txt'] = 'Senha do Host Relay'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Tamanho máximo da Caixa Postal'; $wb['message_size_limit_txt'] = 'Tamanho máximo de mensagem'; $wb['ip_address_txt'] = 'Endereço IP'; diff --git a/interface/web/admin/lib/lang/pt_system_config.lng b/interface/web/admin/lib/lang/pt_system_config.lng index e79ae6a73e074b7dae9f69cd4e475b894b58f3c6..30d73f45b2b5c112235ef9f9b612742accecd996 100644 --- a/interface/web/admin/lib/lang/pt_system_config.lng +++ b/interface/web/admin/lib/lang/pt_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/ro_server_config.lng b/interface/web/admin/lib/lang/ro_server_config.lng index 9f06bc63b6135d95858b5894ea456b2db6468b86..a7ab9bc889b35efd1fa32d5b17f463cc93d385c4 100644 --- a/interface/web/admin/lib/lang/ro_server_config.lng +++ b/interface/web/admin/lib/lang/ro_server_config.lng @@ -18,6 +18,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Module'; $wb['maildir_path_txt'] = 'Maildir Path'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir Path'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -31,6 +32,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost User'; $wb['relayhost_password_txt'] = 'Relayhost Password'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mailbox Size Limit'; $wb['message_size_limit_txt'] = 'Message Size Limit'; $wb['ip_address_txt'] = 'IP Address'; diff --git a/interface/web/admin/lib/lang/ro_system_config.lng b/interface/web/admin/lib/lang/ro_system_config.lng index a56ea013eace59442272a77fad75e866ae7e3395..d2d91931d0ffce018c319bf82c5fe224a42a236c 100644 --- a/interface/web/admin/lib/lang/ro_system_config.lng +++ b/interface/web/admin/lib/lang/ro_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/ru_server_config.lng b/interface/web/admin/lib/lang/ru_server_config.lng index 77fc101d006753181a2e30dd03c7b7cadb7bf6e0..6a4080a12bc59849f8686bd73ccc51f127804d6b 100644 --- a/interface/web/admin/lib/lang/ru_server_config.lng +++ b/interface/web/admin/lib/lang/ru_server_config.lng @@ -16,6 +16,7 @@ $wb['fastcgi_max_requests_txt'] = 'Макс.запросов для FastCGI'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Модуль'; $wb['maildir_path_txt'] = 'Путь Maildir'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Путь Homedir'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -29,6 +30,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relay-хост'; $wb['relayhost_user_txt'] = 'Логин Relay-хоста'; $wb['relayhost_password_txt'] = 'Пароль Relay-хоста'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Лимит размера Mailbox'; $wb['message_size_limit_txt'] = 'Лимит размера сообщения'; $wb['ip_address_txt'] = 'IP-адрес'; diff --git a/interface/web/admin/lib/lang/ru_system_config.lng b/interface/web/admin/lib/lang/ru_system_config.lng index fdfb9d0657198fb808d6d4ac2941fbd315ee8c4d..a3a610c3b0b5aee1f5187ca3312cd0a74289288f 100644 --- a/interface/web/admin/lib/lang/ru_system_config.lng +++ b/interface/web/admin/lib/lang/ru_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/se_server_config.lng b/interface/web/admin/lib/lang/se_server_config.lng index b5d5ea17c5327a85b714151b7fc532bb0f68d1e4..5818cfacb3832063a9f507675ba0e0948c8a05aa 100644 --- a/interface/web/admin/lib/lang/se_server_config.lng +++ b/interface/web/admin/lib/lang/se_server_config.lng @@ -17,6 +17,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Module'; $wb['maildir_path_txt'] = 'Maildir Path'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Homedir Path'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -30,6 +31,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost User'; $wb['relayhost_password_txt'] = 'Relayhost Password'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mailbox Size Limit'; $wb['message_size_limit_txt'] = 'Message Size Limit'; $wb['ip_address_txt'] = 'IP Address'; diff --git a/interface/web/admin/lib/lang/se_system_config.lng b/interface/web/admin/lib/lang/se_system_config.lng index 97850cd15881e66dd08900db984c426cbce16346..0a6a60b7228ba0065c5276516dcfc5e458323d47 100644 --- a/interface/web/admin/lib/lang/se_system_config.lng +++ b/interface/web/admin/lib/lang/se_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Använd jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Använd laddningsindikator'; $wb['f5_to_reload_js_txt'] = 'Om du ändrar detta kan du behöva trycka F5 för att ladda om javascript, eller rensa din webbläsarcache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Visa autosvarsfliken vid detaljerna för epostkonto'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Visa epostfilterfliken vid detaljerna för epostkonto'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/sk_server_config.lng b/interface/web/admin/lib/lang/sk_server_config.lng index d480430d7226530662db6a66a75a117ae7554cbe..392664b7e20407706703348d019ab7b0ac1dcc0d 100644 --- a/interface/web/admin/lib/lang/sk_server_config.lng +++ b/interface/web/admin/lib/lang/sk_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Modul'; $wb['maildir_path_txt'] = 'Maildir Cesta'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Cesta k domovskému adresáru'; $wb['mailuser_uid_txt'] = 'Mailuser UID'; $wb['mailuser_gid_txt'] = 'Mailuser GID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost uživateľ'; $wb['relayhost_password_txt'] = 'Relayhost heslo'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Limit ve?kosti poštovej schránky'; $wb['message_size_limit_txt'] = 'Limit ve?kosti správy'; $wb['ip_address_txt'] = 'IP Adresa'; diff --git a/interface/web/admin/lib/lang/sk_system_config.lng b/interface/web/admin/lib/lang/sk_system_config.lng index 8a5129170aff0b298609d3ee8ab41afcc6461ed5..0a4c0adaccd8a80baa92fad18e216a24e7fa64f2 100644 --- a/interface/web/admin/lib/lang/sk_system_config.lng +++ b/interface/web/admin/lib/lang/sk_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/lang/tr_server_config.lng b/interface/web/admin/lib/lang/tr_server_config.lng index 8b08efe00477e84f20c6960e373c367a11b9e897..60a24ee48b2c987512470c342a821be050ba9059 100644 --- a/interface/web/admin/lib/lang/tr_server_config.lng +++ b/interface/web/admin/lib/lang/tr_server_config.lng @@ -19,6 +19,7 @@ $wb['fastcgi_max_requests_txt'] = 'FastCGI max. Requests'; $wb['fastcgi_bin_txt'] = 'FastCGI Bin'; $wb['module_txt'] = 'Modül'; $wb['maildir_path_txt'] = 'Mail dizini yolu'; +$wb['maildir_format_txt'] = 'Maildir Format'; $wb['homedir_path_txt'] = 'Kullanıcı dizini yolu'; $wb['mailuser_uid_txt'] = 'Mail kullanıcısı UID'; $wb['mailuser_gid_txt'] = 'Mail kullanıcısı GID'; @@ -32,6 +33,7 @@ $wb['mailbox_virtual_uidgid_maps_error_alreadyusers'] = 'Uid-mapping cannot be c $wb['relayhost_txt'] = 'Relayhost'; $wb['relayhost_user_txt'] = 'Relayhost Kullanıcı'; $wb['relayhost_password_txt'] = 'Relayhost Şifre'; +$wb['reject_sender_login_mismatch_txt'] = 'Reject sender and login mismatch'; $wb['mailbox_size_limit_txt'] = 'Mail kutusu boyutu'; $wb['message_size_limit_txt'] = 'Mesaj boyutu'; $wb['ip_address_txt'] = 'IP Adresleri'; diff --git a/interface/web/admin/lib/lang/tr_system_config.lng b/interface/web/admin/lib/lang/tr_system_config.lng index 621f821470772f206e3c983cce9872defa53910b..d652b915e57b72ff7f2c6207c52d2565dad35766 100644 --- a/interface/web/admin/lib/lang/tr_system_config.lng +++ b/interface/web/admin/lib/lang/tr_system_config.lng @@ -48,6 +48,7 @@ $wb['use_combobox_txt'] = 'Use jQuery UI Combobox'; $wb['use_loadindicator_txt'] = 'Use Load Indicator'; $wb['f5_to_reload_js_txt'] = 'If you change this, you might have to press F5 to make the browser reload JavaScript libraries or empty your browser cache.'; $wb['client_username_web_check_disabled_txt'] = 'Disable client username check for the word \'web\'.'; +$wb['backups_include_into_web_quota_txt'] = 'Include backup files into web quota.'; $wb['mailbox_show_autoresponder_tab_txt'] = 'Show autoresponder tab in mail account details'; $wb['mailbox_show_mail_filter_tab_txt'] = 'Show mail filter tab in mail account details'; $wb['mailbox_show_custom_rules_tab_txt'] = 'Show custom mailfilter tab in mail account details'; diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php index 7f4d19da1abd456a7027fdd6729994edc67b2a90..727f7a2d5555918be7282dd705bf8e2f745f72b4 100644 --- a/interface/web/admin/lib/module.conf.php +++ b/interface/web/admin/lib/module.conf.php @@ -7,6 +7,7 @@ $module['title'] = 'top_menu_system'; $module['template'] = 'module.tpl.htm'; $module['startpage'] = 'admin/server_list.php'; $module['tab_width'] = '60'; +$module['order'] = '90'; $items[] = array( 'title' => 'CP Users', diff --git a/interface/web/admin/list/directive_snippets.list.php b/interface/web/admin/list/directive_snippets.list.php index 8522e076414ec05fbb33592aa9a951a816a2b92d..078cebf8608ed82d12ad8f5cc1d12d1d5f1990ff 100644 --- a/interface/web/admin/list/directive_snippets.list.php +++ b/interface/web/admin/list/directive_snippets.list.php @@ -54,7 +54,7 @@ $liste["item"][] = array( 'field' => "active", 'prefix' => "", 'suffix' => "", 'width' => "", - 'value' => array('y' => "
Yes
", 'n' => "
No
")); + 'value' => array('y' => "
".$app->lng('yes_txt')."
", 'n' => "
".$app->lng('no_txt')."
")); $liste["item"][] = array( 'field' => "name", @@ -74,5 +74,14 @@ $liste["item"][] = array( 'field' => "type", 'suffix' => "", 'width' => "", 'value' => array('apache' => 'Apache', 'nginx' => 'nginx', 'php' => 'PHP', 'proxy' => 'Proxy')); + +$liste["item"][] = array( 'field' => "customer_viewable", + 'datatype' => "VARCHAR", + 'formtype' => "SELECT", + 'op' => "=", + 'prefix' => "", + 'suffix' => "", + 'width' => "", + 'value' => array('y' => "
".$app->lng('yes_txt')."
", 'n' => "
".$app->lng('no_txt')."
")); ?> diff --git a/interface/web/admin/list/firewall.list.php b/interface/web/admin/list/firewall.list.php index 058e86c804cfa730fdbed654b2a6ec18a76a8fff..786b7b848ae756f78a69e987b0af7a98a6cfdfed 100644 --- a/interface/web/admin/list/firewall.list.php +++ b/interface/web/admin/list/firewall.list.php @@ -54,7 +54,7 @@ $liste["item"][] = array( 'field' => "active", 'prefix' => "", 'suffix' => "", 'width' => "", - 'value' => array('y' => "
Yes
", 'n' => "
No
")); + 'value' => array('y' => "
".$app->lng('yes_txt')."
", 'n' => "
".$app->lng('no_txt')."
")); $liste["item"][] = array( 'field' => "server_id", 'datatype' => "VARCHAR", diff --git a/interface/web/admin/list/iptables.list.php b/interface/web/admin/list/iptables.list.php index ad487e5b6baf5a688561385956414907d32be758..3ad78404ea4c195e8d35cdd79f9fec4338fe1f97 100644 --- a/interface/web/admin/list/iptables.list.php +++ b/interface/web/admin/list/iptables.list.php @@ -18,14 +18,14 @@ $liste["item"][] = array( 'field' => "active", 'prefix' => "", 'suffix' => "", 'width' => "", - 'value' => array("y" => "
Yes
", "n" => "
No
")); + 'value' => array("y" => "
".$app->lng('yes_txt')."
", "n" => "
".$app->lng('no_txt')."
")); $liste["item"][] = array( 'field' => "server_id", - 'datatype' => "VARCHAR", + 'datatype' => "INTEGER", 'formtype' => "SELECT", - 'op' => "like", - 'prefix' => "%", - 'suffix' => "%", + 'op' => "=", + '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", diff --git a/interface/web/admin/list/server.list.php b/interface/web/admin/list/server.list.php index 0309b7a3c1a60c69ad152ff884a925743ac8bbe9..9ca54c07d5d2df744ac530f6898792264a666d25 100644 --- a/interface/web/admin/list/server.list.php +++ b/interface/web/admin/list/server.list.php @@ -63,7 +63,7 @@ $liste['item'][] = array( 'field' => 'mail_server', 'prefix' => '%', 'suffix' => '%', 'width' => '', - 'value' => array('1' => "
Yes
", '0' => "
No
")); + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); $liste['item'][] = array( 'field' => 'web_server', 'datatype' => 'VARCHAR', @@ -72,7 +72,7 @@ $liste['item'][] = array( 'field' => 'web_server', 'prefix' => '%', 'suffix' => '%', 'width' => '', - 'value' => array('1' => "
Yes
", '0' => "
No
")); + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); $liste['item'][] = array( 'field' => 'dns_server', 'datatype' => 'VARCHAR', @@ -81,7 +81,7 @@ $liste['item'][] = array( 'field' => 'dns_server', 'prefix' => '%', 'suffix' => '%', 'width' => '', - 'value' => array('1' => "
Yes
", '0' => "
No
")); + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); $liste['item'][] = array( 'field' => 'file_server', 'datatype' => 'VARCHAR', @@ -90,7 +90,7 @@ $liste['item'][] = array( 'field' => 'file_server', 'prefix' => '%', 'suffix' => '%', 'width' => '', - 'value' => array('1' => "
Yes
", '0' => "
No
")); + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); $liste['item'][] = array( 'field' => 'db_server', 'datatype' => 'VARCHAR', @@ -99,7 +99,7 @@ $liste['item'][] = array( 'field' => 'db_server', 'prefix' => '%', 'suffix' => '%', 'width' => '', - 'value' => array('1' => "
Yes
", '0' => "
No
")); + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); $liste['item'][] = array( 'field' => 'vserver_server', 'datatype' => 'VARCHAR', @@ -108,6 +108,15 @@ $liste['item'][] = array( 'field' => 'vserver_server', 'prefix' => '%', 'suffix' => '%', 'width' => '', - 'value' => array('1' => "
Yes
", '0' => "
No
")); + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); + +$liste['item'][] = array( 'field' => 'xmpp_server', + 'datatype' => 'VARCHAR', + 'formtype' => 'SELECT', + 'op' => 'like', + 'prefix' => '%', + 'suffix' => '%', + 'width' => '', + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); ?> diff --git a/interface/web/admin/list/server_ip.list.php b/interface/web/admin/list/server_ip.list.php index dba0c68cb1129b58210479614da81a448b52797e..41ac76e2a9dd67409c9b4a99a29021df789779fa 100644 --- a/interface/web/admin/list/server_ip.list.php +++ b/interface/web/admin/list/server_ip.list.php @@ -45,11 +45,11 @@ $liste['auth'] = 'no'; *****************************************************/ $liste['item'][] = array( 'field' => 'server_id', - 'datatype' => 'VARCHAR', + 'datatype' => 'INTEGER', 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', 'datasource' => array ( 'type' => 'SQL', 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', 'keyfield'=> 'server_id', @@ -59,11 +59,11 @@ $liste['item'][] = array( 'field' => 'server_id', 'value' => ''); $liste['item'][] = array( 'field' => 'client_id', - 'datatype' => 'VARCHAR', + 'datatype' => 'INTEGER', 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', 'datasource' => array ( 'type' => 'SQL', 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', 'keyfield'=> 'client_id', @@ -95,7 +95,7 @@ $liste["item"][] = array( 'field' => "virtualhost", 'prefix' => "", 'suffix' => "", 'width' => "", - 'value' => array('y' => "
Yes
", 'n' => "
No
")); + 'value' => array('y' => "
".$app->lng('yes_txt')."
", 'n' => "
".$app->lng('no_txt')."
")); $liste['item'][] = array( 'field' => 'virtualhost_port', diff --git a/interface/web/admin/list/server_php.list.php b/interface/web/admin/list/server_php.list.php index ce8944d5a85e87ce3a4ae5e3874dd6162c53c85d..2414cb8fec37d2c71ad71081afd8a80a3dce6609 100644 --- a/interface/web/admin/list/server_php.list.php +++ b/interface/web/admin/list/server_php.list.php @@ -45,11 +45,11 @@ $liste['auth'] = 'no'; *****************************************************/ $liste['item'][] = array( 'field' => 'server_id', - 'datatype' => 'VARCHAR', + 'datatype' => 'INTEGER', 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', 'datasource' => array ( 'type' => 'SQL', 'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name', 'keyfield'=> 'server_id', @@ -59,11 +59,11 @@ $liste['item'][] = array( 'field' => 'server_id', 'value' => ''); $liste['item'][] = array( 'field' => 'client_id', - 'datatype' => 'VARCHAR', + 'datatype' => 'INTEGER', 'formtype' => 'SELECT', - 'op' => 'like', - 'prefix' => '%', - 'suffix' => '%', + 'op' => '=', + 'prefix' => '', + 'suffix' => '', 'datasource' => array ( 'type' => 'SQL', 'querystring' => 'SELECT client_id,contact_name FROM client WHERE {AUTHSQL} ORDER BY contact_name', 'keyfield'=> 'client_id', diff --git a/interface/web/admin/list/software_repo.list.php b/interface/web/admin/list/software_repo.list.php index 2eb3dd520eeb4d74bd39184f39879b9f6e6c237f..824c66d6d9d29f0ae04727cd605535f272573b71 100644 --- a/interface/web/admin/list/software_repo.list.php +++ b/interface/web/admin/list/software_repo.list.php @@ -54,7 +54,7 @@ $liste["item"][] = array( 'field' => "active", 'prefix' => "", 'suffix' => "", 'width' => "", - 'value' => array('y' => "
Yes
", 'n' => "
No
")); + 'value' => array('y' => "
".$app->lng('yes_txt')."
", 'n' => "
".$app->lng('no_txt')."
")); $liste["item"][] = array( 'field' => "repo_name", 'datatype' => "VARCHAR", diff --git a/interface/web/admin/list/users.list.php b/interface/web/admin/list/users.list.php index b260c2b3c652f01b5c61c277c58d4c3ae7688dbb..53e3f440a6f6e76f6c79e0eb16610ee0bb45c61c 100644 --- a/interface/web/admin/list/users.list.php +++ b/interface/web/admin/list/users.list.php @@ -60,7 +60,7 @@ $liste["item"][] = array( 'field' => "active", 'prefix' => "", 'suffix' => "", 'width' => "", - 'value' => array('1' => "
Yes
", '0' => "
No
")); + 'value' => array('1' => "
".$app->lng('yes_txt')."
", '0' => "
".$app->lng('no_txt')."
")); $liste['item'][] = array( 'field' => 'username', 'datatype' => 'VARCHAR', diff --git a/interface/web/admin/remote_action_ispcupdate.php b/interface/web/admin/remote_action_ispcupdate.php index 32bf0c4333b8973ec352bd7aee2fc07fac5ff633..263400665873c71a00137bcfb8d2e8d423e7bd5a 100644 --- a/interface/web/admin/remote_action_ispcupdate.php +++ b/interface/web/admin/remote_action_ispcupdate.php @@ -80,15 +80,8 @@ 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 (". - $app->functions->intval($serverId) . ", " . - time() . ", " . - "'ispc_update', " . - "'', " . - "'pending', " . - "''" . - ")"; - $app->db->query($sql); + "VALUES (?, UNIX_TIMESTAMP(), 'ispc_update', '', 'pending', '')"; + $app->db->query($sql, $serverId); } $msg = $wb['action_scheduled']; } diff --git a/interface/web/admin/remote_action_osupdate.php b/interface/web/admin/remote_action_osupdate.php index 61c6c23823689ad99558e2becba462b0905ba3e6..8f48e29f2d472d6937c37e73af54237c3f0f8bd3 100644 --- a/interface/web/admin/remote_action_osupdate.php +++ b/interface/web/admin/remote_action_osupdate.php @@ -76,15 +76,8 @@ 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 (". - $app->functions->intval($serverId) . ", " . - time() . ", " . - "'os_update', " . - "'', " . - "'pending', " . - "''" . - ")"; - $app->db->query($sql); + "VALUES (?, UNIX_TIMESTAMP(), 'os_update', '', 'pending', '')"; + $app->db->query($sql, $serverId); } $msg = $wb['action_scheduled']; } diff --git a/interface/web/admin/server_config_edit.php b/interface/web/admin/server_config_edit.php index e561b00ac546fd900a48c0b292e1cbd7d2fcb37d..d64b6dd7dbae3b45eeb9c7133268c4689d9c9889 100644 --- a/interface/web/admin/server_config_edit.php +++ b/interface/web/admin/server_config_edit.php @@ -96,7 +96,7 @@ class page_action extends tform_actions { $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->db->datalogUpdate('server', array("config" => $server_config_str), 'server_id', $server_id); } } diff --git a/interface/web/admin/server_edit.php b/interface/web/admin/server_edit.php index 0adf313181a23764852fd72c63baef27b96c6e38..c2e746d5c58fce1e2d2b8a08b8fa92de282b4079 100644 --- a/interface/web/admin/server_edit.php +++ b/interface/web/admin/server_edit.php @@ -55,8 +55,8 @@ class page_action extends tform_actions { global $app, $conf; // Getting Servers - $sql = "SELECT server_id,server_name FROM server WHERE server_id != ".$app->functions->intval($this->id)." ORDER BY server_name"; - $mirror_servers = $app->db->queryAllRecords($sql); + $sql = "SELECT server_id,server_name FROM server WHERE server_id != ? ORDER BY server_name"; + $mirror_servers = $app->db->queryAllRecords($sql, $this->id); $mirror_server_select = ''; if(is_array($mirror_servers)) { foreach( $mirror_servers as $mirror_server) { diff --git a/interface/web/admin/server_ip_edit.php b/interface/web/admin/server_ip_edit.php index c20f752b86c86c5535fe49a9a37b727ea5c0a469..f7872f4438954d47dc7dbdfbbd495b9032a5fe40 100644 --- a/interface/web/admin/server_ip_edit.php +++ b/interface/web/admin/server_ip_edit.php @@ -57,7 +57,7 @@ class page_action extends tform_actions { //* 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'])) { - $rec = $app->db->queryOneRecord("SELECT server_id from server_ip WHERE server_ip_id = ".$app->functions->intval($this->id)); + $rec = $app->db->queryOneRecord("SELECT server_id from server_ip WHERE server_ip_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.'); diff --git a/interface/web/admin/server_php_edit.php b/interface/web/admin/server_php_edit.php index f60ae997a051a92b5d389701debc40db26b184d9..12aacf60b92a687c75c71f33fad9abe5b83cad5a 100644 --- a/interface/web/admin/server_php_edit.php +++ b/interface/web/admin/server_php_edit.php @@ -57,7 +57,7 @@ class page_action extends tform_actions { //* 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 = ".$app->functions->intval($this->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.'); diff --git a/interface/web/admin/software_package_install.php b/interface/web/admin/software_package_install.php index 0fd58816a0e3056e2593c53ca8ff5d7af35bf95b..ccbfd73ebe6e2c3411f1a1fa32dd579c06b45ccd 100644 --- a/interface/web/admin/software_package_install.php +++ b/interface/web/admin/software_package_install.php @@ -38,11 +38,11 @@ $app->auth->check_security_permissions('admin_allow_software_packages'); //* This is only allowed for administrators if(!$app->auth->is_admin()) die('only allowed for administrators.'); -$package_name = $app->db->quote($_REQUEST['package']); +$package_name = $_REQUEST['package']; $install_server_id = $app->functions->intval($_REQUEST['server_id']); -$install_key = $app->db->quote(trim($_REQUEST['install_key'])); +$install_key = trim($_REQUEST['install_key']); -$package = $app->db->queryOneRecord("SELECT * FROM software_package WHERE package_name = '$package_name'"); +$package = $app->db->queryOneRecord("SELECT * FROM software_package WHERE package_name = ?", $package_name); $install_key_verified = false; $message_err = ''; @@ -51,7 +51,7 @@ $message_ok = ''; //* verify the key if($package['package_installable'] == 'key' && $install_key != '') { - $repo = $app->db->queryOneRecord("SELECT * FROM software_repo WHERE software_repo_id = ".$app->db->quote($package['software_repo_id'])); + $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'])); @@ -63,7 +63,7 @@ if($package['package_installable'] == 'key' && $install_key != '') { $message_err = 'Verification of the key failed.'; } else { // Store the verified key into the database - $app->db->datalogUpdate('software_package', "package_key = '".$app->db->quote($install_key)."'", 'package_id', $package['package_id']); + $app->db->datalogUpdate('software_package', array("package_key" => $install_key), 'package_id', $package['package_id']); } } else { $message_ok = 'Please enter the software key for the package.'; @@ -71,8 +71,8 @@ if($package['package_installable'] == 'key' && $install_key != '') { //* Install packages, if all requirements are fullfilled. if($install_server_id > 0 && $package_name != '' && ($package['package_installable'] == 'yes' || $install_key_verified == true)) { - $sql = "SELECT software_update_id, package_name, update_title FROM software_update WHERE type = 'full' AND package_name = '".$app->db->quote($package_name)."' ORDER BY v1 DESC, v2 DESC, v3 DESC, v4 DESC LIMIT 0,1"; - $tmp = $app->db->queryOneRecord($sql); + $sql = "SELECT software_update_id, package_name, update_title FROM software_update WHERE type = 'full' AND package_name = ? ORDER BY v1 DESC, v2 DESC, v3 DESC, v4 DESC LIMIT 0,1"; + $tmp = $app->db->queryOneRecord($sql, $package_name); $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 @@ -91,7 +91,7 @@ if($install_server_id > 0 && $package_name != '' && ($package['package_installab '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', array("package_config" => $package_config_str), 'package_id', $package['package_id']); } } @@ -105,7 +105,7 @@ if($install_server_id > 0 && $package_name != '' && ($package['package_installab 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']); + $remote_functions = $package['package_remote_functions']; $package_config_array['remote_api'] = array( 'remote_hostname' => $_SERVER['HTTP_HOST'], @@ -116,21 +116,25 @@ if($install_server_id > 0 && $package_name != '' && ($package['package_installab $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', array("package_config" => $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', '', '".$app->db->quote($remote_user)."', '".$app->db->quote($remote_password_md5)."', '".$app->db->quote($remote_functions)."');"; - - $app->db->query($sql); + (1, 1, 'riud', 'riud', '', ?, ?, ?)"; + $app->db->query($sql, $remote_user, $remote_password_md5, $remote_functions); } } //* Add the record to start the install process - $insert_data = "(package_name, server_id, software_update_id, status) VALUES ('".$app->db->quote($package_name)."', '".$app->db->quote($install_server_id)."', '".$app->db->quote($software_update_id)."','installing')"; + $insert_data = array( + "package_name" => $package_name, + "server_id" => $install_server_id, + "software_update_id" => $software_update_id, + "status" => 'installing' + ); $app->db->datalogInsert('software_update_inst', $insert_data, 'software_update_inst_id'); - $message_ok = 'Starting package installation '."".$app->lng('next').""; + $message_ok = 'Starting package installation '."".$app->lng('next').""; } diff --git a/interface/web/admin/software_package_list.php b/interface/web/admin/software_package_list.php index 489b6fbd545de5ddb80ea4a4270f2f98dfb733e5..5e552dbee7b9497c26bf17571c561cb85c4efbe9 100644 --- a/interface/web/admin/software_package_list.php +++ b/interface/web/admin/software_package_list.php @@ -48,27 +48,40 @@ if(is_array($repos) && isset($_GET['action']) && $_GET['action'] == 'repoupdate' $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 = '".$app->db->quote($package_name)."'"); + $package_name = $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']); + $package_title = $p['title']; + $package_description = $p['description']; $software_repo_id = $app->functions->intval($repo['software_repo_id']); - $package_type = $app->db->quote($p['type']); - $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']); + $package_type = $p['type']; + $package_installable = $p['installable']; + $package_requires_db = $p['requires_db']; + $package_remote_functions = $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); - $insert_data = "(software_repo_id, package_name, package_title, package_description,package_type,package_installable,package_requires_db,package_remote_functions) VALUES ($software_repo_id, '$package_name', '$package_title', '$package_description','$package_type','$package_installable','$package_requires_db','$package_remote_functions')"; + $insert_data = array( + "software_repo_id" => $software_repo_id, + "package_name" => $package_name, + "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 + ); $app->db->datalogInsert('software_package', $insert_data, 'package_id'); $packages_added++; } else { - //$sql = "UPDATE software_package SET 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' WHERE package_name = '$package_name'"; - //$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'"; + $update_data = array( + "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']); } @@ -91,25 +104,31 @@ if(is_array($repos) && isset($_GET['action']) && $_GET['action'] == 'repoupdate' $v3 = $app->functions->intval($version_array[2]); $v4 = $app->functions->intval($version_array[3]); - $package_name = $app->db->quote($u['package_name']); + $package_name = $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']); + $update_url = $u['url']; + $update_md5 = $u['md5']; + $update_dependencies = (isset($u['dependencies']))?$u['dependencies']:''; + $update_title = $u['title']; + $type = $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); + $sql = "SELECT * FROM software_update WHERE package_name = ? and v1 = ? and v2 = ? and v3 = ? and v4 = ?"; + $tmp = $app->db->queryOneRecord($sql, $package_name, $v1, $v2, $v3, $v4); 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')"; + $insert_data = array( + "software_repo_id" => $software_repo_id, + "package_name" => $package_name, + "update_url" => $update_url, + "update_md5" => $update_md5, + "update_dependencies" => $update_dependencies, + "update_title" => $update_title, + "v1" => $v1, + "v2" => $v2, + "v3" => $v3, + "v4" => $v4, + "type" => $type + ); $app->db->datalogInsert('software_update', $insert_data, 'software_update_id'); } @@ -120,23 +139,6 @@ if(is_array($repos) && isset($_GET['action']) && $_GET['action'] == 'repoupdate' } } -//* Install packages, if GET Request -/* -if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != '' && $_GET['server_id'] > 0) { - $package_name = $app->db->quote($_GET['package']); - $server_id = $app->functions->intval($_GET['server_id']); - $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'); -} -*/ - - - // Show the list in the interface // Loading the template $app->uses('tpl'); @@ -150,7 +152,7 @@ if(is_array($packages) && count($packages) > 0) { foreach($packages as $key => $p) { $installed_txt = ''; 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 = '".$app->db->quote($p["package_name"])."' AND server_id = '".$app->functions->intval($s["server_id"])."'"); + $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 = ? AND server_id = ?", $p["package_name"], $s["server_id"]); $version = $inst['v1'].'.'.$inst['v2'].'.'.$inst['v3'].'.'.$inst['v4']; if($inst['status'] == 'installed') { @@ -165,7 +167,7 @@ if(is_array($packages) && count($packages) > 0) { if($p['package_installable'] == 'no') { $installed_txt .= $s['server_name'].": ".$app->lng("Package can not be installed.")."
"; } else { - $installed_txt .= $s['server_name'].": Install now
"; + $installed_txt .= $s['server_name'].": Install now
"; } } } diff --git a/interface/web/admin/software_update_list.php b/interface/web/admin/software_update_list.php index 8bc8b79a410613f21d3c1d018b29fc142ce4df95..c987e9e04bebe9606a45cbac217d5c40925a7947 100644 --- a/interface/web/admin/software_update_list.php +++ b/interface/web/admin/software_update_list.php @@ -72,23 +72,23 @@ if(is_array($repos)) { $v3 = $app->functions->intval($version_array[2]); $v4 = $app->functions->intval($version_array[3]); - $package_name = $app->db->quote($u['package_name']); + $package_name = $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']); + $update_url = $u['url']; + $update_md5 = $u['md5']; + $update_dependencies = (isset($u['dependencies']))?$u['dependencies']:''; + $update_title = $u['title']; + $type = $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); + $sql = "SELECT * FROM software_update WHERE package_name = ? and v1 = ? and v2 = ? and v3 = ? and v4 = ?"; + $tmp = $app->db->queryOneRecord($sql, $package_name, $v1, $v2, $v3, $v4); 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')"; + VALUES ($software_repo_id, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; //die($sql); - $app->db->query($sql); + $app->db->query($sql, $package_name, $update_url, $update_md5, $update_dependencies, $update_title, $v1, $v2, $v3, $v4, $type); } } @@ -101,12 +101,16 @@ if(is_array($repos)) { //* Install packages, if GET Request if(isset($_GET['action']) && $_GET['action'] == 'install' && $_GET['package'] != '' && $_GET['server_id'] > 0) { - $package_name = $app->db->quote($_GET['package']); + $package_name = $_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')"; + $insert_data = array( + "package_name" => $package_name, + "server_id" => $server_id, + "software_update_id" => $software_update_id, + "status" => 'installing' + ); $app->db->datalogInsert('software_update_inst', $insert_data, 'software_update_inst_id'); } @@ -162,12 +166,12 @@ 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 = ".$app->functions->intval($server_id)." ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC LIMIT 0,1"; - $lu = $app->db->queryOneRecord($sql); + $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 = ? ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC LIMIT 0,1"; + $lu = $app->db->queryOneRecord($sql, $server_id); // Get all installable updates - $sql = "SELECT * FROM software_update WHERE v1 >= ".$app->functions->intval($lu['v1'])." AND v2 >= ".$app->functions->intval($lu['v2'])." AND v3 >= ".$app->functions->intval($lu['v3'])." AND v4 >= ".$app->functions->intval($lu['v4'])." AND package_name = '".$app->db->quote($ip['package_name'])."' ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC"; - $updates = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM software_update WHERE v1 >= ? AND v2 >= ? AND v3 >= ? AND v4 >= ? AND package_name = ? ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC"; + $updates = $app->db->queryAllRecords($sql, $lu['v1'], $lu['v2'], $lu['v3'], $lu['v4'], $ip['package_name']); //die($sql); if(is_array($updates)) { @@ -176,7 +180,7 @@ if(is_array($installed_packages)) { foreach($updates as $key => $u) { $version = $u['v1'].'.'.$u['v2'].'.'.$u['v3'].'.'.$u['v4']; - $installed_txt = "Install Update
"; + $installed_txt = "Install Update
"; $records_out[] = array('version' => $version, 'update_title' => $u["update_title"], 'installed' => $installed_txt); } @@ -184,30 +188,6 @@ if(is_array($installed_packages)) { } } -/* -$updates = $app->db->queryAllRecords('SELECT 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 ) - WHERE server_id = '.$server_id.' - GROUP BY software_update.package_name - ORDER BY software_update.package_name ASC, v1 DESC , v2 DESC , v3 DESC , v4 DESC'); - -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') { - $installed_txt .= "Installed version $version
"; - } else { - $installed_txt .= "Install now
"; - } - $updates[$key]['installed'] = $installed_txt; - - } -} -*/ - $app->tpl->setLoop('records', $records_out); diff --git a/interface/web/admin/system_config_edit.php b/interface/web/admin/system_config_edit.php index 7108f2707a8aa31bf498b143305dd2f127c8ae89..f48f11b7ed5faf17521c4cb4b18f003568fefdd4 100644 --- a/interface/web/admin/system_config_edit.php +++ b/interface/web/admin/system_config_edit.php @@ -89,13 +89,24 @@ class page_action extends tform_actions { $available_dashlets_txt = ''; $handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); while ($file = @readdir($handle)) { - if ($file != '.' && $file != '..' && !is_dir($file)) { + if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) { $available_dashlets_txt .= '['.substr($file, 0, -4).'] '; } } if($available_dashlets_txt == '') $available_dashlets_txt = '------'; $app->tpl->setVar("available_dashlets_txt", $available_dashlets_txt); + + // Logo + $sys_ini = $app->db->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = ?", $this->id); + if($sys_ini['custom_logo'] != ''){ + $logo = '  '; + } else { + $logo = ''; + } + $default_logo = ''; + $app->tpl->setVar("used_logo", $logo); + $app->tpl->setVar("default_logo", $default_logo); parent::onShowEnd(); } @@ -165,9 +176,7 @@ class page_action extends tform_actions { $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); + if($conf['demo_mode'] != true) $app->db->datalogUpdate('sys_ini', array("config" => $server_config_str), 'sysini_id', 1); /* * If we should use the domain-module, we have to insert all existing domains into the table @@ -185,26 +194,28 @@ class page_action extends tform_actions { "FROM web_domain WHERE type NOT IN ('subdomain','vhostsubdomain')"; $app->db->query($sql); } + + //die(print_r($_FILES)); + // Logo + /* + if(isset($_FILES['file']['name']) && is_uploaded_file($_FILES['file']['tmp_name'])){ + //print_r($_FILES); + + $path= $_FILES['file']['tmp_name']; + $type = pathinfo($path, PATHINFO_EXTENSION); + $data = file_get_contents($path); + $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); + $app->db->query("UPDATE sys_ini SET custom_logo = ? WHERE sysini_id = ?", $base64, $this->id); + } + */ // Maintenance mode if($server_config_array['misc']['maintenance_mode'] == 'y'){ //print_r($_SESSION); //echo $_SESSION['s']['id']; - $app->db->query("DELETE FROM sys_session WHERE session_id != '".$app->db->quote($_SESSION['s']['id'])."'"); + $app->db->query("DELETE FROM sys_session WHERE session_id != ?", $_SESSION['s']['id']); } } - - /* - function onAfterUpdate() { - if($this->_js_changed == true) { - // not the best way, but it works - header('Content-Type: text/html'); - print ''; - exit; - } - } - */ - } $app->tform_actions = new page_action; diff --git a/interface/web/admin/templates/directive_snippets_edit.htm b/interface/web/admin/templates/directive_snippets_edit.htm index 7a17cb679e79a28e96a911b15c730a3c8d7de875..21b76867ec12d468ff7371222951e1ef809276aa 100644 --- a/interface/web/admin/templates/directive_snippets_edit.htm +++ b/interface/web/admin/templates/directive_snippets_edit.htm @@ -1,41 +1,49 @@ -

+

-
- -
-
-
- - -
-
- -
+
+ +
+
+
+
+ +
  {tmpl_var name='variables_txt'}: {DOCROOT}, {FASTCGIPASS}
-
- -   {tmpl_var name='variables_txt'}: {DOCROOT}, {FASTCGIPASS} +
+ +
+ {tmpl_var name='required_php_snippets'} +
+
+
+ +
+ {tmpl_var name='customer_viewable'} +
-
-

{tmpl_var name='active_txt'}

-
+
+ +
{tmpl_var name='active'}
- + -
- - -
-
- -
+
+ + +
\ No newline at end of file diff --git a/interface/web/admin/templates/system_config_sites_edit.htm b/interface/web/admin/templates/system_config_sites_edit.htm index 7811b17550091c2c00b88b045eece5439bf399e1..711d4333b08193e6d412377996d482275098274e 100644 --- a/interface/web/admin/templates/system_config_sites_edit.htm +++ b/interface/web/admin/templates/system_config_sites_edit.htm @@ -1,88 +1,84 @@ -

+

-
- -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='dblist_phpmyadmin_link_txt'}

-
+ + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='dblist_phpmyadmin_link'}
-
- -  {tmpl_var name='phpmyadmin_url_note_txt'} [SERVERNAME], [DATABASENAME] -
-
- - +
+ +
 {tmpl_var name='phpmyadmin_url_note_txt'}
[SERVERNAME], [DATABASENAME]
-
-

{tmpl_var name='vhost_subdomains_txt'}

-
+
+ +
+
+ +
{tmpl_var name='vhost_subdomains'} {tmpl_var name='vhost_subdomains_note_txt'}
-
-

{tmpl_var name='vhost_aliasdomains_txt'}

-
+
+ +
{tmpl_var name='vhost_aliasdomains'} {tmpl_var name='vhost_aliasdomains_note_txt'}
-
-

{tmpl_var name='client_username_web_check_disabled_txt'}

-
+
+ +
{tmpl_var name='client_username_web_check_disabled'}
-
-

{tmpl_var name='reseller_can_use_options_txt'}

-
+
+ +
+ {tmpl_var name='backups_include_into_web_quota'} +
+
+
+ +
{tmpl_var name='reseller_can_use_options'}
-
- - {tmpl_var name='default_webserver'} - +
-
- - {tmpl_var name='default_dbserver'} - +
-
-
- - -
-
- -
+
+ + +
diff --git a/interface/web/admin/templates/tpl_default_basic.htm b/interface/web/admin/templates/tpl_default_basic.htm index a52533165d067444bd23318e2dccad24af2a92d0..29772bcf9db802d1c0f74c01c5bf148975865cc1 100644 --- a/interface/web/admin/templates/tpl_default_basic.htm +++ b/interface/web/admin/templates/tpl_default_basic.htm @@ -1,23 +1,20 @@ -

+

-
-
-
-
- - 152x46px -
-
+ +
+ +
152x46px +
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/admin/templates/users_groups_edit.htm b/interface/web/admin/templates/users_groups_edit.htm index 3d3644dba2db9fa907bf14a22a85a3c0a79daa75..5f09bfa8eaa4081b7244162f73e45c2c933b975f 100644 --- a/interface/web/admin/templates/users_groups_edit.htm +++ b/interface/web/admin/templates/users_groups_edit.htm @@ -1,30 +1,27 @@ -

+

-
- -
-
-
- - {tmpl_var name='default_group'} - +
-
-

{tmpl_var name='groups_txt'}

-
+
+ +
{tmpl_var name='groups'}
- + -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/admin/templates/users_list.htm b/interface/web/admin/templates/users_list.htm index cac25f54e7c6edc7ba3e5784a54413dc12826d55..b7872527ff8127187f45053de94ce15963ac5760 100644 --- a/interface/web/admin/templates/users_list.htm +++ b/interface/web/admin/templates/users_list.htm @@ -1,51 +1,49 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- +

{tmpl_var name="toolsarea_head_txt"}

+ +

-
-
-
+ + -
-
- - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + - - - - - - + + + + + - - - - - - + + + + + @@ -58,11 +56,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="client_id"}{tmpl_var name="active"}
{tmpl_var name="typ"}
{tmpl_var name="groups"} +
{tmpl_var name="client_id"}{tmpl_var name="active"}
{tmpl_var name="typ"}
{tmpl_var name="groups"} - {tmpl_var name='login_as_txt'} - {tmpl_var name='delete_txt'} + +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/admin/templates/users_user_edit.htm b/interface/web/admin/templates/users_user_edit.htm index b973a34b7922635afa0f781972c6b0d2bdeada9d..e0d7c839a5ca8aa551961f0ed660e4d9511fec4e 100644 --- a/interface/web/admin/templates/users_user_edit.htm +++ b/interface/web/admin/templates/users_user_edit.htm @@ -1,73 +1,74 @@ -

+

-
- -
-
-
- - -
-
- -  {tmpl_var name='generate_password_txt'} + + +
+ +
+
+ +
 
{tmpl_var name='generate_password_txt'}
-
-

{tmpl_var name='password_strength_txt'}

+
+

 

-
- - -
+
+ +
-
-

{tmpl_var name='modules_txt'}

-
+
+ +
{tmpl_var name='modules'}
-
- - {tmpl_var name='startmodule'} - +
-
-

{tmpl_var name='app_theme_txt'}

-
+
+ +
{tmpl_var name='app_theme'}
-
-

{tmpl_var name='typ_txt'}

-
+
+ +
{tmpl_var name='typ'}
-
-

{tmpl_var name='active_txt'}

-
+
+ +
{tmpl_var name='active'}
-
- - {tmpl_var name='language'} - +
+
+
+ +
+ {tmpl_var name='lost_password_function'} +
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
diff --git a/interface/web/admin/tpl_default.php b/interface/web/admin/tpl_default.php index 57395cfb285436e69945474389d9be203545db90..c7b79112ca4cbf015637e94d662e7f8eeaafcd41 100644 --- a/interface/web/admin/tpl_default.php +++ b/interface/web/admin/tpl_default.php @@ -51,21 +51,6 @@ $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); - // } - // } } $page = new page_action; diff --git a/interface/web/admin/users_edit.php b/interface/web/admin/users_edit.php index 0a14ca5e1e4e30bf11480d8d5f504f4874396876..e3919649b934644a5eafcd2da22546314885d154 100644 --- a/interface/web/admin/users_edit.php +++ b/interface/web/admin/users_edit.php @@ -96,23 +96,23 @@ class page_action extends tform_actions { function onAfterUpdate() { global $app, $conf; - $client = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = ".$this->id); + $client = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE userid = ?", $this->id); $client_id = $app->functions->intval($client['client_id']); - $username = $app->db->quote($this->dataRecord["username"]); - $old_username = $app->db->quote($this->oldDataRecord['username']); + $username = $this->dataRecord["username"]; + $old_username = $this->oldDataRecord['username']; // username changed if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['username']) && $this->dataRecord['username'] != '' && $this->oldDataRecord['username'] != $this->dataRecord['username']) { - $sql = "UPDATE client SET username = '$username' WHERE client_id = $client_id AND username = '$old_username'"; - $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']); + $sql = "UPDATE client SET username = ? WHERE client_id = ? AND username = ?"; + $app->db->query($sql, $username, $client_id, $old_username); + $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = ?", $client_id); + $app->db->datalogUpdate("sys_group", array("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"]); + $password = $this->dataRecord["passwort"]; $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n=0;$n<8;$n++) { @@ -120,28 +120,17 @@ class page_action extends tform_actions { } $salt.="$"; $password = crypt(stripslashes($password), $salt); - $sql = "UPDATE client SET password = '$password' WHERE client_id = $client_id AND username = '$username'"; - $app->db->query($sql); + $sql = "UPDATE client SET password = ? WHERE client_id = ? AND username = ?"; + $app->db->query($sql, $password, $client_id, $username); } // 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); + $language = $this->dataRecord["language"]; + $sql = "UPDATE client SET language = ? WHERE client_id = ? AND username = ?"; + $app->db->query($sql, $language, $client_id, $username); } - // reseller status changed - /* - if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) { - $modules = $conf['interface_modules_enabled']; - if($this->dataRecord["limit_client"] > 0) $modules .= ',client'; - $modules = $app->db->quote($modules); - $client_id = $this->id; - $sql = "UPDATE sys_user SET modules = '$modules' WHERE client_id = $client_id"; - $app->db->query($sql); - } - */ parent::onAfterUpdate(); } diff --git a/interface/web/capp.php b/interface/web/capp.php index 2c143180f0cb24f459c53757af4f5a158a3346cd..39392691f8908276dd660d63988b387dee9320d7 100644 --- a/interface/web/capp.php +++ b/interface/web/capp.php @@ -43,6 +43,7 @@ if($_SESSION["s"]["user"]['active'] != 1) { } if(!preg_match("/^[a-z]{2,20}$/i", $mod)) die('module name contains unallowed chars.'); +if($redirect != '' && !preg_match("/^[a-z0-9]+\/[a-z0-9_\.\-]+\?id=[0-9]{1,9}$/i", $redirect)) die('redirect contains unallowed chars.'); //* Check if user may use the module. $user_modules = explode(",", $_SESSION["s"]["user"]["modules"]); diff --git a/interface/web/client/client_del.php b/interface/web/client/client_del.php index a8cd7cc954749bbb3ca8809c3763177f2f06206b..3e0d6bccb3152e475d7bdc29422c8fdfa456581c 100644 --- a/interface/web/client/client_del.php +++ b/interface/web/client/client_del.php @@ -74,11 +74,7 @@ class page_action extends tform_actions { $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"); + $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'; @@ -89,7 +85,7 @@ class page_action extends tform_actions { 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); + $records = $app->db->queryAllRecords("SELECT * FROM ?? WHERE sys_groupid = ?", $table, $client_group_id); $number = count($records); if($number > 0) $table_list[] = array('table' => $table."(".$number.")"); } @@ -121,15 +117,15 @@ class page_action extends tform_actions { 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"); + $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']); // delete the group of the client - $app->db->query("DELETE FROM sys_group WHERE client_id = $client_id"); + $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"); + $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'; @@ -138,7 +134,7 @@ class page_action extends tform_actions { 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); + $records = $app->db->queryAllRecords("SELECT * FROM ?? WHERE sys_groupid = ?", $table, $client_group_id); //* find the primary ID of the table $table_info = $app->db->tableInfo($table); $index_field = ''; @@ -152,11 +148,11 @@ class page_action extends tform_actions { $app->db->datalogDelete($table, $index_field, $rec[$index_field]); //* Delete traffic records that dont have a sys_groupid column if($table == 'web_domain') { - $app->db->query("DELETE FROM web_traffic WHERE hostname = '".$app->db->quote($rec['domain'])."'"); + $app->db->query("DELETE FROM web_traffic WHERE hostname = ?", $rec['domain']); } //* Delete mail_traffic records that dont have a sys_groupid if($table == 'mail_user') { - $app->db->query("DELETE FROM mail_traffic WHERE mailuser_id = '".$app->db->quote($rec['mailuser_id'])."'"); + $app->db->query("DELETE FROM mail_traffic WHERE mailuser_id = ?", $rec['mailuser_id']); } } } diff --git a/interface/web/client/client_edit.php b/interface/web/client/client_edit.php index 5c47fe5fa187c071ac50ffbee1cbda0f27b832ff..bbeb82223a5782401d138ba3ee47fe051d647deb 100644 --- a/interface/web/client/client_edit.php +++ b/interface/web/client/client_edit.php @@ -59,11 +59,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $app->functions->intval($_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"); + $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"); + $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id); if($tmp["number"] >= $client["limit_client"]) { $app->error($app->tform->wordbook["limit_client_txt"]); } @@ -82,11 +82,11 @@ class page_action extends tform_actions { // 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"); + $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"); + $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id); if($tmp["number"] >= $client["limit_client"]) { $app->error($app->tform->wordbook["limit_client_txt"]); } @@ -103,7 +103,7 @@ 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); + $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']); @@ -140,7 +140,7 @@ class page_action extends tform_actions { $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); + $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(); @@ -166,8 +166,8 @@ class page_action extends tform_actions { unset($tmprec); } else { // old style - $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id; - $result = $app->db->queryOneRecord($sql); + $sql = "SELECT template_additional FROM client WHERE client_id = ?"; + $result = $app->db->queryOneRecord($sql, $this->id); $tplAdd = explode("/", $result['template_additional']); $text = ''; foreach($tplAdd as $item){ @@ -196,31 +196,18 @@ class page_action extends tform_actions { $customer_no = $app->functions->intval($system_config['misc']['customer_no_start']+$system_config['misc']['customer_no_counter']); $customer_no_string = str_replace('[CUSTOMER_NO]',$customer_no,$system_config['misc']['customer_no_template']); $app->tpl->setVar('customer_no',$customer_no_string); - - //* save new counter value - /* - $system_config['misc']['customer_no_counter']++; - $system_config_str = $app->ini_parser->get_ini_string($system_config); - $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1); - */ } } else { //* Logged in user must be a reseller //* get the record of the reseller $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id); + $reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id); if($reseller['customer_no_template'] != '') { //* Set customer no default $customer_no = $app->functions->intval($reseller['customer_no_start']+$reseller['customer_no_counter']); $customer_no_string = str_replace('[CUSTOMER_NO]',$customer_no,$reseller['customer_no_template']); $app->tpl->setVar('customer_no',$customer_no_string); - - //* save new counter value - /* - $customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1); - $app->db->query("UPDATE client SET customer_no_counter = $customer_no_counter WHERE client_id = ".$app->functions->intval($reseller['client_id'])); - */ } } } @@ -254,42 +241,42 @@ class page_action extends tform_actions { function onAfterInsert() { global $app, $conf; // 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'); + $groupid = $app->db->datalogInsert('sys_group', array("name" => $this->dataRecord["username"], "description" => '', "client_id" => $this->id), 'groupid'); $groups = $groupid; - $username = $app->db->quote($this->dataRecord["username"]); - $password = $app->db->quote($this->dataRecord["password"]); + $username = $this->dataRecord["username"]; + $password = $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'; - $usertheme = $app->db->quote($this->dataRecord["usertheme"]); + $usertheme = $this->dataRecord["usertheme"]; $type = 'user'; $active = 1; - $language = $app->db->quote($this->dataRecord["language"]); + $language = $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); + $app->db->query("UPDATE client SET created_at = UNIX_TIMESTAMP(), id_rsa = ?, ssh_rsa = ? WHERE client_id = ?", @file_get_contents('/tmp/id_rsa'), @file_get_contents('/tmp/id_rsa.pub'), $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); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + $app->db->query($sql, $username, $password, $modules, $startmodule, $usertheme, $type, $active, $language, $groups, $groupid, $this->id); //* 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->db->query("UPDATE client SET parent_client_id = ".$app->functions->intval($_SESSION['s']['user']['client_id'])." WHERE client_id = ".$this->id); + $app->db->query("UPDATE client SET parent_client_id = ? WHERE client_id = ?", $_SESSION['s']['user']['client_id'], $this->id); } else { if($this->dataRecord['parent_client_id'] > 0) { //* get userid of the reseller and add it to the group of the client - $tmp = $app->db->queryOneRecord("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ".$app->functions->intval($this->dataRecord['parent_client_id'])); + $tmp = $app->db->queryOneRecord("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ?", $this->dataRecord['parent_client_id']); $app->auth->add_group_to_user($tmp['userid'], $groupid); - $app->db->query("UPDATE client SET parent_client_id = ".$app->functions->intval($this->dataRecord['parent_client_id'])." WHERE client_id = ".$this->id); + $app->db->query("UPDATE client SET parent_client_id = ? WHERE client_id = ?", $this->dataRecord['parent_client_id'], $this->id); unset($tmp); } } @@ -319,8 +306,8 @@ class page_action extends tform_actions { $default_dnsserver = $app->functions->intval($tmp['server_id']); } - $sql = "UPDATE client SET mail_servers = $default_mailserver, web_servers = $default_webserver, dns_servers = $default_dnsserver, default_slave_dnsserver = $default_dnsserver, db_servers = $default_dbserver WHERE client_id = ".$this->id; - $app->db->query($sql); + $sql = "UPDATE client SET mail_servers = ?, web_servers = ?, dns_servers = ?, default_slave_dnsserver = ?, db_servers = ? WHERE client_id = ?"; + $app->db->query($sql, $default_mailserver, $default_webserver, $default_dnsserver, $default_dnsserver, $default_dbserver, $this->id); if(isset($this->dataRecord['template_master'])) { $app->uses('client_templates'); @@ -338,26 +325,26 @@ class page_action extends tform_actions { //* save new counter value $system_config['misc']['customer_no_counter']++; $system_config_str = $app->ini_parser->get_ini_string($system_config); - $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1); + $app->db->datalogUpdate('sys_ini', array("config" => $system_config_str), 'sysini_id', 1); } } else { //* Logged in user must be a reseller //* get the record of the reseller $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id); + $reseller = $app->db->queryOneRecord("SELECT client.client_id, client.customer_no_template, client.customer_no_counter, client.customer_no_start FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id); if($reseller['customer_no_template'] != '') { //* save new counter value $customer_no_counter = $app->functions->intval($reseller['customer_no_counter']+1); - $app->db->query("UPDATE client SET customer_no_counter = $customer_no_counter WHERE client_id = ".$app->functions->intval($reseller['client_id'])); + $app->db->query("UPDATE client SET customer_no_counter = ? WHERE client_id = ?", $customer_no_counter, $reseller['client_id']); } } } //* Send welcome email $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ".$client_group_id; - $email_template = $app->db->queryOneRecord($sql); + $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ?"; + $email_template = $app->db->queryOneRecord($sql, $client_group_id); $client = $app->tform->getDataRecord($this->id); if(is_array($email_template) && $client['email'] != '') { @@ -387,7 +374,7 @@ class page_action extends tform_actions { $from = $system_config['admin_mail']; } else { $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id); + $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id); $from = $reseller["email"]; } @@ -408,19 +395,19 @@ class page_action extends tform_actions { 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"]); + $username = $this->dataRecord["username"]; $client_id = $this->id; - $sql = "UPDATE sys_user SET username = '$username' WHERE client_id = $client_id"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET username = ? WHERE client_id = ?"; + $app->db->query($sql, $username, $client_id); - $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = $client_id"); - $app->db->datalogUpdate("sys_group", "name = '$username'", 'groupid', $tmp['groupid']); + $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = ?", $client_id); + $app->db->datalogUpdate("sys_group", array("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"]); + $password = $this->dataRecord["password"]; $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; for ($n=0;$n<8;$n++) { @@ -429,8 +416,8 @@ class page_action extends tform_actions { $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); + $sql = "UPDATE sys_user SET passwort = ? WHERE client_id = ?"; + $app->db->query($sql, $password, $client_id); } if(!isset($this->dataRecord['locked'])) $this->dataRecord['locked'] = 'n'; @@ -439,7 +426,7 @@ class page_action extends tform_actions { // get tmp_data of client - $client_data = $app->db->queryOneRecord('SELECT `tmp_data` FROM `client` WHERE `client_id` = ' . $this->id); + $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']); @@ -463,8 +450,8 @@ class page_action extends tform_actions { '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); + $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']; @@ -486,7 +473,7 @@ class page_action extends tform_actions { if(!isset($prev_active[$current])) $prev_active[$current] = array(); if(!isset($prev_sysuser[$current])) $prev_sysuser[$current] = array(); - $entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id`, `sys_userid`, `' . $active_col . '` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid); + $entries = $app->db->queryAllRecords('SELECT ?? as `id`, `sys_userid`, ?? FROM ?? WHERE `sys_groupid` = ?', $keycolumn, $active_col, $current, $sys_groupid); foreach($entries as $item) { if($item[$active_col] != 'y' && $reverse == false) $prev_active[$current][$item['id']][$active_col] = 'n'; @@ -500,7 +487,7 @@ class page_action extends tform_actions { $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); + $app->db->query("UPDATE `client` SET `tmp_data` = ? WHERE `client_id` = ?", serialize($tmp_data), $this->id); unset($prev_active); unset($prev_sysuser); } elseif($this->dataRecord['locked'] == 'n') { @@ -515,7 +502,7 @@ class page_action extends tform_actions { $reverse = true; } - $entries = $app->db->queryAllRecords('SELECT `' . $keycolumn . '` as `id` FROM `' . $current . '` WHERE `sys_groupid` = ' . $sys_groupid); + $entries = $app->db->queryAllRecords('SELECT ?? as `id` FROM ?? WHERE `sys_groupid` = ?', $keycolumn, $current, $sys_groupid); foreach($entries as $item) { $set_active = ($reverse == true ? 'n' : 'y'); $set_inactive = ($reverse == true ? 'y' : 'n'); @@ -533,7 +520,7 @@ class page_action extends tform_actions { } } 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); + $app->db->query("UPDATE `client` SET `tmp_data` = ? WHERE `client_id` = ?", serialize($tmp_data), $this->id); } unset($tmp_data); unset($entries); @@ -543,43 +530,42 @@ class page_action extends tform_actions { 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); + $sql = "UPDATE sys_user SET active = '0' WHERE client_id = ?"; + $app->db->query($sql, $this->id); } elseif($this->dataRecord['canceled'] == 'n') { - $sql = "UPDATE sys_user SET active = '1' WHERE client_id = " . $this->id; - $app->db->query($sql); + $sql = "UPDATE sys_user SET active = '1' WHERE client_id = ?"; + $app->db->query($sql, $this->id); } } // 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"]); + $language = $this->dataRecord["language"]; $client_id = $this->id; - $sql = "UPDATE sys_user SET language = '$language' WHERE client_id = $client_id"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET language = ? WHERE client_id = ?"; + $app->db->query($sql, $language, $client_id); } //* reseller status changed if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) { $modules = $conf['interface_modules_enabled']; if($this->dataRecord["limit_client"] > 0) $modules .= ',client'; - $modules = $app->db->quote($modules); $client_id = $this->id; - $sql = "UPDATE sys_user SET modules = '$modules' WHERE client_id = $client_id"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET modules = ? WHERE client_id = ?"; + $app->db->query($sql, $modules, $client_id); } //* Client has been moved to another reseller if($_SESSION['s']['user']['typ'] == 'admin' && isset($this->dataRecord['parent_client_id']) && $this->dataRecord['parent_client_id'] != $this->oldDataRecord['parent_client_id']) { //* Get groupid of the client - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".intval($this->id)); + $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $this->id); $groupid = $tmp['groupid']; unset($tmp); //* Remove sys_user of old reseller from client group if($this->oldDataRecord['parent_client_id'] > 0) { //* get userid of the old reseller remove it from the group of the client - $tmp = $app->db->queryOneRecord("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ".$app->functions->intval($this->oldDataRecord['parent_client_id'])); + $tmp = $app->db->queryOneRecord("SELECT sys_user.userid FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ?", $this->oldDataRecord['parent_client_id']); $app->auth->remove_group_from_user($tmp['userid'], $groupid); unset($tmp); } @@ -587,13 +573,13 @@ class page_action extends tform_actions { //* Add sys_user of new reseller to client group if($this->dataRecord['parent_client_id'] > 0) { //* get userid of the reseller and add it to the group of the client - $tmp = $app->db->queryOneRecord("SELECT sys_user.userid, sys_user.default_group FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ".$app->functions->intval($this->dataRecord['parent_client_id'])); + $tmp = $app->db->queryOneRecord("SELECT sys_user.userid, sys_user.default_group FROM sys_user,sys_group WHERE sys_user.default_group = sys_group.groupid AND sys_group.client_id = ?", $this->dataRecord['parent_client_id']); $app->auth->add_group_to_user($tmp['userid'], $groupid); - $app->db->query("UPDATE client SET sys_userid = ".$app->functions->intval($tmp['userid']).", sys_groupid = ".$app->functions->intval($tmp['default_group']).", parent_client_id = ".$app->functions->intval($this->dataRecord['parent_client_id'])." WHERE client_id = ".$this->id); + $app->db->query("UPDATE client SET sys_userid = ?, sys_groupid = ?, parent_client_id = ? WHERE client_id = ?", $tmp['userid'], $tmp['default_group'], $this->dataRecord['parent_client_id'], $this->id); unset($tmp); } else { //* Client is not assigned to a reseller anymore, so we assign it to the admin - $app->db->query("UPDATE client SET sys_userid = 1, sys_groupid = 1, parent_client_id = 0 WHERE client_id = ".$this->id); + $app->db->query("UPDATE client SET sys_userid = 1, sys_groupid = 1, parent_client_id = 0 WHERE client_id = ?", $this->id); } } diff --git a/interface/web/client/client_list.php b/interface/web/client/client_list.php index 7d092177105f9770ba528549b49629dfb22afe26..43cc028b5ba5ff1b719bfa58782d4596af15a46a 100644 --- a/interface/web/client/client_list.php +++ b/interface/web/client/client_list.php @@ -19,7 +19,7 @@ $app->uses('listform_actions'); $app->listform_actions->SQLOrderBy = 'ORDER BY client.company_name, client.contact_name, client.client_id'; $app->listform_actions->SQLExtWhere = "client.limit_client = 0"; -$app->listform_actions->SQLExtSelect = ', client.country as countryiso'; +$app->listform_actions->SQLExtSelect = ', LOWER(client.country) as countryiso'; $app->listform_actions->onLoad(); diff --git a/interface/web/client/client_message.php b/interface/web/client/client_message.php index 5707e88206be5b02ffe24d8be088f3d14d184b2b..0e3bd2e9fec9f0885eac5b11baf5fd949266534c 100644 --- a/interface/web/client/client_message.php +++ b/interface/web/client/client_message.php @@ -60,7 +60,7 @@ if(isset($_POST) && count($_POST) > 1) { //* 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')); + $circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ? AND ".$app->tform->getAuthSQL('r'), $_POST['recipient']); if(isset($circle['client_ids']) && $circle['client_ids'] != ''){ $tmp_client_ids = explode(',', $circle['client_ids']); $where = array(); @@ -120,8 +120,8 @@ if(isset($_POST) && count($_POST) > 1) { if($_SESSION["s"]["user"]["typ"] != 'admin'){ $client_id = $app->functions->intval($_SESSION['s']['user']['client_id']); if($client_id > 0){ - $sql = "SELECT email FROM client WHERE client_id = ".$client_id; - $client = $app->db->queryOneRecord($sql); + $sql = "SELECT email FROM client WHERE client_id = ?"; + $client = $app->db->queryOneRecord($sql, $client_id); if($client['email'] != '') $app->tpl->setVar('sender', $client['email']); } } diff --git a/interface/web/client/client_template_del.php b/interface/web/client/client_template_del.php index b57224f8ebfd3d73f4852f5f5185491a49f4ad16..12883546020b88afe12c9768603a76604dc508bf 100644 --- a/interface/web/client/client_template_del.php +++ b/interface/web/client/client_template_del.php @@ -54,13 +54,13 @@ class page_action extends tform_actions { 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 - $rec = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE template_master = ".$this->id." OR template_additional like '%/".$this->id."/%'"); + $rec = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE template_master = ? OR template_additional like ?", $this->id, '%/".$this->id."/%'); if($rec['number'] > 0) { $app->error($app->tform->lng('template_del_aborted_txt')); } diff --git a/interface/web/client/client_template_edit.php b/interface/web/client/client_template_edit.php index 256ff49732350fbd23ef1255659fe28381f5211b..a895105ef6921eed10501e6a8b6f2ced47e9756c 100644 --- a/interface/web/client/client_template_edit.php +++ b/interface/web/client/client_template_edit.php @@ -69,7 +69,7 @@ class page_action extends tform_actions { 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); + $rec = $app->db->queryOneRecord("SELECT template_type from client_template WHERE template_id = ?", $this->id); if($rec['template_type'] != $this->dataRecord['template_type']) { //* Add a error message and switch back to old server $app->tform->errorMessage .= $app->lng('The template type can not be changed.'); @@ -99,11 +99,12 @@ class page_action extends tform_actions { * the template has changed. apply the new data to all clients */ if ($template_type == 'm'){ - $sql = "SELECT client_id FROM client WHERE template_master = " . $this->id; + $sql = "SELECT client_id FROM client WHERE template_master = ?"; + $clients = $app->db->queryAllRecords($sql, $this->id); } else { - $sql = "SELECT client_id FROM client WHERE template_additional LIKE '%/" . $this->id . "/%' OR template_additional LIKE '" . $this->id . "/%' OR template_additional LIKE '%/" . $this->id . "' UNION SELECT client_id FROM client_template_assigned WHERE client_template_id = " . $this->id; + $sql = "SELECT client_id FROM client WHERE template_additional LIKE ? OR template_additional LIKE ? OR template_additional LIKE ? UNION SELECT client_id FROM client_template_assigned WHERE client_template_id = ?"; + $clients = $app->db->queryAllRecords($sql, '%/' . $this->id . '/%', $this->id . '/%', '%/' . $this->id, $this->id); } - $clients = $app->db->queryAllRecords($sql); if (is_array($clients)){ foreach ($clients as $client){ $app->client_templates->apply_client_templates($client['client_id']); diff --git a/interface/web/client/domain_del.php b/interface/web/client/domain_del.php index 6bc07e60ddebfd823adf6933e4bc8d113bcc97ff..701b4494b8f92a1885a45ca750931a1f30a852f2 100644 --- a/interface/web/client/domain_del.php +++ b/interface/web/client/domain_del.php @@ -62,26 +62,26 @@ class page_action extends tform_actions { */ $domain = $this->dataRecord['domain']; - $sql = "SELECT id FROM dns_soa WHERE origin = '" . $app->db->quote($domain.".") . "'"; - $res = $app->db->queryOneRecord($sql); + $sql = "SELECT id FROM dns_soa WHERE origin = ?"; + $res = $app->db->queryOneRecord($sql, $domain."."); if (is_array($res)){ $app->error($wb['error_domain_in dnsuse']); } - $sql = "SELECT id FROM dns_slave WHERE origin = '" . $app->db->quote($domain.".") . "'"; - $res = $app->db->queryOneRecord($sql); + $sql = "SELECT id FROM dns_slave WHERE origin = ?"; + $res = $app->db->queryOneRecord($sql, $domain."."); if (is_array($res)){ $app->error($wb['error_domain_in dnsslaveuse']); } - $sql = "SELECT domain_id FROM mail_domain WHERE domain = '" . $app->db->quote($domain) . "'"; - $res = $app->db->queryOneRecord($sql); + $sql = "SELECT domain_id FROM mail_domain WHERE domain = ?"; + $res = $app->db->queryOneRecord($sql, $domain); if (is_array($res)){ $app->error($wb['error_domain_in mailuse']); } - $sql = "SELECT domain_id FROM web_domain WHERE (domain = '" . $app->db->quote($domain) . "' AND type IN ('alias', 'vhost', 'vhostalias')) OR (domain LIKE '%." . $app->db->quote($domain) . "' AND type IN ('subdomain', 'vhostsubdomain'))"; - $res = $app->db->queryOneRecord($sql); + $sql = "SELECT domain_id FROM web_domain WHERE (domain = ? AND type IN ('alias', 'vhost', 'vhostalias')) OR (domain LIKE ? AND type IN ('subdomain', 'vhostsubdomain'))"; + $res = $app->db->queryOneRecord($sql, $domain, '%.' . $domain); if (is_array($res)){ $app->error($wb['error_domain_in webuse']); } diff --git a/interface/web/client/domain_edit.php b/interface/web/client/domain_edit.php index 889bb4f4bdf2966be36002dd4df78e3dfb7aff6f..9064581c17396cd64623157bf83040c2f6403882 100644 --- a/interface/web/client/domain_edit.php +++ b/interface/web/client/domain_edit.php @@ -97,13 +97,13 @@ class page_action extends tform_actions { } else { // Get the limits of the client $client_group_id = $app->functions->intval($_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"); + $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 client.company_name, client.contact_name, sys_group.name"; + $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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; //die($sql); - $records = $app->db->queryAllRecords($sql); - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client['client_id'])); + $records = $app->db->queryAllRecords($sql, $client['client_id']); + $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($records)) { @@ -197,7 +197,7 @@ class page_action extends tform_actions { // 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"])) || ($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid']))) { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); - $app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id); + $app->db->query("UPDATE domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $this->id); } } @@ -206,23 +206,23 @@ class page_action extends tform_actions { if($_SESSION["s"]["user"]["typ"] != 'admin' && isset($this->dataRecord["client_group_id"])) { $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); - $group = $app->db->queryOneRecord("SELECT sys_group.groupid FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ".$client['client_id']." AND sys_group.groupid = ".$this->dataRecord["client_group_id"]." ORDER BY client.company_name, client.contact_name, sys_group.name"); + $client = $app->db->queryOneRecord("SELECT client.client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); + $group = $app->db->queryOneRecord("SELECT sys_group.groupid FROM sys_group, client WHERE sys_group.client_id = client.client_id AND client.parent_client_id = ? AND sys_group.groupid = ? ORDER BY client.company_name, client.contact_name, sys_group.name", $client['client_id'], $this->dataRecord["client_group_id"]); $this->dataRecord["client_group_id"] = $group["groupid"]; - } + } // make sure that the record belongs to the client 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(isset($this->dataRecord["client_group_id"])) { $client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); - $app->db->query("UPDATE domain SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE domain_id = ".$this->id); + $app->db->query("UPDATE domain SET sys_groupid = ?, sys_perm_group = 'ru' WHERE domain_id = ?", $client_group_id, $this->id); $data = new tform_actions(); $tform = $app->tform; $app->tform = new tform(); $app->tform->loadFormDef("../dns/form/dns_soa.tform.php"); - $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin LIKE '".$this->dataRecord['domain'].".'"); + $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE origin = ?", $this->dataRecord['domain']."."); if ($data->oldDataRecord) { $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"])); $data->id = $data->dataRecord['id']; @@ -230,7 +230,7 @@ class page_action extends tform_actions { } $app->tform->loadFormDef("../dns/form/dns_slave.tform.php"); - $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_slave WHERE origin LIKE '".$this->dataRecord['domain'].".'"); + $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM dns_slave WHERE origin = ?", $this->dataRecord['domain']."."); if ($data->oldDataRecord) { $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"])); $data->id = $data->dataRecord['id']; @@ -238,7 +238,7 @@ class page_action extends tform_actions { } $app->tform->loadFormDef("../mail/form/mail_domain.tform.php"); - $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '".$this->dataRecord['domain']."'"); + $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = ?", $this->dataRecord['domain']); if ($data->oldDataRecord) { $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"])); $data->id = $data->dataRecord['domain_id']; @@ -246,7 +246,7 @@ class page_action extends tform_actions { } $app->tform->loadFormDef("../sites/form/web_vhost_domain.tform.php"); - $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '".$this->dataRecord['domain']."'"); + $data->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = ?", $this->dataRecord['domain']); if ($data->oldDataRecord) { $data->dataRecord = array_merge($data->oldDataRecord, array('client_group_id' => $this->dataRecord["client_group_id"])); $data->id = $data->dataRecord['domain_id']; diff --git a/interface/web/client/form/client.tform.php b/interface/web/client/form/client.tform.php index 362545256f54860e541716c93f0bc7a91c733a60..ef8ce33879ae59ca5dd67e514cf11864c2011757 100644 --- a/interface/web/client/form/client.tform.php +++ b/interface/web/client/form/client.tform.php @@ -116,7 +116,10 @@ $form["tabs"]['address'] = array ( 'maxlength' => '255', 'rows' => '', 'cols' => '', - 'searchable' => 1 + 'searchable' => 1, + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'TRIM'), + ), ), 'contact_name' => array ( 'datatype' => 'VARCHAR', @@ -131,7 +134,10 @@ $form["tabs"]['address'] = array ( 'maxlength' => '255', 'rows' => '', 'cols' => '', - 'searchable' => 1 + 'searchable' => 1, + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'TRIM'), + ), ), 'customer_no' => array ( 'datatype' => 'VARCHAR', @@ -367,7 +373,12 @@ $form["tabs"]['address'] = array ( 'width' => '30', 'maxlength' => '255', 'rows' => '', - 'cols' => '' + 'cols' => '', + 'validators' => array ( 0 => array ( 'type' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'check_vat_id', + 'errmsg'=> 'invalid_vat_id'), + ), ), 'company_id' => array ( 'datatype' => 'VARCHAR', @@ -768,6 +779,105 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'default_xmppserver' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'client_servers' + ), + 'value' => '', + 'name' => 'default_xmppserver' + ), + 'xmpp_servers' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'MULTIPLE', + 'separator' => ',', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'client_servers' + ), + 'validators' => array ( + 0 => array ( 'type' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'check_used_servers', + 'errmsg'=> 'xmpp_servers_used'), + ), + 'value' => '', + 'name' => 'xmpp_servers' + ), + 'limit_xmpp_domain' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_xmpp_domain_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_xmpp_user' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_xmpp_user_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_xmpp_muc' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_anon' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_vjud' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_proxy' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_status' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_pastebin' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_httparchive' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), 'default_webserver' => array ( 'datatype' => 'INTEGER', 'formtype' => 'SELECT', diff --git a/interface/web/client/form/client_template.tform.php b/interface/web/client/form/client_template.tform.php index b1fd7d350f5879365b5d79182843c07450613cad..21f85963ee84d3a0fd7940e09d51d03c22600fc0 100644 --- a/interface/web/client/form/client_template.tform.php +++ b/interface/web/client/form/client_template.tform.php @@ -322,6 +322,105 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'default_xmppserver' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'client_servers' + ), + 'value' => '', + 'name' => 'default_xmppserver' + ), + 'xmpp_servers' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'MULTIPLE', + 'separator' => ',', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'client_servers' + ), + 'validators' => array ( + 0 => array ( 'type' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'check_used_servers', + 'errmsg'=> 'xmpp_servers_used'), + ), + 'value' => '', + 'name' => 'xmpp_servers' + ), + 'limit_xmpp_domain' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_xmpp_domain_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_xmpp_user' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_xmpp_user_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_xmpp_muc' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_anon' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_vjud' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_proxy' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_status' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_pastebin' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_httparchive' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), 'default_webserver' => array ( 'datatype' => 'INTEGER', 'formtype' => 'SELECT', diff --git a/interface/web/client/form/reseller.tform.php b/interface/web/client/form/reseller.tform.php index 8efedf710d30fd7aaa84934c62ded69e21abac93..822e96ab72b488dfb92ca8ce0b75ef7ed3c1253f 100644 --- a/interface/web/client/form/reseller.tform.php +++ b/interface/web/client/form/reseller.tform.php @@ -116,7 +116,10 @@ $form["tabs"]['address'] = array ( 'maxlength' => '255', 'rows' => '', 'cols' => '', - 'searchable' => 1 + 'searchable' => 1, + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'TRIM'), + ), ), 'contact_name' => array ( 'datatype' => 'VARCHAR', @@ -131,7 +134,10 @@ $form["tabs"]['address'] = array ( 'maxlength' => '255', 'rows' => '', 'cols' => '', - 'searchable' => 1 + 'searchable' => 1, + 'filters' => array( 0 => array( 'event' => 'SAVE', + 'type' => 'TRIM'), + ), ), 'customer_no' => array ( 'datatype' => 'VARCHAR', @@ -364,7 +370,12 @@ $form["tabs"]['address'] = array ( 'width' => '30', 'maxlength' => '255', 'rows' => '', - 'cols' => '' + 'cols' => '', + 'validators' => array ( 0 => array ( 'type' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'check_vat_id', + 'errmsg'=> 'invalid_vat_id'), + ), ), 'company_id' => array ( 'datatype' => 'VARCHAR', @@ -764,6 +775,105 @@ $form["tabs"]['limits'] = array ( 'rows' => '', 'cols' => '' ), + 'default_xmppserver' => array ( + 'datatype' => 'INTEGER', + 'formtype' => 'SELECT', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'client_servers' + ), + 'value' => '', + 'name' => 'default_xmppserver' + ), + 'xmpp_servers' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'MULTIPLE', + 'separator' => ',', + 'default' => '1', + 'datasource' => array ( 'type' => 'CUSTOM', + 'class'=> 'custom_datasource', + 'function'=> 'client_servers' + ), + 'validators' => array ( + 0 => array ( 'type' => 'CUSTOM', + 'class' => 'validate_client', + 'function' => 'check_used_servers', + 'errmsg'=> 'xmpp_servers_used'), + ), + 'value' => '', + 'name' => 'xmpp_servers' + ), + 'limit_xmpp_domain' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_xmpp_domain_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_xmpp_user' => array( + 'datatype' => 'INTEGER', + 'formtype' => 'TEXT', + 'validators' => array ( 0 => array ( 'type' => 'ISINT', + 'errmsg'=> 'limit_xmpp_user_error_notint'), + ), + 'default' => '-1', + 'value' => '', + 'separator' => '', + 'width' => '10', + 'maxlength' => '10', + 'rows' => '', + 'cols' => '' + ), + 'limit_xmpp_muc' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_anon' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_vjud' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_proxy' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_status' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_pastebin' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), + 'limit_xmpp_httparchive' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'CHECKBOX', + 'default' => 'n', + 'value' => array(0 => 'n', 1 => 'y') + ), 'default_webserver' => array ( 'datatype' => 'INTEGER', 'formtype' => 'SELECT', diff --git a/interface/web/client/lib/lang/de_client.lng b/interface/web/client/lib/lang/de_client.lng index dbaa9a59647361775c61ca874be73b6556b30b6c..7ee7226d8cc780c7e6f22c35ac8effe9aa034c90 100644 --- a/interface/web/client/lib/lang/de_client.lng +++ b/interface/web/client/lib/lang/de_client.lng @@ -110,7 +110,7 @@ $wb['limit_webdav_user_error_notint'] = 'Das WebDAV Benutzer Limit muss eine Zah $wb['limit_backup_txt'] = 'Backupfunktion verfügbar'; $wb['limit_dns_slave_zone_error_notint'] = 'Das Secondary DNS Zonen Limit muss eine Zahl sein.'; $wb['customer_no_txt'] = 'Kundennummer'; -$wb['vat_id_txt'] = 'USt-ID'; +$wb['vat_id_txt'] = 'USt.-ID'; $wb['required_fields_txt'] = '* Benötigte Felder'; $wb['limit_mailmailinglist_txt'] = 'Max. Anzahl an Mailinglisten'; $wb['limit_mailmailinglist_error_notint'] = 'Das Mailinglisten Limit muss eine Zahl sein.'; @@ -151,8 +151,30 @@ $wb['canceled_txt'] = 'Gekündigt (verhindert Kundenlogin)'; $wb['gender_txt'] = 'Anrede'; $wb['gender_m_txt'] = 'Herr'; $wb['gender_f_txt'] = 'Frau'; +$wb["web_servers_txt"] = 'Webserver'; +$wb["web_servers_placeholder"] = 'Webserver auswählen'; +$wb['no_web_server_error'] = 'Bitte wählen Sie mind. einen Webserver aus.'; +$wb['web_servers_used'] = 'Der Server, den Sie entfernen möchten, wird als Webserver verwendet. Bitte stellen Sie sicher, daß dieser Server nicht von diesem Kunden benutzt wird, bevor Sie ihn entfernen.'; +$wb["dns_servers_txt"] = 'DNS-Server'; +$wb["dns_servers_placeholder"] = 'DNS-Server wählen'; +$wb['no_dns_server_error'] = 'Bitte wählen Sie mind. einen DNS-Server aus.'; +$wb['dns_servers_used'] = 'Der Server, den Sie entfernen möchten, wird als DNS-Server verwendet. Bitte stellen Sie sicher, daß dieser Server nicht von diesem Kunden benutzt wird, bevor Sie ihn entfernen.'; +$wb["db_servers_txt"] = 'Datenbank-Server'; +$wb["db_servers_placeholder"] = 'Datenbank-Server wählen'; +$wb['no_db_server_error'] = 'Bitte wählen Sie mind. einen Datenbank-Server aus.'; +$wb['db_servers_used'] = 'Der Server, den Sie entfernen möchten, wird als Datenbank-Server verwendet. Bitte stellen Sie sicher, daß dieser Server nicht von diesem Kunden benutzt wird, bevor Sie ihn entfernen.'; +$wb["mail_servers_txt"] = 'Mailserver'; +$wb["mail_servers_placeholder"] = 'Mailserver wählen'; +$wb['no_mail_server_error'] = 'Bitte wählen Sie mind. einen Mailserver aus.'; +$wb['mail_servers_used'] = 'Der Server, den Sie entfernen möchten, wird als Mailserver verwendet. Bitte stellen Sie sicher, daß dieser Server nicht von diesem Kunden benutzt wird, bevor Sie ihn entfernen.'; $wb['added_by_txt'] = 'Added by'; $wb['added_date_txt'] = 'Added date'; -$wb['parent_client_id_txt'] = 'Client of reseller'; -$wb['none_txt'] = 'none'; +$wb['parent_client_id_txt'] = 'Kunde von Reseller'; +$wb['none_txt'] = 'keiner'; +$wb['limit_database_quota_txt'] = 'Datenbank-Quota'; +$wb['limit_database_quota_error_notint'] = 'Das Datenbank-quota muß eine Nummer sein.'; +$wb['reseller_txt'] = 'Reseller'; +$wb['btn_save_txt'] = 'Speichern'; +$wb['btn_cancel_txt'] = 'Abbrechen'; +$wb['invalid_vat_id'] = 'Die USt.-ID ist ungültig.'; ?> diff --git a/interface/web/client/lib/lang/de_reseller.lng b/interface/web/client/lib/lang/de_reseller.lng index 1595e567b951dc4da9da07e1182984faf8aa4731..541b5d2dd18879d2c87f371d7565e610d18cbeb3 100644 --- a/interface/web/client/lib/lang/de_reseller.lng +++ b/interface/web/client/lib/lang/de_reseller.lng @@ -106,7 +106,7 @@ $wb['limit_dns_slave_zone_txt'] = 'Max. Anzahl an Secondary DNS Zonen'; $wb['limit_dns_slave_zone_error_notint'] = 'Das Secondary DNS Zonen Limit muss eine Zahl sein.'; $wb['limit_dns_record_error_notint'] = 'Das DNS Eintrag Limit muss eine Zahl sein.'; $wb['customer_no_txt'] = 'Kundennummer'; -$wb['vat_id_txt'] = 'USt-ID'; +$wb['vat_id_txt'] = 'USt.-ID'; $wb['required_fields_txt'] = '* Benötigte Felder'; $wb['limit_webdav_user_txt'] = 'Max. Anzahl an WebDAV Benutzern'; $wb['limit_webdav_user_error_notint'] = 'Das WebDAV Benutzer Limit muss eine Zahl sein.'; @@ -160,4 +160,5 @@ $wb['limit_domainmodule_error_notint'] = 'Domainmodule limit must be a number.'; $wb['limit_domainmodule_txt'] = 'Domainmodule Limit'; $wb['client_limits_txt'] = 'Client Limits'; $wb['err_msg_master_tpl_set'] = 'All custom limit settings are ignored if any master template other than \\"custom\\" is selected.'; +$wb['invalid_vat_id'] = 'Die USt.-ID ist ungültig.'; ?> diff --git a/interface/web/client/lib/lang/en_client.lng b/interface/web/client/lib/lang/en_client.lng index d14df622a35715c19c614f4e3b8d0df4d3cc2eb9..663d27615a74809285043ecf1dd8510ce1f5ecbf 100644 --- a/interface/web/client/lib/lang/en_client.lng +++ b/interface/web/client/lib/lang/en_client.lng @@ -132,6 +132,7 @@ $wb["bank_account_iban_txt"] = 'IBAN'; $wb["bank_account_swift_txt"] = 'BIC / Swift'; $wb["web_limits_txt"] = 'Web Limits'; $wb["email_limits_txt"] = 'Email Limits'; +$wb["xmpp_limits_txt"] = 'XMPP Limits'; $wb["database_limits_txt"] = 'Database Limits'; $wb["cron_job_limits_txt"] = 'Cron Job Limits'; $wb["dns_limits_txt"] = 'DNS Limits'; @@ -155,21 +156,39 @@ $wb['gender_txt'] = 'Title'; $wb['gender_m_txt'] = 'Mr.'; $wb['gender_f_txt'] = 'Ms.'; $wb["web_servers_txt"] = 'Webservers'; -$wb["web_servers_placeholder"] = 'Select Webservers'; +$wb["web_servers_placeholder"] = 'Select webservers'; $wb['no_web_server_error'] = 'At least one webserver must be selected.'; -$wb['web_servers_used'] = 'The server you are trying to remove from this client is used as a webserver. Be sure that this server is not used by this client before to remove it.'; -$wb["dns_servers_txt"] = 'DNS Server'; -$wb["dns_servers_placeholder"] = 'Select DNS Servers'; +$wb['web_servers_used'] = 'The server you are trying to remove from this client is used as a webserver. Be sure that this server is not used by this client before you remove it.'; +$wb["dns_servers_txt"] = 'DNS servers'; +$wb["dns_servers_placeholder"] = 'Select DNS servers'; $wb['no_dns_server_error'] = 'At least one DNS server must be selected.'; -$wb['dns_servers_used'] = 'The server you are trying to remove from this client is used as a DNS server. Be sure that this server is not used by this client before to remove it.'; -$wb["db_servers_txt"] = 'Database Server'; -$wb["db_servers_placeholder"] = 'Select Database Servers'; +$wb['dns_servers_used'] = 'The server you are trying to remove from this client is used as a DNS server. Be sure that this server is not used by this client before you remove it.'; +$wb["db_servers_txt"] = 'Database servers'; +$wb["db_servers_placeholder"] = 'Select database servers'; $wb['no_db_server_error'] = 'At least one Database server must be selected.'; -$wb['db_servers_used'] = 'The server you are trying to remove from this client is used as a Database server. Be sure that this server is not used by this client before to remove it.'; +$wb['db_servers_used'] = 'The server you are trying to remove from this client is used as a Database server. Be sure that this server is not used by this client before you remove it.'; $wb["mail_servers_txt"] = 'Mailservers'; -$wb["mail_servers_placeholder"] = 'Select Mailservers'; -$wb['no_mail_server_error'] = 'At least one Mailserver must be selected.'; -$wb['mail_servers_used'] = 'The server you are trying to remove from this client is used as a Mailserver. Be sure that this server is not used by this client before to remove it.'; +$wb["mail_servers_placeholder"] = 'Select mailservers'; +$wb['no_mail_server_error'] = 'At least one mailserver must be selected.'; +$wb['mail_servers_used'] = 'The server you are trying to remove from this client is used as a Mailserver. Be sure that this server is not used by this client before you remove it.'; + +$wb["xmpp_servers_txt"] = 'XMPP Servers'; +$wb["xmpp_servers_placeholder"] = 'Select XMPP Servers'; +$wb['no_xmpp_server_error'] = 'At least one XMPP Server must be selected.'; +$wb['xmpp_servers_used'] = 'The server you are trying to remove from this client is used as a XMPP Server. Be sure that this server is not used by this client before you remove it.'; +$wb['limit_xmpp_domain_error_notint'] = 'The XMPP domain limit must be a number.'; +$wb['limit_xmpp_user_error_notint'] = 'The XMPP user limit must be a number.'; +$wb['limit_xmpp_domain_txt'] = 'Max. number of XMPP domains'; +$wb['limit_xmpp_user_txt'] = 'Max. number of XMPP accounts'; +$wb['limit_xmpp_muc_txt'] = 'Multiuser chat available'; +$wb['limit_xmpp_pastebin_txt'] = 'Pastebin for MUC available'; +$wb['limit_xmpp_httparchive_txt'] = 'HTTP archive for MUC available'; +$wb['limit_xmpp_anon_txt'] = 'Anonymous host available'; +$wb['limit_xmpp_vjud_txt'] = 'VJUD user directory available'; +$wb['limit_xmpp_proxy_txt'] = 'Bytestream proxy available'; +$wb['limit_xmpp_status_txt'] = 'Status host available'; + + $wb['added_by_txt'] = 'Added by'; $wb['added_date_txt'] = 'Added date'; $wb['parent_client_id_txt'] = 'Client of reseller'; @@ -177,4 +196,7 @@ $wb['none_txt'] = 'none'; $wb['limit_database_quota_txt'] = 'Database quota'; $wb['limit_database_quota_error_notint'] = 'The database quota limit must be a number.'; $wb['reseller_txt'] = 'Reseller'; +$wb['btn_save_txt'] = "Save"; +$wb['btn_cancel_txt'] = "Cancel"; +$wb['invalid_vat_id'] = 'The VAT ID is invalid.'; ?> diff --git a/interface/web/client/lib/lang/en_client_template.lng b/interface/web/client/lib/lang/en_client_template.lng index 9aacf40319d5504ba998e4c61f5f95be318f8fcd..a65c1a514b2c278b2afe7436c09d250af909fd9a 100644 --- a/interface/web/client/lib/lang/en_client_template.lng +++ b/interface/web/client/lib/lang/en_client_template.lng @@ -98,4 +98,21 @@ $wb['limit_domainmodule_txt'] = 'Domainmodule Limit'; $wb['client_limits_txt'] = 'Client Limits'; $wb['limit_database_quota_txt'] = 'Database quota'; $wb['limit_database_quota_error_notint'] = 'The database quota limit must be a number.'; + +$wb["xmpp_limits_txt"] = 'XMPP Limits'; +$wb["xmpp_servers_txt"] = 'XMPP Servers'; +$wb["xmpp_servers_placeholder"] = 'Select XMPP Servers'; +$wb['no_xmpp_server_error'] = 'At least one XMPP Server must be selected.'; +$wb['xmpp_servers_used'] = 'The server you are trying to remove from this client is used as a XMPP Server. Be sure that this server is not used by this client before you remove it.'; +$wb['limit_xmpp_domain_error_notint'] = 'The XMPP domain limit must be a number.'; +$wb['limit_xmpp_user_error_notint'] = 'The XMPP user limit must be a number.'; +$wb['limit_xmpp_domain_txt'] = 'Max. number of XMPP domains'; +$wb['limit_xmpp_user_txt'] = 'Max. number of XMPP accounts'; +$wb['limit_xmpp_muc_txt'] = 'Multiuser chat available'; +$wb['limit_xmpp_pastebin_txt'] = 'Pastebin for MUC available'; +$wb['limit_xmpp_httparchive_txt'] = 'HTTP archive for MUC available'; +$wb['limit_xmpp_anon_txt'] = 'Anonymous host available'; +$wb['limit_xmpp_vjud_txt'] = 'VJUD user directory available'; +$wb['limit_xmpp_proxy_txt'] = 'Bytestream proxy available'; +$wb['limit_xmpp_status_txt'] = 'Status host available'; ?> diff --git a/interface/web/client/lib/lang/en_reseller.lng b/interface/web/client/lib/lang/en_reseller.lng index b94c30e86098d290f29066624c0adbae5fbd04bb..eb47bfdecdd11a91a2361f273e6e3f08d4b13064 100644 --- a/interface/web/client/lib/lang/en_reseller.lng +++ b/interface/web/client/lib/lang/en_reseller.lng @@ -172,10 +172,29 @@ $wb['customer_no_template_txt'] = 'Customer No. template'; $wb['customer_no_template_error_regex_txt'] = 'The customer No. template contains invalid characters'; $wb['customer_no_start_txt'] = 'Customer No. start value'; $wb['customer_no_counter_txt'] = 'Customer No. counter'; + +$wb["xmpp_limits_txt"] = 'XMPP Limits'; +$wb["xmpp_servers_txt"] = 'XMPP Servers'; +$wb["xmpp_servers_placeholder"] = 'Select XMPP Servers'; +$wb['no_xmpp_server_error'] = 'At least one XMPP Server must be selected.'; +$wb['xmpp_servers_used'] = 'The server you are trying to remove from this client is used as a XMPP Server. Be sure that this server is not used by this client before you remove it.'; +$wb['limit_xmpp_domain_error_notint'] = 'The XMPP domain limit must be a number.'; +$wb['limit_xmpp_user_error_notint'] = 'The XMPP user limit must be a number.'; +$wb['limit_xmpp_domain_txt'] = 'Max. number of XMPP domains'; +$wb['limit_xmpp_user_txt'] = 'Max. number of XMPP accounts'; +$wb['limit_xmpp_muc_txt'] = 'Multiuser chat available'; +$wb['limit_xmpp_pastebin_txt'] = 'Pastebin for MUC available'; +$wb['limit_xmpp_httparchive_txt'] = 'HTTP archive for MUC available'; +$wb['limit_xmpp_anon_txt'] = 'Anonymous host available'; +$wb['limit_xmpp_vjud_txt'] = 'VJUD user directory available'; +$wb['limit_xmpp_proxy_txt'] = 'Bytestream proxy available'; +$wb['limit_xmpp_status_txt'] = 'Status host available'; + $wb['added_by_txt'] = 'Added by'; $wb['added_date_txt'] = 'Added date'; $wb['limit_domainmodule_error_notint'] = 'Domainmodule limit must be a number.'; $wb['limit_domainmodule_txt'] = 'Domainmodule Limit'; $wb['client_limits_txt'] = 'Client Limits'; $wb['err_msg_master_tpl_set'] = 'All custom limit settings are ignored if any master template other than "custom" is selected.'; +$wb['invalid_vat_id'] = 'The VAT ID is invalid.'; ?> diff --git a/interface/web/client/lib/module.conf.php b/interface/web/client/lib/module.conf.php index e4bddd72f292e8c6738175c9c61d84449a17bf96..7d6f1b34e82c13d073b9bc209905e13789aa5a74 100644 --- a/interface/web/client/lib/module.conf.php +++ b/interface/web/client/lib/module.conf.php @@ -5,6 +5,7 @@ $module["title"] = "top_menu_client"; $module["template"] = "module.tpl.htm"; $module["startpage"] = "client/client_list.php"; $module["tab_width"] = ''; +$module['order'] = '20'; $items[] = array( 'title' => "Edit Client", diff --git a/interface/web/client/lib/remote.conf.php b/interface/web/client/lib/remote.conf.php index fd24dd5d26a9a0d9733c51177713e42f6970cace..d58029e8513ad78a26ca2abfa783ec41d70bfea8 100644 --- a/interface/web/client/lib/remote.conf.php +++ b/interface/web/client/lib/remote.conf.php @@ -1,8 +1,8 @@ diff --git a/interface/web/client/list/client_circle.list.php b/interface/web/client/list/client_circle.list.php index d1ef3ad50b832e36fd464f46ad7d87f178938981..56085c4c366858aff2b2361b9306610cf728b054 100644 --- a/interface/web/client/list/client_circle.list.php +++ b/interface/web/client/list/client_circle.list.php @@ -63,7 +63,7 @@ $liste["item"][] = array( 'field' => "active", 'prefix' => "", 'suffix' => "", 'width' => "", - 'value' => array('y' => "
Yes
", 'n' => "
No
")); + 'value' => array('y' => "
".$app->lng('yes_txt')."
", 'n' => "
".$app->lng('no_txt')."
")); $liste["item"][] = array( 'field' => "circle_name", 'datatype' => "VARCHAR", diff --git a/interface/web/client/message_template_edit.php b/interface/web/client/message_template_edit.php index 819e267657aab3c753984138b8512f4993d0ef20..7d285ac7ef86e6bd1f6ee7a379ef21cb24f62e7d 100644 --- a/interface/web/client/message_template_edit.php +++ b/interface/web/client/message_template_edit.php @@ -56,12 +56,11 @@ class page_action extends tform_actions { // Check for duplicates if($this->dataRecord['template_type'] == 'welcome') { $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $sql = "SELECT count(client_message_template_id) as number FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ".$client_group_id; + $sql = "SELECT count(client_message_template_id) as number FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ?"; if($this->id > 0) { - $sql .= " AND client_message_template_id != ".$this->id; + $sql .= " AND client_message_template_id != ?"; } - - $tmp = $app->db->queryOneRecord($sql); + $tmp = $app->db->queryOneRecord($sql, $client_group_id, $this->id); if($tmp['number'] > 0) $app->tform->errorMessage .= $app->tform->lng('duplicate_welcome_error'); } diff --git a/interface/web/client/reseller_del.php b/interface/web/client/reseller_del.php index e9d1dd32b8947a67bd2544b269fe4d61cbcc81ee..55872beabd3567f1c536bf775ac534d3d6133cee 100644 --- a/interface/web/client/reseller_del.php +++ b/interface/web/client/reseller_del.php @@ -59,7 +59,7 @@ class page_action extends tform_actions { $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); + $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')); } @@ -74,15 +74,15 @@ class page_action extends tform_actions { // 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"); + $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']); // delete the group of the client - $app->db->query("DELETE FROM sys_group WHERE client_id = $client_id"); + $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"); + $app->db->query("DELETE FROM sys_user WHERE client_id = ?", $client_id); } } diff --git a/interface/web/client/reseller_edit.php b/interface/web/client/reseller_edit.php index 4a7cc874077c524334e7438585536e9d8c9c75d1..fff4202064b27d4246ede0649bebaaf1ef378678 100644 --- a/interface/web/client/reseller_edit.php +++ b/interface/web/client/reseller_edit.php @@ -61,11 +61,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $app->functions->intval($_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"); + $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"); + $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id); if($tmp["number"] >= $client["limit_client"]) { $app->error($app->tform->wordbook["limit_client_txt"]); } @@ -84,11 +84,11 @@ class page_action extends tform_actions { // Get the limits of the client $client_group_id = $app->functions->intval($_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"); + $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"); + $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id); if($tmp["number"] >= $client["limit_client"]) { $app->error($app->tform->wordbook["limit_client_txt"]); } @@ -96,7 +96,7 @@ 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); + $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']); @@ -134,7 +134,7 @@ class page_action extends tform_actions { $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); + $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(); @@ -160,8 +160,8 @@ class page_action extends tform_actions { unset($tmprec); } else { // old style - $sql = "SELECT template_additional FROM client WHERE client_id = " . $this->id; - $result = $app->db->queryOneRecord($sql); + $sql = "SELECT template_additional FROM client WHERE client_id = ?"; + $result = $app->db->queryOneRecord($sql, $this->id); $tplAdd = explode("/", $result['template_additional']); $text = ''; foreach($tplAdd as $item){ @@ -186,13 +186,6 @@ class page_action extends tform_actions { $customer_no = $app->functions->intval($system_config['misc']['customer_no_start']+$system_config['misc']['customer_no_counter']); $customer_no_string = str_replace('[CUSTOMER_NO]',$customer_no,$system_config['misc']['customer_no_template']); $app->tpl->setVar('customer_no',$customer_no_string); - - //* save new counter value - /* - $system_config['misc']['customer_no_counter']++; - $system_config_str = $app->ini_parser->get_ini_string($system_config); - $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1); - */ } } @@ -207,17 +200,17 @@ class page_action extends tform_actions { function onAfterInsert() { global $app, $conf; // 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'); + $groupid = $app->db->datalogInsert('sys_group', array("name" => $this->dataRecord["username"], "description" => '', "client_id" => $this->id), 'groupid'); $groups = $groupid; - $username = $app->db->quote($this->dataRecord["username"]); - $password = $app->db->quote($this->dataRecord["password"]); - $modules = $app->db->quote($conf['interface_modules_enabled'] . ',client'); + $username = $this->dataRecord["username"]; + $password = $this->dataRecord["password"]; + $modules = $conf['interface_modules_enabled'] . ',client'; $startmodule = (stristr($modules, 'dashboard'))?'dashboard':'client'; - $usertheme = $app->db->quote($this->dataRecord["usertheme"]); + $usertheme = $this->dataRecord["usertheme"]; $type = 'user'; $active = 1; - $language = $app->db->quote($this->dataRecord["language"]); + $language = $this->dataRecord["language"]; $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; @@ -229,11 +222,11 @@ class page_action extends tform_actions { // 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); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + $app->db->query($sql, $username, $password, $modules, $startmodule, $usertheme, $type, $active, $language, $groups, $groupid, $this->id); //* set the number of clients to 1 - $app->db->query("UPDATE client SET limit_client = 1 WHERE client_id = ".$this->id); + $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'); @@ -245,8 +238,8 @@ class page_action extends tform_actions { $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); + $sql = "UPDATE client SET default_mailserver = ?, default_webserver = ?, default_dnsserver = ?, default_slave_dnsserver = ?, default_dbserver = ? WHERE client_id = ?"; + $app->db->query($sql, $default_mailserver, $default_webserver, $default_dnsserver, $default_dnsserver, $default_dbserver, $this->id); if(isset($this->dataRecord['template_master'])) { $app->uses('client_templates'); @@ -262,15 +255,15 @@ class page_action extends tform_actions { //* save new counter value $system_config['misc']['customer_no_counter']++; $system_config_str = $app->ini_parser->get_ini_string($system_config); - $app->db->datalogUpdate('sys_ini', "config = '".$app->db->quote($system_config_str)."'", 'sysini_id', 1); + $app->db->datalogUpdate('sys_ini', array("config" => $system_config_str), 'sysini_id', 1); } } //* Send welcome email $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ".$client_group_id; - $email_template = $app->db->queryOneRecord($sql); + $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ?"; + $email_template = $app->db->queryOneRecord($sql, $client_group_id); $client = $app->tform->getDataRecord($this->id); if(is_array($email_template) && $client['email'] != '') { @@ -300,7 +293,7 @@ class page_action extends tform_actions { $from = $system_config['admin_mail']; } else { $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ".$client_group_id); + $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id); $from = $reseller["email"]; } @@ -321,19 +314,19 @@ class page_action extends tform_actions { // 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"]); + $username = $this->dataRecord["username"]; $client_id = $this->id; - $sql = "UPDATE sys_user SET username = '$username' WHERE client_id = $client_id"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET username = ? WHERE client_id = ?"; + $app->db->query($sql, $username, $client_id); - $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = $client_id"); - $app->db->datalogUpdate("sys_group", "name = '$username'", 'groupid', $tmp['groupid']); + $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = ?", $client_id); + $app->db->datalogUpdate("sys_group", array("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"]); + $password = $this->dataRecord["password"]; $client_id = $this->id; $salt="$1$"; $base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; @@ -342,32 +335,32 @@ class page_action extends tform_actions { } $salt.="$"; $password = crypt(stripslashes($password), $salt); - $sql = "UPDATE sys_user SET passwort = '$password' WHERE client_id = $client_id"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET passwort = ? WHERE client_id = ?"; + $app->db->query($sql, $password, $client_id); } // 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"]); + $language = $this->dataRecord["language"]; $client_id = $this->id; - $sql = "UPDATE sys_user SET language = '$language' WHERE client_id = $client_id"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET language = ? WHERE client_id = ?"; + $app->db->query($sql, $language, $client_id); } // 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); + $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 = $app->db->quote($conf['interface_modules_enabled'] . ',client'); - $modules = $app->db->quote($modules); + $modules = $conf['interface_modules_enabled'] . ',client'; + $modules = $modules; $client_id = $this->id; - $sql = "UPDATE sys_user SET modules = '$modules' WHERE client_id = $client_id"; - $app->db->query($sql); + $sql = "UPDATE sys_user SET modules = ? WHERE client_id = ?"; + $app->db->query($sql, $modules, $client_id); } if(isset($this->dataRecord['template_master'])) { diff --git a/interface/web/client/reseller_list.php b/interface/web/client/reseller_list.php index 83f5d6199110b6a6d638c3ba8384281f3f2ec647..d849ab9648c153d1584765f8b44a8fb8872a19e5 100644 --- a/interface/web/client/reseller_list.php +++ b/interface/web/client/reseller_list.php @@ -49,7 +49,7 @@ $app->uses('listform_actions'); $app->listform_actions->SQLOrderBy = 'ORDER BY client.company_name, client.contact_name, client.client_id'; $app->listform_actions->SQLExtWhere = "(client.limit_client > 0 or client.limit_client = -1)"; -$app->listform_actions->SQLExtSelect = ', client.country as countryiso'; +$app->listform_actions->SQLExtSelect = ', LOWER(client.country) as countryiso'; $app->listform_actions->onLoad(); diff --git a/interface/web/client/templates/client_circle_edit.htm b/interface/web/client/templates/client_circle_edit.htm index 95c5f32698af6d22eeb18508bc6501181ebcfee8..0bdf2f49a059d6465061168d530d8a4bac587100 100644 --- a/interface/web/client/templates/client_circle_edit.htm +++ b/interface/web/client/templates/client_circle_edit.htm @@ -1,39 +1,36 @@ -

-

+ + + +

-
-
-
{tmpl_var name='circle_txt'} -
- - -
-
-

{tmpl_var name='client_ids_txt'}

-
+
+ +
+
+ +
{tmpl_var name='client_ids'}
-
- - +
+ +
-
-

{tmpl_var name='active_txt'}

-
+
+ +
{tmpl_var name='active'}
{tmpl_var name='required_fields_txt'} -
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/client/templates/client_circle_list.htm b/interface/web/client/templates/client_circle_list.htm index a0d7991d9efd0c9d6777d2b1454a7a2f269db849..56bce62d6c3b823587308506199607790bbd8eb6 100644 --- a/interface/web/client/templates/client_circle_list.htm +++ b/interface/web/client/templates/client_circle_list.htm @@ -1,48 +1,46 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + - - - - - - + + + + + - - - - - - + + + + + @@ -54,11 +52,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="circle_id"}{tmpl_var name="active"}{tmpl_var name="circle_name"}{tmpl_var name="description"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="circle_id"}{tmpl_var name="active"}{tmpl_var name="circle_name"}{tmpl_var name="description"} +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/client/templates/client_del.htm b/interface/web/client/templates/client_del.htm index efde39da935b8ba26cd6c1058a76ffac1ce5721b..2ae0a8e700683abd9f4877dce9b5ceefeade8ae0 100644 --- a/interface/web/client/templates/client_del.htm +++ b/interface/web/client/templates/client_del.htm @@ -1,9 +1,9 @@ -

+

-
-
@@ -16,14 +16,11 @@
- +
-
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/client/templates/client_edit_address.htm b/interface/web/client/templates/client_edit_address.htm index b3c5757cb3fd1d18348af5cff646a37ca9d84ba0..4069c474b0785253f1419211e3955c4236f4fd4a 100644 --- a/interface/web/client/templates/client_edit_address.htm +++ b/interface/web/client/templates/client_edit_address.htm @@ -1,179 +1,149 @@ -

+

-
-
-
Address -
- - -
-
- -
+
+ +
-
-
- - -
-
- - -
-
- - - -
-
- - -
-
- -  {tmpl_var name='generate_password_txt'} -
-
-

{tmpl_var name='password_strength_txt'}

+
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
 
{tmpl_var name='generate_password_txt'} +
+
+

 

-
- - -
+
+ +
-
- - {tmpl_var name='language'} - +
-
- - {tmpl_var name='usertheme'} - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='locked_txt'}

-
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
{tmpl_var name='locked'}
-
-

{tmpl_var name='canceled_txt'}

-
+
+ +
{tmpl_var name='canceled'}
{tmpl_var name='required_fields_txt'} - + -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/client/templates/client_edit_limits.htm b/interface/web/client/templates/client_edit_limits.htm index 2d40fc455fe3a775584ecc9ee60e1e69cceba421..e7de5c66540845b19a40fcbd274bbf18901d5bcc 100644 --- a/interface/web/client/templates/client_edit_limits.htm +++ b/interface/web/client/templates/client_edit_limits.htm @@ -1,321 +1,356 @@ -

-

+ + + +

- -
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
- -
+ +
Limits -
- - {tmpl_var name='template_master'} - +
-
- - {tmpl_var name='tpl_add_select'} - -
-
-

{tmpl_var name='active_template_additional_txt'}

-
+
+
+
+ +
+
+ +
    {tmpl_var name='template_additional_list'}
-
+
 
-
- - {tmpl_var name='parent_client_id'} - -
-
- - +
+
+ +
{tmpl_var name='web_limits_txt'}
-
- - {tmpl_var name='web_servers'} - -
-
- - -
-
- -  MB -
-
- -  MB -
-
-

{tmpl_var name='web_php_options_txt'}

-
+
+
+
+ +
+
+ +
 MB +
+
+ +
 MB +
+
+ +
{tmpl_var name='web_php_options'}
-
-

{tmpl_var name='limit_cgi_txt'}

-
+
+ +
{tmpl_var name='limit_cgi'}
-
-

{tmpl_var name='limit_ssi_txt'}

-
+
+ +
{tmpl_var name='limit_ssi'}
-
-

{tmpl_var name='limit_perl_txt'}

-
+
+ +
{tmpl_var name='limit_perl'}
-
-

{tmpl_var name='limit_ruby_txt'}

-
+
+ +
{tmpl_var name='limit_ruby'}
-
-

{tmpl_var name='limit_python_txt'}

-
+
+ +
{tmpl_var name='limit_python'}
-
-

{tmpl_var name='force_suexec_txt'}

-
+
+ +
{tmpl_var name='force_suexec'}
-
-

{tmpl_var name='limit_hterror_txt'}

-
+
+ +
{tmpl_var name='limit_hterror'}
-
-

{tmpl_var name='limit_wildcard_txt'}

-
+
+ +
{tmpl_var name='limit_wildcard'}
-
-

{tmpl_var name='limit_ssl_txt'}

-
+
+ +
{tmpl_var name='limit_ssl'}
-
- - -
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='ssh_chroot_txt'}

-
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='ssh_chroot'}
-
- - -
-
-

{tmpl_var name='limit_backup_txt'}

-
+
+ +
+
+ +
{tmpl_var name='limit_backup'}
-
{tmpl_var name='email_limits_txt'}
-
-
- - {tmpl_var name='mail_servers'} - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
 MB +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+ +
+ +
+ {tmpl_var name='limit_xmpp_muc'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_pastebin'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_httparchive'} +
-
- -  MB +
+ +
+ {tmpl_var name='limit_xmpp_anon'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_vjud'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_proxy'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_status'} +
+
-
{tmpl_var name='database_limits_txt'}
-
-
- - {tmpl_var name='db_servers'} - -
-
- - -
-
- -  MB -
+
+
+
+ +
+
+ +
 MB +
-
{tmpl_var name='cron_job_limits_txt'}
-
-
- - -
-
- -
+
+ +
-
-
- - +
+
+ +
-
{tmpl_var name='dns_limits_txt'}
-
-
- - {tmpl_var name='dns_servers'} - -
-
- - -
-
- -
+
+
+ +
+
+ +
-
-
- - -
-
- - -
+
+
+
+ +
+
+ +
-
{tmpl_var name='virtualization_limits_txt'}
-
-
- - -
-
- -
+
+ +
+
-
{tmpl_var name='aps_limits_txt'}
-
-
- - -
+
+
+
+ +
- + -
- - -
+
+ + +
@@ -326,13 +361,9 @@ function custom_template_selected() { return ($('#template_master').val() == '0' ? true : false); } -$('.subsectiontoggle').on("click", function(){ - $(this).children().toggleClass('showing').end().next().slideToggle(); -}); - $('#template_additional_list').find('li > a').click(function(e) { e.preventDefault(); - delAdditionalTemplate($(this).parent().attr('rel')); + ISPConfig.delAdditionalTemplate($(this).parent().attr('rel')); }); $('div.panel_client') diff --git a/interface/web/client/templates/client_message.htm b/interface/web/client/templates/client_message.htm index 6cff7105c4b8d0686a8b79ba739e8a294e41771b..e65846c749cf6df4c4c734b6237b52f00388b579 100644 --- a/interface/web/client/templates/client_message.htm +++ b/interface/web/client/templates/client_message.htm @@ -1,39 +1,34 @@ -

+

-
- -
-
{tmpl_var name='form_legend_txt'} + + {tmpl_var name='form_legend_txt'}

-

ERROR

+

-
- - -
-
- -
+
+ +
-
-
- - +
-
- -  {tmpl_var name="variables_txt"} {tmpl_var name="message_variables"} +
+ +
+
+ +
 {tmpl_var name="variables_txt"} {tmpl_var name="message_variables"}
- -
- - -
-
- -
\ No newline at end of file + +
+ + +
\ No newline at end of file diff --git a/interface/web/client/templates/client_message_template_list.htm b/interface/web/client/templates/client_message_template_list.htm index 95f6f00bd0c1c11021dfa56f79c4b42cb50f02fe..46337c519b95d27e465e69ab77c6bc21d737a003 100644 --- a/interface/web/client/templates/client_message_template_list.htm +++ b/interface/web/client/templates/client_message_template_list.htm @@ -1,40 +1,38 @@ -

+ -
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - + +

+
+
+ - - - + + + - - - + + + - - - - + + + @@ -47,11 +45,10 @@ - +
  
{tmpl_var name="template_type"}{tmpl_var name="template_name"} +
{tmpl_var name="template_type"}{tmpl_var name="template_name"}
-
-
-
+ + \ No newline at end of file diff --git a/interface/web/client/templates/client_template_edit_limits.htm b/interface/web/client/templates/client_template_edit_limits.htm index 71ab963f3e463e42fd99e25758ffd5f724fbb663..abb68792b343b9e705ee321849e6d49628c77707 100644 --- a/interface/web/client/templates/client_template_edit_limits.htm +++ b/interface/web/client/templates/client_template_edit_limits.htm @@ -1,290 +1,322 @@ -

+

-
-
-
Limits + Limits
{tmpl_var name='web_limits_txt'}
-
- - {tmpl_var name='default_webserver'} - -
-
- - -
-
- -  MB -
-
- -  MB -
-
-

{tmpl_var name='web_php_options_txt'}

-
+
+
+
+ +
+
+ +
 MB +
+
+ +
 MB +
+
+ +
{tmpl_var name='web_php_options'}
-
-

{tmpl_var name='limit_cgi_txt'}

-
+
+ +
{tmpl_var name='limit_cgi'}
-
-

{tmpl_var name='limit_ssi_txt'}

-
+
+ +
{tmpl_var name='limit_ssi'}
-
-

{tmpl_var name='limit_perl_txt'}

-
+
+ +
{tmpl_var name='limit_perl'}
-
-

{tmpl_var name='limit_ruby_txt'}

-
+
+ +
{tmpl_var name='limit_ruby'}
-
-

{tmpl_var name='limit_python_txt'}

-
+
+ +
{tmpl_var name='limit_python'}
-
-

{tmpl_var name='force_suexec_txt'}

-
+
+ +
{tmpl_var name='force_suexec'}
-
-

{tmpl_var name='limit_hterror_txt'}

-
+
+ +
{tmpl_var name='limit_hterror'}
-
-

{tmpl_var name='limit_wildcard_txt'}

-
+
+ +
{tmpl_var name='limit_wildcard'}
-
-

{tmpl_var name='limit_ssl_txt'}

-
+
+ +
{tmpl_var name='limit_ssl'}
-
- - -
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='ssh_chroot_txt'}

-
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='ssh_chroot'}
-
- - -
-
-

{tmpl_var name='limit_backup_txt'}

-
+
+ +
+
+ +
{tmpl_var name='limit_backup'}
-
{tmpl_var name='email_limits_txt'}
-
-
- - {tmpl_var name='default_mailserver'} - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+ +
+ +
+ +
+ {tmpl_var name='limit_xmpp_muc'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_pastebin'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_httparchive'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_anon'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_vjud'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_proxy'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_status'} +
+
-
{tmpl_var name='database_limits_txt'}
-
-
- - {tmpl_var name='default_dbserver'} - -
-
- - -
-
- -  MB -
+
+
+
+ +
+
+ +
 MB +
-
{tmpl_var name='cron_job_limits_txt'}
-
-
- - -
-
- -
+
+ +
-
-
- - +
+
+ +
-
{tmpl_var name='dns_limits_txt'}
-
-
- - {tmpl_var name='default_dnsserver'} - -
-
- - -
-
- -
+
+
+ +
+
+ +
-
-
- - -
-
- - -
+
+
+
+ +
+
+ +
-
{tmpl_var name='virtualization_limits_txt'}
-
-
- - -
-
- -
+
+ +
+
-
{tmpl_var name='aps_limits_txt'}
-
-
- - -
+
+
+
+ +
-
{tmpl_var name='client_limits_txt'}
-
-
- - -
-
- - -
+
+
+
+ +
+
+ +
-
+ -
- - -
-
- -
+
+ + +
diff --git a/interface/web/client/templates/client_template_edit_template.htm b/interface/web/client/templates/client_template_edit_template.htm index 79ea1094af020ba40993d6a3f417c61adb2a7826..e06d07792d9b5e45a7271378a485a71430f98de9 100644 --- a/interface/web/client/templates/client_template_edit_template.htm +++ b/interface/web/client/templates/client_template_edit_template.htm @@ -1,28 +1,26 @@ -

-

+ + + +

-
-
-
Template -
- - {tmpl_var name='template_type'} - -
-
- - +
- +
+ +
+ -
- - -
-
- -
+
+ + +
diff --git a/interface/web/client/templates/client_template_list.htm b/interface/web/client/templates/client_template_list.htm index 5106aef6c97c9c9fc6484f2bfeaa7aa14282a1c6..37b8aa289272d885e4bca219050c5e7fa062458a 100644 --- a/interface/web/client/templates/client_template_list.htm +++ b/interface/web/client/templates/client_template_list.htm @@ -1,45 +1,43 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + - - - - - + + + + - - - - - + + + + @@ -51,11 +49,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="template_id"}{tmpl_var name="template_type"}{tmpl_var name="template_name"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="template_id"}{tmpl_var name="template_type"}{tmpl_var name="template_name"} +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/client/templates/clients_list.htm b/interface/web/client/templates/clients_list.htm index 820e27c86ef6e33eabf8c5eb447b1c219428630b..27d4b7da66b603d5e20a49a13e32cfd0aa5eda6e 100644 --- a/interface/web/client/templates/clients_list.htm +++ b/interface/web/client/templates/clients_list.htm @@ -1,62 +1,60 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + @@ -68,11 +66,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="client_id"}{tmpl_var name="company_name"}{tmpl_var name="contact_name"}{tmpl_var name="customer_no"}{tmpl_var name="username"}{tmpl_var name="city"}
{tmpl_var name="country"}
+
{tmpl_var name="client_id"}{tmpl_var name="company_name"}{tmpl_var name="contact_name"}{tmpl_var name="customer_no"}{tmpl_var name="username"}{tmpl_var name="city"}{tmpl_var name="country"} - {tmpl_var name='login_as_txt'} + - {tmpl_var name='login_as_txt'} + - {tmpl_var name='delete_txt'} +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/client/templates/domain_edit.htm b/interface/web/client/templates/domain_edit.htm index 551dbbed0d95b891c2efc8b56e9e05a09a1ca002..97fefc85e0f1f1920773cdc3c3938b56deec769f 100644 --- a/interface/web/client/templates/domain_edit.htm +++ b/interface/web/client/templates/domain_edit.htm @@ -1,32 +1,25 @@

-
-
-
-
- + +
+ - - - - +
+
-
- - {tmpl_var name='client_group_id'} - +
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/client/templates/domain_list.htm b/interface/web/client/templates/domain_list.htm index 6224cbc2470dde678aea1793aa4ecf1f764dc153..825b2987117ff9f4367a8215b9a304933ca98d9b 100644 --- a/interface/web/client/templates/domain_list.htm +++ b/interface/web/client/templates/domain_list.htm @@ -1,40 +1,38 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - + +

+
+
+ - - - + + + - - - + + + - - - - + + + @@ -47,11 +45,10 @@ - +
{tmpl_var name='search_limit'}{tmpl_var name='search_limit'}
{tmpl_var name="domain"}{tmpl_var name="sys_groupid"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="domain"}{tmpl_var name="sys_groupid"} +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/client/templates/message_template.htm b/interface/web/client/templates/message_template.htm index 4c0c6231623c2180028c877a2534c5f2b92fc64f..aa27d181fc72a5876ac2bf8d7ee5c07b8c663fd7 100644 --- a/interface/web/client/templates/message_template.htm +++ b/interface/web/client/templates/message_template.htm @@ -1,35 +1,36 @@ -

+

-
Settings -
- - {tmpl_var name='template_type'} - +
-
- - -
-
- - -
{tmpl_var name='variables_txt'}: {tmpl_var name="message_variables"}
{tmpl_var name='variables_description_txt'} +
+ +
+
+ +
+
{tmpl_var name='variables_txt'}: {tmpl_var name="message_variables"}
{tmpl_var name='variables_description_txt'}
-
- - -
{tmpl_var name='variables_txt'}: {tmpl_var name="message_variables"}
{tmpl_var name='variables_description_txt'} +
+ +
+
{tmpl_var name='variables_txt'}: {tmpl_var name="message_variables"}
{tmpl_var name='variables_description_txt'}
-
- - -
- +
+ + +
+ diff --git a/interface/web/client/templates/message_template_list.htm b/interface/web/client/templates/message_template_list.htm index 27b0113df4d68d30d2675ca3f43a0ce0c3b5d088..70224abc8d2ceecc554874e6428d44b1ce1b4163 100644 --- a/interface/web/client/templates/message_template_list.htm +++ b/interface/web/client/templates/message_template_list.htm @@ -1,40 +1,38 @@ -

+ -
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - + +

+
+
+ - - - + + + - - - + + + - - - - + + + @@ -42,11 +40,10 @@ - +
  
{tmpl_var name="template_type"}{tmpl_var name="template_name"} +
{tmpl_var name="template_type"}{tmpl_var name="template_name"}
-
-
-
+ + \ No newline at end of file diff --git a/interface/web/client/templates/reseller_edit_address.htm b/interface/web/client/templates/reseller_edit_address.htm index 41160cf5dc66cbefac38b7c1b15920104c70d497..4cc639a5dfc62cb90d1e1fd21ed8d33c6e1c3d29 100644 --- a/interface/web/client/templates/reseller_edit_address.htm +++ b/interface/web/client/templates/reseller_edit_address.htm @@ -1,179 +1,149 @@ -

+

-
-
-
Address -
- - -
-
- -
+
+ +
-
-
- - -
-
- - -
-
- - - -
-
- - -
-
- -  {tmpl_var name='generate_password_txt'} -
-
-

{tmpl_var name='password_strength_txt'}

+
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
 
{tmpl_var name='generate_password_txt'} +
+
+

 

-
- - -
+
+ +
-
- - {tmpl_var name='language'} - +
-
- - {tmpl_var name='usertheme'} - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='locked_txt'}

-
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+ +
{tmpl_var name='locked'}
-
-

{tmpl_var name='canceled_txt'}

-
+
+ +
{tmpl_var name='canceled'}
{tmpl_var name='required_fields_txt'} - + -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/client/templates/reseller_edit_limits.htm b/interface/web/client/templates/reseller_edit_limits.htm index 55652d597068139dea5cde0ed197c31fbcd305f2..d58e28416db36db802e9dbce0be99ddc2adce6dd 100644 --- a/interface/web/client/templates/reseller_edit_limits.htm +++ b/interface/web/client/templates/reseller_edit_limits.htm @@ -1,332 +1,363 @@ -

-

+ + + +

- -
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
-
-
-
Limits + Limits -
- - {tmpl_var name='template_master'} - +
-
- - {tmpl_var name='tpl_add_select'} - -
-
-

{tmpl_var name='active_template_additional_txt'}

-
+
+
+ +
+ +
+
+
+ +
    {tmpl_var name='template_additional_list'}
-
+
 
-
- - -
-
- - -
-
- - -
+
+ +
+
+ +
+
+ +
{tmpl_var name='web_limits_txt'}
-
- - {tmpl_var name='web_servers'} - -
-
- - -
-
- -  MB -
-
- -  MB -
-
-

{tmpl_var name='web_php_options_txt'}

-
+
+
+
+ +
+
+ +
 MB +
+
+ +
 MB +
+
+ +
{tmpl_var name='web_php_options'}
-
-

{tmpl_var name='limit_cgi_txt'}

-
+
+ +
{tmpl_var name='limit_cgi'}
-
-

{tmpl_var name='limit_ssi_txt'}

-
+
+ +
{tmpl_var name='limit_ssi'}
-
-

{tmpl_var name='limit_perl_txt'}

-
+
+ +
{tmpl_var name='limit_perl'}
-
-

{tmpl_var name='limit_ruby_txt'}

-
+
+ +
{tmpl_var name='limit_ruby'}
-
-

{tmpl_var name='limit_python_txt'}

-
+
+ +
{tmpl_var name='limit_python'}
-
-

{tmpl_var name='force_suexec_txt'}

-
+
+ +
{tmpl_var name='force_suexec'}
-
-

{tmpl_var name='limit_hterror_txt'}

-
+
+ +
{tmpl_var name='limit_hterror'}
-
-

{tmpl_var name='limit_wildcard_txt'}

-
+
+ +
{tmpl_var name='limit_wildcard'}
-
-

{tmpl_var name='limit_ssl_txt'}

-
+
+ +
{tmpl_var name='limit_ssl'}
-
- - -
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='ssh_chroot_txt'}

-
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='ssh_chroot'}
-
- - -
-
-

{tmpl_var name='limit_backup_txt'}

-
+
+ +
+
+ +
{tmpl_var name='limit_backup'}
-
{tmpl_var name='email_limits_txt'}
-
-
- - {tmpl_var name='mail_servers'} - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - +
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
 MB +
+
+ +
+
+ +
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+ +
+ +
+ {tmpl_var name='limit_xmpp_muc'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_pastebin'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_httparchive'} +
-
- -  MB +
+ +
+ {tmpl_var name='limit_xmpp_anon'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_vjud'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_proxy'} +
-
- - +
+ +
+ {tmpl_var name='limit_xmpp_status'} +
+
-
{tmpl_var name='database_limits_txt'}
-
-
- - {tmpl_var name='db_servers'} - -
-
- - +
+
+ +
-
{tmpl_var name='cron_job_limits_txt'}
-
-
- - -
-
- -
+
+ +
-
-
- - +
+
+ +
-
{tmpl_var name='dns_limits_txt'}
-
-
- - {tmpl_var name='dns_servers'} - -
-
- - -
-
- -
+
+
+ +
+
+ +
-
-
- - -
-
- - -
+
+
+
+ +
+
+ +
-
{tmpl_var name='virtualization_limits_txt'}
-
-
- - -
-
- -
+
+ +
+
-
{tmpl_var name='aps_limits_txt'}
-
-
- - -
+
+
+
+ +
-
{tmpl_var name='client_limits_txt'}
-
-
- - -
-
- - -
+
+
+
+ +
+
+ +
- + -
- - -
+
+ + +
@@ -339,7 +370,7 @@ function custom_template_selected() { jQuery('#template_additional_list').find('li > a').click(function(e) { e.preventDefault(); - delAdditionalTemplate($(this).parent().attr('rel')); + ISPConfig.delAdditionalTemplate($(this).parent().attr('rel')); }); jQuery('div.panel_client') diff --git a/interface/web/client/templates/resellers_list.htm b/interface/web/client/templates/resellers_list.htm index 507449726d22c3aaa950d7722759afe85a6ee208..9538e710865e90ab9d98e8b7269c60ce27eec2a8 100644 --- a/interface/web/client/templates/resellers_list.htm +++ b/interface/web/client/templates/resellers_list.htm @@ -1,58 +1,56 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + @@ -64,11 +62,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="client_id"}{tmpl_var name="company_name"}{tmpl_var name="contact_name"}{tmpl_var name="customer_no"}{tmpl_var name="username"}{tmpl_var name="city"}
{tmpl_var name="country"}
- {tmpl_var name='login_as_txt'} - {tmpl_var name='delete_txt'} +
{tmpl_var name="client_id"}{tmpl_var name="company_name"}{tmpl_var name="contact_name"}{tmpl_var name="customer_no"}{tmpl_var name="username"}{tmpl_var name="city"}{tmpl_var name="country"} + +
-
-
- -
\ No newline at end of file +
+ + \ 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 2bc21d4e03e95f77ce90d01c1fe8dbed4e1d9233..30a668a77f01436b2b818a5e2374444c7c24b115 100644 --- a/interface/web/dashboard/ajax_get_json.php +++ b/interface/web/dashboard/ajax_get_json.php @@ -40,7 +40,7 @@ $type = $_GET["type"]; //if($_SESSION["s"]["user"]["typ"] == 'admin') { - +/* TODO: change sql queries */ if($type == 'globalsearch'){ $q = $app->db->quote(trim($_GET["q"])); $authsql = " AND ".$app->tform->getAuthSQL('r'); @@ -55,19 +55,19 @@ if($type == 'globalsearch'){ $result[] = _search('client', 'reseller', "AND limit_client != 0"); // web sites - $result[] = _search('sites', 'web_domain', "AND type = 'vhost'"); + $result[] = _search('sites', 'web_vhost_domain', "AND type = 'vhost'"); // subdomains - $result[] = _search('sites', 'web_subdomain', "AND type = 'subdomain'"); + $result[] = _search('sites', 'web_childdomain', "AND type = 'subdomain'", 'type=subdomain'); // web site aliases - $result[] = _search('sites', 'web_aliasdomain', "AND type = 'alias'"); + $result[] = _search('sites', 'web_childdomain', "AND type = 'alias'", 'type=aliasdomain'); // vhostsubdomains - $result[] = _search('sites', 'web_vhost_subdomain', "AND type = 'vhostsubdomain'"); + $result[] = _search('sites', 'web_vhost_domain', "AND type = 'vhostsubdomain'", 'type=subdomain'); // vhostaliasdomains - $result[] = _search('sites', 'web_vhost_aliasdomain', "AND type = 'vhostalias'"); + $result[] = _search('sites', 'web_vhost_domain', "AND type = 'vhostalias'", 'type=aliasdomain'); // FTP users $result[] = _search('sites', 'ftp_user'); @@ -76,28 +76,6 @@ if($type == 'globalsearch'){ $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)){ - $result_databases['cheader'] = array('title' => 'Databases', - 'total' => count($results), - 'limit' => count($results) - ); - foreach($results as $result){ - $description = 'Database User: '.$result['database_user'].' - Remote IPs: '.$result['remote_ips']; - $result_databases['cdata'][] = array('title' => $result['database_name'], - 'description' => $description, - 'onclick' => 'capp(\'sites\',\'sites/database_edit.php?id='.$result['database_id'].'\');', - 'fill_text' => strtolower($result['database_name']) - ); - } - } - } - */ $result[] = _search('sites', 'database'); // database users @@ -156,7 +134,7 @@ if($type == 'globalsearch'){ //} -function _search($module, $section, $additional_sql = ''){ +function _search($module, $section, $additional_sql = '', $params = ''){ global $app, $q, $authsql, $modules; $result_array = array('cheader' => array(), 'cdata' => array()); @@ -164,9 +142,13 @@ 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 '../'.$module.'/form/'.$section.'.tform.php'; $category_title = $form["title"]; + if($params == 'type=subdomain' && $section == 'web_childdomain') $category_title = 'Subdomain'; + if($params == 'type=aliasdomain' && $section == 'web_childdomain') $category_title = 'Aliasdomain'; + if($params == 'type=subdomain' && $section == 'web_vhost_domain') $category_title = 'Subdomain (Vhost)'; + if($params == 'type=aliasdomain' && $section == 'web_vhost_domain') $category_title = 'Aliasdomain (Vhost)'; $form_file = $form["action"]; $db_table = $form["db_table"]; $db_table_idx = $form["db_table_idx"]; @@ -205,8 +187,8 @@ function _search($module, $section, $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); + $sql = "SELECT * FROM ?? WHERE ".$where_clause.$authsql.$order_clause." LIMIT 0,10"; + $results = $app->db->queryAllRecords($sql, $db_table); if(is_array($results) && !empty($results)){ $lng_file = '../'.$module.'/lib/lang/'.$_SESSION['s']['language'].'_'.$section.'.lng'; @@ -227,7 +209,7 @@ function _search($module, $section, $additional_sql = ''){ $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]."');", + 'onclick' => "ISPConfig.capp('".$module."','".$module."/".$form_file.urlencode("?id=".$result[$db_table_idx]).($params != ''? urlencode('&'.$params) : '')."');", 'fill_text' => strtolower($result[$title_key]) ); } diff --git a/interface/web/dashboard/dashboard.php b/interface/web/dashboard/dashboard.php index 485bb320651be3b9fea60873e17ec934db078277..51068b10850182047283a1a28f75249e59d329ce 100644 --- a/interface/web/dashboard/dashboard.php +++ b/interface/web/dashboard/dashboard.php @@ -51,7 +51,7 @@ $app->tpl_defaults(); if($_SESSION['s']['user']['typ'] == 'admin') { $name = $_SESSION['s']['user']['username']; } else { - $tmp = $app->db->queryOneRecord("SELECT contact_name FROM client WHERE username = '".$app->db->quote($_SESSION['s']['user']['username'])."'"); + $tmp = $app->db->queryOneRecord("SELECT contact_name FROM client WHERE username = ?", $_SESSION['s']['user']['username']); $name = $tmp['contact_name']; } @@ -146,7 +146,7 @@ $app->tpl->setloop('info', $info); $dashlet_list = array(); $handle = @opendir(ISPC_WEB_PATH.'/dashboard/dashlets'); while ($file = @readdir($handle)) { - if ($file != '.' && $file != '..' && !is_dir($file)) { + if ($file != '.' && $file != '..' && !is_dir(ISPC_WEB_PATH.'/dashboard/dashlets/'.$file)) { $dashlet_name = substr($file, 0, -4); $dashlet_class = 'dashlet_'.$dashlet_name; include_once ISPC_WEB_PATH.'/dashboard/dashlets/'.$file; @@ -157,8 +157,8 @@ while ($file = @readdir($handle)) { /* Which dashlets in which column */ /******************************************************************************/ -$default_leftcol_dashlets = array('modules', 'invoices', 'quota', 'mailquota'); -$default_rightcol_dashlets = array('limits'); +$default_leftcol_dashlets = array('modules', 'invoices', 'quota', 'mailquota', 'databasequota'); +$default_rightcol_dashlets = array('customer', 'products', 'shop', 'limits'); $app->uses('getconf'); $dashlets_config = $app->getconf->get_global_config('misc'); diff --git a/interface/web/dashboard/dashlets/databasequota.php b/interface/web/dashboard/dashlets/databasequota.php new file mode 100644 index 0000000000000000000000000000000000000000..6880d780a030be3206ba43678b6b9859dfaf9318 --- /dev/null +++ b/interface/web/dashboard/dashlets/databasequota.php @@ -0,0 +1,41 @@ +uses('tpl,quota_lib'); + + $tpl = new tpl; + $tpl->newTemplate("dashlets/templates/databasequota.htm"); + + $wb = array(); + $lng_file = 'lib/lang/'.$_SESSION['s']['language'].'_dashlet_databasequota.lng'; + if(is_file($lng_file)) include $lng_file; + $tpl->setVar($wb); + + $databases = $app->quota_lib->get_databasequota_data( ($_SESSION["s"]["user"]["typ"] != 'admin') ? $_SESSION['s']['user']['client_id'] : null); + //print_r($databases); + + $has_databasequota = false; + if(is_array($databases) && !empty($databases)){ + $tpl->setloop('databasequota', $databases); + $has_databasequota = isset($databases[0]['used']); + } + $tpl->setVar('has_databasequota', $has_databasequota); + + return $tpl->grab(); + } + +} + + + + + + + + +?> diff --git a/interface/web/dashboard/dashlets/limits.php b/interface/web/dashboard/dashlets/limits.php index 87898eb8a4bfb7f84e608a5c346e781b65545aca..2455da87bdeabd7c4d088f3dbbd5b0bf90ba0c1e 100644 --- a/interface/web/dashboard/dashlets/limits.php +++ b/interface/web/dashboard/dashlets/limits.php @@ -130,7 +130,7 @@ class dashlet_limits { if($user_is_admin == false) { $client_group_id = $app->functions->intval($_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"); + $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(); @@ -143,10 +143,15 @@ class dashlet_limits { } if($value != 0 || $value == $wb['unlimited_txt']) { $value_formatted = ($value == '-1')?$wb['unlimited_txt']:$value; + $usage = $this->_get_limit_usage($limit); + $percentage = ($value == '-1' || $value == 0 ? 0 : round(100 * $usage / $value)); $rows[] = array('field' => $field, 'field_txt' => $wb[$field.'_txt'], 'value' => $value_formatted, - 'usage' => $this->_get_limit_usage($limit)); + 'value_raw' => $value, + 'usage' => $usage, + 'usage_raw' => $usage, + 'percentage' => $percentage); } } $tpl->setLoop('rows', $rows); @@ -159,10 +164,10 @@ class dashlet_limits { function _get_limit_usage($limit) { global $app; - $sql = "SELECT count(sys_userid) as number FROM ".$app->db->quote($limit['db_table'])." WHERE "; + $sql = "SELECT count(sys_userid) as number FROM ?? WHERE "; if($limit['db_where'] != '') $sql .= $limit['db_where']." AND "; $sql .= $app->tform->getAuthSQL('r'); - $rec = $app->db->queryOneRecord($sql); + $rec = $app->db->queryOneRecord($sql, $limit['db_table']); return $rec['number']; } diff --git a/interface/web/dashboard/dashlets/modules.php b/interface/web/dashboard/dashlets/modules.php index 1b1d2ef99fcd5cc540f7375e4a7b75a19d219a4b..da1eb0be77be2dc60f6368fd437c105f1135d189 100644 --- a/interface/web/dashboard/dashlets/modules.php +++ b/interface/web/dashboard/dashlets/modules.php @@ -28,19 +28,32 @@ class dashlet_modules { include_once '../' . $mt.'/lib/module.conf.php'; /* We don't want to show the dashboard */ if ($mt != 'dashboard') { + if($mt == 'dns'){ + $dns_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE dns_server = 1 AND active = 1"); + if($dns_servers['cnt'] == 0) continue; + } + if($mt == 'mail'){ + $mail_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE mail_server = 1 AND active = 1"); + if($mail_servers['cnt'] == 0) continue; + } + if($mt == 'sites'){ + $web_servers = $app->db->queryOneRecord("SELECT COUNT(*) as cnt FROM server WHERE web_server = 1 AND active = 1"); + if($web_servers['cnt'] == 0) continue; + } + $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").'..'; } else { if(strlen($module_title) > 8) $module_title = substr($module_title, 0, 7).'..'; } - $mod[] = array( 'modules_title' => $module_title, + $mod[$module['order']] = array( 'modules_title' => $module_title, 'modules_startpage' => $module['startpage'], 'modules_name' => $module['name']); } } } - + ksort($mod); $tpl->setloop('modules', $mod); } diff --git a/interface/web/dashboard/dashlets/templates/databasequota.htm b/interface/web/dashboard/dashlets/templates/databasequota.htm new file mode 100644 index 0000000000000000000000000000000000000000..828e344a283f88e833ee886854f68b416792f0c7 --- /dev/null +++ b/interface/web/dashboard/dashlets/templates/databasequota.htm @@ -0,0 +1,28 @@ +
+ + + + + + + + + + + + + + + + + + + +
{tmpl_var name='databasequota_txt'}
{tmpl_var name='database_txt'}{tmpl_var name='used_txt'}{tmpl_var name='quota_txt'}
{tmpl_var name='database_name'}{tmpl_var name='used'}{tmpl_var name='database_quota'} +
+
+ {tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='database_quota'} +
+
+
+
\ No newline at end of file diff --git a/interface/web/dashboard/dashlets/templates/limits.htm b/interface/web/dashboard/dashlets/templates/limits.htm index 11fe0bbe6a9a5d2571dab430ec8d8ae9e472dd88..145d54a342b8737860b6360e7783f5ac974db0da 100644 --- a/interface/web/dashboard/dashlets/templates/limits.htm +++ b/interface/web/dashboard/dashlets/templates/limits.htm @@ -1,11 +1,26 @@ -

{tmpl_var name='limits_txt'}

-
- - - - - - - -
{tmpl_var name='field_txt'}{tmpl_var name='usage'} {tmpl_var name='of_txt'} {tmpl_var name='value'}
-
\ No newline at end of file +
+ + + + + + + + + + + + + + + + + +
{tmpl_var name='limits_txt'}
  
{tmpl_var name='field_txt'}{tmpl_var name='usage'} {tmpl_var name='of_txt'} {tmpl_var name='value'} +
+
+ {tmpl_var name='usage'} {tmpl_var name='of_txt'} {tmpl_var name='value'} +
+
+
+
diff --git a/interface/web/dashboard/dashlets/templates/mailquota.htm b/interface/web/dashboard/dashlets/templates/mailquota.htm index a239c48babcff5fea8a8b8fcb111884ab095178a..3c3bd2c62b8250702c25c445a3a191750b766f7c 100644 --- a/interface/web/dashboard/dashlets/templates/mailquota.htm +++ b/interface/web/dashboard/dashlets/templates/mailquota.htm @@ -1,29 +1,30 @@ -
-

{tmpl_var name='mailquota_txt'}

-
- - - - - - - - +
+
{tmpl_var name='email_txt'}{tmpl_var name='name_txt'}{tmpl_var name='used_txt'}{tmpl_var name='quota_txt'}
+ + + + + + + + - - - - - - - - - - - - - - -
{tmpl_var name='mailquota_txt'}
{tmpl_var name='email_txt'}{tmpl_var name='name_txt'}{tmpl_var name='used_txt'}{tmpl_var name='quota_txt'}
{tmpl_var name='email'}{tmpl_var name='name'}{tmpl_var name='used'}{tmpl_var name='quota'}
{tmpl_var name='no_email_accounts_txt'}
-
-
\ No newline at end of file + + + + {tmpl_var name='email'} + {tmpl_var name='name'} + {tmpl_var name='used'} + {tmpl_var name='quota'} + +
+
+ {tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='quota'} +
+
+ + +
+ + +
\ No newline at end of file diff --git a/interface/web/dashboard/dashlets/templates/modules.htm b/interface/web/dashboard/dashlets/templates/modules.htm index 03fb8cb887217143376804d44d6f0c5433ab16dd..0f60b1b56a464e98849c6a32f4e51e15ede5f4da 100644 --- a/interface/web/dashboard/dashlets/templates/modules.htm +++ b/interface/web/dashboard/dashlets/templates/modules.htm @@ -1,10 +1,18 @@

{tmpl_var name='available_modules_txt'}

-
+
+
\ No newline at end of file diff --git a/interface/web/dashboard/dashlets/templates/quota.htm b/interface/web/dashboard/dashlets/templates/quota.htm index feb8e1f5b07d1dd262d35acdcd8eda8a09773aba..09895a69b654eab9f06b04230a64e05b31191afe 100644 --- a/interface/web/dashboard/dashlets/templates/quota.htm +++ b/interface/web/dashboard/dashlets/templates/quota.htm @@ -1,29 +1,30 @@ -
-

{tmpl_var name='quota_txt'}

-
- - - - - - - - +
+
{tmpl_var name='domain_txt'}{tmpl_var name='used_txt'}{tmpl_var name='soft_txt'}{tmpl_var name='hard_txt'}
+ + + + + + + + - - - - - - - - - - - - - - -
{tmpl_var name='quota_txt'}
{tmpl_var name='domain_txt'}{tmpl_var name='used_txt'}{tmpl_var name='soft_txt'}{tmpl_var name='hard_txt'}
{tmpl_var name='domain'}{tmpl_var name='used'}{tmpl_var name='soft'}{tmpl_var name='hard'}
{tmpl_var name='no_sites_txt'}
+ + + + {tmpl_var name='domain'} + {tmpl_var name='used'} + {tmpl_var name='soft'} + {tmpl_var name='hard'} + +
+
+ {tmpl_var name='used'} {tmpl_var name='of_txt'} {tmpl_var name='soft'} +
+
+ + +
+ +
-
\ 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 b71bd16f6db677ae14e5df56ae412131c46c49ff..176805ea0e911a68845d504af45740c1b0fdc72f 100644 --- a/interface/web/dashboard/lib/custom_menu.inc.php +++ b/interface/web/dashboard/lib/custom_menu.inc.php @@ -71,7 +71,7 @@ if( $atom_url != '' ) { $rows[] = array('title' => $item->get_title(), 'link' => $item->get_link(), 'content' => $item->get_content(), - 'date' => $item->get_date('Y-m-d') + 'date' => $item->get_date($app->lng('conf_format_dateshort')) ); } $n++; diff --git a/interface/web/dashboard/lib/lang/ar_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/ar_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/ar_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/bg_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/bg_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/bg_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/br_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/br_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/br_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/cz_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/cz_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..2a33b3d894d0fa9af19b6e850d010d5116d210e2 --- /dev/null +++ b/interface/web/dashboard/lib/lang/cz_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/de_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/de_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..6c8660d652ed99159a94d4b242582642e881a91a --- /dev/null +++ b/interface/web/dashboard/lib/lang/de_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/el_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/el_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/el_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/en_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/en_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/en_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/es_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/es_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/es_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/fi_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/fi_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/fi_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/fr_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/fr_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/fr_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/hr_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/hr_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/hr_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/hu_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/hu_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/hu_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/id_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/id_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/id_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/it_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/it_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/it_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/ja_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/ja_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/ja_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/nl_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/nl_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/nl_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/pl_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/pl_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/pl_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/pt_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/pt_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/pt_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/ro_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/ro_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/ro_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/ru_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/ru_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/ru_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/se_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/se_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/se_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/sk_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/sk_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/sk_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/lang/tr_dashlet_databasequota.lng b/interface/web/dashboard/lib/lang/tr_dashlet_databasequota.lng new file mode 100644 index 0000000000000000000000000000000000000000..bd2402dbf6c113dde8190fbbdec29490f948d725 --- /dev/null +++ b/interface/web/dashboard/lib/lang/tr_dashlet_databasequota.lng @@ -0,0 +1,7 @@ + diff --git a/interface/web/dashboard/lib/module.conf.php b/interface/web/dashboard/lib/module.conf.php index 67f769e6b927271bdbe1455d611f172578726375..4471f9bf826d83a5b485dce6a3501f600b8ac76f 100644 --- a/interface/web/dashboard/lib/module.conf.php +++ b/interface/web/dashboard/lib/module.conf.php @@ -32,6 +32,7 @@ $module['title'] = 'top_menu_dashboard'; $module['template'] = 'dashboard.tpl.htm'; $module['startpage'] = 'dashboard/dashboard.php'; $module['tab_width'] = ''; +$module['order'] = '1'; //$items = array(); // diff --git a/interface/web/dashboard/templates/custom_menu.htm b/interface/web/dashboard/templates/custom_menu.htm index 4b06779659c111b19e1f639e828521dccef9837b..05e2d4d7df295d074aebb1b6bb8d08df7000f52f 100644 --- a/interface/web/dashboard/templates/custom_menu.htm +++ b/interface/web/dashboard/templates/custom_menu.htm @@ -1,5 +1,5 @@ -

-
{tmpl_var name="toolsarea_head_txt"} +

{tmpl_var name="toolsarea_head_txt"}

- - - - - - - - - - - - + + + + + + + + + + + + + +
-
+
-
-
- - - - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + + + - - - - - - - - + + + + + + + - - - - - - - - + + + + + + + @@ -80,9 +83,9 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="active"}{tmpl_var name="type"}{tmpl_var name="name"}{tmpl_var name="data"}{tmpl_var name="aux"}{tmpl_var name="ttl"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="active"}{tmpl_var name="type"}{tmpl_var name="name"}{tmpl_var name="data"}{tmpl_var name="aux"}{tmpl_var name="ttl"} +
-
+ diff --git a/interface/web/dns/templates/dns_aaaa_edit.htm b/interface/web/dns/templates/dns_aaaa_edit.htm index 44beefc909f7a7e4ac5a3c892872a7aab81d2fa1..fbbc757ceca1d0d3b41ff421382fa9ab72a883b1 100644 --- a/interface/web/dns/templates/dns_aaaa_edit.htm +++ b/interface/web/dns/templates/dns_aaaa_edit.htm @@ -1,42 +1,36 @@ -

+

-
-
-
-
- - -

{tmpl_var name='name_hint_txt'}

-
-
- - + +
+ +

{tmpl_var name='name_hint_txt'}

-
- - -
-
-

{tmpl_var name='active_txt'}

-
+
+ +
+
+ +
+
+ +
{tmpl_var name='active'}
-
+ -
- - -
-
- -
+
+ + +
\ No newline at end of file diff --git a/interface/web/dns/templates/dns_alias_edit.htm b/interface/web/dns/templates/dns_alias_edit.htm index 517df750e86ba523bfddfbef703f376b201ee18c..5ab2a3ccaa23ddb7954266715b6645f2b40bd8fa 100644 --- a/interface/web/dns/templates/dns_alias_edit.htm +++ b/interface/web/dns/templates/dns_alias_edit.htm @@ -1,38 +1,32 @@ -

+

-
-
-
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='active_txt'}

-
+ +
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='active'}
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/dns/templates/dns_cname_edit.htm b/interface/web/dns/templates/dns_cname_edit.htm index 50212131f1dfa22adb88d2d2f3a0ee7d20209724..778279cbd80687f507086c6870107b8388a3f603 100644 --- a/interface/web/dns/templates/dns_cname_edit.htm +++ b/interface/web/dns/templates/dns_cname_edit.htm @@ -1,38 +1,32 @@ -

+

-
-
-
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='active_txt'}

-
+ +
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='active'}
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/dns/templates/dns_dkim_edit.htm b/interface/web/dns/templates/dns_dkim_edit.htm index 052f6d56a7ce2adceaacd9256d3bc0cdf6f95587..6914f13d95a38f0ddedf35bd659b5f1788ff4d04 100644 --- a/interface/web/dns/templates/dns_dkim_edit.htm +++ b/interface/web/dns/templates/dns_dkim_edit.htm @@ -1,29 +1,28 @@ -

+

-
-
-
-
- - + + +
+ +
-
- - -
-
- - -
+
+ +
+
+ +
-
-

{tmpl_var name='active_txt'}

-
+
+ +
{tmpl_var name='active'}
-
+ @@ -31,12 +30,7 @@
-
- - -
-
- -
- - +
+ + +
diff --git a/interface/web/dns/templates/dns_dmarc_edit.htm b/interface/web/dns/templates/dns_dmarc_edit.htm new file mode 100644 index 0000000000000000000000000000000000000000..51116bd506c70a8ecea949c10e31cb2a02aa5f06 --- /dev/null +++ b/interface/web/dns/templates/dns_dmarc_edit.htm @@ -0,0 +1,163 @@ + +

+ + + +
+ +
+ +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_policy_note_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_rua_note_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_ruf_note_txt'} +
+
+ +
+ +
+ +
+
+ {tmpl_var name='dmarc_fo0_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_fo1_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_fod_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_fos_txt'} +
+
+ +
+ +
+ +
+
+ {tmpl_var name='dmarc_adkim_note_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_aspf_note_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_rf_afrf_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_rf_iodef_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_pct_note_txt'} +
+
+
+ +
+ +
+
+ {tmpl_var name='dmarc_ri_note_txt'} +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ + + + + +
+ +
+ + +
+ diff --git a/interface/web/dns/templates/dns_hinfo_edit.htm b/interface/web/dns/templates/dns_hinfo_edit.htm index 0a9e0282f48ab37161373e82d6d4c019a394d628..0be975f529bee5aa8c25147866b789bd27007fec 100644 --- a/interface/web/dns/templates/dns_hinfo_edit.htm +++ b/interface/web/dns/templates/dns_hinfo_edit.htm @@ -1,38 +1,32 @@ -

+

-
-
-
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='active_txt'}

-
+ +
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='active'}
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/dns/templates/dns_import.htm b/interface/web/dns/templates/dns_import.htm index d4806e10f0b3d6506638c62aea44039287fc3e51..aa9346cad088fc52b39d855bc37403e1883baae8 100644 --- a/interface/web/dns/templates/dns_import.htm +++ b/interface/web/dns/templates/dns_import.htm @@ -1,69 +1,63 @@ -

+

-
-
-
+ -
- - {tmpl_var name='server_id'} - +
-
- - {tmpl_var name='client_group_id'} - +
-
- - {tmpl_var name='server_id'} - +
-
- +
+ - {tmpl_var name='domain_option'} - +
- - -

+

+
-
- - +
+ +

-

ERROR

+

-
- - -
- - -
- -
+
+ + +
diff --git a/interface/web/dns/templates/dns_slave_list.htm b/interface/web/dns/templates/dns_slave_list.htm index 9c871fff66905dca3ced47c4ce128fe73f3df72c..27916f4b25976827f1c342742f81f7c63b22e1d7 100644 --- a/interface/web/dns/templates/dns_slave_list.htm +++ b/interface/web/dns/templates/dns_slave_list.htm @@ -1,9 +1,9 @@ -

+

-
-
@@ -20,45 +20,43 @@

-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + - - - - - - + + + + + - - - - - - + + + + + @@ -70,11 +68,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="active"}{tmpl_var name="server_id"}{tmpl_var name="origin"}{tmpl_var name="ns"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="active"}{tmpl_var name="server_id"}{tmpl_var name="origin"}{tmpl_var name="ns"} +
-
-
-
+ + \ No newline at end of file diff --git a/interface/web/dns/templates/dns_soa_admin_list.htm b/interface/web/dns/templates/dns_soa_admin_list.htm index b77f884499b58ed88453a89a134367436468cccd..0f14534c536b829778d1d835014887457d7e5ec4 100644 --- a/interface/web/dns/templates/dns_soa_admin_list.htm +++ b/interface/web/dns/templates/dns_soa_admin_list.htm @@ -1,9 +1,9 @@ -

+

-
-
@@ -20,51 +20,51 @@

-
{tmpl_var name="toolsarea_head_txt"} -
- - - -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + + + -
-
- - - - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + + + - - - - - - - - + + + + + + + - - - - - - - - + + + + + + + @@ -76,11 +76,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="active"}{tmpl_var name="sys_groupid"}{tmpl_var name="server_id"}{tmpl_var name="origin"}{tmpl_var name="ns"}{tmpl_var name="mbox"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="active"}{tmpl_var name="sys_groupid"}{tmpl_var name="server_id"}{tmpl_var name="origin"}{tmpl_var name="ns"}{tmpl_var name="mbox"} +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/dns/templates/dns_soa_edit.htm b/interface/web/dns/templates/dns_soa_edit.htm index d222dffb9f6cc8110cb54ac255852c9a5014ab9c..54d84fad5f5427984d6dfb8ee8c6b3c479e57f0d 100644 --- a/interface/web/dns/templates/dns_soa_edit.htm +++ b/interface/web/dns/templates/dns_soa_edit.htm @@ -1,135 +1,126 @@ -

+

-
-
-
DNS Zone + DNS Zone -
+
- - {tmpl_var name='server_id'} - +
- - {tmpl_var name='server_id'} - +
-
- - {tmpl_var name='client_group_id'} - +
-
+
- - {tmpl_var name='client_server_id'} - +
- - {tmpl_var name='client_server_id'} - +
-
- - {tmpl_var name='client_group_id'} - +
-
- +
+ - {tmpl_var name='domain_option'} - +
- - +

{tmpl_var name='eg_domain_tld'}

-
- - -

{tmpl_var name='eg_ns1_domain_tld'}

-
-
- - -

{tmpl_var name='eg_webmaster_domain_tld'}

-
-
- -  {tmpl_var name='seconds_txt'} -
-
- -  {tmpl_var name='seconds_txt'} -
-
- -  {tmpl_var name='seconds_txt'} +
+ +

{tmpl_var name='eg_ns1_domain_tld'}

-
- -  {tmpl_var name='seconds_txt'} -
-
- -  {tmpl_var name='seconds_txt'} -
-
- - -
-
- - -
-
- - +
+ +

{tmpl_var name='eg_webmaster_domain_tld'}

+
+ +
 {tmpl_var name='seconds_txt'} +
+
+ +
 {tmpl_var name='seconds_txt'} +
+
+ +
 {tmpl_var name='seconds_txt'} +
+
+ +
 {tmpl_var name='seconds_txt'} +
+
+ +
 {tmpl_var name='seconds_txt'} +
+
+ +
+
+ +
+
+ +
-
-

{tmpl_var name='active_txt'}

-
+
+ +
{tmpl_var name='active'}
- + -
- - -
-
- -
+
+ + +
diff --git a/interface/web/dns/templates/dns_soa_list.htm b/interface/web/dns/templates/dns_soa_list.htm index 0429407c44d883f9aabf8b36d24f09bead1aa087..5162119900ca21c5cc5234c0a1a36409c62cb16f 100644 --- a/interface/web/dns/templates/dns_soa_list.htm +++ b/interface/web/dns/templates/dns_soa_list.htm @@ -1,9 +1,9 @@ -

+

-
-
@@ -20,48 +20,48 @@

-
{tmpl_var name="toolsarea_head_txt"} -
- - - -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + + + -
-
- - - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + + - - - - - - - + + + + + + - - - - - - - + + + + + + @@ -73,11 +73,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="active"}{tmpl_var name="server_id"}{tmpl_var name="origin"}{tmpl_var name="ns"}{tmpl_var name="mbox"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="active"}{tmpl_var name="server_id"}{tmpl_var name="origin"}{tmpl_var name="ns"}{tmpl_var name="mbox"} +
-
-
-
+ + \ No newline at end of file diff --git a/interface/web/dns/templates/dns_spf_edit.htm b/interface/web/dns/templates/dns_spf_edit.htm new file mode 100644 index 0000000000000000000000000000000000000000..bc8c1a20e643d01ea64627a5e2aa968126ddc0cd --- /dev/null +++ b/interface/web/dns/templates/dns_spf_edit.htm @@ -0,0 +1,62 @@ + +

+ + + +
+ +
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+ {tmpl_var name='spf_ip_note_txt'} +
+
+ +
+ {tmpl_var name='spf_hostname_note_txt'} +
+
+ +
+ {tmpl_var name='spf_domain_note_txt'} +
+
+ +
+
+ +
+ +
+
+ + + + + + + +
+ +
+ + +
+ diff --git a/interface/web/dns/templates/dns_srv_edit.htm b/interface/web/dns/templates/dns_srv_edit.htm index b50abe6dcf4ff071e64cc00cdf2dfe4b41f15221..fd9f00d7b48058871fc68373d7ff8d2be8ac7320 100644 --- a/interface/web/dns/templates/dns_srv_edit.htm +++ b/interface/web/dns/templates/dns_srv_edit.htm @@ -1,50 +1,41 @@ -

+

-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='active_txt'}

-
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='active'}
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/dns/templates/dns_template_edit.htm b/interface/web/dns/templates/dns_template_edit.htm index 36ab9e05ba59ff1612c1fc1b9633595f7f09be6d..132cc92810846675e769c56decc87ac4df8df314 100644 --- a/interface/web/dns/templates/dns_template_edit.htm +++ b/interface/web/dns/templates/dns_template_edit.htm @@ -1,38 +1,34 @@ -

+

-
-
-
-
- - -
-
-

{tmpl_var name='fields_txt'}

-
+ +
+ +
+
+ +
{tmpl_var name='fields'}
-
- - +
+ +
-
-

{tmpl_var name='visible_txt'}

-
+
+ +
{tmpl_var name='visible'}
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/dns/templates/dns_template_list.htm b/interface/web/dns/templates/dns_template_list.htm index 7b6ec0a1e0cedfe3690b8fb20d92c9afa4c3a327..f7816cf4d8aed22884545a539eb007e8e14e7560 100644 --- a/interface/web/dns/templates/dns_template_list.htm +++ b/interface/web/dns/templates/dns_template_list.htm @@ -1,42 +1,40 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + - - - - + + + - - - - + + + @@ -48,11 +46,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="visible"}{tmpl_var name="name"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="visible"}{tmpl_var name="name"} +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/dns/templates/dns_txt_edit.htm b/interface/web/dns/templates/dns_txt_edit.htm index 7884a86bd6b8174f039a5401d7c0a0b63b88ed8c..f03f6d36c86209aec2aff3e2c368ba83e13b7f41 100644 --- a/interface/web/dns/templates/dns_txt_edit.htm +++ b/interface/web/dns/templates/dns_txt_edit.htm @@ -1,38 +1,32 @@ -

+

-
-
-
-
- - -
-
- - -
-
- - -
-
-

{tmpl_var name='active_txt'}

-
+ +
+ +
+
+ +
+
+ +
+
+ +
{tmpl_var name='active'}
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/dns/templates/dns_wizard.htm b/interface/web/dns/templates/dns_wizard.htm index d518b4a77feb7699bbbcf3de1f443f1b7b79cc2a..fc57fb99e226661b78b1ba126c0f5832b781c012 100644 --- a/interface/web/dns/templates/dns_wizard.htm +++ b/interface/web/dns/templates/dns_wizard.htm @@ -1,115 +1,106 @@ -

+

-

ERROR

+

-
-
-
-
- - {tmpl_var name='template_id_option'} - +
-
- - {tmpl_var name='server_id'} - +
-
- - {tmpl_var name='client_group_id'} - +
-
- - {tmpl_var name='server_id'} - +
-
- - {tmpl_var name='client_group_id'} - +
-
- +
+ - {tmpl_var name='domain_option'} - +
- - +
-
- - -
+
+ +
-
- - -
+
+ +
-
- - -
+
+ +
-
- - -
+
+ +
-
- - -
+
+ +
- + - + -
- - -
-
- -
+
+ + +
diff --git a/interface/web/help/faq_list.php b/interface/web/help/faq_list.php index 53b2992c622465d6ab56a5b6176aceb49a4caa46..128480dca2c2573d3dcb630a4a4d0730d00ce640 100644 --- a/interface/web/help/faq_list.php +++ b/interface/web/help/faq_list.php @@ -29,7 +29,7 @@ if(!$hf_section) $app->listform_actions->SQLExtWhere = "help_faq.hf_section = $hf_section"; -if($hf_section) $res = $app->db->queryOneRecord("SELECT hfs_name FROM help_faq_sections WHERE hfs_id=$hf_section"); +if($hf_section) $res = $app->db->queryOneRecord("SELECT hfs_name FROM help_faq_sections WHERE hfs_id=?", $hf_section); // Start the form rendering and action ahndling echo "

FAQ: ".$res['hfs_name']."

"; if($hf_section) $app->listform_actions->onLoad(); diff --git a/interface/web/help/form/support_message.tform.php b/interface/web/help/form/support_message.tform.php index d982712c6499f4a77de2d80b07dc28653f7f072a..d80cc158157afa3f8aa6b79fc97dddad9b76a546 100644 --- a/interface/web/help/form/support_message.tform.php +++ b/interface/web/help/form/support_message.tform.php @@ -46,7 +46,7 @@ $sm_default_subject = ''; if(isset($_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"); + $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']; diff --git a/interface/web/help/support_message_edit.php b/interface/web/help/support_message_edit.php index 2d47bbf2513d7fa8397a929ed2a3ee63d5765df0..4fcf5da215b7a99e226eacce34d52dd3612d89e6 100644 --- a/interface/web/help/support_message_edit.php +++ b/interface/web/help/support_message_edit.php @@ -33,8 +33,8 @@ class page_action extends tform_actions { //* Get recipient email address if($this->dataRecord['recipient_id'] > 1){ - $sql = "SELECT client.email FROM sys_user, client WHERE sys_user.userid = ".$app->functions->intval($this->dataRecord['recipient_id'])." AND sys_user.client_id = client.client_id"; - $client = $app->db->queryOneRecord($sql); + $sql = "SELECT client.email FROM sys_user, client WHERE sys_user.userid = ? AND sys_user.client_id = client.client_id"; + $client = $app->db->queryOneRecord($sql, $this->dataRecord['recipient_id']); $recipient_email = $client['email']; } else { $app->uses('ini_parser,getconf'); @@ -44,8 +44,8 @@ class page_action extends tform_actions { //* Get sender email address if($this->dataRecord['sender_id'] > 1){ - $sql = "SELECT client.email FROM sys_user, client WHERE sys_user.userid = ".$app->functions->intval($this->dataRecord['sender_id'])." AND sys_user.client_id = client.client_id"; - $client = $app->db->queryOneRecord($sql); + $sql = "SELECT client.email FROM sys_user, client WHERE sys_user.userid = ? AND sys_user.client_id = client.client_id"; + $client = $app->db->queryOneRecord($sql, $this->dataRecord['sender_id']); $sender_email = $client['email']; } else { $app->uses('ini_parser,getconf'); @@ -91,7 +91,7 @@ class page_action extends tform_actions { //* 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); + $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)) { @@ -113,7 +113,7 @@ class page_action extends tform_actions { global $app, $conf; if($_SESSION['s']['user']['typ'] == 'admin') { - $app->db->query("UPDATE support_message SET sys_userid = ".$app->functions->intval($this->dataRecord['recipient_id'])." WHERE support_message_id = ".$this->id); + $app->db->query("UPDATE support_message SET sys_userid = ? WHERE support_message_id = ?", $this->dataRecord['recipient_id'], $this->id); } } diff --git a/interface/web/help/templates/faq_edit.htm b/interface/web/help/templates/faq_edit.htm index dc353589de5ccf9a0e1766d2d762f6524e051cd5..3bf9d8a903a100a998e8b1e9b3ae878b5273a9c3 100644 --- a/interface/web/help/templates/faq_edit.htm +++ b/interface/web/help/templates/faq_edit.htm @@ -1,29 +1,23 @@ -
-
-
{tmpl_var name='faq_faq_txt'} -
- - {tmpl_var name='hf_section'} - +
-
- - +
+ +
+
+ +
-
- - -
- + -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/help/templates/faq_manage_questions_list.htm b/interface/web/help/templates/faq_manage_questions_list.htm index e7b5eafe829d3598fef5382703cd910224c24997..7659d39092be009160a7ddb33dcc71c69c978baf 100644 --- a/interface/web/help/templates/faq_manage_questions_list.htm +++ b/interface/web/help/templates/faq_manage_questions_list.htm @@ -1,37 +1,33 @@

{tmpl_var name="faq_faq_questions_txt"}

-
- -
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
-
-
- - - - - - - +

{tmpl_var name="toolsarea_head_txt"}

+ + + + + + +

+
+
{tmpl_var name="faq_question_txt"}{tmpl_var name="faq_section_name_txt"}{tmpl_var name="faq_delete_txt"}{tmpl_var name="faq_edit_txt"}
+ + + + + + - + - - @@ -43,11 +39,10 @@ - +
{tmpl_var name="faq_question_txt"}{tmpl_var name="faq_section_name_txt"}{tmpl_var name="faq_delete_txt"}{tmpl_var name="faq_edit_txt"}
{tmpl_var name='hf_question'} {tmpl_var name='hf_section'} - {tmpl_var name="faq_delete_txt"} + + - {tmpl_var name="faq_edit_txt"} + +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/help/templates/faq_sections_edit.htm b/interface/web/help/templates/faq_sections_edit.htm index b4c2754741d100267240ff07d2ba4de507c17f4d..1380447db870743aada6e519c00c4959e9e50a9d 100644 --- a/interface/web/help/templates/faq_sections_edit.htm +++ b/interface/web/help/templates/faq_sections_edit.htm @@ -1,20 +1,14 @@ -
-
-
{tmpl_var name='faq_section_name_txt'} -
- - -
-
+ {tmpl_var name='faq_section_name_txt'} +
+ +
+ -
- - -
-
- -
+
+ + +
diff --git a/interface/web/help/templates/help_faq_list.htm b/interface/web/help/templates/help_faq_list.htm index ae5ae11e5df08b7790ff8f98381e5642080b1199..e81dae2e0ba7279ce2c4f5a03203c4e0e04cf15f 100644 --- a/interface/web/help/templates/help_faq_list.htm +++ b/interface/web/help/templates/help_faq_list.htm @@ -5,8 +5,8 @@ {tmpl_var name='hf_answer'}

-
{tmpl_var name="delete_txt"} - {tmpl_var name="edit_txt"} + + {tmpl_var name="edit_txt"}


diff --git a/interface/web/help/templates/help_faq_sections_list.htm b/interface/web/help/templates/help_faq_sections_list.htm index 298b9073bba44607228b4b40aea37b1393d3c2d8..5a3733aa0b6da6333fee5cdd762ef3b804f1f974 100644 --- a/interface/web/help/templates/help_faq_sections_list.htm +++ b/interface/web/help/templates/help_faq_sections_list.htm @@ -1,37 +1,35 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - + +

+
+
{tmpl_var name="faq_section_name_txt"}{tmpl_var name="faq_delete_txt"}{tmpl_var name="faq_edit_txt"}
+ + + + + - - - + + - @@ -43,11 +41,10 @@ - +
{tmpl_var name="faq_section_name_txt"}{tmpl_var name="faq_delete_txt"}{tmpl_var name="faq_edit_txt"}
{tmpl_var name='hfs_name'} - {tmpl_var name="faq_delete_txt"} +
{tmpl_var name='hfs_name'} + - {tmpl_var name="faq_edit_txt"} + +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/help/templates/support_message_edit.htm b/interface/web/help/templates/support_message_edit.htm index c3f23a3c3830269890c347a8f4b1d5fc13f96a20..fb54578e1670cc3d87a73c5d5cf06ced8bcd82fc 100644 --- a/interface/web/help/templates/support_message_edit.htm +++ b/interface/web/help/templates/support_message_edit.htm @@ -1,33 +1,29 @@ -

+

-
-
-
{tmpl_var name='message_txt'} -
- - {tmpl_var name='recipient_id'} - +
-
- - +
+ +
+
+ +
-
- - -
- + -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/help/templates/support_message_list.htm b/interface/web/help/templates/support_message_list.htm index d3fa429a074429415a812e5bf7c4c37ade4d0dc6..1695cccd77dbba128923d76dd9ad2f79755ee4ee 100644 --- a/interface/web/help/templates/support_message_list.htm +++ b/interface/web/help/templates/support_message_list.htm @@ -1,45 +1,43 @@ -

+

-
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + - - - - - + + + + - - - - - + + + + @@ -51,11 +49,10 @@ - +
{tmpl_var name='search_limit'}
  - +
  +
{tmpl_var name="sender_id"}{tmpl_var name="subject"}{tmpl_var name="tstamp"} - {tmpl_var name='delete_txt'} +
{tmpl_var name="sender_id"}{tmpl_var name="subject"}{tmpl_var name="tstamp"} +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/interface/web/help/templates/support_message_view.htm b/interface/web/help/templates/support_message_view.htm index f7145e0b65a4e34e1e706e0983570868584b668d..faaaf859cd0843cc8e7070b68232abfac6bb97f3 100644 --- a/interface/web/help/templates/support_message_view.htm +++ b/interface/web/help/templates/support_message_view.htm @@ -1,26 +1,23 @@ -

+

-
-
-
{tmpl_var name='message_txt'} -
- + {tmpl_var name='message_txt'} +
+

{tmpl_var name='subject'}

-
- +
+

{tmpl_var name='message'}

-
- +
+

{tmpl_var name='date'}

-
-
- -
-
- -
\ No newline at end of file + +
+ +
\ No newline at end of file diff --git a/interface/web/index.php b/interface/web/index.php index 80eab1110e8c915037aa89b3dae986dc87ad9c23..af91b265a2b1f45f5541fb0d9fc49e47a9cd39a7 100644 --- a/interface/web/index.php +++ b/interface/web/index.php @@ -35,6 +35,7 @@ if(!isset($_SESSION['s']['module']['name'])) $_SESSION['s']['module']['name'] = $app->uses('tpl'); $app->tpl->newTemplate('main.tpl.htm'); +$app->tpl->setVar('logged_in', ($_SESSION['s']['user']['active'] != 1 ? 'n' : 'y')); // tab change warning? // read misc config @@ -51,6 +52,14 @@ if($sys_config['tab_change_discard'] == 'y') { $app->tpl->setVar('global_tabchange_discard_txt', $app->lng('global_tabchange_discard_txt')); } +if($sys_config['use_loadindicator'] == 'y') { + $app->tpl->setVar('use_loadindicator', 'y'); +} +if($sys_config['use_combobox'] == 'y') { + $app->tpl->setVar('use_combobox', 'y'); +} + + if(isset($_SESSION['show_info_msg'])) { $app->tpl->setVar('show_info_msg', $_SESSION['show_info_msg']); unset($_SESSION['show_info_msg']); @@ -77,6 +86,21 @@ if(@is_dir($js_d)) { if (!empty($js_d_files)) $app->tpl->setLoop('js_d_includes', $js_d_files); unset($js_d_files); +$app->tpl->setVar('current_theme', isset($_SESSION['s']['theme']) ? $_SESSION['s']['theme'] : 'default'); + +// Logo +$logo = $app->db->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1"); +if($logo['custom_logo'] != ''){ + $base64_logo_txt = $logo['custom_logo']; +} else { + $base64_logo_txt = $logo['default_logo']; +} +$tmp_base64 = explode(',', $base64_logo_txt, 2); +$logo_dimensions = $app->functions->getimagesizefromstring(base64_decode($tmp_base64[1])); +$app->tpl->setVar('base64_logo_width', $logo_dimensions[0]); +$app->tpl->setVar('base64_logo_height', $logo_dimensions[1]); +$app->tpl->setVar('base64_logo_txt', $base64_logo_txt); + $app->tpl_defaults(); $app->tpl->pparse(); ?> diff --git a/interface/web/js/dns_dkim.js b/interface/web/js/dns_dkim.js deleted file mode 100644 index 58f8dcf0321c63a368ad9369750b0bd32bab2973..0000000000000000000000000000000000000000 --- a/interface/web/js/dns_dkim.js +++ /dev/null @@ -1,72 +0,0 @@ -/* -Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh -Copyright (c) 2013, Florian Schaal, info@schaal-24.de -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of ISPConfig nor the names of its contributors - may be used to endorse or promote products derived from this software without - specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - -This Javascript is invoked by - * dns/templates/dns_dkim_edit.htm to get the public key -*/ - var request = false; - - function setRequest(zone) { - if (window.XMLHttpRequest) {request = new XMLHttpRequest();} - else if (window.ActiveXObject) { - try {request = new ActiveXObject('Msxml2.XMLHTTP');} - catch (e) { - try {request = new ActiveXObject('Microsoft.XMLHTTP');} - catch (e) {} - } - } - if (!request) { - alert("Error creating XMLHTTP-instance"); - return false; - } else { - request.open('POST', 'dns/dns_dkim_get.php', true); - request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); - request.send('&zone='+zone); - request.onreadystatechange = interpretRequest; - } - } - - function interpretRequest() { - switch (request.readyState) { - case 4: - if (request.status != 200) {alert("Request done but NOK\nError:"+request.status);} - else { - document.getElementsByName('data')[0].value = request.responseXML.getElementsByTagName('data')[0].firstChild.nodeValue; - document.getElementsByName('name')[0].value = request.responseXML.getElementsByTagName('name')[0].firstChild.nodeValue; - document.getElementsByName('selector')[0].value = request.responseXML.getElementsByTagName('selector')[0].firstChild.nodeValue; - } - break; - default: - break; - } - } - -var serverType = jQuery('#zone').val(); -setRequest(serverType); diff --git a/interface/web/js/jquery-2.1.1.min.js b/interface/web/js/jquery-2.1.1.min.js deleted file mode 100755 index 05fb1ec2be090d3cf9ae6a2517d2bac4a6745ce2..0000000000000000000000000000000000000000 --- a/interface/web/js/jquery-2.1.1.min.js +++ /dev/null @@ -1,26 +0,0 @@ -/*! - * jQuery JavaScript Library v2.1.1 - * http://jquery.com/ - * - * Includes Sizzle.js - * http://sizzlejs.com/ - * - * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors - * Released under the MIT license - * http://jquery.org/license - * - * Date: 2014-05-01T17:11Z - */ -!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b=a.length,c=_.type(a);return"function"===c||_.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(hb.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=ob[a]={};return _.each(a.match(nb)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+Math.random()}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ub,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:tb.test(c)?_.parseJSON(c):c}catch(e){}sb.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Kb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)rb.set(a[c],"globalEval",!b||rb.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(rb.hasData(a)&&(f=rb.access(a),g=rb.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sb.hasData(a)&&(h=sb.access(a),i=_.extend({},h),sb.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&yb.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Ob[a];return c||(c=t(a,b),"none"!==c&&c||(Nb=(Nb||_(" -
- - diff --git a/interface/web/themes/default/CHANGELOG b/interface/web/themes/default/CHANGELOG deleted file mode 100644 index 454964210b1c78a57d230d7230ffbaf243d4ce40..0000000000000000000000000000000000000000 --- a/interface/web/themes/default/CHANGELOG +++ /dev/null @@ -1,32 +0,0 @@ -CHANGELOG -default -> default-v2 -source: default $3241 07/06/2012 @ 12:00 UTC+2 -resources @ https://github.com/foe-services/ispc-resources - -- changed doctype to (HTML5) -- rm yaml/* -- rm css/patches/* -- cp yaml/patches/iehacks.css css/* -- rm - " /> - <tmpl_var name="app_title"> <tmpl_var name="app_version"> - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- -

ISPConfig 3

- hosting control panel -
- - - - - + + + + - -
- - -
-
- -
-
-
 
- -
- -
- - - + /assets/stylesheets/bootstrap.min.css' /> + /assets/stylesheets/fonts.min.css' /> + /assets/stylesheets/ispconfig.min.css' /> + /assets/stylesheets/pushy.min.css' /> + /assets/stylesheets/bootstrap-datetimepicker.min.css' /> + /assets/stylesheets/responsive.min.css' /> + /assets/stylesheets/themes/default/theme.min.css' /> + /assets/stylesheets/select2.css' /> + /assets/stylesheets/select2-bootstrap.css' /> + /assets/stylesheets/login.css' /> + + + + + +
+ +
+
+
+
+
+ + + + +
+
+ + + + + +
+
+
+
+ + + + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
- - - - + +
+
+
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/interface/web/themes/default/templates/module.tpl.htm b/interface/web/themes/default/templates/module.tpl.htm index f8a26defc603072660ccf9fd3e8bc2bab395506f..ebbaf91b1466f0ef3505718c1d6fc2c72e6b3fdd 100644 --- a/interface/web/themes/default/templates/module.tpl.htm +++ b/interface/web/themes/default/templates/module.tpl.htm @@ -19,7 +19,7 @@ - +
diff --git a/interface/web/themes/default/templates/module_tree.tpl.htm b/interface/web/themes/default/templates/module_tree.tpl.htm index be213819d0e5ea4d992f942dc69fe6c466519e06..3eca1dfe68fe6d846ae0da7b9d52e603abbc7ea7 100644 --- a/interface/web/themes/default/templates/module_tree.tpl.htm +++ b/interface/web/themes/default/templates/module_tree.tpl.htm @@ -20,7 +20,7 @@ - +
diff --git a/interface/web/themes/default/templates/sidenav.tpl.htm b/interface/web/themes/default/templates/sidenav.tpl.htm index b42ea6667a363b29b8e52a029813aa339a5b4ee3..b85100336026b611656d73f5630f6a3052cfddef 100644 --- a/interface/web/themes/default/templates/sidenav.tpl.htm +++ b/interface/web/themes/default/templates/sidenav.tpl.htm @@ -1,28 +1,22 @@ - \ No newline at end of file + +
+ +
diff --git a/interface/web/themes/default/templates/tabbed_form.tpl.htm b/interface/web/themes/default/templates/tabbed_form.tpl.htm index 08002d5282c918377fac880c45db6ba926bbc5e6..5560f3e12c733b8f6ef6e4e4336b0c39fe35619b 100644 --- a/interface/web/themes/default/templates/tabbed_form.tpl.htm +++ b/interface/web/themes/default/templates/tabbed_form.tpl.htm @@ -1,27 +1,43 @@ - -

-
-
-
    - - -
  • - -
  • -
    + + + + +
    + +
    +
    + +
    +
    +
    +
    +
    TODO: IP address is empty.
    +
    TODO: Hostname is empty.
    +
    +
    +
    + + +
    + + -
    -
    - -

    -
    - -

    ERROR

    -
    - - -
    +
+ +
+
+ +
+
+ + + +
+ - - \ No newline at end of file diff --git a/interface/web/themes/default/templates/topnav.tpl.htm b/interface/web/themes/default/templates/topnav.tpl.htm index 485fa23083e2fb75b5a014cf413d4268fce0e63b..8637eaf6577b3fe5ede6226d1db4f2eea896353f 100644 --- a/interface/web/themes/default/templates/topnav.tpl.htm +++ b/interface/web/themes/default/templates/topnav.tpl.htm @@ -1,9 +1,9 @@ - + diff --git a/interface/web/themes/default_64_navimg/css/additional.css b/interface/web/themes/default_64_navimg/css/additional.css deleted file mode 100644 index c064817d930b3baf0db516a41e8db492fe137483..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_64_navimg/css/additional.css +++ /dev/null @@ -1,64 +0,0 @@ -@media all -{ - #topNav a { - background-color: #D3D3D3; - background-position: center top; - background-repeat: no-repeat; - color:black; - display:inline-block; - height:20px; - padding-top:68px; - text-align:center; - text-decoration:none; - width:97px; - } - - .topnav-admin { - background-image: url('/themes/default_304/icons/x64/system.png') !important; - } - - .topnav-client { - background-image: url('/themes/default_304/icons/x64/client.png') !important; - } - - .topnav-mail { - background-image: url('/themes/default_304/icons/x64/email.png') !important; - } - - .topnav-monitor { - background-image: url('/themes/default_304/icons/x64/monitor.png') !important; - } - - .topnav-sites { - background-image: url('/themes/default_304/icons/x64/sites.png') !important; - } - - .topnav-dns { - background-image: url('/themes/default_304/icons/x64/dns.png') !important; - } - - .topnav-tools { - background-image: url('/themes/default_304/icons/x64/tools.png') !important; - } - - .topnav-help { - background-image: url('/themes/default_304/icons/x64/help.png') !important; - } - - .topnav- { - background-image: url('/themes/default_304/icons/x64/login.png') !important; - } - - .topnav-domain { - background-image: url('/themes/default_304/icons/x64/domain.png') !important; - } - - .topnav-dashboard { - background-image: url('/themes/default_304/icons/x64/dashboard.png') !important; - } - - .topnav-vm { - background-image: url("/themes/default_304/icons/x64/drawer.png") !important; - } - -} \ No newline at end of file diff --git a/interface/web/themes/default_64_navimg/icons/x16/arrow.png b/interface/web/themes/default_64_navimg/icons/x16/arrow.png deleted file mode 100644 index 82cfae37cce484b4f63c7cabf3eb6ab65fe8ccd5..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_64_navimg/icons/x16/arrow.png and /dev/null differ diff --git a/interface/web/themes/default_64_navimg/icons/x16/arrow_180.png b/interface/web/themes/default_64_navimg/icons/x16/arrow_180.png deleted file mode 100644 index a1e5e6bc61f8403e588f24a32090b5ccae1eef74..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_64_navimg/icons/x16/arrow_180.png and /dev/null differ diff --git a/interface/web/themes/default_64_navimg/icons/x16/arrow_stop.png b/interface/web/themes/default_64_navimg/icons/x16/arrow_stop.png deleted file mode 100644 index 702b9b7b791ab1ffbc3ceb962b75434421d1f156..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_64_navimg/icons/x16/arrow_stop.png and /dev/null differ diff --git a/interface/web/themes/default_64_navimg/icons/x16/arrow_stop_180.png b/interface/web/themes/default_64_navimg/icons/x16/arrow_stop_180.png deleted file mode 100644 index 573ff4889bd49f1a63d35d9c4e7e1b440c43629e..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_64_navimg/icons/x16/arrow_stop_180.png and /dev/null differ diff --git a/interface/web/themes/default_64_navimg/ispconfig_version b/interface/web/themes/default_64_navimg/ispconfig_version deleted file mode 100644 index bb19ac367e61ef69398f09154456075f734e0d46..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_64_navimg/ispconfig_version +++ /dev/null @@ -1 +0,0 @@ -3.0.4.6 \ No newline at end of file diff --git a/interface/web/themes/default_64_navimg/templates/main.tpl.htm b/interface/web/themes/default_64_navimg/templates/main.tpl.htm deleted file mode 100644 index 6d0395ba1fff1849b6d1e2bda095d107d6dd11b7..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_64_navimg/templates/main.tpl.htm +++ /dev/null @@ -1,188 +0,0 @@ - - - - <tmpl_var name="app_title"> <tmpl_var name="app_version"> - "/> - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- -
-
-
 
-
-
- - -
-
- - -
- -
-
-
-
 
- -
- -
- - - -
-
- - diff --git a/interface/web/themes/default_combobox/css/additional.css b/interface/web/themes/default_combobox/css/additional.css deleted file mode 100644 index be7769b331e25a47bf166be8ca851694c38085d3..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_combobox/css/additional.css +++ /dev/null @@ -1,153 +0,0 @@ -.list button.ui-widget{position:absolute} - -/* - * jQuery UI CSS Framework 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Theming/API - */ - -/* Layout helpers -----------------------------------*/ -.ui-helper-hidden { display: none; } -.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } -.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } -.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } -.ui-helper-clearfix { display: inline-block; } -/* required comment for clearfix to work in Opera \*/ -* html .ui-helper-clearfix { height:1%; } -.ui-helper-clearfix { display:block; } -/* end clearfix */ -.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } - - -/* Interaction Cues -----------------------------------*/ -.ui-state-disabled { cursor: default !important; } - - -/* Icons -----------------------------------*/ - -/* states and ../images */ -.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } - - -/* Misc visuals -----------------------------------*/ - -/* Overlays */ -.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } - - - -/* Component containers -----------------------------------*/ -.ui-widget-content a { color: #333333; } -.ui-widget-header { border: 1px solid #e78f08; background: #f6a828; color: #ffffff; font-weight: bold; } -.ui-widget-header a { color: #ffffff; } - -/* Interaction states -----------------------------------*/ -.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #F5F5F5; font-weight: bold; color: #1c94c4; } -.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; } -.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #dfdfdf; background: #FFFACD; font-weight: bold; } -.ui-state-hover a, .ui-state-hover a:hover { color: #c77405; text-decoration: none; } -.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #dfdfdf; background: #ffffff; font-weight: bold;} -.ui-widget :active { outline: none; } - -/* Interaction Cues -----------------------------------*/ -.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(../images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; } -.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } -.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; } -.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; } -.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } - - -/* Icons -----------------------------------*/ - -/* states and ../images */ -.ui-icon { width: 16px; height: 16px; background-image: url(../images/ui-image.png); } -.ui-widget-content .ui-icon {background-image: url(../images/ui-image.png); } -.ui-widget-header .ui-icon {background-image: url(../images/ui-icons_ffffff_256x240.png); } -.ui-state-default .ui-icon { background-image: url(../images/ui-image.png); } -.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(../images/ui-image.png); } -.ui-state-active .ui-icon {background-image: url(../images/ui-image.png); } -.ui-state-highlight .ui-icon {background-image: url(../images/ui-image.png); } -.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(../images/ui-image.png); } - -/* positioning */ -.ui-icon-triangle-1-s { background-position: -64px -16px; } - -.ui-autocomplete { position: absolute; cursor: default; } - -/* workarounds */ -* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ - - -.ui-menu { - list-style:none; - padding: 2px; - margin: 0; - display:block; - float: left; -} -.ui-menu .ui-menu { - margin-top: -3px; -} -.ui-menu .ui-menu-item { - margin:0; - padding: 0; - zoom: 1; - float: left; - clear: left; - width: 100%; -} -.ui-menu .ui-menu-item a {text-align:left;text-decoration:none; - display:block; - padding:.1em .4em; - line-height:1.5; - zoom:1; - height: 15px; -} -.ui-menu .ui-menu-item a.ui-state-hover, -.ui-menu .ui-menu-item a.ui-state-active { - font-weight: normal; - margin: -1px; -} -.ui-widget-content{background:#fff;border:1px solid #DFDFDF} -.ui-autocomplete-input{width:60%} -.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ -.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ -button.ui-button-icon-only { width:17px } /* button elements seem to need a little more width */ -.ui-button-icons-only { width: 3.4em; } -button.ui-button-icons-only { width: 3.7em; } - -/*button text element */ -.ui-button .ui-button-text { display: block; line-height: 1; } -.ui-button-text-only .ui-button-text { padding: .4em 1em; } -.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .20em; text-indent: -9999999px; } -.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } -.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; } -.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } -/* no icon support for input elements, provide padding by default */ -input.ui-button { padding: .4em 1em; } - -/*button icon element(s) */ -.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -10px; } -.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } -.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } -.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } -.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } - -/*button sets*/ -.ui-buttonset { margin-right: 7px; } -.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } - -/* workarounds */ -button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ \ No newline at end of file diff --git a/interface/web/themes/default_combobox/icons/x16/arrow.png b/interface/web/themes/default_combobox/icons/x16/arrow.png deleted file mode 100644 index 82cfae37cce484b4f63c7cabf3eb6ab65fe8ccd5..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_combobox/icons/x16/arrow.png and /dev/null differ diff --git a/interface/web/themes/default_combobox/icons/x16/arrow_180.png b/interface/web/themes/default_combobox/icons/x16/arrow_180.png deleted file mode 100644 index a1e5e6bc61f8403e588f24a32090b5ccae1eef74..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_combobox/icons/x16/arrow_180.png and /dev/null differ diff --git a/interface/web/themes/default_combobox/icons/x16/arrow_stop.png b/interface/web/themes/default_combobox/icons/x16/arrow_stop.png deleted file mode 100644 index 702b9b7b791ab1ffbc3ceb962b75434421d1f156..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_combobox/icons/x16/arrow_stop.png and /dev/null differ diff --git a/interface/web/themes/default_combobox/icons/x16/arrow_stop_180.png b/interface/web/themes/default_combobox/icons/x16/arrow_stop_180.png deleted file mode 100644 index 573ff4889bd49f1a63d35d9c4e7e1b440c43629e..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_combobox/icons/x16/arrow_stop_180.png and /dev/null differ diff --git a/interface/web/themes/default_combobox/images/ui-image.png b/interface/web/themes/default_combobox/images/ui-image.png deleted file mode 100644 index d1de91b97885eaefee236617223ddcf576137cf0..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_combobox/images/ui-image.png and /dev/null differ diff --git a/interface/web/themes/default_combobox/ispconfig_version b/interface/web/themes/default_combobox/ispconfig_version deleted file mode 100644 index bb19ac367e61ef69398f09154456075f734e0d46..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_combobox/ispconfig_version +++ /dev/null @@ -1 +0,0 @@ -3.0.4.6 \ No newline at end of file diff --git a/interface/web/themes/default_combobox/templates/main.tpl.htm b/interface/web/themes/default_combobox/templates/main.tpl.htm deleted file mode 100644 index 1df185fdad92300523917b5edb867d00cfdd3511..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_combobox/templates/main.tpl.htm +++ /dev/null @@ -1,343 +0,0 @@ - - - - <tmpl_var name="app_title"> <tmpl_var name="app_version"> - "/> - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- -
-
-
 
-
-
- - -
-
- - -
- -
-
-
-
 
- -
- -
- - - -
-
- - diff --git a/interface/web/themes/default_no_navimg/css/additional.css b/interface/web/themes/default_no_navimg/css/additional.css deleted file mode 100644 index d17ab55d200eea01cc3df64e92a532821dd6e2b4..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_no_navimg/css/additional.css +++ /dev/null @@ -1,68 +0,0 @@ -@media all -{ - #topNav a { - background-color: #D3D3D3; - background-position: center top; - background-repeat: no-repeat; - color:black; - display:inline-block; - height:20px; - padding-top:5px; - text-align:center; - text-decoration:none; - width:66px; - } - - .topnav-admin { - background-image: none !important; - } - - .topnav-client { - background-image: none !important; - } - - .topnav-mail { - background-image: none !important; - } - - .topnav-monitor { - background-image: none !important; - } - - .topnav-vm { - background-image: none !important; - } - - .topnav-sites { - background-image: none !important; - } - - .topnav-dns { - background-image: none !important; - } - - .topnav-tools { - background-image: none !important; - } - - .topnav-help { - background-image: none !important; - } - - .topnav- { - background-image: none !important; - } - - .topnav-domain { - background-image: none !important; - } - - .topnav-dashboard { - background-image: none !important; - } - - .topnav-billing { - background-image: none !important; - } - -} \ No newline at end of file diff --git a/interface/web/themes/default_no_navimg/icons/x16/arrow.png b/interface/web/themes/default_no_navimg/icons/x16/arrow.png deleted file mode 100644 index 82cfae37cce484b4f63c7cabf3eb6ab65fe8ccd5..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_no_navimg/icons/x16/arrow.png and /dev/null differ diff --git a/interface/web/themes/default_no_navimg/icons/x16/arrow_180.png b/interface/web/themes/default_no_navimg/icons/x16/arrow_180.png deleted file mode 100644 index a1e5e6bc61f8403e588f24a32090b5ccae1eef74..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_no_navimg/icons/x16/arrow_180.png and /dev/null differ diff --git a/interface/web/themes/default_no_navimg/icons/x16/arrow_stop.png b/interface/web/themes/default_no_navimg/icons/x16/arrow_stop.png deleted file mode 100644 index 702b9b7b791ab1ffbc3ceb962b75434421d1f156..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_no_navimg/icons/x16/arrow_stop.png and /dev/null differ diff --git a/interface/web/themes/default_no_navimg/icons/x16/arrow_stop_180.png b/interface/web/themes/default_no_navimg/icons/x16/arrow_stop_180.png deleted file mode 100644 index 573ff4889bd49f1a63d35d9c4e7e1b440c43629e..0000000000000000000000000000000000000000 Binary files a/interface/web/themes/default_no_navimg/icons/x16/arrow_stop_180.png and /dev/null differ diff --git a/interface/web/themes/default_no_navimg/ispconfig_version b/interface/web/themes/default_no_navimg/ispconfig_version deleted file mode 100644 index bb19ac367e61ef69398f09154456075f734e0d46..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_no_navimg/ispconfig_version +++ /dev/null @@ -1 +0,0 @@ -3.0.4.6 \ No newline at end of file diff --git a/interface/web/themes/default_no_navimg/templates/main.tpl.htm b/interface/web/themes/default_no_navimg/templates/main.tpl.htm deleted file mode 100644 index adfc656e0bd01b2aab4fe154878772626f651b92..0000000000000000000000000000000000000000 --- a/interface/web/themes/default_no_navimg/templates/main.tpl.htm +++ /dev/null @@ -1,189 +0,0 @@ - - - - <tmpl_var name="app_title"> <tmpl_var name="app_version"> - "/> - - - - - - - - - - - - - - - - - - -
-
- - - - - -
- -
-
-
 
-
-
- - -
-
- - -
- -
-
-
-
 
- -
- -
- - - -
-
- - diff --git a/interface/web/tools/dns_import_tupa.php b/interface/web/tools/dns_import_tupa.php index 775d515289e09103a5302b5ab99f720fbbf1c647..b81a83bdec6277f32bcf5842312a49842fea5ac3 100644 --- a/interface/web/tools/dns_import_tupa.php +++ b/interface/web/tools/dns_import_tupa.php @@ -86,44 +86,74 @@ if(isset($_POST['start']) && $_POST['start'] == 1) { $domains = $exdb->queryAllRecords("SELECT * FROM domains WHERE type = 'MASTER'"); if(is_array($domains)) { foreach($domains as $domain) { - $soa = $exdb->queryOneRecord("SELECT * FROM records WHERE type = 'SOA' AND domain_id = ".$domain['id']); + $soa = $exdb->queryOneRecord("SELECT * FROM records WHERE type = 'SOA' AND domain_id = ?", $domain['id']); if(is_array($soa)) { $parts = explode(' ', $soa['content']); - $origin = $app->db->quote(addot($soa['name'])); - $ns = $app->db->quote(addot($parts[0])); - $mbox = $app->db->quote(addot($parts[1])); - $serial = $app->db->quote($parts[2]); + $origin = addot($soa['name']); + $ns = addot($parts[0]); + $mbox = addot($parts[1]); + $serial = $parts[2]; $refresh = 7200; $retry = 540; $expire = 604800; - $minimum = 86400; - $ttl = $app->db->quote($soa['ttl']); - - $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', '')"; + $minimum = 3600; + $ttl = $soa['ttl']; + + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $sys_groupid, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $server_id, + "origin" => $origin, + "ns" => $ns, + "mbox" => $mbox, + "serial" => $serial, + "refresh" => $refresh, + "retry" => $retry, + "expire" => $expire, + "minimum" => $minimum, + "ttl" => $ttl, + "active" => 'Y', + "xfer" => '' + ); $dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id'); unset($parts); $msg .= 'Import Zone: '.$soa['name'].'
'; //* Process the other records - $records = $exdb->queryAllRecords("SELECT * FROM records WHERE type != 'SOA' AND domain_id = ".$domain['id']); + $records = $exdb->queryAllRecords("SELECT * FROM records WHERE type != 'SOA' AND domain_id = ?", $domain['id']); if(is_array($records)) { foreach($records as $rec) { $rr = array(); - $rr['name'] = $app->db->quote(addot($rec['name'])); - $rr['type'] = $app->db->quote($rec['type']); - $rr['aux'] = $app->db->quote($rec['prio']); - $rr['ttl'] = $app->db->quote($rec['ttl']); + $rr['name'] = addot($rec['name']); + $rr['type'] = $rec['type']; + $rr['aux'] = $rec['prio']; + $rr['ttl'] = $rec['ttl']; if($rec['type'] == 'NS' || $rec['type'] == 'MX' || $rec['type'] == 'CNAME') { - $rr['data'] = $app->db->quote(addot($rec['content'])); + $rr['data'] = addot($rec['content']); } else { - $rr['data'] = $app->db->quote($rec['content']); + $rr['data'] = $rec['content']; } - $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')"; + $insert_data = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $sys_groupid, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $server_id, + "zone" => $dns_soa_id, + "name" => $rr['name'], + "type" => $rr['type'], + "data" => $rr['data'], + "aux" => $rr['aux'], + "ttl" => $rr['ttl'], + "active" => 'Y' + ); $dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id'); //$msg .= $insert_data.'
'; diff --git a/interface/web/tools/form/interface_settings.tform.php b/interface/web/tools/form/interface_settings.tform.php index f81ce2d1572ff259983b4639b81c98c6ab6e22e4..f213605bf787aaa739f69b7b853507f607128e17 100644 --- a/interface/web/tools/form/interface_settings.tform.php +++ b/interface/web/tools/form/interface_settings.tform.php @@ -96,7 +96,7 @@ if($_SESSION["s"]["user"]["typ"] == 'admin') { } } } else { - $tmp = $app->db->queryOneRecord("SELECT * FROM sys_user where username = '".$_SESSION["s"]["user"]['username']."'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM sys_user where username = ?", $_SESSION["s"]["user"]['username']); $modules = $tmp['modules']; //$modules = $conf['interface_modules_enabled']; if($_SESSION["s"]["user"]["typ"] != 'admin' && $app->auth->has_clients($_SESSION['s']['user']['userid'])) { diff --git a/interface/web/tools/form/resync.tform.php b/interface/web/tools/form/resync.tform.php index 01c9470c45c4e4ecdc19d4de66478598ce994170..3bc10a6c7cc887c4e83f48b9a7458049df16fa68 100644 --- a/interface/web/tools/form/resync.tform.php +++ b/interface/web/tools/form/resync.tform.php @@ -2,10 +2,10 @@ $form["title"] = "Resync Tool"; $form["description"] = ""; $form["name"] = "resync"; -$form["action"] = "resync_do.php"; +$form["action"] = "resync.php"; $form["db_history"] = "no"; $form["tab_default"] = "resync"; -$form["list_default"] = "resync_show.php"; +$form["list_default"] = "resync.php"; $form["auth"] = 'yes'; $form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user @@ -18,96 +18,6 @@ $form["tabs"]['resync'] = array ( 'title' => "Resync", 'width' => 100, 'template' => "templates/resync.htm", - 'fields' => array ( - 'mail_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE mail_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'web_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE web_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'dns_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE dns_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'file_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE file_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'db_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE db_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'vserver_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'proxy_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE proxy_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - 'firewall_server_id' => array ( - 'datatype' => 'INTEGER', - 'formtype' => 'SELECT', - 'default' => '', - 'datasource' => array ( 'type' => 'SQL', - 'querystring' => 'SELECT server_id FROM server WHERE firewall_server = 1 AND mirror_server_id = 0 AND {AUTHSQL}', - 'keyfield'=> 'server_id', - 'valuefield'=> 'server_name' - ), - 'value' => '' - ), - ) ); diff --git a/interface/web/tools/import_ispconfig.php b/interface/web/tools/import_ispconfig.php index 75e59929df7eeeeb768c23175942fa2a3466029e..0998d1840ef049e43116858636089f0cec814ccd 100644 --- a/interface/web/tools/import_ispconfig.php +++ b/interface/web/tools/import_ispconfig.php @@ -143,7 +143,7 @@ function start_domain_import($mail_domain) { //* Get the user and groupid for the new records $sys_groupid = $app->functions->intval($_POST['client_group_id']); - $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = $sys_groupid"); + $tmp = $app->db->queryOneRecord("SELECT userid FROM sys_user WHERE default_group = ?", $sys_groupid); $sys_userid = $app->functions->intval($tmp['userid']); unset($tmp); if($sys_groupid == 0) $error .= 'Inavlid groupid
'; @@ -159,7 +159,7 @@ function start_domain_import($mail_domain) { $mail_domain_rec = $client->mail_domain_get($remote_session_id, array('domain' => $mail_domain)); if(is_array($mail_domain_rec)) { $mail_domain_rec = $mail_domain_rec[0]; - $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE domain = '".$app->db->quote($mail_domain)."'"); + $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE domain = ?", $mail_domain); if($tmp['number'] > 0) $error .= 'Domain '.$mail_domain.' exists already in local database.
'; unset($tmp); @@ -182,7 +182,7 @@ function start_domain_import($mail_domain) { $mail_users = $client->mail_user_get($remote_session_id, array('email' => '%@'.$mail_domain)); if(is_array($mail_users)) { foreach($mail_users as $mail_user) { - $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE email = '".$app->db->quote($mail_user['email'])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE email = ?", $mail_user['email']); if($tmp['number'] == 0) { //* Prepare record @@ -229,7 +229,7 @@ function start_domain_import($mail_domain) { $mail_aliases = $client->mail_alias_get($remote_session_id, array('type' => 'alias', 'destination' => '%@'.$mail_domain)); if(is_array($mail_aliases)) { foreach($mail_aliases as $mail_alias) { - $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE `type` = 'alias' AND source = '".$app->db->quote($mail_alias['source'])."' AND destination = '".$app->db->quote($mail_alias['destination'])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE `type` = 'alias' AND source = ? AND destination = ?", $mail_alias['source'], $mail_alias['destination']); if($tmp['number'] == 0) { $mail_alias['sys_userid'] = $sys_userid; $mail_alias['sys_groupid'] = $sys_groupid; @@ -250,7 +250,7 @@ function start_domain_import($mail_domain) { $mail_aliases = $client->mail_alias_get($remote_session_id, array('type' => 'aliasdomain', 'destination' => '@'.$mail_domain)); if(is_array($mail_aliases)) { foreach($mail_aliases as $mail_alias) { - $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE `type` = 'aliasdomain' AND source = '".$app->db->quote($mail_alias['source'])."' AND destination = '".$app->db->quote($mail_alias['destination'])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE `type` = 'aliasdomain' AND source = ? AND destination = ?", $mail_alias['source'], $mail_alias['destination']); if($tmp['number'] == 0) { $mail_alias['sys_userid'] = $sys_userid; $mail_alias['sys_groupid'] = $sys_groupid; @@ -271,7 +271,7 @@ function start_domain_import($mail_domain) { $mail_forwards = $client->mail_forward_get($remote_session_id, array('type' => 'forward', 'source' => '%@'.$mail_domain)); if(is_array($mail_forwards)) { foreach($mail_forwards as $mail_forward) { - $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE `type` = 'forward' AND source = '".$app->db->quote($mail_forward['source'])."' AND destination = '".$app->db->quote($mail_forward['destination'])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE `type` = 'forward' AND source = ? AND destination = ?", $mail_forward['source'], $mail_forward['destination']); if($tmp['number'] == 0) { $mail_forward['sys_userid'] = $sys_userid; $mail_forward['sys_groupid'] = $sys_groupid; @@ -292,7 +292,7 @@ function start_domain_import($mail_domain) { $mail_spamfilters = $client->mail_spamfilter_user_get($remote_session_id, array('email' => '%@'.$mail_domain)); if(is_array($mail_spamfilters)) { foreach($mail_spamfilters as $mail_spamfilter) { - $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM spamfilter_users WHERE email = '".$app->db->quote($mail_spamfilter['email'])."'"); + $tmp = $app->db->queryOneRecord("SELECT count(id) as number FROM spamfilter_users WHERE email = ?", $mail_spamfilter['email']); if($tmp['number'] == 0) { $mail_spamfilter['sys_userid'] = $sys_userid; $mail_spamfilter['sys_groupid'] = $sys_groupid; diff --git a/interface/web/tools/import_plesk.php b/interface/web/tools/import_plesk.php deleted file mode 100644 index f6e2890ea1546d28d3d8fae078df7e03adfec797..0000000000000000000000000000000000000000 --- a/interface/web/tools/import_plesk.php +++ /dev/null @@ -1,1430 +0,0 @@ -queryAllRecords("SELECT l.id, l.limit_name, l.value FROM Limits as l"); - foreach($limit_data as $entry) { - if(array_key_exists($entry['id'], $limits) == false) $limits[$entry['id']] = array(); - $limits[$entry['id']][$entry['limit_name']] = $entry['value']; - - // limits that are there: - /* - disk_space - disk_space_soft - expiration - max_box - max_db - max_dom_aliases - max_maillists - max_mn - max_site - max_site_builder - max_subdom - max_subftp_users - max_traffic - max_traffic_soft - max_unity_mobile_sites - max_webapps - max_wu - mbox_quota - */ - } - - return $limits; -} - - -/** - * - * @param array $limits - * @param int $id - * @param string $limit - * @param mixed $default - * @return mixed - */ -function get_limit($limits, $id, $limit, $default = false) { - $ret = $default; - if(isset($limits[$id][$limit])) $ret = $limits[$id][$limit]; - - return $ret; -} - -function get_option($options, $option, $default = false) { - $ret = $default; - if(isset($options[$option])) $ret = $options[$option]; - - return $ret; -} - -function add_dot($string) { - if(strlen($string) > 0 && substr($string, -1, 1) !== '.') $string .= '.'; - return $string; -} - -function byte_to_mbyte($byte) { - if($byte <= 0) return $byte; // limit = -1 -> unlimited - return round($byte / (1024*1024)); -} - -function yes_no($num, $reverse = false) { - return ($num == 1 && !$reverse) || ($num != 1 && $reverse) ? 'y' : 'n'; -} - -// taken from the web_domain_edit.php -function id_hash($id, $levels) { - $hash = "" . $id % 10 ; - $id /= 10 ; - $levels -- ; - while ( $levels > 0 ) { - $hash .= "/" . $id % 10 ; - $id /= 10 ; - $levels-- ; - } - return $hash; -} - -$COMMANDS = 'unset HISTFILE -MYSERVER="192.168.1.10" -MYSQL_EXPORT_USER="root" -MYSQL_EXPORT_PASS="" -MYSQL_IMPORT_USER="root" -MYSQL_IMPORT_PASS="" -'; - -function add_command($cmd) { - global $COMMANDS; - - $COMMANDS .= $cmd . "\n"; -} - - -/* TODO: document root rewrite on ftp account and other home directories */ - -//* Check permissions for module -$app->auth->check_module_permissions('admin'); - -//* This is only allowed for administrators -if(!$app->auth->is_admin()) die('only allowed for administrators.'); - -$app->uses('tpl,getconf'); -$app->load('importer'); - -$app->tpl->newTemplate('form.tpl.htm'); -$app->tpl->setInclude('content_tpl', 'templates/import_plesk.htm'); -$msg = ''; -$error = ''; - -// Start migrating plesk data -if(isset($_POST['start']) && $_POST['start'] == 1) { - - //* Set variable sin template - $app->tpl->setVar('dbhost', $_POST['dbhost']); - $app->tpl->setVar('dbname', $_POST['dbname']); - $app->tpl->setVar('dbuser', $_POST['dbuser']); - $app->tpl->setVar('dbpassword', $_POST['dbpassword']); - $app->tpl->setVar('webcontent', $_POST['webcontent']); - $app->tpl->setVar('mailcontent', $_POST['mailcontent']); - - //* Establish connection to external database - $msg .= 'Connecting to external database...
'; - - //* Backup DB login details - /*$conf_bak['db_host'] = $conf['db_host']; - $conf_bak['db_database'] = $conf['db_database']; - $conf_bak['db_user'] = $conf['db_user']; - $conf_bak['db_password'] = $conf['db_password'];*/ - - //* Set external Login details - $conf['imp_db_host'] = $_POST['dbhost']; - $conf['imp_db_database'] = $_POST['dbname']; - $conf['imp_db_user'] = $_POST['dbuser']; - $conf['imp_db_password'] = $_POST['dbpassword']; - $conf['imp_db_charset'] = $conf['db_charset']; - $conf['imp_db_new_link'] = $conf['db_new_link']; - $conf['imp_db_client_flags'] = $conf['db_client_flags']; - - //* create new db object - $exdb = new db('imp'); - - $msg .= 'db object created...
'; - - $importer = new importer(); - $session_id = 'ISPC3'; // set dummy session id for remoting lib - $msg .= 'importer object created...
'; - - // import on server - $server_id = 1; - - //* Connect to DB - if($exdb !== false) { - $msg .= 'Connecting to external database done...
'; - - $limits = read_limit_data($exdb); - - $msg .= 'read all limit data...
'; - - // param_id -> cl_params table - not needed for import - // tpye = admin, reseller, client - $admins = $exdb->queryAllRecords("SELECT c.id, c.parent_id, c.type, c.cr_date, c.cname, c.pname, c.login, c.account_id, a.password, a.type as `pwtype`, c.status, c.phone, c.fax, c.email, c.address, c.city, c.state, c.pcode, c.country, c.locale, c.limits_id, c.params_id, c.perm_id, c.pool_id, c.logo_id, c.tmpl_id, c.guid, c.overuse, c.vendor_id, c.external_id FROM clients as c LEFT JOIN accounts as a ON (a.id = c.account_id) WHERE c.type = 'admin' ORDER BY c.parent_id, c.id"); - $resellers = $exdb->queryAllRecords("SELECT c.id, c.parent_id, c.type, c.cr_date, c.cname, c.pname, c.login, c.account_id, a.password, a.type as `pwtype`, c.status, c.phone, c.fax, c.email, c.address, c.city, c.state, c.pcode, c.country, c.locale, c.limits_id, c.params_id, c.perm_id, c.pool_id, c.logo_id, c.tmpl_id, c.guid, c.overuse, c.vendor_id, c.external_id FROM clients as c LEFT JOIN accounts as a ON (a.id = c.account_id) WHERE c.type = 'reseller' ORDER BY c.parent_id, c.id"); - $clients = $exdb->queryAllRecords("SELECT c.id, c.parent_id, c.type, c.cr_date, c.cname, c.pname, c.login, c.account_id, a.password, a.type as `pwtype`, c.status, c.phone, c.fax, c.email, c.address, c.city, c.state, c.pcode, c.country, c.locale, c.limits_id, c.params_id, c.perm_id, c.pool_id, c.logo_id, c.tmpl_id, c.guid, c.overuse, c.vendor_id, c.external_id FROM clients as c LEFT JOIN accounts as a ON (a.id = c.account_id) WHERE c.type = 'client' ORDER BY c.parent_id, c.id"); - - $users = array_merge($admins, $resellers, $clients); - $msg .= 'read all users (' . count($users) . ')...
'; - - - $plesk_ispc_ids = array(); // array with key = plesk id, value = ispc id - - $phpopts = array('no', 'fast-cgi', 'cgi', 'mod', 'suphp', 'php-fpm'); - - // import admins / resellers - for($i = 0; $i < count($users); $i++) { - $entry = $users[$i]; - - $old_client = $importer->client_get_by_username($session_id, $entry['login']); - if($old_client) { - if($old_client['client_id'] == 0) { - $entry['login'] = 'psa_' . $entry['login']; - $old_client = $importer->client_get_by_username($session_id, $entry['login']); - if($old_client) { - $msg .= $entry['login'] . ' existed, updating id ' . $old_client['client_id'] . '
'; - } - } else { - $msg .= $entry['login'] . ' existed, updating id ' . $old_client['client_id'] . '
'; - } - } - $params = array( - 'company_name' => $entry['cname'], - 'contact_name' => $entry['pname'], - 'customer_no' => 'Plesk' . $entry['id'], - 'username' => $entry['login'], - 'password' => $entry['password'], - 'language' => substr($entry['locale'], 0, 2), // plesk stores as de-DE or en-US - //'usertheme' => '', - 'street' => $entry['address'], - 'zip' => $entry['pcode'], - 'city' => $entry['city'], - 'state' => $entry['state'], - 'country' => $entry['country'], - 'telephone' => $entry['phone'], - //'mobile' => $entry[''], - 'fax' => $entry['fax'], - 'email' => $entry['email'], - //'internet' => $entry[''], - //'icq' => $entry[''], - //'vat_id' => $entry[''], - //'company_id' => $entry[''], - //'bank_account_number' => $entry[''], - //'bank_code' => $entry[''], - //'bank_name' => $entry[''], - //'bank_account_iban' => $entry[''], - //'bank_account_swift' => $entry[''], - 'notes' => 'imported from Plesk id ' . $entry['id'], - //'template_master' => $entry[''], - //'template_additional' => $entry[''], - //'default_mailserver' => $entry[''], - 'limit_maildomain' => get_limit($limits, $entry['id'], 'max_site', -1), - 'limit_mailbox' => get_limit($limits, $entry['id'], 'max_box', -1), - 'limit_mailalias' => get_limit($limits, $entry['id'], 'max_mn', -1), - 'limit_mailaliasdomain' => get_limit($limits, $entry['id'], 'max_dom_aliases', -1), - 'limit_mailmailinglist' => get_limit($limits, $entry['id'], 'max_maillists', -1), - 'limit_mailforward' => get_limit($limits, $entry['id'], 'max_mn', -1), - 'limit_mailcatchall' => 1, - 'limit_mailrouting' => 0, - 'limit_mailfilter' => 0, - 'limit_fetchmail' => 0, - 'limit_mailquota' => get_limit($limits, $entry['id'], 'mbox_quota', -1), - 'limit_spamfilter_wblist' => 0, - 'limit_spamfilter_user' => 0, - 'limit_spamfilter_policy' => 0, - //'default_webserver' => '', - 'limit_web_domain' => get_limit($limits, $entry['id'], 'max_site', -1), - 'limit_web_quota' => intval(get_limit($limits, $entry['id'], 'disk_space', -1)), - 'web_php_options' => implode(',', $phpopts), - 'limit_web_aliasdomain' => get_limit($limits, $entry['id'], 'max_dom_aliases', -1), - 'limit_web_subdomain' => get_limit($limits, $entry['id'], 'max_subdom', -1), - 'limit_ftp_user' => (string)($app->functions->intval(get_limit($limits, $entry['id'], 'max_subftp_users', -2)) + 1), - 'limit_shell_user' => 0, - 'ssh_chroot' => 'no,jailkit', - 'limit_webdav_user' => get_limit($limits, $entry['id'], 'max_wu', 0), - //'default_dnsserver' => '', - 'limit_dns_zone' => -1, - 'limit_dns_slave_zone' => -1, - 'limit_dns_record' => -1, - 'limit_client' => ($entry['type'] == 'client' ? 0 : -1), - //'default_dbserver' => '', - 'limit_database' => get_limit($limits, $entry['id'], 'max_db', -1), - 'limit_cron' => 0, - 'limit_cron_type' => 'url', - 'limit_cron_frequency' => '5', - 'limit_traffic_quota' => intval(get_limit($limits, $entry['id'], 'max_traffic', -1)), - 'limit_openvz_vm' => 0, - 'limit_openvz_vm_template_id' => '' - ); - $reseller_id = 0; - if($entry['parent_id'] != 0) { - if(array_key_exists($entry['parent_id'], $plesk_ispc_ids)) { - $reseller_id = $plesk_ispc_ids[$entry['parent_id']]; - } - } - - if($old_client) { - $new_id = $old_client['client_id']; - $ok = $importer->client_update($session_id, $old_client['client_id'], $reseller_id, array_merge($old_client, $params)); - if($ok === false) { - - } - } else { - $new_id = $importer->client_add($session_id, $reseller_id, $params); - } - if($new_id === false) { - //something went wrong here... - $msg .= "Client " . $entry['id'] . " (" . $entry['pname'] . ") could not be inserted/updated.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Client " . $entry['id'] . " (" . $entry['pname'] . ") inserted/updated.
"; - } - - $plesk_ispc_ids[$entry['id']] = $new_id; - } - unset($users); - unset($clients); - unset($resellers); - unset($admins); - - $web_config = $app->getconf->get_server_config($server_id, 'web'); - - $domains = $exdb->queryAllRecords("SELECT d.id, d.cr_date, d.name, d.displayName, d.dns_zone_id, d.status, d.htype, d.real_size, d.cl_id, d.limits_id, d.params_id, d.guid, d.overuse, d.gl_filter, d.vendor_id, d.webspace_id, d.webspace_status, d.permissions_id, d.external_id FROM domains as d WHERE d.parentDomainId = 0"); - $dom_ftp_users = array(); - $domain_ids = array(); - $domain_roots = array(); - $domain_owners = array(); - $dns_domain_ids = array(); - $maildomain_ids = array(); - foreach($domains as $entry) { - $res = $exdb->query("SELECT d.dom_id, d.param, d.val FROM dom_param as d WHERE d.dom_id = '" . $entry['id'] . "'"); - $options = array(); - while($opt = $res->get()) { - $options[$opt['param']] = $opt['val']; - } - - /* TODO: options that might be used later: - * OveruseBlock true/false - * OveruseNotify true/false - * OveruseSuspend true/false - * wu_script true/false (webusers allowed to use scripts?) - * webmail string (webmailer used - horde) - */ - - $redir_type = ''; - $redir_path = ''; - - if($entry['htype'] === 'std_fwd') { - // redirection - $redir = $exdb->queryOneRecord("SELECT f.dom_id, f.ip_address_id, f.redirect FROM forwarding as f WHERE f.dom_id = '" . $entry['id'] . "'"); - $redir_type = 'R,L'; - $redir_path = $redir['redirect']; - } elseif($entry['htype'] === 'vrt_hst') { - // default virtual hosting (vhost) - } else { - /* TODO: unknown type */ - } - - $hosting = $exdb->queryOneRecord("SELECT h.dom_id, h.sys_user_id, h.ip_address_id, h.real_traffic, h.fp, h.fp_ssl, h.fp_enable, h.fp_adm, h.fp_pass, h.ssi, h.php, h.cgi, h.perl, h.python, h.fastcgi, h.miva, h.coldfusion, h.asp, h.asp_dot_net, h.ssl, h.webstat, h.same_ssl, h.traffic_bandwidth, h.max_connection, h.php_handler_type, h.www_root, h.maintenance_mode, h.certificate_id, s.login, s.account_id, s.home, s.shell, s.quota, s.mapped_to, a.password, a.type as `pwtype` FROM hosting as h LEFT JOIN sys_users as s ON (s.id = h.sys_user_id) LEFT JOIN accounts as a ON (s.account_id = a.id) WHERE h.dom_id = '" . $entry['id'] . "'"); - if($hosting['sys_user_id']) { - $dom_ftp_users[] = array('id' => 0, - 'dom_id' => $hosting['dom_id'], - 'sys_user_id' => $hosting['sys_user_id'], - 'login' => $hosting['login'], - 'account_id' => $hosting['account_id'], - 'home' => $hosting['home'], - 'shell' => $hosting['shell'], - 'quota' => $hosting['quota'], - 'mapped_to' => $hosting['mapped_to'], - 'password' => $hosting['password'], - 'pwtype' => $hosting['pwtype'] - ); - } - - $phpmode = 'no'; - if(get_option($hosting, 'php', 'false') === 'true') { - $mode = get_option($hosting, 'php_handler_type', 'module'); - if($mode === 'module') $phpmode = 'mod'; - else $phpmode = 'fast-cgi'; - /* TODO: what other options could be in "php_handler_type"? */ - } - - /* TODO: plesk offers some more options: - * sys_user_id -> owner of files? - * ip_address_id - needed? - * fp - frontpage extensions - * miva - ? - * coldfusion - * asp - * asp_dot_net - * traffic_bandwidth - * max_connections - */ - $params = array( - 'server_id' => $server_id, - 'ip_address' => '*', - //'ipv6_address' => '', - 'domain' => $entry['name'], - 'type' => 'vhost', // can be vhost or alias - 'parent_domain_id' => '', // only if alias - 'vhost_type' => 'name', // or ip (-based) - 'hd_quota' => byte_to_mbyte(get_limit($limits, $entry['id'], 'disk_space', -1)), - 'traffic_quota' => byte_to_mbyte(get_limit($limits, $entry['id'], 'max_traffic', -1)), - 'cgi' => yes_no(get_option($hosting, 'cgi', 'false') === 'true' ? 1 : 0), - 'ssi' => yes_no(get_option($hosting, 'ssi', 'false') === 'true' ? 1 : 0), - 'suexec' => yes_no(1), // does plesk use this?! - 'errordocs' => get_option($options, 'apacheErrorDocs', 'false') === 'true' ? 1 : 0, - 'subdomain' => 'www', // plesk always uses this option - 'ssl' => yes_no(get_option($hosting, 'ssl', 'false') === 'true' ? 1 : 0), - 'php' => $phpmode, - 'fastcgi_php_version' => '', // plesk has no different php versions - 'ruby' => yes_no(0), // plesk has no ruby support - 'python' => yes_no(get_option($hosting, 'python', 'false') === 'true' ? 1 : 0), - 'active' => yes_no(($entry['status'] == 0 && get_option($hosting, 'maintenance_mode', 'false') !== 'true') ? 1 : 0), - 'redirect_type' => $redir_type, - 'redirect_path' => $redir_path, - 'seo_redirect' => '', - 'ssl_state' => $entry[''], - 'ssl_locality' => $entry[''], - 'ssl_organisation' => $entry[''], - 'ssl_organisation_unit' => $entry[''], - 'ssl_country' => $entry[''], - 'ssl_domain' => $entry[''], - 'ssl_request' => $entry[''], - 'ssl_cert' => $entry[''], - 'ssl_bundle' => $entry[''], - 'ssl_action' => $entry[''], - 'stats_password' => '', - 'stats_type' => get_option($hosting, 'webstat', 'webalizer') === 'awstats' ? 'awstats' : 'webalizer', - 'backup_interval' => 'none', - 'backup_copies' => 1, - 'allow_override' => 'All', - 'pm_process_idle_timeout' => 10, - 'pm_max_requests' => 0 - ); - - // find already inserted domain - $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '" . $entry['name'] . "'"); - if(!$old_domain) $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE CONCAT(subdomain, '.', domain) = '" . $entry['name'] . "'"); - if($old_domain) { - $new_id = $old_domain['domain_id']; - $msg .= "Found domain with id " . $new_id . ", updating it.
"; - $params = array_merge($old_domain, $params); - $ok = $importer->sites_web_domain_update($session_id, $plesk_ispc_ids[$entry['cl_id']], $new_id, $params); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->sites_web_domain_add($session_id, $plesk_ispc_ids[$entry['cl_id']], $params, true); // read only... - } - - $domain_ids[$entry['id']] = $new_id; - $domain_roots[$entry['id']] = $entry['www_root']; - $domain_owners[$entry['id']] = $entry['cl_id']; - $dns_domain_ids[$entry['dns_zone_id']] = $entry['id']; - - if($new_id === false) { - //something went wrong here... - $msg .= "Domain " . $entry['id'] . " (" . $entry['name'] . ") could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Domain " . $entry['id'] . " (" . $entry['name'] . ") inserted -> " . $new_id . ".
"; - - $cmd_data = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = '" . $new_id . "'"); - $path = $cmd_data['document_root']; - add_command('chattr -i ' . escapeshellarg($path)); - add_command('if [[ -f ' . $path . '/web/index.html ]] ; then rm ' . $path . '/web/index.html ; fi'); - add_command('rsync -av --modify-window 10 --progress -e ssh root@${MYSERVER}:' . $hosting['www_root'] . '/ ' . $path . '/web/'); - add_command('chown -R ' . $cmd_data['system_user'] . ':' . $cmd_data['system_group'] . ' ' . escapeshellarg($path)); - add_command('grep ' . escapeshellarg($hosting['www_root']) . ' ' . $path . '/web -r -l | xargs replace ' . escapeshellarg($hosting['www_root']) . ' ' . escapeshellarg($path . '/web') . ' --'); - add_command('chown -R root:root ' . escapeshellarg($path . '/log') . ' ' . escapeshellarg($path . '/ssl') . ' ' . escapeshellarg($path . '/web/stats')); - add_command('chattr +i ' . escapeshellarg($path)); - } - - // add domain to mail domains too - $params = array( - 'server_id' => $server_id, - 'domain' => $entry['name'], - 'active' => yes_no(($entry['status'] == 0 ? 1 : 0)) - ); - $old_domain = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '" . $entry['name'] . "'"); - if($old_domain) { - $new_id = $old_domain['domain_id']; - $params = array_merge($old_domain, $params); - $msg .= "Found maildomain with id " . $new_id . ", updating it.
"; - $ok = $importer->mail_domain_update($session_id, $plesk_ispc_ids[$entry['cl_id']], $new_id, $params); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Inserting new maildomain " . $entry['name'] . ".
"; - $new_id = $importer->mail_domain_add($session_id, $plesk_ispc_ids[$entry['cl_id']], $params); - } - - $maildomain_ids[$entry['id']] = $new_id; - if($new_id === false) { - //something went wrong here... - $msg .= "Maildomain (" . $entry['name'] . ") could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Maildomain " . $new_id . " (" . $entry['name'] . ") inserted.
"; - } - - } - - $domain_aliases = $exdb->queryAllRecords("SELECT da.id, da.name, da.displayName, da.dns, da.mail, da.web, da.dom_id, da.status FROM domainaliases as da"); - foreach($domain_aliases as $entry) { - $params = array( - 'server_id' => $server_id, - 'domain' => $entry['name'], - 'type' => 'alias', - 'parent_domain_id' => $domain_ids[$entry['dom_id']], - 'redirect_type' => '', - 'redirect_path' => '', - 'subdomain' => 'www', - 'active' => yes_no(($entry['status'] == 0 && $entry['web'] === 'true') ? 1 : 0) - ); - - $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '" . $entry['name'] . "'"); - if(!$old_domain) $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE CONCAT(subdomain, '.', domain) = '" . $entry['name'] . "'"); - if($old_domain) { - $new_id = $old_domain['domain_id']; - $params = array_merge($old_domain, $params); - $msg .= "Found domain with id " . $new_id . ", updating it.
"; - $ok = $importer->sites_web_aliasdomain_update($session_id, $plesk_ispc_ids[$domain_owners[$entry['dom_id']]], $new_id, $params); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->sites_web_aliasdomain_add($session_id, $plesk_ispc_ids[$domain_owners[$entry['dom_id']]], $params); - } - - if($new_id === false) { - //something went wrong here... - $msg .= "Aliasdomain " . $entry['id'] . " (" . $entry['name'] . ") could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Aliasdomain " . $entry['id'] . " (" . $entry['name'] . ") inserted.
"; - } - - // add alias to mail domains, too - $params = array( - 'server_id' => $server_id, - 'domain' => $entry['name'], - 'active' => yes_no(($entry['status'] == 0 && $entry['mail'] === 'true') ? 1 : 0) - ); - - $old_domain = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '" . $entry['name'] . "'"); - if($old_domain) { - $new_id = $old_domain['domain_id']; - $params = array_merge($old_domain, $params); - $msg .= "Found mail domain with id " . $new_id . ", updating it.
"; - $ok = $importer->mail_domain_update($session_id, $plesk_ispc_ids[$domain_owners[$entry['dom_id']]], $new_id, $params); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->mail_domain_add($session_id, $plesk_ispc_ids[$domain_owners[$entry['dom_id']]], $params); - } - - $maildomain_ids[$entry['id']] = $new_id; - if($new_id === false) { - //something went wrong here... - $msg .= "Aliasmaildomain " . $entry['id'] . " (" . $entry['name'] . ") could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Aliasmaildomain " . $entry['id'] . " (" . $entry['name'] . ") inserted.
"; - } - } - - $subdomain_ids = array(); - $subdomain_roots = array(); - $subdomain_owners = array(); - - $subdomains = $exdb->queryAllRecords("SELECT d.id, d.cr_date, d.name, d.displayName, d.dns_zone_id, d.status, d.htype, d.real_size, d.cl_id, d.limits_id, d.params_id, d.guid, d.overuse, d.gl_filter, d.vendor_id, d.webspace_id, d.webspace_status, d.permissions_id, d.external_id, d.parentDomainId FROM domains as d WHERE d.parentDomainId != 0"); - foreach($subdomains as $entry) { - $res = $exdb->query("SELECT d.dom_id, d.param, d.val FROM dom_param as d WHERE d.dom_id = '" . $entry['id'] . "'"); - $options = array(); - while($opt = $exdb->nextRecord()) { - $options[$opt['param']] = $opt['val']; - } - - $parent_domain = $exdb->queryOneRecord("SELECT d.id, d.cl_id, d.name FROM domains as d WHERE d.id = '" . $entry['parentDomainId'] . "'"); - $redir_type = ''; - $redir_path = ''; - - if($entry['htype'] === 'std_fwd') { - // redirection - $redir = $exdb->queryOneRecord("SELECT f.dom_id, f.ip_address_id, f.redirect FROM forwarding as f WHERE f.dom_id = '" . $entry['id'] . "'"); - $redir_type = 'R,L'; - $redir_path = $redir['redirect']; - } elseif($entry['htype'] === 'vrt_hst') { - // default virtual hosting (vhost) - } else { - /* TODO: unknown type */ - } - - $hosting = $exdb->queryOneRecord("SELECT h.dom_id, h.sys_user_id, h.ip_address_id, h.real_traffic, h.fp, h.fp_ssl, h.fp_enable, h.fp_adm, h.fp_pass, h.ssi, h.php, h.cgi, h.perl, h.python, h.fastcgi, h.miva, h.coldfusion, h.asp, h.asp_dot_net, h.ssl, h.webstat, h.same_ssl, h.traffic_bandwidth, h.max_connection, h.php_handler_type, h.www_root, h.maintenance_mode, h.certificate_id, s.login, s.account_id, s.home, s.shell, s.quota, s.mapped_to, a.password, a.type as `pwtype` FROM hosting as h LEFT JOIN sys_users as s ON (s.id = h.sys_user_id) LEFT JOIN accounts as a ON (s.account_id = a.id) WHERE h.dom_id = '" . $entry['id'] . "'"); - if($hosting['sys_user_id']) { - $dom_ftp_users[] = array('id' => 0, - 'dom_id' => $hosting['dom_id'], - 'sys_user_id' => $hosting['sys_user_id'], - 'login' => $hosting['login'], - 'account_id' => $hosting['account_id'], - 'home' => $hosting['home'], - 'shell' => $hosting['shell'], - 'quota' => $hosting['quota'], - 'mapped_to' => $hosting['mapped_to'], - 'password' => $hosting['password'], - 'pwtype' => $hosting['pwtype'] - ); - } - - $phpmode = 'no'; - if(get_option($hosting, 'php', 'false') === 'true') { - $mode = get_option($hosting, 'php_handler_type', 'module'); - if($mode === 'module') $phpmode = 'mod'; - else $phpmode = 'fast-cgi'; - /* TODO: what other options could be in "php_handler_type"? */ - } - /* TODO: plesk offers some more options: - * sys_user_id -> owner of files? - * ip_address_id - needed? - * fp - frontpage extensions - * miva - ? - * coldfusion - * asp - * asp_dot_net - * traffic_bandwidth - * max_connections - */ - - $web_folder = $hosting['www_root']; - $web_folder = preg_replace('/^\/(var|srv)\/www\/(vhosts\/)?[^\/]+\/(.*)\/httpdocs.*/', '$3', $web_folder); - - //if(substr($web_folder, 0, 1) === '/') $web_folder = substr($web_folder, 1); - //if(substr($web_folder, -1, 1) === '/') $web_folder = substr($web_folder, 0, -1); - $params = array( - 'server_id' => $server_id, - 'ip_address' => '*', - //'ipv6_address' => '', - 'domain' => $entry['name'], - 'web_folder' => $web_folder, - 'type' => 'vhostsubdomain', // can be vhost or alias - 'parent_domain_id' => $domain_ids[$entry['parentDomainId']], - 'vhost_type' => 'name', // or ip (-based) - 'hd_quota' => byte_to_mbyte(get_limit($limits, $entry['dom_id'], 'disk_space', -1)), - 'traffic_quota' => byte_to_mbyte(get_limit($limits, $entry['dom_id'], 'max_traffic', -1)), - 'cgi' => yes_no(get_option($hosting, 'cgi', 'false') === 'true' ? 1 : 0), - 'ssi' => yes_no(get_option($hosting, 'ssi', 'false') === 'true' ? 1 : 0), - 'suexec' => yes_no(1), // does plesk use this?! - 'errordocs' => get_option($options, 'apacheErrorDocs', 'false') === 'true' ? 1 : 0, - 'subdomain' => '', // plesk always uses this option - 'ssl' => yes_no(get_option($hosting, 'ssl', 'false') === 'true' ? 1 : 0), - 'php' => $phpmode, - 'fastcgi_php_version' => '', // plesk has no different php versions - 'ruby' => yes_no(0), // plesk has no ruby support - 'python' => yes_no(get_option($hosting, 'python', 'false') === 'true' ? 1 : 0), - 'active' => yes_no(($entry['status'] == 0 && get_option($hosting, 'maintenance_mode', 'false') !== 'true') ? 1 : 0), - 'redirect_type' => $redir_type, - 'redirect_path' => $redir_path, - 'seo_redirect' => '', - 'ssl_state' => $entry[''], - 'ssl_locality' => $entry[''], - 'ssl_organisation' => $entry[''], - 'ssl_organisation_unit' => $entry[''], - 'ssl_country' => $entry[''], - 'ssl_domain' => $entry[''], - 'ssl_request' => $entry[''], - 'ssl_cert' => $entry[''], - 'ssl_bundle' => $entry[''], - 'ssl_action' => $entry[''], - 'stats_password' => '', - 'stats_type' => get_option($hosting, 'webstat', 'webalizer') === 'awstats' ? 'awstats' : 'webalizer', - 'backup_interval' => 'none', - 'backup_copies' => 1, - 'allow_override' => 'All', - 'pm_process_idle_timeout' => 10, - 'pm_max_requests' => 0 - ); - - $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '" . $entry['name'] . "'"); - if(!$old_domain) $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE CONCAT(subdomain, '.', domain) = '" . $entry['name'] . "'"); - if($old_domain) { - $new_id = $old_domain['domain_id']; - $params = array_merge($old_domain, $params); - $msg .= "Found domain " . $entry['name'] . " with id " . $new_id . ", updating it.
"; - $ok = $importer->sites_web_vhost_subdomain_update($session_id, $plesk_ispc_ids[$parent_domain['cl_id']], $new_id, $params); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->sites_web_vhost_subdomain_add($session_id, $plesk_ispc_ids[$parent_domain['cl_id']], $params, true); // read only... - } - - $subdomain_ids[$entry['id']] = $new_id; - $subdomain_roots[$entry['id']] = $hosting['www_root']; - $subdomain_owners[$entry['id']] = $entry['cl_id']; - if($new_id === false) { - //something went wrong here... - $msg .= "Subdomain " . $entry['id'] . " (" . $entry['name'] . ") with folder \"" . $web_folder . "\" could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Subdomain " . $entry['id'] . " (" . $entry['name'] . ") inserted.
"; - - $cmd_data = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = '" . $new_id . "'"); - $path = $cmd_data['document_root']; - add_command('chattr -i ' . escapeshellarg($path)); - add_command('if [[ -f ' . $path . '/' . $web_folder . '/index.html ]] ; then rm ' . $path . '/' . $web_folder . '/index.html ; fi'); - add_command('rsync -av --modify-window 10 --progress -e ssh root@${MYSERVER}:' . $hosting['www_root'] . '/ ' . $path . '/' . $web_folder . '/'); - add_command('chown -R ' . $cmd_data['system_user'] . ':' . $cmd_data['system_group'] . ' ' . escapeshellarg($path)); - add_command('grep ' . escapeshellarg($hosting['www_root']) . ' ' . $path . '/web -r -l | xargs replace ' . escapeshellarg($hosting['www_root']) . ' ' . escapeshellarg($path . '/web') . ' --'); - add_command('chown -R root:root ' . escapeshellarg($path . '/log') . ' ' . escapeshellarg($path . '/ssl') . ' ' . escapeshellarg($path . '/web/stats')); - add_command('chattr +i ' . escapeshellarg($path)); - - } - $domain_ids[$entry['id']] = $new_id; - } - - // subdomains in plesk are real vhosts, so we have to treat them as vhostsubdomains - $subdomains = $exdb->queryAllRecords("SELECT d.id, d.dom_id, d.name, d.displayName, d.sys_user_id, d.ssi, d.php, d.cgi, d.perl, d.python, d.fastcgi, d.miva, d.coldfusion, d.asp, d.asp_dot_net, d.ssl, d.same_ssl, d.php_handler_type, d.www_root, d.maintenance_mode, d.certificate_id FROM subdomains as d"); - foreach($subdomains as $entry) { - $res = $exdb->query("SELECT d.dom_id, d.param, d.val FROM dom_param as d WHERE d.dom_id = '" . $entry['dom_id'] . "'"); - $options = array(); - while($opt = $res->get()) { - $options[$opt['param']] = $opt['val']; - } - - $parent_domain = $exdb->queryOneRecord("SELECT d.id, d.cl_id, d.name FROM domains as d WHERE d.id = '" . $entry['dom_id'] . "'"); - - /* TODO: options that might be used later: - * OveruseBlock true/false - * OveruseNotify true/false - * OveruseSuspend true/false - * wu_script true/false (webusers allowed to use scripts?) - * webmail string (webmailer used - horde) - */ - - $redir_type = ''; - $redir_path = ''; - - if($entry['htype'] === 'std_fwd') { - // redirection - $redir = $exdb->queryOneRecord("SELECT f.dom_id, f.ip_address_id, f.redirect FROM forwarding as f WHERE f.dom_id = '" . $entry['id'] . "'"); - $redir_type = 'R,L'; - $redir_path = $redir['redirect']; - } elseif($entry['htype'] === 'vrt_hst') { - // default virtual hosting (vhost) - } else { - /* TODO: unknown type */ - } - - $hosting = $exdb->queryOneRecord("SELECT h.dom_id, h.sys_user_id, h.ip_address_id, h.real_traffic, h.fp, h.fp_ssl, h.fp_enable, h.fp_adm, h.fp_pass, h.ssi, h.php, h.cgi, h.perl, h.python, h.fastcgi, h.miva, h.coldfusion, h.asp, h.asp_dot_net, h.ssl, h.webstat, h.same_ssl, h.traffic_bandwidth, h.max_connection, h.php_handler_type, h.www_root, h.maintenance_mode, h.certificate_id FROM hosting as h WHERE h.dom_id = '" . $entry['dom_id'] . "'"); - $hosting = array_merge($hosting, $entry); //settings from subdomain override parent settings - - $phpmode = 'no'; - if(get_option($hosting, 'php', 'false') === 'true') { - $mode = get_option($hosting, 'php_handler_type', 'module'); - if($mode === 'module') $phpmode = 'mod'; - else $phpmode = 'fast-cgi'; - /* TODO: what other options could be in "php_handler_type"? */ - } - /* TODO: plesk offers some more options: - * sys_user_id -> owner of files? - * ip_address_id - needed? - * fp - frontpage extensions - * miva - ? - * coldfusion - * asp - * asp_dot_net - * traffic_bandwidth - * max_connections - */ - - $web_folder = $entry['www_root']; - $web_folder = preg_replace('/^\/(var|srv)\/www\/(vhosts\/)?[^\/]+\/(.*)\/httpdocs.*/', '$3', $web_folder); - - $params = array( - 'server_id' => $server_id, - 'ip_address' => '*', - //'ipv6_address' => '', - 'domain' => $entry['name'] . '.' . $parent_domain['name'], - 'web_folder' => $web_folder, - 'type' => 'vhostsubdomain', // can be vhost or alias - 'parent_domain_id' => $domain_ids[$entry['dom_id']], - 'vhost_type' => 'name', // or ip (-based) - 'hd_quota' => byte_to_mbyte(get_limit($limits, $entry['dom_id'], 'disk_space', -1)), - 'traffic_quota' => byte_to_mbyte(get_limit($limits, $entry['dom_id'], 'max_traffic', -1)), - 'cgi' => yes_no(get_option($hosting, 'cgi', 'false') === 'true' ? 1 : 0), - 'ssi' => yes_no(get_option($hosting, 'ssi', 'false') === 'true' ? 1 : 0), - 'suexec' => yes_no(1), // does plesk use this?! - 'errordocs' => get_option($options, 'apacheErrorDocs', 'false') === 'true' ? 1 : 0, - 'subdomain' => '', // plesk always uses this option - 'ssl' => yes_no(get_option($hosting, 'ssl', 'false') === 'true' ? 1 : 0), - 'php' => $phpmode, - 'fastcgi_php_version' => '', // plesk has no different php versions - 'ruby' => yes_no(0), // plesk has no ruby support - 'python' => yes_no(get_option($hosting, 'python', 'false') === 'true' ? 1 : 0), - 'active' => yes_no(($entry['status'] == 0 && get_option($hosting, 'maintenance_mode', 'false') !== 'true') ? 1 : 0), - 'redirect_type' => $redir_type, - 'redirect_path' => $redir_path, - 'seo_redirect' => '', - 'ssl_state' => $entry[''], - 'ssl_locality' => $entry[''], - 'ssl_organisation' => $entry[''], - 'ssl_organisation_unit' => $entry[''], - 'ssl_country' => $entry[''], - 'ssl_domain' => $entry[''], - 'ssl_request' => $entry[''], - 'ssl_cert' => $entry[''], - 'ssl_bundle' => $entry[''], - 'ssl_action' => $entry[''], - 'stats_password' => '', - 'stats_type' => get_option($hosting, 'webstat', 'webalizer') === 'awstats' ? 'awstats' : 'webalizer', - 'backup_interval' => 'none', - 'backup_copies' => 1, - 'allow_override' => 'All', - 'pm_process_idle_timeout' => 10, - 'pm_max_requests' => 0 - ); - - $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain = '" . $entry['name'] . '.' . $parent_domain['name'] . "'"); - if(!$old_domain) $old_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE CONCAT(subdomain, '.', domain) = '" . $entry['name'] . "'"); - if($old_domain) { - $new_id = $old_domain['domain_id']; - $params = array_merge($old_domain, $params); - $msg .= "Found domain with id " . $new_id . ", updating it.
"; - $ok = $importer->sites_web_vhost_subdomain_update($session_id, $plesk_ispc_ids[$parent_domain['cl_id']], $new_id, $params); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->sites_web_vhost_subdomain_add($session_id, $plesk_ispc_ids[$parent_domain['cl_id']], $params, true); // read only... - } - - $subdomain_ids[$entry['id']] = $new_id; - $subdomain_roots[$entry['id']] = $entry['www_root']; - $subdomain_owners[$entry['id']] = $entry['cl_id']; - if($new_id === false) { - //something went wrong here... - $msg .= "Subdomain " . $entry['id'] . " (" . $entry['name'] . ") could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Subdomain " . $entry['id'] . " (" . $entry['name'] . ") inserted.
"; - - $cmd_data = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = '" . $new_id . "'"); - $path = $cmd_data['document_root']; - add_command('chattr -i ' . escapeshellarg($path)); - add_command('if [[ -f ' . $path . '/' . $web_folder . '/index.html ]] ; then rm ' . $path . '/' . $web_folder . '/index.html ; fi'); - add_command('rsync -av --modify-window 10 --progress -e ssh root@${MYSERVER}:' . $entry['www_root'] . '/ ' . $path . '/' . $web_folder . '/'); - add_command('chown -R ' . $cmd_data['system_user'] . ':' . $cmd_data['system_group'] . ' ' . escapeshellarg($path)); - add_command('chown -R root:root ' . escapeshellarg($path . '/log') . ' ' . escapeshellarg($path . '/ssl') . ' ' . escapeshellarg($path . '/web/stats')); - add_command('chattr +i ' . escapeshellarg($path)); - } - } - - // dns have to be done AFTER domains due to missing client info - /* - $dns_zone_ids = array(); - $dns_zone_serials = array(); - $dns_zones = $exdb->queryAllRecords("SELECT d.id, d.name, d.displayName, d.status, d.email, d.type, d.ttl, d.ttl_unit, d.refresh, d.refresh_unit, d.retry, d.retry_unit, d.expire, d.expire_unit, d.minimum, d.minimum_unit, d.serial_format, d.serial FROM dns_zone as d"); - foreach($dns_zones as $entry) { - $ns = $exdb->queryOneRecord("SELECT d.id, d.val FROM dns_recs as d WHERE d.dns_zone_id = '" . $entry['id'] . "' AND d.type = 'NS'"); - if(!$ns) $ns = array('id' => 0, 'val' => 'ns.' . $entry['name']); - - $dom_id = $dns_domain_ids[$entry['id']]; - $client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]]; - if(!$client_id) $client_id = 0; - - $params = array( - 'server_id' => $server_id, - 'origin' => add_dot($entry['name']), // what to put here? - 'ns' => add_dot($ns['val']), // what to put here? - 'mbox' => str_replace('@', '.', add_dot($entry['email'])), - 'serial' => $entry['serial'], - 'refresh' => $entry['refresh'], - 'retry' => $entry['retry'], - 'expire' => $entry['expire'], - 'minimum' => $entry['minimum'], - 'ttl' => $entry['ttl'], - 'xfer' => '', - 'also_notify' => '', - 'update_acl' => '', - 'active' => yes_no(($entry['status'] == 0 ? 1 : 0)) - ); - - $old_dns = $app->db->queryOneRecord("SELECT id FROM dns_soa WHERE origin = '" . add_dot($entry['name']) . "'"); - if($old_dns) $old_id = $old_dns['id']; - if($old_id) { - $new_id = $old_id; - $ok = $importer->dns_zone_update($session_id, $client_id, $old_id, $params); - /if($ok === false) { - // $msg .= "DNS " . $entry['id'] . " (" . $entry['name'] . ") could not be updated.
"; - // $msg .= "  Error: " . $importer->getFault() . "
"; - //} else { - $msg .= "DNS " . $entry['id'] . " (" . $entry['name'] . ") updated.
"; - //} - } else { - $new_id = $importer->dns_zone_add($session_id, $client_id, $params); - if($new_id === false) { - //something went wrong here... - $msg .= "DNS " . $entry['id'] . " (" . $entry['name'] . ") could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "DNS " . $entry['id'] . " (" . $entry['name'] . ") inserted.
"; - } - } - $dns_zone_ids[$entry['id']] = $new_id; - $dns_zone_serials[$entry['id']] = $entry['serial']; - } - unset($dns_zones); - */ - /* types: - * PTR, NS, A, CNAME, MX, TXT, AAAA - *//* - $dns_records = $exdb->queryAllRecords("SELECT d.id, d.dns_zone_id, d.type, d.displayHost, d.host, d.displayVal, d.val, d.opt, d.time_stamp FROM dns_recs as d"); - foreach($dns_records as $entry) { - $dns_id = (array_key_exists($entry['dns_zone_id'], $dns_zone_ids) ? $dns_zone_ids[$entry['dns_zone_id']] : 0); - if(!$dns_id) { - // entry for missing dns zone...? - continue; - } - - $dom_id = $dns_domain_ids[$entry['dns_zone_id']]; - $client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]]; - if(!$client_id) $client_id = 0; - - $params = array( - 'server_id' => $server_id, - 'zone' => $dns_id, - 'name' => add_dot($entry['host']), - 'type' => $entry['type'], - 'data' => $entry['val'], - //'ttl' => '', - 'active' => yes_no(1), - 'stamp' => $entry['time_stamp'], - //'serial' => $dns_zone_serials[$entry['id']] - ); - - - $record = $app->db->queryOneRecord("SELECT id FROM dns_rr WHERE zone = '" . $dns_zone_ids[$entry['dns_zone_id']] . "' AND name = '" . add_dot($entry['host']) . "' AND type = '" . $entry['type'] . "'"); - $old_id = 0; - if($record) { - $old_id = $record['id']; - } - - $new_id = false; - if($entry['type'] === 'MX') { - $params['aux'] = $entry['opt']; - if($old_id) { - $ok = $importer->dns_mx_update($session_id, $client_id, $old_id, $params); - if($ok !== false) $new_id = $old_id; - } else { - $new_id = $importer->dns_mx_add($session_id, $client_id, $params); - } - } elseif($entry['type'] === 'PTR') { - if($old_id) { - $ok = $importer->dns_ptr_update($session_id, $client_id, $old_id, $params); - if($ok !== false) $new_id = $old_id; - } else { - $new_id = $importer->dns_ptr_add($session_id, $client_id, $params); - } - } elseif($entry['type'] === 'A') { - if($old_id) { - $ok = $importer->dns_a_update($session_id, $client_id, $old_id, $params); - if($ok !== false) $new_id = $old_id; - } else { - $new_id = $importer->dns_a_add($session_id, $client_id, $params); - } - } elseif($entry['type'] === 'AAAA') { - if($old_id) { - $ok = $importer->dns_aaaa_update($session_id, $client_id, $old_id, $params); - if($ok !== false) $new_id = $old_id; - } else { - $new_id = $importer->dns_aaaa_add($session_id, $client_id, $params); - } - } elseif($entry['type'] === 'TXT') { - if($old_id) { - $ok = $importer->dns_txt_update($session_id, $client_id, $old_id, $params); - if($ok !== false) $new_id = $old_id; - } else { - $new_id = $importer->dns_txt_add($session_id, $client_id, $params); - } - } elseif($entry['type'] === 'CNAME') { - if($old_id) { - $ok = $importer->dns_cname_update($session_id, $client_id, $old_id, $params); - if($ok !== false) $new_id = $old_id; - } else { - $new_id = $importer->dns_cname_add($session_id, $client_id, $params); - } - } elseif($entry['type'] === 'NS') { - if($old_id) { - $ok = $importer->dns_ns_update($session_id, $client_id, $old_id, $params); - if($ok !== false) $new_id = $old_id; - } else { - $new_id = $importer->dns_ns_add($session_id, $client_id, $params); - } - } - if($new_id === false) { - //something went wrong here... - $msg .= "DNS " . $entry['id'] . " (" . $entry['name'] . ") could not be inserted/updated.
"; - $msg .= "  Error: " . $importer->getFault() . "
" . var_export($params, true) . '
'; - } else { - $msg .= "DNS " . $entry['id'] . " (" . $entry['name'] . ") inserted/updated.
"; - } - - } - unset($dns_records); - */ - - $folder_ids = array(); - /* web_folder creation*/ - $protected_dirs = $exdb->queryAllRecords("SELECT `id`, `non_ssl`, `ssl`, `cgi_bin`, `realm`, `path`, `dom_id` FROM protected_dirs"); - foreach($protected_dirs as $entry) { - if($entry['path'] == 'plesk-stat') continue; - - $params = array('server_id' => $server_id, - 'parent_domain_id' => $domain_ids[$entry['dom_id']], - 'path' => $entry['path'], - 'active' => 'y'); - - $client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]]; - - $folder_id = 0; - $check = $app->db->queryOneRecord('SELECT * FROM `web_folder` WHERE `parent_domain_id` = \'' . $domain_ids[$entry['dom_id']] . '\' AND `path` = \'' . $app->db->quote($entry['path']) . '\''); - if($check) { - $ok = $importer->sites_web_folder_update($session_id, $client_id, $check['web_folder_id'], array_merge($check, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - $folder_id = $check['web_folder_id']; - $msg .= 'Updated HTTP AUTH folder (' . $folder_id . '): ' . $entry['path'] . '
'; - } else { - $folder_id = $importer->sites_web_folder_add($session_id, $client_id, $params); - $msg .= 'Created HTTP AUTH folder (' . $folder_id . '): ' . $entry['path'] . '
'; - if(!$folder_id) $msg .= "  Error: " . $importer->getFault() . "
" . var_export($params, true) . '
'; - } - - $folder_ids[$entry['id']] = $folder_id; - } - - $pd_users = $exdb->queryAllRecords("SELECT u.id, u.login, u.account_id, u.pd_id, a.password, d.dom_id FROM pd_users as u INNER JOIN protected_dirs as d ON (d.id = u.pd_id) INNER JOIN accounts as a ON (a.id = u.account_id)"); - foreach($pd_users as $entry) { - $params = array('server_id' => $server_id, - 'web_folder_id' => $folder_ids[$entry['pd_id']], - 'username' => $entry['login'], - 'password' => $entry['password'], - 'active' => 'y'); - if($entry['login'] == '' || !isset($folder_ids[$entry['pd_id']])) { - $msg .= 'Skipping Folder user because of missing data.
'; - continue; - } - $client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]]; - - $check = $app->db->queryOneRecord('SELECT * FROM `web_folder_user` WHERE `web_folder_id` = ' . intval($folder_ids[$entry['pd_id']]) . ' AND `username` = \'' . $entry['login'] . '\''); - if($check) { - $ok = $importer->sites_web_folder_user_update($session_id, $client_id, $check['web_folder_user_id'], array_merge($check, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - $msg .= 'Updated HTTP AUTH folder user (' . $fu_id . '): ' . $entry['login'] . '
'; - } else { - $fu_id = $importer->sites_web_folder_user_add($session_id, $client_id, $params); - $msg .= 'Created HTTP AUTH folder user (' . $fu_id . '): ' . $entry['login'] . '
'; - if(!$fu_id) $msg .= "  Error: " . $importer->getFault() . "
" . var_export($params, true) . '
'; - } - } - - /*$web_users = $exdb->queryAllRecords("SELECT id, dom_id, sys_user_id, ssi, php, cgi, perl, python, fastcgi, asp, asp_dot_net FROM web_users"); - foreach($web_users as $entry) { - $params = - } - */ - - - $ftp_users = $exdb->queryAllRecords("SELECT f.id, f.dom_id, f.sys_user_id, s.login, s.account_id, s.home, s.shell, s.quota, s.mapped_to, a.password, a.type as `pwtype` FROM ftp_users as f INNER JOIN sys_users as s ON (s.id = f.sys_user_id) INNER JOIN accounts as a ON (a.id = s.account_id)"); - $ftp_users = array_merge($ftp_users, $dom_ftp_users); - foreach($ftp_users as $entry) { - $parent_domain = $exdb->queryOneRecord("SELECT d.id, d.cl_id, d.name FROM domains as d WHERE d.id = '" . $entry['dom_id'] . "'"); - if(!$entry['id']) continue; - $ispc_dom_id = $domain_ids[$entry['dom_id']]; - $client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]]; - if(!$client_id) $client_id = 0; - - $document_root = str_replace("[website_id]", $ispc_dom_id, $web_config["website_path"]); - $document_root = str_replace("[website_idhash_1]", id_hash($ispc_dom_id, 1), $document_root); - $document_root = str_replace("[website_idhash_2]", id_hash($ispc_dom_id, 1), $document_root); - $document_root = str_replace("[website_idhash_3]", id_hash($ispc_dom_id, 1), $document_root); - $document_root = str_replace("[website_idhash_4]", id_hash($ispc_dom_id, 1), $document_root); - - // Set the values for document_root, system_user and system_group - $system_user = 'web'.$ispc_dom_id; - $system_group = 'client'.$client_id; - $document_root = str_replace("[client_id]", $client_id, $document_root); - $document_root = str_replace("[client_idhash_1]", id_hash($client_id, 1), $document_root); - $document_root = str_replace("[client_idhash_2]", id_hash($client_id, 2), $document_root); - $document_root = str_replace("[client_idhash_3]", id_hash($client_id, 3), $document_root); - $document_root = str_replace("[client_idhash_4]", id_hash($client_id, 4), $document_root); - - $uid = $system_user; - $gid = $system_group; - - $sys_grp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = '" . $client_id . "'"); - if(!$sys_grp) $sys_grp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = 0"); - - if(!$sys_grp) $sys_groupid = 1; - else $sys_groupid = $sys_grp['groupid']; - - $params = array( - 'server_id' => $server_id, - 'parent_domain_id' => $domain_ids[$entry['dom_id']], - 'username' => $entry['login'], - 'password' => $entry['password'], - 'quota_size' => byte_to_mbyte(($entry['quota'] == 0 ? -1 : $entry['quota'])), - 'active' => yes_no(1), - 'uid' => $uid, - 'gid' => $gid, - 'dir' => $document_root . (substr($document_root, -1) !== '/' ? '/' : ''), - 'sys_groupid' => $sys_groupid - //'quota_files' => $entry[''], - //'ul_ratio' => $entry[''], - //'dl_ratio' => $entry[''], - //'ul_bandwidth' => $entry[''], - //'dl_bandwidth' => $entry[''] - ); - $new_id = false; - $old_ftp = $app->db->queryOneRecord("SELECT ftp_user_id, parent_domain_id FROM ftp_user WHERE username = '" . $entry['login'] ."'"); - if($old_ftp) { - if($old_ftp['parent_domain_id'] != $domain_ids[$entry['dom_id']]) { - $msg .= "FTP Account conflicts with other domain!
"; - } else { - $new_id = $old_ftp['ftp_user_id']; - $ok = $importer->sites_ftp_user_update($session_id, $client_id, $new_id, array_merge($old_ftp, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } - } else { - $new_id = $importer->sites_ftp_user_add($session_id, $client_id, $params); - } - if($new_id === false) { - //something went wrong here... - $msg .= "FTP " . $entry['id'] . " (" . $entry['login'] . ") could not be inserted.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - $msg .= "Params: " . var_export($params, true) . "
"; - } else { - $msg .= "FTP Account " . $entry['id'] . " (" . $entry['login'] . ") inserted.
"; - } - } - - $mail_config = $app->getconf->get_server_config($server_id, 'mail'); - - $mail_addresses = $exdb->queryAllRecords("SELECT m.id, m.mail_name, m.perm_id, m.postbox, m.account_id, m.redirect, m.redir_addr, m.mail_group, m.autoresponder, m.spamfilter, m.virusfilter, m.mbox_quota, m.dom_id, m.userId, a.password, a.type as `pwtype` FROM mail as m LEFT JOIN accounts as a ON (a.id = m.account_id) "); - $mail_ids = array(); - foreach($mail_addresses as $entry) { - - $parent_domain = $exdb->queryOneRecord("SELECT d.id, d.cl_id, d.name FROM domains as d WHERE d.id = '" . $entry['dom_id'] . "'"); - if(!$parent_domain) { - $msg .= "Could not insert/update mail address " . $entry['mail_name'] . " as domain is missing.
"; - continue; - } - - /* postbox true/false - * mail_group true/false - * spamfilter true/false - */ - - - $has_responder = false; - if($entry['autoresponder'] === 'true') { - $responder = $exdb->queryOneRecord("SELECT id, mn_id, resp_name, keystr, key_where, subject, reply_to, content_type, charset, text, resp_on, ans_freq, mem_limit FROM mail_resp WHERE mn_id = '" . $entry['id'] . "'"); - if($responder) $has_responder = true; - } - - $maildir = str_replace("[domain]", $parent_domain["name"], $mail_config["maildir_path"]); - $maildir = str_replace("[localpart]", strtolower($entry["mail_name"]), $maildir); - - - $params = array( - 'server_id' => $server_id, - 'email' => $entry['mail_name'] . "@" . $parent_domain['name'], - 'login' => strtolower($entry['mail_name'] . "@" . $parent_domain['name']), - 'password' => $entry['password'], - 'name' => $entry[''], - 'quota' => ($entry['mbox_quota'] == -1 ? 0 : $entry['mbox_quota']), // in bytes! - 'cc' => $entry['redir_addr'], - 'maildir' => $maildir, - 'homedir' => $mail_config["homedir_path"], - 'uid' => $mail_config["mailuser_uid"], - 'gid' => $mail_config["mailuser_gid"], - 'postfix' => yes_no(1), - 'disableimap' => yes_no(0), - 'disablepop3' => yes_no(0), - 'autoresponder_subject' => ($has_responder ? $responder['subject'] : ''), - 'autoresponder_text' => ($has_responder ? $responder['text'] : ''), - 'autoresponder' => yes_no($has_responder ? 1 : 0), - 'autoresponder_start_date' => ($has_responder && $responder['resp_on'] === 'true' ? strftime('%Y-%m-%d', time()) : strftime('%Y-%m-%d', time() - (3600*24))), - 'autoresponder_end_date' => ($has_responder && $responder['resp_on'] === 'true' ? strftime('%Y-%m-%d', time() + (3600*24*365)) : strftime('%Y-%m-%d', time())), - 'move_junk' => yes_no(0) - ); - $client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]]; - - // if this is no postbox we do not need to create a mailuser - if($entry['postbox'] !== 'false') { - $old_mail = $app->db->queryOneRecord("SELECT mailuser_id FROM mail_user WHERE email = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "'"); - if($old_mail) { - $new_id = $old_mail['mailuser_id']; - $ok = $importer->mail_user_update($session_id, $client_id, $new_id, array_merge($old_mail, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->mail_user_add($session_id, $client_id, $params); - } - - if($new_id === false) { - //something went wrong here... - $msg .= "Mail" . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . ") could not be inserted/updated.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Mail " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . ") inserted/updated.
"; - - add_command('rsync -av --delete-after --modify-window 10 --progress -e ssh root@${MYSERVER}:/var/qmail/mailnames/' . $parent_domain['name'] . '/' . strtolower($entry['mail_name']) . '/Maildir/ ' . $maildir . '/Maildir/'); - add_command('chown -R vmail:vmail ' . $maildir); - add_command('chmod 744 ' . $maildir . '/Maildir/subscriptions'); - add_command('chmod 600 ' . $maildir . '/Maildir/dovecot-*'); - add_command('chmod 700 ' . $maildir . '/Maildir/cur ' . $maildir . '/Maildir/new ' . $maildir . '/Maildir/tmp'); - add_command('chmod 600 ' . $maildir . '/Maildir/cur/* ' . $maildir . '/Maildir/new/* ' . $maildir . '/Maildir/tmp/*'); - } - $mail_ids[$entry['id']] = $new_id; - } - - // select all redirs for this address - $mail_redir = $exdb->queryAllRecords("SELECT id, mn_id, address FROM mail_redir WHERE mn_id = '" . $entry['id'] . "'"); - foreach($mail_redir as $redir) { - $params = array( - 'server_id' => $server_id, - 'source' => $entry['mail_name'] . "@" . $parent_domain['name'], - 'destination' => $redir['address'], - 'type' => 'forward', // or forward - 'active' => yes_no(1) - ); - - $old_mail = $app->db->queryOneRecord("SELECT forwarding_id FROM mail_forwarding WHERE source = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "' AND destination = '" . $redir['address'] . "'"); - if($old_mail) { - $new_id = $old_mail['forwarding_id']; - $ok = $importer->mail_forward_update($session_id, $client_id, $new_id, array_merge($old_mail, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->mail_forward_add($session_id, $client_id, $params); - } - - if($new_id === false) { - //something went wrong here... - $msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") could not be inserted/updated.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") inserted/updated.
"; - } - } - unset($mail_redir); - } - unset($mail_addresses); - - $mail_aliases = $exdb->queryAllRecords("SELECT a.id, a.mn_id, a.alias, m.dom_id, m.mail_name FROM mail_aliases as a INNER JOIN mail as m ON (m.id = a.mn_id)"); - foreach($mail_aliases as $entry) { - - $parent_domain = $exdb->queryOneRecord("SELECT d.id, d.cl_id, d.name FROM domains as d WHERE d.id = '" . $entry['dom_id'] . "'"); - if(!$parent_domain) { - $msg .= "Could not insert/update mail alias " . $entry['alias'] . " as domain is missing.
"; - continue; - } - - $params = array( - 'server_id' => $server_id, - 'source' => $entry['alias'] . "@" . $parent_domain['name'], - 'destination' => $entry['mail_name'] . "@" . $parent_domain['name'], - 'type' => 'alias', // or forward - 'active' => yes_no(1) - ); - $client_id = $plesk_ispc_ids[$domain_owners[$entry['dom_id']]]; - - $old_mail = $app->db->queryOneRecord("SELECT forwarding_id FROM mail_forwarding WHERE source = '" . $entry['alias'] . "@" . $parent_domain['name'] . "' AND destination = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "'"); - if($old_mail) { - $new_id = $old_mail['forwarding_id']; - $ok = $importer->mail_alias_update($session_id, $client_id, $new_id, array_merge($old_mail, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $new_id = $importer->mail_alias_add($session_id, $client_id, $params); - } - - if($new_id === false) { - //something went wrong here... - $msg .= "Mail alias " . $entry['id'] . " (" . $entry['alias'] . "@" . $parent_domain['name'] . ") could not be inserted/updated.
"; - $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $msg .= "Mail alias " . $entry['id'] . " (" . $entry['alias'] . "@" . $parent_domain['name'] . ") inserted/updated.
"; - } - } - unset($mail_aliases); - - //spamfilter // preferences = true/false, username = email address, can be *@* - //id, username, preferences - - //spamfilter_preferences - //prefid, spamfilter_id, preference, value - - - - //$client_traffic = $exdb->queryAllRecords("SELECT t.cl_id, t.date, t.http_in, t.http_out, t.ftp_in, t.ftp_out, t.smtp_in, t.smtp_out, t.pop3_imap_in, t.pop3_imap_out FROM ClientsTraffic as t"); - - $db_userids = array(); - - $db_users = $exdb->queryAllRecords("SELECT u.id, u.login, u.account_id, u.db_id, a.password, a.type as `pwtype`, d.dom_id FROM db_users as u INNER JOIN data_bases as d ON (d.id = u.db_id) LEFT JOIN accounts as a ON (a.id = u.account_id)"); - foreach($db_users as $db_user) { - // database user - $params = array('server_id' => $server_id, - 'database_user' => $db_user['login'], - 'database_password' => $db_user['password']); - - $client_id = $plesk_ispc_ids[$domain_owners[$db_user['dom_id']]]; - - $check = $app->db->queryOneRecord('SELECT * FROM `web_database_user` WHERE `database_user` = \'' . $app->db->quote($db_user['login']) . '\''); - $db_user_id = 0; - if($check) { - $ok = $importer->sites_database_user_update($session_id, $client_id, $check['database_user_id'], array_merge($check, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - $db_user_id = $check['database_user_id']; - } else { - $db_user_id = $importer->sites_database_user_add($session_id, $client_id, $params); - } - - if(!isset($db_userids[$db_user['db_id']])) $db_userids[$db_user['db_id']] = $db_user_id; - $msg .= 'Created / updated database user: ' . $db_user['login'] . '
'; - } - - add_command('# DATABASES'); - - $databases = $exdb->queryAllRecords("SELECT d.id, d.name, d.type, d.dom_id, d.db_server_id, d.default_user_id FROM `data_bases` as d"); - foreach($databases as $database) { - $params = array('server_id' => $server_id, - 'parent_domain_id' => $domain_ids[$database['dom_id']], - 'type' => 'mysql', - 'database_name' => $database['name'], - 'database_user_id' => $db_userids[$database['id']], - 'database_ro_user_id' => 0, - 'database_charset' => 'utf8', - 'remote_access' => 'n', - 'active' => 'y', - 'remote_ips' => ''); - - $client_id = $plesk_ispc_ids[$domain_owners[$database['dom_id']]]; - - $check = $app->db->queryOneRecord('SELECT * FROM `web_database` WHERE `database_name` = \'' . $app->db->quote($database['name']) . '\''); - if($check) { - $ok = $importer->sites_database_update($session_id, $client_id, $check['database_id'], array_merge($check, $params)); - if($ok === false) $msg .= "  Error: " . $importer->getFault() . "
"; - } else { - $importer->sites_database_add($session_id, $client_id, $params); - } - - add_command('for T in `mysql -u ${MYSQL_IMPORT_USER} -p${MYSQL_IMPORT_PASS} ' . $database['name'] . ' -e \'show tables\' | awk \'{ print $1}\' | grep -v \'^Tables\'` ; do echo "DROP TABLE \\`$T\\`" ; mysql -u ${MYSQL_IMPORT_USER} -p${MYSQL_IMPORT_PASS} ' . $database['name'] . ' -e "DROP TABLE \\`$T\\`" ; done'); - add_command('mysqldump -cCQ --quote-names --hex-blob -h ${MYSERVER} -u ${MYSQL_EXPORT_USER} -p${MYSQL_EXPORT_PASS} ' . $database['name'] . ' | mysql -D ' . $database['name'] . ' -u ${MYSQL_IMPORT_USER} -p${MYSQL_IMPORT_PASS}'); - - $msg .= 'Created / updated database: ' . $database['name'] . '
'; - } - - // do we need table disk_usage for import? i think we don't - - // name is domain name, displayName is including "Umlaute" - //$anon_ftp = $exdb->queryAllRecords("SELECT f.id, f.dom_id, f.max_conn, f.bandwidth, f.incoming, f.incoming_readable, f.incoming_subdirs, f.status, f.quota, f.display_login, f.login_text FROM anon_ftp as f"); - - - //DomainServices - //id, dom_id, type, status, parameters_id, ipCollectionId - - //DomainsTraffic - //dom_id, date, http_in, http_out, ftp_in, ftp_out, smtp_in, smtp_out, pop3_imap_in, pop3_imap_out - - - //IP_Adresses - //id, ip_address, mask, iface, ssl_certificate_id, default_domain_id, ftps, main, status - - //ip_pool - //id, ip_address_id, type - - /* TODO: - */ - //misc // needed? global settings - //param, val - - //Permissions - //id, permission, value - - //smb_users // pass is base64 encoded plaintext - //id, login, password, contactName, email, companyName, phone, fax, address, city, state, zip, country, creationDate, isBuiltIn, roleId, uuid, isLocked, authCookie, sessionId, externalId, ownerId, isDomainAdmin, additionalInfo, imNumber, imType, isLegacyUser - - /* TODO: - sys_users // mapped_to = parent_id - id, login, account_id, home, shell, quota, mapped_to - - */ - add_command('unset MYSERVER'); - add_command('unset MYSQL_EXPORT_USER'); - add_command('unset MYSQL_EXPORT_PASS'); - add_command('unset MYSQL_IMPORT_USER'); - add_command('unset MYSQL_IMPORT_PASS'); - add_command('# END'); - file_put_contents('/tmp/plesk_import_commands.sh', $COMMANDS); - } else { - $msg .= 'Connecting to external database failed!
'; - $msg .= $exdb->connect_error; - $msg .= substr($exdb->errorMessage, 0, 25); - - $error .= $exdb->errorMessage; - } - - //* restore db login details - /*$conf['db_host'] = $conf_bak['db_host']; - $conf['db_database'] = $conf_bak['db_database']; - $conf['db_user'] = $conf_bak['db_user']; - $conf['db_password'] = $conf_bak['db_password'];*/ - -} - -$app->tpl->setVar('msg', $msg); -$app->tpl->setVar('error', $error); - - -$app->tpl_defaults(); -$app->tpl->pparse(); - - -?> diff --git a/interface/web/tools/import_vpopmail.php b/interface/web/tools/import_vpopmail.php index 119bfb87aa4f613b2d1c84dfba57ea98d83bd8a4..3c8db20aebc45de35353ce4cbd2298a8fe86a61a 100644 --- a/interface/web/tools/import_vpopmail.php +++ b/interface/web/tools/import_vpopmail.php @@ -68,7 +68,7 @@ if(isset($_POST['db_hostname']) && $_POST['db_hostname'] != '') { $msg .= 'Databse connection succeeded
'; $local_server_id = intval($_POST['local_server_id']); - $tmp = $app->db->queryOneRecord("SELECT mail_server FROM server WHERE server_id = $local_server_id"); + $tmp = $app->db->queryOneRecord("SELECT mail_server FROM server WHERE server_id = ?", $local_server_id); if($tmp['mail_server'] == 1) { start_import(); @@ -106,41 +106,41 @@ function start_import() { foreach($records as $rec) { $pw_domain = $rec['pw_domain']; //* Check if we have a client with that username already - $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE username = '$pw_domain'"); + $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE username = ?", $pw_domain); if($tmp['number'] == 0) { $pw_crypt_password = $app->auth->crypt_password($rec['pw_clear_passwd']); $country = 'FI'; //* add client $sql = "INSERT INTO `client` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `company_name`, `company_id`, `contact_name`, `customer_no`, `vat_id`, `street`, `zip`, `city`, `state`, `country`, `telephone`, `mobile`, `fax`, `email`, `internet`, `icq`, `notes`, `bank_account_owner`, `bank_account_number`, `bank_code`, `bank_name`, `bank_account_iban`, `bank_account_swift`, `default_mailserver`, `limit_maildomain`, `limit_mailbox`, `limit_mailalias`, `limit_mailaliasdomain`, `limit_mailforward`, `limit_mailcatchall`, `limit_mailrouting`, `limit_mailfilter`, `limit_fetchmail`, `limit_mailquota`, `limit_spamfilter_wblist`, `limit_spamfilter_user`, `limit_spamfilter_policy`, `default_webserver`, `limit_web_ip`, `limit_web_domain`, `limit_web_quota`, `web_php_options`, `limit_cgi`, `limit_ssi`, `limit_perl`, `limit_ruby`, `limit_python`, `force_suexec`, `limit_hterror`, `limit_wildcard`, `limit_ssl`, `limit_web_subdomain`, `limit_web_aliasdomain`, `limit_ftp_user`, `limit_shell_user`, `ssh_chroot`, `limit_webdav_user`, `limit_aps`, `default_dnsserver`, `limit_dns_zone`, `limit_dns_slave_zone`, `limit_dns_record`, `default_dbserver`, `limit_database`, `limit_cron`, `limit_cron_type`, `limit_cron_frequency`, `limit_traffic_quota`, `limit_client`, `limit_mailmailinglist`, `limit_openvz_vm`, `limit_openvz_vm_template_id`, `parent_client_id`, `username`, `password`, `language`, `usertheme`, `template_master`, `template_additional`, `created_at`, `id_rsa`, `ssh_rsa`) - VALUES(1, 1, 'riud', 'riud', '', '', '', '$pw_domain', '', '', '', '', '', '', '$country', '', '', '', '', 'http://', '', '', '', '', '', '', '', '', 1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, 0, 0, 1, NULL, -1, -1, 'no,fast-cgi,cgi,mod,suphp', 'n', 'n', 'n', 'n', 'n', 'y', 'n', 'n', 'n', -1, -1, -1, 0, 'no,jailkit', 0, 0, 1, -1, -1, -1, 1, -1, 0, 'url', 5, -1, 0, -1, 0, 0, 0, '$pw_domain', '$pw_crypt_password', '".$conf['language']."', 'default', 0, '', NOW(), '', '')"; - $app->db->query($sql); + VALUES(1, 1, 'riud', 'riud', '', '', '', ?, '', '', '', '', '', '', ?, '', '', '', '', 'http://', '', '', '', '', '', '', '', '', 1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, 0, 0, 0, 1, NULL, -1, -1, 'no,fast-cgi,cgi,mod,suphp', 'n', 'n', 'n', 'n', 'n', 'y', 'n', 'n', 'n', -1, -1, -1, 0, 'no,jailkit', 0, 0, 1, -1, -1, -1, 1, -1, 0, 'url', 5, -1, 0, -1, 0, 0, 0, ?, ?, ?, 'default', 0, '', NOW(), '', '')"; + $app->db->query($sql, $pw_domain,$country, $pw_domain, $pw_crypt_password, $conf['language']); $client_id = $app->db->insertID(); //* add sys_group - $groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('".$app->db->quote($pw_domain)."','',".$client_id.")", 'groupid'); + $groupid = $app->db->datalogInsert('sys_group', array("name" => $pw_domain, "description" => '', "client_id" => $client_id), 'groupid'); $groups = $groupid; - $username = $app->db->quote($pw_domain); + $username = $pw_domain; $password = $pw_crypt_password; $modules = $conf['interface_modules_enabled']; $startmodule = 'dashboard'; - $usertheme = $app->db->quote('default'); + $usertheme = 'default'; $type = 'user'; $active = 1; - $language = $app->db->quote($conf["language"]); + $language = $conf["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 = ".$client_id); + $app->db->query("UPDATE client SET created_at = UNIX_TIMESTAMP(), id_rsa = ?, ssh_rsa = ? WHERE client_id = ?", @file_get_contents('/tmp/id_rsa'), @file_get_contents('/tmp/id_rsa.pub'), $client_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,".$client_id.")"; - $app->db->query($sql); + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + $app->db->query($sql, $username,$password,$modules,$startmodule,$usertheme,$type,$active,$language,$groups,$groupid,$client_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'); @@ -152,8 +152,8 @@ function start_import() { $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_dbserver = $default_dbserver WHERE client_id = ".$client_id; - $app->db->query($sql); + $sql = "UPDATE client SET default_mailserver = ?, default_webserver = ?, default_dnsserver = ?, default_dbserver = ? WHERE client_id = ?"; + $app->db->query($sql, $default_mailserver, $default_webserver, $default_dnsserver, $default_dbserver, $client_id); $msg .= "Added Client $username.
"; } else { @@ -169,14 +169,22 @@ function start_import() { $domain = $rec['pw_domain']; //* Check if domain exists already - $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE domain = '$domain'"); + $tmp = $app->db->queryOneRecord("SELECT count(domain_id) as number FROM mail_domain WHERE domain = ?", $domain); if($tmp['number'] == 0) { - $user_rec = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE username = '$domain'"); + $user_rec = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE username = ?", $domain); $sys_userid = ($user_rec['userid'] > 0)?$user_rec['userid']:1; $sys_groupid = ($user_rec['default_group'] > 0)?$user_rec['default_group']:1; - $sql = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `domain`, `active`) - VALUES(".$sys_userid.", ".$sys_groupid.", 'riud', 'riud', '', $local_server_id, '$domain', 'y')"; + $sql = array( + "sys_userid" => $sys_userid, + "sys_groupid" => $sys_groupid, + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $local_server_id, + "domain" => $domain, + "active" => 'y' + ); $app->db->datalogInsert('mail_domain', $sql, 'domain_id'); $msg .= "Imported domain $domain
"; } else { @@ -193,20 +201,52 @@ function start_import() { $email = $rec['pw_name'].'@'.$rec['pw_domain']; //* Check for duplicate mailboxes - $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE email = '".$app->db->quote($email)."'"); + $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE email = ?", $email); if($tmp['number'] == 0) { //* get the mail domain for the mailbox - $domain_rec = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '$domain'"); + $domain_rec = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = ?", $domain); if(is_array($domain_rec)) { $pw_crypt_password = $app->auth->crypt_password($rec['pw_clear_passwd']); $maildir_path = "/var/vmail/".$rec['pw_domain']."/".$rec['pw_name']; //* Insert the mailbox - $sql = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `email`, `login`, `password`, `name`, `uid`, `gid`, `maildir`, `quota`, `cc`, `homedir`, `autoresponder`, `autoresponder_start_date`, `autoresponder_end_date`, `autoresponder_subject`, `autoresponder_text`, `move_junk`, `custom_mailfilter`, `postfix`, `access`, `disableimap`, `disablepop3`, `disabledeliver`, `disablesmtp`, `disablesieve`, `disablelda`, `disabledoveadm`) - VALUES(".$domain_rec['sys_userid'].", ".$domain_rec['sys_groupid'].", 'riud', 'riud', '', $local_server_id, '$email', '$email', '$pw_crypt_password', '$email', 5000, 5000, '$maildir_path', 0, '', '/var/vmail', 'n', '0000-00-00 00:00:00', '0000-00-00 00:00:00', 'Out of office reply', '', 'n', '', 'y', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n')"; + $sql = array( + "sys_userid" => $domain_rec['sys_userid'], + "sys_groupid" => $domain_rec['sys_groupid'], + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $local_server_id, + "email" => $email, + "login" => $email, + "password" => $pw_crypt_password, + "name" => $email, + "uid" => 5000, + "gid" => 5000, + "maildir" => $maildir_path, + "quota" => 0, + "cc" => '', + "homedir" => '/var/vmail', + "autoresponder" => 'n', + "autoresponder_start_date" => '0000-00-00 00:00:00', + "autoresponder_end_date" => '0000-00-00 00:00:00', + "autoresponder_subject" => 'Out of office reply', + "autoresponder_text" => '', + "move_junk" => 'n', + "custom_mailfilter" => '', + "postfix" => 'y', + "access" => 'n', + "disableimap" => 'n', + "disablepop3" => 'n', + "disabledeliver" => 'n', + "disablesmtp" => 'n', + "disablesieve" => 'n', + "disablelda" => 'n', + "disabledoveadm" => 'n' + ); $app->db->datalogInsert('mail_user', $sql, 'mailuser_id'); $msg .= "Imported mailbox $email
"; } @@ -242,16 +282,26 @@ function start_import() { } //* Check for duplicate forwards - $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE source = '".$app->db->quote($email)."' AND destination = '".$app->db->quote($target)."'"); + $tmp = $app->db->queryOneRecord("SELECT count(forwarding_id) as number FROM mail_forwarding WHERE source = ? AND destination = ?", $email, $target); if($tmp['number'] == 0 && $target != '') { //* get the mail domain - $domain_rec = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = '".$rec['domain']."'"); + $domain_rec = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = ?", $rec['domain']); if(is_array($domain_rec)) { - $sql = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `source`, `destination`, `type`, `active`) - VALUES(".$domain_rec['sys_userid'].", ".$domain_rec['sys_groupid'].", 'riud', 'riud', '', $local_server_id, '".$app->db->quote($email)."', '".$app->db->quote($target)."', 'forward', 'y')"; + $sql = array( + "sys_userid" => $domain_rec['sys_userid'], + "sys_groupid" => $domain_rec['sys_groupid'], + "sys_perm_user" => 'riud', + "sys_perm_group" => 'riud', + "sys_perm_other" => '', + "server_id" => $local_server_id, + "source" => $email, + "destination" => $target, + "type" => 'forward', + "active" => 'y' + ); $app->db->datalogInsert('mail_forwarding', $sql, 'forwarding_id'); } $msg .= "Imported alias $email.
"; diff --git a/interface/web/tools/lib/lang/ar_resync.lng b/interface/web/tools/lib/lang/ar_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/ar_resync.lng +++ b/interface/web/tools/lib/lang/ar_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/bg_resync.lng b/interface/web/tools/lib/lang/bg_resync.lng index 3a6a9db74e6a71c2afac95fab71f31f8cfa84ec2..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/bg_resync.lng +++ b/interface/web/tools/lib/lang/bg_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/br_resync.lng b/interface/web/tools/lib/lang/br_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/br_resync.lng +++ b/interface/web/tools/lib/lang/br_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/cz_resync.lng b/interface/web/tools/lib/lang/cz_resync.lng index 56b937c3d0c10ba9b1bd925cfe7d99081a72d1aa..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/cz_resync.lng +++ b/interface/web/tools/lib/lang/cz_resync.lng @@ -1,20 +1,45 @@ - diff --git a/interface/web/tools/lib/lang/de_resync.lng b/interface/web/tools/lib/lang/de_resync.lng index 59d85b99b177e65a125ebe12d2de425d30606263..32d1c23c10580d6b3b2a98b26ee021f12b76d9c7 100644 --- a/interface/web/tools/lib/lang/de_resync.lng +++ b/interface/web/tools/lib/lang/de_resync.lng @@ -1,20 +1,45 @@ diff --git a/interface/web/tools/lib/lang/el_resync.lng b/interface/web/tools/lib/lang/el_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/el_resync.lng +++ b/interface/web/tools/lib/lang/el_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/en_resync.lng b/interface/web/tools/lib/lang/en_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/en_resync.lng +++ b/interface/web/tools/lib/lang/en_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/es_resync.lng b/interface/web/tools/lib/lang/es_resync.lng index a699866cb2c34451f1c841a1603a13e1610b93bf..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/es_resync.lng +++ b/interface/web/tools/lib/lang/es_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/fi_resync.lng b/interface/web/tools/lib/lang/fi_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/fi_resync.lng +++ b/interface/web/tools/lib/lang/fi_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/fr_resync.lng b/interface/web/tools/lib/lang/fr_resync.lng index 2113530776904f487938a2a6a1eb0551abf80871..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/fr_resync.lng +++ b/interface/web/tools/lib/lang/fr_resync.lng @@ -1,20 +1,45 @@ diff --git a/interface/web/tools/lib/lang/hr_resync.lng b/interface/web/tools/lib/lang/hr_resync.lng index 8a97ae481c5c3deac777337140ae77f9b016b1a9..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/hr_resync.lng +++ b/interface/web/tools/lib/lang/hr_resync.lng @@ -1,16 +1,45 @@ - - diff --git a/interface/web/tools/lib/lang/hu_resync.lng b/interface/web/tools/lib/lang/hu_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/hu_resync.lng +++ b/interface/web/tools/lib/lang/hu_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/id_resync.lng b/interface/web/tools/lib/lang/id_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/id_resync.lng +++ b/interface/web/tools/lib/lang/id_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/it_resync.lng b/interface/web/tools/lib/lang/it_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/it_resync.lng +++ b/interface/web/tools/lib/lang/it_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/ja_resync.lng b/interface/web/tools/lib/lang/ja_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/ja_resync.lng +++ b/interface/web/tools/lib/lang/ja_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/nl_resync.lng b/interface/web/tools/lib/lang/nl_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/nl_resync.lng +++ b/interface/web/tools/lib/lang/nl_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/pl_resync.lng b/interface/web/tools/lib/lang/pl_resync.lng index 77e656d46af103e60d86fbded0fbf771d96e0bf4..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/pl_resync.lng +++ b/interface/web/tools/lib/lang/pl_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/pt_resync.lng b/interface/web/tools/lib/lang/pt_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/pt_resync.lng +++ b/interface/web/tools/lib/lang/pt_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/ro_resync.lng b/interface/web/tools/lib/lang/ro_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/ro_resync.lng +++ b/interface/web/tools/lib/lang/ro_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/ru_resync.lng b/interface/web/tools/lib/lang/ru_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/ru_resync.lng +++ b/interface/web/tools/lib/lang/ru_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/se_resync.lng b/interface/web/tools/lib/lang/se_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/se_resync.lng +++ b/interface/web/tools/lib/lang/se_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/sk_resync.lng b/interface/web/tools/lib/lang/sk_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/sk_resync.lng +++ b/interface/web/tools/lib/lang/sk_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/lang/tr_resync.lng b/interface/web/tools/lib/lang/tr_resync.lng index 4e89bdeada5f93ce2817484d22fc9362a86278ea..97537c347655f9f0cc2cbcf32dabb0a6defa59a2 100644 --- a/interface/web/tools/lib/lang/tr_resync.lng +++ b/interface/web/tools/lib/lang/tr_resync.lng @@ -1,19 +1,45 @@ diff --git a/interface/web/tools/lib/menu.d/resync.menu.php b/interface/web/tools/lib/menu.d/resync.menu.php index bc25fff1aead75e63b563b2b0f053c461658306d..65a331f46d22723e9d841ac6f2416c713d4c2d1a 100644 --- a/interface/web/tools/lib/menu.d/resync.menu.php +++ b/interface/web/tools/lib/menu.d/resync.menu.php @@ -9,8 +9,7 @@ if($app->auth->is_admin()) { $items[] = array( 'title' => 'Resync', 'target' => 'content', - 'link' => 'tools/resync_show.php'); - + 'link' => 'tools/resync.php'); $module['nav'][] = array( 'title' => 'Sync Tools', 'open' => 1, diff --git a/interface/web/tools/lib/module.conf.php b/interface/web/tools/lib/module.conf.php index 853fd649ea8472b2a81523e96ae8958e20ba9e79..617ab0b6cd6d354e96499bfecbf90b8700b86d0c 100644 --- a/interface/web/tools/lib/module.conf.php +++ b/interface/web/tools/lib/module.conf.php @@ -7,6 +7,7 @@ $module['title'] = 'top_menu_tools'; $module['template'] = 'module.tpl.htm'; $module['startpage'] = 'tools/index.php'; $module['tab_width'] = '60'; +$module['order'] = '80'; //**** Change User password diff --git a/interface/web/tools/resync.php b/interface/web/tools/resync.php new file mode 100644 index 0000000000000000000000000000000000000000..e99e5119db4abcfcaa4a1503ff027e8d19f8d491 --- /dev/null +++ b/interface/web/tools/resync.php @@ -0,0 +1,561 @@ +auth->check_module_permissions('admin'); + +// Loading classes +$app->uses('tpl,tform,tform_actions'); +$app->load('tform_actions'); + +class page_action extends tform_actions { + + //* called during onShowEnd + private function create_list($server_rec, $server_type, $search) { + + $server_count = 0; + + //* we allow multiple search-pattern - convert string to array + if (!is_array($search)) { + $_search = $search; + $search=array(); + $search[]=$_search; + } + + foreach ($server_rec as $server) { + //* check the database for existing records + $server_data = $this->server_has_data($server_type, $server['server_id']); + foreach ($search as $needle) + if (in_array($needle, $server_data) && strpos($options_servers, $server['server_name']) === false) { + $options_servers .= ""; + $server_count++; + } + } + + return array($options_servers, $server_count); + } + + //* called from create_list + private function server_has_data($type, $server) { + + global $app; + + $server_id = $app->functions->intval($server); + + if($type == 'mail') { + $server_data = array ( + 'mail_domain' => array ( + 'index_field' => 'domain_id', + 'server_type' => 'mail', + 'server_id' => $server_id, + ), + 'mail_mailinglist' => array ( + 'index_field' => 'mailinglist_id', + 'server_type' => 'mail', + 'server_id' => $server_id, + ), + 'mail_user' => array ( + 'index_field' => 'mailuser_id', + 'server_type' => 'mail', + 'server_id' => $server_id, + ), + ); + } + if($type == 'mail_filter') { + $server_data = array ( + 'mail_access' => array ( + 'index_field' => 'access_id', + 'server_type' => 'mail', + 'server_id' => $server_id, + ), + 'mail_content_filter' => array ( + 'index_field' => 'content_filter_id', + 'server_type' => 'mail', + ), + 'mail_user_filter' => array ( + 'index_field' => 'filter_id', + 'server_type' => 'mail', + ), + ); + } + if($type == 'web' ) { + $server_data = array ( + 'web_domain' => array ( + 'index_field' => 'domain_id', + 'server_type' => 'web', + 'server_id' => $server_id, + ), + 'shell_user' => array ( + 'index_field' => 'shell_user_id', + 'server_type' => 'web', + 'server_id' => $server_id, + ), + 'cron' => array ( + 'index_field' => 'id', + 'server_type' => 'cron', + 'server_id' => $server_id, + ), + 'ftp_user' => array ( + 'index_field' => 'ftp_user_id', + 'server_type' => 'web', + 'server_id' => $server_id, + ), + ); + } + if($type == 'dns' ) { + $server_data = array ( + 'dns_soa' => array ( + 'index_field' => 'id', + 'server_type' => 'dns', + 'server_id' => $server_id, + ), + ); + } + if($type == 'file' ) { + $server_data = array ( + 'webdav_user' => array ( + 'index_field' => 'webdav_user_id', + 'server_type' => 'file', + 'server_id' => $server_id, + ), + ); + } + if($type == 'db' ) { + $server_data = array ( + 'web_database' => array ( + 'index_field' => 'web_database_id', + 'server_type' => 'db', + 'server_id' => $server_id, + ), + ); + } + if($type == 'vserver' ) { + $server_data = array ( + 'openvz_vm' => array ( + 'index_field' => 'vm_id', + 'server_type' => 'vserver', + 'server_id' => $server_id, + ), + ); + } + //* proxy + //* firewall + $array_out = array(); + foreach($server_data as $db_table => $data) { + $sql = @(isset($data['server_id']))?"SELECT * FROM ?? WHERE server_id = ?":"SELECT * FROM ??"; + $records = $app->db->queryAllRecords($sql, $db_table, $server_id); + if (!empty($records)) array_push($array_out, $db_table); + } + + return $array_out; + } + + function onShowEnd() { + global $app; + + //* fetch all-server + $server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); + $server_count = 0; + foreach ($server_rec as $server) { + $options_servers .= ""; + $server_count++; + } + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('all_server_id', $options_servers); + unset($options_servers); + + //* fetch mail-server + $mail_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE mail_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); + if (!empty($mail_server_rec)) { + $app->tpl->setVar('mail_server_found', 1); + + //* mail-domain + $server_list = $this->create_list($mail_server_rec, 'mail', 'mail_domain'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('mail_server_id', $options_servers); + $app->tpl->setVar('mail_domain_found', 1); + unset($options_servers); + } + + //* mailbox + $server_list = $this->create_list($mail_server_rec, 'mail', 'mail_user'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('mailbox_server_id', $options_servers); + $app->tpl->setVar('mail_user_found', 1); + unset($options_servers); + } + + //* mailfilter + $server_list = $this->create_list($mail_server_rec, 'mail_filter', array('mail_access', 'mail_content_filter', 'mail_user_filter')); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('mailfilter_server_id', $options_servers); + $app->tpl->setVar('mail_filter_found', 1); + unset($options_servers); + } + + //* mailinglist + $server_list = $this->create_list($mail_server_rec, 'mail', 'mail_mailinglist'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('mailinglist_server_id', $options_servers); + $app->tpl->setVar('mailinglist_found', 1); + unset($options_servers); + } + } + + //* fetch web-server + $web_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE web_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); + if (!empty($web_server_rec)) { + $app->tpl->setVar('web_server_found', 1); + + //* web-domain + $server_list = $this->create_list($web_server_rec, 'web', 'web_domain'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('web_server_id', $options_servers); + $app->tpl->setVar('web_domain_found', 1); + unset($options_servers); + } + + //* ftp-user + $server_list = $this->create_list($web_server_rec, 'web', 'ftp_user'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('ftp_server_id', $options_servers); + $app->tpl->setVar('ftp_user_found', 1); + unset($options_servers); + } + + //* shell-user + $server_list = $this->create_list($web_server_rec, 'web', 'shell_user'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('shell_server_id', $options_servers); + $app->tpl->setVar('shell_user_found', 1); + unset($options_servers); + } + + //* cron + $server_list = $this->create_list($web_server_rec, 'web', 'cron'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('cron_server_id', $options_servers); + $app->tpl->setVar('cron_found', 1); + unset($options_servers); + } + } + + //* fetch dns-server + $dns_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE dns_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); + if (!empty($dns_server_rec)) { + $app->tpl->setVar('dns_server_found', 1); + + $server_list = $this->create_list($dns_server_rec, 'dns', 'dns_soa'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('dns_server_id', $options_servers); + $app->tpl->setVar('dns_soa_found', 1); + unset($options_servers); + } + } + + //* fetch webdav-user + $file_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE file_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); + if (!empty($file_server_rec)) { + $app->tpl->setVar('file_server_found', 1); + + $server_list = $this->create_list($file_server_rec, 'file', 'webdav_user'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('file_server_id', $options_servers); + $app->tpl->setVar('webdav_user_found', 1); + unset($options_servers); + } + } + + //* fetch database-server + $db_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE db_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); + if (!empty($db_server_rec)) { + $app->tpl->setVar('db_server_found', 1); + + $server_list = $this->create_list($db_server_rec, 'db', 'web_database'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('db_server_id', $options_servers); + $app->tpl->setVar('client_db_found', 1); + unset($options_servers); + } + } + + //* fetch vserver + $v_server_rec = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE vserver_server = 1 AND active = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); + if (!empty($db_server_rec)) { + $app->tpl->setVar('vserver_server_found', 1); + + $server_list = $this->create_list($v_server_rec, 'vserver', 'openvz_vm'); + $options_servers = $server_list[0];$server_count = $server_list[1]; + unset($server_list); + if (isset($options_servers)) { //* server with data found + if ($server_count > 1) $options_servers = "" . $options_servers; + $app->tpl->setVar('vserver_server_id', $options_servers); + $app->tpl->setVar('vserver_found', 1); + unset($options_servers); + } + } + + parent::onShowEnd(); + } + + //* fetch values during do_resync + private function query_server($db_table, $server_id, $server_type, $active=true, $opt='') { + global $app; + + $server_name = array(); + if ( $server_id == 0 ) { //* resync multiple server + $temp = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE ?? = 1 AND active = 1 AND mirror_server_id = 0", $server_type."_server"); + foreach ($temp as $server) { + $temp_id .= $server['server_id'].','; + $server_name[$server['server_id']] = $server['server_name']; + } + } else { + $temp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ?", $server_id); + $server_name[$server_id] = $temp['server_name']; + } + unset($temp); + + if ( isset($temp_id) ) $server_id = rtrim($temp_id,','); + $sql = "SELECT * FROM ??"; + if ($db_table != "mail_user_filter") $sql .= " WHERE server_id IN (".$server_id.") "; + $sql .= $opt; + if ($active) $sql .= " AND active = 'y'"; + $records = $app->db->queryAllRecords($sql, $db_table); + + return array($records, $server_name); + } + + private function do_resync($db_table, $index_field, $server_type, $server_id, $msg_field, $wordbook, $active=true) { + global $app; + + $server_id = $app->functions->intval($server_id); + $rec = $this->query_server($db_table, $server_id, $server_type, $active); + $records = $rec[0]; + $server_name = $rec[1]; + $msg = ''.$wordbook.'
'; + if(!empty($records)) + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + if(!empty($rec[$msg_field])) $msg .= '['.$server_name[$rec['server_id']].'] '.$rec[$msg_field].'
'; + } + else $msg .= $app->tform->wordbook['no_results_txt'].'
'; + + return $msg.'
'; + } + + function onSubmit() { + global $app; + + //* all services + if($this->dataRecord['resync_all'] == 1) { + $this->dataRecord['resync_sites'] = 1; + $this->dataRecord['resync_ftp'] = 1; + $this->dataRecord['resync_webdav'] = 1; + $this->dataRecord['resync_shell'] = 1; + $this->dataRecord['resync_cron'] = 1; + $this->dataRecord['resync_db'] = 1; + $this->dataRecord['resync_mail'] = 1; + $this->dataRecord['resync_mailbox'] = 1; + $this->dataRecord['resync_mailfilter'] = 1; + $this->dataRecord['resync_mailinglist'] = 1; + $this->dataRecord['resync_vserver'] = 1; + $this->dataRecord['resync_dns'] = 1; + $this->dataRecord['resync_client'] = 1; + $this->dataRecord['web_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['ftp_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['webdav_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['shell_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['cron_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['db_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['mail_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['mailbox_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['verserver_server_id'] = $this->dataRecord['all_server_id']; + $this->dataRecord['dns_server_id'] = $this->dataRecord['all_server_id']; + } + + //* websites + if($this->dataRecord['resync_sites'] == 1) + $msg .= $this->do_resync('web_domain', 'domain_id', 'web', $this->dataRecord['web_server_id'], 'domain', $app->tform->wordbook['do_sites_txt']); + + //* ftp + if($this->dataRecord['resync_ftp'] == 1) + $msg .= $this->do_resync('ftp_user', 'ftp_user_id', 'web', $this->dataRecord['ftp_server_id'], 'username', $app->tform->wordbook['do_ftp_txt']); + + //* webdav + if($this->dataRecord['resync_webdav'] == 1) + $msg .= $this->do_resync('webdav_user', 'webdav_user_id', 'file', $this->dataRecord['webdav_server_id'], 'username', $app->tform->wordbook['do_webdav_txt']); + + //* shell + if($this->dataRecord['resync_shell'] == 1) + $msg .= $this->do_resync('shell_user', 'shell_user_id', 'web', $this->dataRecord['shell_server_id'], 'username', $app->tform->wordbook['do_shell_txt']); + + //* cron + if($this->dataRecord['resync_cron'] == 1) + $msg .= $this->do_resync('cron', 'id', 'web', $this->dataRecord['cron_server_id'], 'command', $app->tform->wordbook['do_cron_txt']); + + //* database + if(isset($this->dataRecord['resync_db']) && $this->dataRecord['resync_db'] == 1) { + $msg .= $this->do_resync('web_database_user', 'database_user_id', 'db', $this->dataRecord['db_server_id'], 'database_user', $app->tform->wordbook['do_db_user_txt'], false); + $msg .= $this->do_resync('web_database', 'database_id', 'db', $this->dataRecord['db_server_id'], 'database_name', $app->tform->wordbook['do_db_txt']); + } + + //* maildomains + if($this->dataRecord['resync_mail'] == 1) + $msg .= $this->do_resync('mail_domain', 'domain_id', 'mail', $this->dataRecord['mail_server_id'], 'domain', $app->tform->wordbook['do_mail_txt']); + + //* mailbox + if($this->dataRecord['resync_mailbox'] == 1) { + $msg .= $this->do_resync('mail_user', 'mailuser_id', 'mail', $this->dataRecord['mailbox_server_id'], 'email', $app->tform->wordbook['do_mailbox_txt'], false); + $msg .= $this->do_resync('mail_forwarding', 'forwarding_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_alias_txt']); + } + + //* mailfilter + if($this->dataRecord['resync_mailfilter'] == 1) { + $msg .= $this->do_resync('mail_access', 'access_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_access_txt']); + $msg .= $this->do_resync('mail_content_filter', 'content_filter_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_contentfilter_txt']); + $msg .= $this->do_resync('mail_user_filter', 'filter_id', 'mail', $this->dataRecord['mailbox_server_id'], '', $app->tform->wordbook['do_mail_userfilter_txt'], false); + } + + //* mailinglists + if($this->dataRecord['resync_mailinglist'] == 1) + $msg .= $this->do_resync('mail_mailinglist', 'mailinglist_id', 'mail', $this->dataRecord['mail_server_id'], 'listname', $app->tform->wordbook['do_mailinglist_txt'], false); + + //* vserver + if($this->dataRecord['resync_vserver'] == 1) + $msg .= $this->do_resync('openvz_vm', 'vm_id', 'vserver', $this->dataRecord['verserver_server_id'], 'hostname', $app->tform->wordbook['do_vserver_txt']); + + //* dns + if($this->dataRecord['resync_dns'] == 1) { + $rec=$this->query_server('dns_soa', $this->dataRecord['dns_server_id'], 'dns'); + $soa_records = $rec[0]; + $server_name = $rec[1]; + unset($rec); + $msg .= ''.$app->tform->wordbook['do_dns_txt'].'
'; + if(is_array($soa_records) && !empty($soa_records)) + foreach($soa_records as $soa_rec) { + $temp = $this->query_server('dns_rr', $soa_rec['server_id'], 'dns', true, "AND zone = ".$app->functions->intval($soa_rec['id'])); + $rr_records = $temp[0]; + if(!empty($rr_records)) { + foreach($rr_records as $rec) { + $new_serial = $app->validate_dns->increase_serial($rec['serial']); + $app->db->datalogUpdate('dns_rr', array("serial" => $new_serial), 'id', $rec['id']); + } + } else { + $msg .= $app->tform->wordbook['no_results_txt'].'
'; + } + $new_serial = $app->validate_dns->increase_serial($soa_rec['serial']); + $app->db->datalogUpdate('dns_soa', array("serial" => $new_serial), 'id', $soa_rec['id']); + $msg .= '['.$server_name[$soa_rec['server_id']].'] '.$soa_rec['origin'].' ('.count($rr_records).')
'; + } + else $msg .= $app->tform->wordbook['no_results_txt'].'
'; + + $msg .= '
'; + } + + //* clients + if($this->dataRecord['resync_client'] == 1) { + $db_table = 'client'; + $index_field = 'client_id'; + $records = $app->db->queryAllRecords("SELECT * FROM ??", $db_table); + $msg .= ''.$app->tform->wordbook['do_clients_txt'].'
'; + if(!empty($records)) { + $tform_def_file = '../client/form/client.tform.php'; + $app->uses('tpl,tform,tform_actions'); + $app->load('tform_actions'); + foreach($records as $rec) { + $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); + $tmp = new tform_actions; + $tmp->id = $rec[$index_field]; + $tmp->dataRecord = $rec; + $tmp->oldDataRecord = $rec; + $app->plugin->raiseEvent('client:client:on_after_update', $tmp); + $msg .= $rec['contact_name'].'
'; + unset($tmp); + } + } else { + $msg .= $app->tform->wordbook['no_results_txt'].'
'; + } + $msg .= '
'; + } + + echo $msg; + } //* end onSumbmit + +} + +$page = new page_action; +$page->onLoad(); +?> diff --git a/interface/web/tools/resync_do.php b/interface/web/tools/resync_do.php deleted file mode 100644 index 08157376f63d01dbaadb085e9f940d0f952c2c88..0000000000000000000000000000000000000000 --- a/interface/web/tools/resync_do.php +++ /dev/null @@ -1,383 +0,0 @@ -auth->check_module_permissions('admin'); - -// Loading classes -$app->uses('tpl,tform,tform_actions'); -$app->load('tform_actions'); - -class page_action extends tform_actions { - - function onSubmit() { - global $app, $conf, $interfaceConf; - - function query_server($table, $server_id, $server_type, $where = "WHERE active = 'y'", $active_only = true) { - global $app; - $server_name = array(); - if ( $server_id <= 0 ) { //* resync multiple server - if ($active_only) { - $tmp = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE ".$server_type."_server = 1 AND active = 1 AND mirror_server_id = 0"); - } else { - $tmp = $app->db->queryAllRecords("SELECT server_id, server_name FROM server WHERE ".$server_type."_server = 1 AND mirror_server_id = 0"); - } - foreach ($tmp as $server) { - $tmp_id .= $server['server_id'].','; - $server_name[$server['server_id']] = $server['server_name']; - } - } else { - $temp = $app->db->queryOneRecord("SELECT server_name FROM server WHERE server_id = ".$server_id); - $server_name[$server_id] = $temp['server_name']; - unset($temp); - } - - if ( isset($tmp_id) ) $server_id = rtrim($tmp_id,','); - - if ($active_only) { - $sql = "SELECT * FROM ".$table." ".$where." AND server_id IN (".$server_id.")"; - } else { - $sql = "SELECT * FROM ".$table." ".$where; - } - $records = $app->db->queryAllRecords($sql); - - return array($records, $server_name); - } - - //* websites - if(isset($this->dataRecord['resync_sites']) && $this->dataRecord['resync_sites'] == 1) { - $db_table = 'web_domain'; - $index_field = 'domain_id'; - $server_type = 'web'; - $server_id = $app->functions->intval($this->dataRecord['web_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg = 'Resynced Website:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['domain'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* ftp - if(isset($this->dataRecord['resync_ftp']) && $this->dataRecord['resync_ftp'] == 1) { - $db_table = 'ftp_user'; - $index_field = 'ftp_user_id'; - $server_type = 'web'; - $server_id = $app->functions->intval($this->dataRecord['ftp_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced FTP user:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['username'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* webdav - if(isset($this->dataRecord['resync_webdav']) && $this->dataRecord['resync_webdav'] == 1) { - $db_table = 'webdav_user'; - $index_field = 'webdav_user_id'; - $server_type = 'file'; - $server_id = $app->functions->intval($this->dataRecord['webdav_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced WebDav-User
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['username'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* shell - if(isset($this->dataRecord['resync_shell']) && $this->dataRecord['resync_shell'] == 1) { - $db_table = 'shell_user'; - $index_field = 'shell_user_id'; - $server_type = 'web'; - $server_id = $app->functions->intval($this->dataRecord['shell_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced Shell user:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['username'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* cron - if(isset($this->dataRecord['resync_cron']) && $this->dataRecord['resync_cron'] == 1) { - $db_table = 'cron'; - $index_field = 'id'; - $server_type = 'web'; - $server_id = $app->functions->intval($this->dataRecord['cron_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced Cronjob:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['command'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* database - if(isset($this->dataRecord['resync_db']) && $this->dataRecord['resync_db'] == 1) { - $db_table = 'web_database_user'; - $index_field = 'database_user_id'; - $server_type = 'db'; - $server_id = $app->functions->intval($this->dataRecord['db_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1'); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced Database User:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['database_user'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - - $db_table = 'web_database'; - $index_field = 'database_id'; - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $msg .= 'Resynced Database:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['database_name'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - - } - - //* maildomains - if(isset($this->dataRecord['resync_mail']) && $this->dataRecord['resync_mail'] == 1) { - $db_table = 'mail_domain'; - $index_field = 'domain_id'; - $server_type = 'mail'; - $server_id = $app->functions->intval($this->dataRecord['mail_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced Maildomain:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['domain'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* mailbox - if(isset($this->dataRecord['resync_mailbox']) && $this->dataRecord['resync_mailbox'] == 1) { - $db_table = 'mail_user'; - $index_field = 'mailuser_id'; - $server_type = 'mail'; - $server_id = $app->functions->intval($this->dataRecord['mailbox_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1'); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced Mailbox:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['email'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - - $db_table = 'mail_forwarding'; - $index_field = 'forwarding_id'; - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced Alias
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* dns - if(isset($this->dataRecord['resync_dns']) && $this->dataRecord['resync_dns'] == 1) { - $db_table = 'dns_soa'; - $index_field = 'id'; - $server_type = 'dns'; - $server_id = $app->functions->intval($this->dataRecord['dns_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type, "WHERE active = 'Y'"); - $zone_records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced DNS zone
'; - if(is_array($zone_records) && !empty($zone_records)) { - foreach($zone_records as $zone_rec) { - if ($server_id == -1) { - $temp = query_server('dns_rr', $server_id, $server_type, 'WHERE 1', false); - $records = $temp[0]; - unset($temp); - } else { - $temp= query_server('dns_rr', $server_id, $server_type, "WHERE active = 'Y'"); - $records = $temp[0]; - unset($temp); - } - $rr_count = 0; - if (is_array($records)) { - foreach($records as $rec) { - $new_serial = $app->validate_dns->increase_serial($rec['serial']); - $app->db->datalogUpdate('dns_rr', "serial = '".$new_serial."'", 'id', $rec['id']); - $rr_count++; - } - } else { $msg .= 'no dns recordsesults
'; } - $new_serial = $app->validate_dns->increase_serial($zone_rec['serial']); - $app->db->datalogUpdate('dns_soa', "serial = '".$new_serial."'", 'id', $zone_rec['id']); - $msg .= $zone_rec['origin'].' on '.$server_name[$zone_rec['server_id']].' with '.$rr_count.' records
'; - } - } else { $msg .= 'no results
'; } - $msg .= '
'; - } - - //* clients - if(isset($this->dataRecord['resync_client']) && $this->dataRecord['resync_client'] == 1) { - $db_table = 'client'; - $index_field = 'client_id'; - $records = $app->db->queryAllRecords("SELECT * FROM ".$db_table); - $msg .= 'Resynced clients
'; - if(is_array($records)) { - $tform_def_file = '../client/form/client.tform.php'; - $app->uses('tpl,tform,tform_actions'); - $app->load('tform_actions'); - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $tmp = new tform_actions; - $tmp->id = $rec[$index_field]; - $tmp->dataRecord = $rec; - $tmp->oldDataRecord = $rec; - $app->plugin->raiseEvent('client:client:on_after_update', $tmp); - $msg .= $rec['contact_name'].'
'; - unset($tmp); - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* vserver - if(isset($this->dataRecord['resync_vserver']) && $this->dataRecord['resync_vserver'] == 1) { - $db_table = 'openvz_vm'; - $index_field = 'vm_id'; - $server_type = 'vserver'; - $server_id = $app->functions->intval($this->dataRecord['vserver_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced vServer:
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - $msg .= $rec['hostname'].' on '.$server_name[$rec['server_id']].'
'; - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - //* firewall - if(isset($this->dataRecord['resync_firewall']) && $this->dataRecord['resync_firewall'] == 1) { - $db_table = 'iptables'; - $index_field = 'iptables_id'; - $server_type = 'firewall'; - $server_id = $app->functions->intval($this->dataRecord['firewall_server_id']); - if ($server_id == -1) $tmp = query_server($db_table, $server_id, $server_type, 'WHERE 1', false); else $tmp = query_server($db_table, $server_id, $server_type); - $records = $tmp[0]; - $server_name = $tmp[1]; - unset($tmp); - $msg .= 'Resynced Firewall
'; - if(is_array($records)) { - foreach($records as $rec) { - $app->db->datalogUpdate($db_table, $rec, $index_field, $rec[$index_field], true); - } - } else { $msg .= 'no results'; } - $msg .= '
'; - } - - echo $msg; - } - -} - -$page = new page_action; -$page->onLoad(); -?> diff --git a/interface/web/tools/resync_show.php b/interface/web/tools/resync_show.php deleted file mode 100644 index b74515d6549d6f38202fd1744bfccaeac967eadd..0000000000000000000000000000000000000000 --- a/interface/web/tools/resync_show.php +++ /dev/null @@ -1,114 +0,0 @@ -auth->check_module_permissions('admin'); - -// Loading classes -$app->uses('tpl,tform,tform_actions'); -$app->load('tform_actions'); - -class page_action extends tform_actions { - - function get_servers($type) { - global $app; - - $inactive_server = false; - $tmp = $app->db->queryAllRecords("SELECT server_id, server_name, active FROM server WHERE ".$type."_server = 1 AND mirror_server_id = 0 ORDER BY active DESC, server_name"); - foreach ($tmp as $server) { - if ( $server['active'] == '0' ) { - $server['server_name'] .= ' [inactive]'; - $inactive_server = true; - } - $options_servers .= ""; - } - if ( count ($tmp) > 1 ) { - $options_servers = "" . $options_servers; - if ($inactive_server) $options_servers .= ""; - } - - return $options_servers; - - } - - function onShowEnd() { - global $app, $conf; - - $servers = $this->get_servers('mail'); - $app->tpl->setVar('mail_server_id', $servers); - if ( !empty($servers) ) $app->tpl->setVar('mail_server_found', 1); - - $servers = $this->get_servers('web'); - $app->tpl->setVar('web_server_id', $servers); - $app->tpl->setVar('ftp_server_id', $servers); - if ( !empty($servers) ) $app->tpl->setVar('web_server_found', 1); - - $servers = $this->get_servers('dns'); - $app->tpl->setVar('dns_server_id', $servers); - if ( !empty($servers) ) $app->tpl->setVar('dns_server_found', 1); - - $servers = $this->get_servers('file'); - $app->tpl->setVar('file_server_id', $servers); - if ( !empty($servers) ) $app->tpl->setVar('file_server_found', 1); - - $servers = $this->get_servers('db'); - $app->tpl->setVar('db_server_id', $servers); - if ( !empty($servers) ) $app->tpl->setVar('db_server_found', 1); - - $servers = $this->get_servers('vserver'); - $app->tpl->setVar('vserver_server_id', $servers); - if ( !empty($servers) ) $app->tpl->setVar('vserver_server_found', 1); - - $servers = $this->get_servers('firewall'); - $app->tpl->setVar('firewall_server_id', $servers); - if ( !empty($servers) ) $app->tpl->setVar('firewall_server_found', 1); - - parent::onShowEnd(); - } - -} - -$page = new page_action; -$page->onLoad(); - -?> diff --git a/interface/web/tools/templates/dns_import_tupa.htm b/interface/web/tools/templates/dns_import_tupa.htm index ca44696fac6becf332623bac0ddb0a89a67be485..6aadf711ee5545660312d70f128d642df41d79c0 100644 --- a/interface/web/tools/templates/dns_import_tupa.htm +++ b/interface/web/tools/templates/dns_import_tupa.htm @@ -1,50 +1,37 @@

Import DNS records from Tupa PowerDNS controlpanel

-
- -
-
PowerDNS Tupa import -
-

Tupa database hostname

-
- -
+ + PowerDNS Tupa import +
+ +
-
-

Tupa database name

-
- -
+
+ +
-
-

Tupa database user

-
- -
+
+ +
-
-

Tupa database password

-
- -
+
+ +
-
+

-

ERROR

+

-
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/tools/templates/import_ispconfig.htm b/interface/web/tools/templates/import_ispconfig.htm index f7b97e8e6255873891e7c885402f21e4db92c706..83d79e671fc9888d33ad56cb6550d6db62e501c8 100644 --- a/interface/web/tools/templates/import_ispconfig.htm +++ b/interface/web/tools/templates/import_ispconfig.htm @@ -1,82 +1,68 @@ -

+

-
{tmpl_var name="legend_txt"} -
-

Remote API URL

-
- (e.g. https://www.example.com:8080/remote/ ) -
+ {tmpl_var name="legend_txt"} +
+ +
+
(e.g. https://www.example.com:8080/remote/ ) +
-
-

Remote User

-
- -
+
+ +
-
-

Remote password

-
- -
+
+ +
-
+
-
{tmpl_var name="legend2_txt"} -
- - {tmpl_var name='mail_domain'} - +
-
- - {tmpl_var name='client_group_id'} - +
-
-

{tmpl_var name="import_mailbox_txt"}

-
- -
+
+ +
-
-

{tmpl_var name="import_user_filter_txt"}

-
- -
+
+ +
-
-

{tmpl_var name="import_spamfilter_txt"}

-
- -
+
+ +
-
-

{tmpl_var name="import_alias_txt"}

-
- -
+
+ +
-
-

{tmpl_var name="import_forward_txt"}

-
- -
+
+ +
-
-

{tmpl_var name="import_aliasdomain_txt"}

-
- -
+
+ +
- +
@@ -84,20 +70,20 @@

-

ERROR

+

-
- - -
+
+ + +
-
- - -
+
+ + +
\ No newline at end of file diff --git a/interface/web/tools/templates/import_plesk.htm b/interface/web/tools/templates/import_plesk.htm index 363d72860c06e8d2f59b858a4c88f39989ce6c88..645913abd64cad157d11a75d9e5d35e408fd9e7c 100644 --- a/interface/web/tools/templates/import_plesk.htm +++ b/interface/web/tools/templates/import_plesk.htm @@ -1,74 +1,53 @@

Import plesk panel data

-
- -
-
Plesk data import -
-

Plesk database hostname

-
- -
+ + Plesk data import +
+ +
-
-

Plesk database name

-
- -
+
+ +
-
-

Plesk database user

-
- -
+
+ +
-
-

Plesk database password

-
- -
+
+ +
-
-

Web content backup file (on this server, optional)

-
- -
+
+ +
-
-

Maildir content backup file (on this server, optional)

-
- -
+
+ +
-
-

Import all data (that can be imported)

-
- -
+
+ +
-
-

Import database contents (make sure the database user has the rights to do so)

-
- -
+
+ +
-
+

-

ERROR

+

-
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/tools/templates/import_vpopmail.htm b/interface/web/tools/templates/import_vpopmail.htm index ade9476943acb525ef95e033c5fa1002800e0265..749ce74a411d1543ca0aec6a07c65948f14c709e 100644 --- a/interface/web/tools/templates/import_vpopmail.htm +++ b/interface/web/tools/templates/import_vpopmail.htm @@ -1,53 +1,45 @@ -

+

-
{tmpl_var name="legend_txt"} -
-

Database Hostname

-
- -
+ {tmpl_var name="legend_txt"} +
+ +
-
-

Database Name

-
- -
+
+ +
-
-

Database User

-
- -
+
+ +
-
-

Database password

-
- -
+
+ +
-
-

Server ID of local mailserver

-
- -
+
+ +
-
+

-

ERROR

+

-
- - -
+
+ + +
diff --git a/interface/web/tools/templates/index.htm b/interface/web/tools/templates/index.htm index 21147c90e4a923ed096d0519c841463d5982dfae..951c43b564aed11344cd2e7e45642e5fee12a9e2 100644 --- a/interface/web/tools/templates/index.htm +++ b/interface/web/tools/templates/index.htm @@ -1,19 +1,21 @@ -

+

-
+

 

-
+ -
+
  -
+
\ No newline at end of file diff --git a/interface/web/tools/templates/interface_settings.htm b/interface/web/tools/templates/interface_settings.htm index a9057c874d63e76c463ca1179ba3b659608b7f4c..ccd500044521a6e29e5e093811fdaaa081b3f0bb 100644 --- a/interface/web/tools/templates/interface_settings.htm +++ b/interface/web/tools/templates/interface_settings.htm @@ -1,32 +1,29 @@ -

+

-
-
-
+ -
- - {tmpl_var name='app_theme'} - +
-
- - {tmpl_var name='startmodule'} - +
- + -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/tools/templates/resync.htm b/interface/web/tools/templates/resync.htm index 064dc6fae9d4982b26c33ef97153e3f3e8b56e20..48e20cc8510b3f799cd3366dbf3b19ba65ee07ea 100644 --- a/interface/web/tools/templates/resync.htm +++ b/interface/web/tools/templates/resync.htm @@ -1,211 +1,134 @@ -

+

+ +
+
+ +
+
-
-
-
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
-
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
-
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
-
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
-
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + + + + +
+
+ +
-
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + + + + +
+
+ +
-
+ + -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
-
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
-
- -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - + + +
+
+ +
-
+
+ -
-
- - - - - - - - {tmpl_var name="resync_no_server_txt"} - - -
-
-
-
- - + + +
+
+ +
-
- - - -
- - + + + + + +
+
+ +
+
+
+
+ + +
+
+ +
+
+ +
+
+
-
+ + + +
+ + +
diff --git a/interface/web/tools/templates/tpl_default.htm b/interface/web/tools/templates/tpl_default.htm index fadcd36f8015612c57cb52b2bb64f322b7719494..656518ec1915c2cb3ee95028ac8b90d70dfbb31c 100644 --- a/interface/web/tools/templates/tpl_default.htm +++ b/interface/web/tools/templates/tpl_default.htm @@ -1,21 +1,18 @@ -

+

-
-
-
-
+ +

-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/tools/templates/user_settings.htm b/interface/web/tools/templates/user_settings.htm index d6f57d020628eeccc5d205cd72b12688eda4eaac..b493c0397f084f7f9aa914d177f7c7efca334fa5 100644 --- a/interface/web/tools/templates/user_settings.htm +++ b/interface/web/tools/templates/user_settings.htm @@ -1,39 +1,35 @@ -

+

-
-
-
-
- -  {tmpl_var name='generate_password_txt'} + +
+ +
 
{tmpl_var name='generate_password_txt'}
-
-

{tmpl_var name='password_strength_txt'}

+
+

 

-
- - -
+
+ +
-
- - {tmpl_var name='language'} - +
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/tools/user_settings.php b/interface/web/tools/user_settings.php index 02fc4f73d2d3c8e9cd6b86ad1a60cbed115b9a9a..57542458eff600b069e8fbe118d406d82e15feed 100644 --- a/interface/web/tools/user_settings.php +++ b/interface/web/tools/user_settings.php @@ -102,7 +102,7 @@ class page_action extends tform_actions { global $app; if($_POST['passwort'] != '') { - $tmp_user = $app->db->queryOneRecord("SELECT passwort FROM sys_user WHERE userid = '".$app->functions->intval($_SESSION['s']['user']['userid'])."'"); + $tmp_user = $app->db->queryOneRecord("SELECT passwort FROM sys_user WHERE userid = ?", $_SESSION['s']['user']['userid']); $_SESSION['s']['user']['passwort'] = $tmp_user['passwort']; unset($tmp_user); } diff --git a/interface/web/vm/ajax_get_ip.php b/interface/web/vm/ajax_get_ip.php index 64400775ee5ded8a8d843d63a1139e9201c7a55e..3ff5c0d294a296167f0031f2fd80bf7155da4e99 100644 --- a/interface/web/vm/ajax_get_ip.php +++ b/interface/web/vm/ajax_get_ip.php @@ -38,8 +38,8 @@ $server_id = $app->functions->intval($_GET["server_id"]); if($_SESSION["s"]["user"]["typ"] == 'admin' or $app->auth->has_clients($_SESSION['s']['user']['userid'])) { - $sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND server_id = $server_id"; - $ips = $app->db->queryAllRecords($sql); + $sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND server_id = ?"; + $ips = $app->db->queryAllRecords($sql, $server_id); $ip_select = ""; if(is_array($ips)) { foreach( $ips as $ip) { diff --git a/interface/web/vm/form/openvz_ip.tform.php b/interface/web/vm/form/openvz_ip.tform.php index 181d6415d95e84d44e4868405045955f054cf86a..e43b28de2028e4469629930918dd7e27152429ab 100644 --- a/interface/web/vm/form/openvz_ip.tform.php +++ b/interface/web/vm/form/openvz_ip.tform.php @@ -77,10 +77,9 @@ $form["tabs"]['main'] = array ( 'ip_address' => array ( 'datatype' => 'VARCHAR', 'formtype' => 'TEXT', - 'validators' => array ( 0 => array ( 'type' => 'ISIPV4', - 'errmsg'=> 'ip_error_wrong'), - 1 => array ( 'type' => 'UNIQUE', - 'errmsg'=> 'ip_error_unique'), + 'validators' => array ( + 0 => array ( 'type' => 'ISIP', 'errmsg'=> 'ip_error_wrong'), + 1 => array ( 'type' => 'UNIQUE', 'errmsg'=> 'ip_error_unique'), ), 'default' => '', 'value' => '', diff --git a/interface/web/vm/form/openvz_template.tform.php b/interface/web/vm/form/openvz_template.tform.php index ea49e3a1f770607652f4d87f420e8968420b87d3..fd67c99179837855f5e65ca16bcf9c32cdcb9dae 100644 --- a/interface/web/vm/form/openvz_template.tform.php +++ b/interface/web/vm/form/openvz_template.tform.php @@ -459,6 +459,22 @@ $form["tabs"]['advanced'] = array ( 'width' => '30', 'maxlength' => '255' ), + 'features' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'iptables' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), //################################# // ENDE Datatable fields //################################# diff --git a/interface/web/vm/form/openvz_vm.tform.php b/interface/web/vm/form/openvz_vm.tform.php index 759ba2f00cb4418b5a99a59e7e16eb901474622a..666d06cf353c37a4bdff4f340fa7c00f1ac8470f 100644 --- a/interface/web/vm/form/openvz_vm.tform.php +++ b/interface/web/vm/form/openvz_vm.tform.php @@ -306,6 +306,22 @@ if($_SESSION["s"]["user"]["typ"] == 'admin') { 'width' => '30', 'maxlength' => '255' ), + 'features' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), + 'iptables' => array ( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'default' => '', + 'value' => '', + 'width' => '30', + 'maxlength' => '255' + ), //################################# // ENDE Datatable fields //################################# diff --git a/interface/web/vm/lib/lang/ar_openvz_template.lng b/interface/web/vm/lib/lang/ar_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/ar_openvz_template.lng +++ b/interface/web/vm/lib/lang/ar_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/ar_openvz_vm.lng b/interface/web/vm/lib/lang/ar_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/ar_openvz_vm.lng +++ b/interface/web/vm/lib/lang/ar_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/bg_openvz_template.lng b/interface/web/vm/lib/lang/bg_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/bg_openvz_template.lng +++ b/interface/web/vm/lib/lang/bg_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/bg_openvz_vm.lng b/interface/web/vm/lib/lang/bg_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/bg_openvz_vm.lng +++ b/interface/web/vm/lib/lang/bg_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/br_openvz_template.lng b/interface/web/vm/lib/lang/br_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/br_openvz_template.lng +++ b/interface/web/vm/lib/lang/br_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/br_openvz_vm.lng b/interface/web/vm/lib/lang/br_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/br_openvz_vm.lng +++ b/interface/web/vm/lib/lang/br_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/cz_openvz_template.lng b/interface/web/vm/lib/lang/cz_openvz_template.lng index cf926f6b33b0f8ec8831360f9f7ec1288572d54e..7fff3b31fe28cdd8d6b159ea1063b708f6aa2965 100644 --- a/interface/web/vm/lib/lang/cz_openvz_template.lng +++ b/interface/web/vm/lib/lang/cz_openvz_template.lng @@ -90,5 +90,7 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Šablona'; $wb['Advanced'] = 'Pokročilý'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/cz_openvz_vm.lng b/interface/web/vm/lib/lang/cz_openvz_vm.lng index b9043e4a95e819cec4d2f71ee7b90363a47485f1..c2c26d002d0e66fd1ff26460d52052e46a2d2208 100644 --- a/interface/web/vm/lib/lang/cz_openvz_vm.lng +++ b/interface/web/vm/lib/lang/cz_openvz_vm.lng @@ -37,5 +37,7 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Pokročilý'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/de_openvz_template.lng b/interface/web/vm/lib/lang/de_openvz_template.lng index 329a10601d4f2ef50d6b68ac70f5f858d2a49071..0f0e3ae27aa444ffc8f24d99d5325ba7d555e789 100644 --- a/interface/web/vm/lib/lang/de_openvz_template.lng +++ b/interface/web/vm/lib/lang/de_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent ist leer.'; $wb['swappages_error_empty'] = 'Swappages ist leer.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Erweitert'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/de_openvz_vm.lng b/interface/web/vm/lib/lang/de_openvz_vm.lng index c773885c69426bfc0bd1c044c15a86e10f5ed7fd..b41c65dcf6bd04c9e0a19a350b43bfa980fc6c5d 100644 --- a/interface/web/vm/lib/lang/de_openvz_vm.lng +++ b/interface/web/vm/lib/lang/de_openvz_vm.lng @@ -37,4 +37,5 @@ $wb['io_priority_error_empty'] = 'I/O Priorität ist leer.'; $wb['template_nameserver_error_empty'] = 'Nameserver ist leer.'; $wb['Virtual server'] = 'Virtueller Server'; $wb['Advanced'] = 'Erweitert'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/el_openvz_template.lng b/interface/web/vm/lib/lang/el_openvz_template.lng index afe2bcda65ec3e081c340f6f5714e86759a6817c..2f5c8f6efa2ceb77d75fc5df834b3625aa1e94de 100644 --- a/interface/web/vm/lib/lang/el_openvz_template.lng +++ b/interface/web/vm/lib/lang/el_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/el_openvz_vm.lng b/interface/web/vm/lib/lang/el_openvz_vm.lng index 4c7950af36056e064ea15af0d96e75641117eef2..889d1f3bbbe6e699bdbea55b7a12244cd0381710 100644 --- a/interface/web/vm/lib/lang/el_openvz_vm.lng +++ b/interface/web/vm/lib/lang/el_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'Το Προτεραιότητα Ε/Ε είνα $wb['template_nameserver_error_empty'] = 'Το Nameserver(s) είναι κενό.'; $wb['Virtual server'] = 'Εικονικός server'; $wb['Advanced'] = 'Για προχωρημένους'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/en_openvz_template.lng b/interface/web/vm/lib/lang/en_openvz_template.lng index e52165b996e660a605c58571c07812b9452019cc..1d9d457eafd7e402ee4a77306a90cb45e6e0ee48 100644 --- a/interface/web/vm/lib/lang/en_openvz_template.lng +++ b/interface/web/vm/lib/lang/en_openvz_template.lng @@ -90,4 +90,7 @@ $wb["numiptent_error_empty"] = 'Numiptent is empty.'; $wb["swappages_error_empty"] = 'Swappages is empty.'; $wb["Template"] = 'Template'; $wb["Advanced"] = 'Advanced'; -?> \ No newline at end of file +$wb['features_txt'] = 'Features'; +$wb['features_txt'] = 'iptables'; +$wb["iptables_txt"] = "iptables"; +?> diff --git a/interface/web/vm/lib/lang/en_openvz_vm.lng b/interface/web/vm/lib/lang/en_openvz_vm.lng index ddd9903ced01c0ce6207e4373a36b70e0c2c2bf1..d7ad26c95c0740dd3609142953ec9f1174ffae2c 100644 --- a/interface/web/vm/lib/lang/en_openvz_vm.lng +++ b/interface/web/vm/lib/lang/en_openvz_vm.lng @@ -37,4 +37,6 @@ $wb["io_priority_error_empty"] = 'I/O priority is empty.'; $wb["template_nameserver_error_empty"] = 'Nameserver(s) is empty.'; $wb["Virtual server"] = 'Virtual server'; $wb["Advanced"] = 'Advanced'; -?> \ No newline at end of file +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; +?> diff --git a/interface/web/vm/lib/lang/es_openvz_template.lng b/interface/web/vm/lib/lang/es_openvz_template.lng index 0f73d409c36368401b8abd0e8669bec9461a7daa..d64c9813e334f6f79889b4177d0183d21ec2f123 100644 --- a/interface/web/vm/lib/lang/es_openvz_template.lng +++ b/interface/web/vm/lib/lang/es_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent esta vacío.'; $wb['swappages_error_empty'] = 'Swappages esta vacío.'; $wb['Template'] = 'Plantilla'; $wb['Advanced'] = 'Avanzado'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/es_openvz_vm.lng b/interface/web/vm/lib/lang/es_openvz_vm.lng index ce5eccb749629bfe9c556bd0c99ed5024d1be14a..495de6fcb903f7ad164d9207887ec43fc47cd4c4 100644 --- a/interface/web/vm/lib/lang/es_openvz_vm.lng +++ b/interface/web/vm/lib/lang/es_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority está vacío.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) está vacío.'; $wb['Virtual server'] = 'Servidor virtual'; $wb['Advanced'] = 'Avanzado'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/fi_openvz_template.lng b/interface/web/vm/lib/lang/fi_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/fi_openvz_template.lng +++ b/interface/web/vm/lib/lang/fi_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/fi_openvz_vm.lng b/interface/web/vm/lib/lang/fi_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/fi_openvz_vm.lng +++ b/interface/web/vm/lib/lang/fi_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/fr_openvz_template.lng b/interface/web/vm/lib/lang/fr_openvz_template.lng index d33091bd993af4b1c0a8640763256b456bc815f3..14655c0ec5d14e54f5fea9798b975a71965b72c1 100644 --- a/interface/web/vm/lib/lang/fr_openvz_template.lng +++ b/interface/web/vm/lib/lang/fr_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent est vide.'; $wb['swappages_error_empty'] = 'Swappages est vide.'; $wb['Template'] = 'Modèle'; $wb['Advanced'] = 'Avancé'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/fr_openvz_vm.lng b/interface/web/vm/lib/lang/fr_openvz_vm.lng index f3d69c10e3daf5529a877f73ab7a8b91ad560539..96728481b5797e8e37d51f2d94f020bbe5103e35 100644 --- a/interface/web/vm/lib/lang/fr_openvz_vm.lng +++ b/interface/web/vm/lib/lang/fr_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'Les priorités I/O sont vides.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) est vide.'; $wb['Virtual server'] = 'Serveur virtuel'; $wb['Advanced'] = 'Avancé'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/hr_openvz_template.lng b/interface/web/vm/lib/lang/hr_openvz_template.lng index cd2ad194c604c6907b148c4b04e18c96ffa8407c..19a371fbfec0525bd00e88a351c70edd11581ada 100644 --- a/interface/web/vm/lib/lang/hr_openvz_template.lng +++ b/interface/web/vm/lib/lang/hr_openvz_template.lng @@ -90,6 +90,8 @@ $wb['numiptent_error_empty'] = 'Numiptent polje je prazno.'; $wb['swappages_error_empty'] = 'Swappages polje je prazno.'; $wb['Template'] = 'Predložak'; $wb['Advanced'] = 'Napredno'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/hr_openvz_vm.lng b/interface/web/vm/lib/lang/hr_openvz_vm.lng index bebfd297c52ba13d7f70cf6082aabc02e474adb3..4be9932c38bda9b66807a179f8b1f536ff9735df 100644 --- a/interface/web/vm/lib/lang/hr_openvz_vm.lng +++ b/interface/web/vm/lib/lang/hr_openvz_vm.lng @@ -37,6 +37,8 @@ $wb['io_priority_error_empty'] = 'I/O priority polje je prazno.'; $wb['template_nameserver_error_empty'] = 'Nameserver(i) polje je prazno.'; $wb['Virtual server'] = 'Virtualni server'; $wb['Advanced'] = 'Napredno'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/hu_openvz_template.lng b/interface/web/vm/lib/lang/hu_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/hu_openvz_template.lng +++ b/interface/web/vm/lib/lang/hu_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/hu_openvz_vm.lng b/interface/web/vm/lib/lang/hu_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/hu_openvz_vm.lng +++ b/interface/web/vm/lib/lang/hu_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/id_openvz_template.lng b/interface/web/vm/lib/lang/id_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/id_openvz_template.lng +++ b/interface/web/vm/lib/lang/id_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/id_openvz_vm.lng b/interface/web/vm/lib/lang/id_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/id_openvz_vm.lng +++ b/interface/web/vm/lib/lang/id_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/it_openvz_template.lng b/interface/web/vm/lib/lang/it_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/it_openvz_template.lng +++ b/interface/web/vm/lib/lang/it_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/it_openvz_vm.lng b/interface/web/vm/lib/lang/it_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/it_openvz_vm.lng +++ b/interface/web/vm/lib/lang/it_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/ja_openvz_template.lng b/interface/web/vm/lib/lang/ja_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/ja_openvz_template.lng +++ b/interface/web/vm/lib/lang/ja_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/ja_openvz_vm.lng b/interface/web/vm/lib/lang/ja_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/ja_openvz_vm.lng +++ b/interface/web/vm/lib/lang/ja_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/nl_openvz_template.lng b/interface/web/vm/lib/lang/nl_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/nl_openvz_template.lng +++ b/interface/web/vm/lib/lang/nl_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/nl_openvz_vm.lng b/interface/web/vm/lib/lang/nl_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/nl_openvz_vm.lng +++ b/interface/web/vm/lib/lang/nl_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/pl_openvz_template.lng b/interface/web/vm/lib/lang/pl_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/pl_openvz_template.lng +++ b/interface/web/vm/lib/lang/pl_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/pl_openvz_vm.lng b/interface/web/vm/lib/lang/pl_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/pl_openvz_vm.lng +++ b/interface/web/vm/lib/lang/pl_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/pt_openvz_template.lng b/interface/web/vm/lib/lang/pt_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/pt_openvz_template.lng +++ b/interface/web/vm/lib/lang/pt_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/pt_openvz_vm.lng b/interface/web/vm/lib/lang/pt_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/pt_openvz_vm.lng +++ b/interface/web/vm/lib/lang/pt_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/ro_openvz_template.lng b/interface/web/vm/lib/lang/ro_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/ro_openvz_template.lng +++ b/interface/web/vm/lib/lang/ro_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/ro_openvz_vm.lng b/interface/web/vm/lib/lang/ro_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/ro_openvz_vm.lng +++ b/interface/web/vm/lib/lang/ro_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/ru_openvz_template.lng b/interface/web/vm/lib/lang/ru_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/ru_openvz_template.lng +++ b/interface/web/vm/lib/lang/ru_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/ru_openvz_vm.lng b/interface/web/vm/lib/lang/ru_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/ru_openvz_vm.lng +++ b/interface/web/vm/lib/lang/ru_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/se_openvz_template.lng b/interface/web/vm/lib/lang/se_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/se_openvz_template.lng +++ b/interface/web/vm/lib/lang/se_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/se_openvz_vm.lng b/interface/web/vm/lib/lang/se_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/se_openvz_vm.lng +++ b/interface/web/vm/lib/lang/se_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/sk_openvz_template.lng b/interface/web/vm/lib/lang/sk_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/sk_openvz_template.lng +++ b/interface/web/vm/lib/lang/sk_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/sk_openvz_vm.lng b/interface/web/vm/lib/lang/sk_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/sk_openvz_vm.lng +++ b/interface/web/vm/lib/lang/sk_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/tr_openvz_template.lng b/interface/web/vm/lib/lang/tr_openvz_template.lng index d285512dcab15fffb604da4ce421f5e5e056d485..217747c711fec3173b3986e05f6d47eb1458562e 100644 --- a/interface/web/vm/lib/lang/tr_openvz_template.lng +++ b/interface/web/vm/lib/lang/tr_openvz_template.lng @@ -90,4 +90,6 @@ $wb['numiptent_error_empty'] = 'Numiptent is empty.'; $wb['swappages_error_empty'] = 'Swappages is empty.'; $wb['Template'] = 'Template'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/lang/tr_openvz_vm.lng b/interface/web/vm/lib/lang/tr_openvz_vm.lng index f2be022dd0ae060ae8688cdcaa356b4200185d7c..06a10d2fab952faca1e5452f5b63a43152021103 100644 --- a/interface/web/vm/lib/lang/tr_openvz_vm.lng +++ b/interface/web/vm/lib/lang/tr_openvz_vm.lng @@ -37,4 +37,6 @@ $wb['io_priority_error_empty'] = 'I/O priority is empty.'; $wb['template_nameserver_error_empty'] = 'Nameserver(s) is empty.'; $wb['Virtual server'] = 'Virtual server'; $wb['Advanced'] = 'Advanced'; +$wb['features_txt'] = 'Features'; +$wb["iptables_txt"] = "iptables"; ?> diff --git a/interface/web/vm/lib/module.conf.php b/interface/web/vm/lib/module.conf.php index a7e31bb5319bc51bd551e969f995badfc332d607..ee5e6b6ad11b0f4eeb1dffc748ab5056426bff22 100644 --- a/interface/web/vm/lib/module.conf.php +++ b/interface/web/vm/lib/module.conf.php @@ -5,6 +5,7 @@ $module['title'] = 'top_menu_vm'; $module['template'] = 'module.tpl.htm'; $module['startpage'] = 'vm/openvz_vm_list.php'; $module['tab_width'] = ''; +$module['order'] = '50'; //**** Templates menu $items = array(); diff --git a/interface/web/vm/openvz_action.php b/interface/web/vm/openvz_action.php index 6e090d74683c7957c9d28e1228f2758184719f3a..757f55e8b63d3006016a6aea1395767fbf60bca8 100644 --- a/interface/web/vm/openvz_action.php +++ b/interface/web/vm/openvz_action.php @@ -17,7 +17,7 @@ $notify_msg = ''; if($vm_id == 0) die('Invalid VM ID'); -$vm = $app->db->queryOneRecord("SELECT server_id, veid FROM openvz_vm WHERE vm_id = $vm_id"); +$vm = $app->db->queryOneRecord("SELECT server_id, veid FROM openvz_vm WHERE vm_id = ?", $vm_id); $veid = $app->functions->intval($vm['veid']); $server_id = $app->functions->intval($vm['server_id']); @@ -47,15 +47,8 @@ if($action == 'show') { //* Start the virtual machine $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$server_id . ", ". - time() . ", ". - "'openvz_start_vm', ". - $veid.", ". - "'pending', ". - "''". - ")"; - $app->db->query($sql); + "VALUES (?, UNIX_TIMESTAMP(), 'openvz_start_vm', ?, 'pending', '')"; + $app->db->query($sql, $server_id, $veid); $app->tpl->setVar('msg', $wb['start_exec_txt']); $options['start_option_enabled'] = 'checked="checked"'; @@ -64,15 +57,8 @@ if($action == 'show') { //* Stop the virtual machine $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$server_id . ", ". - time() . ", ". - "'openvz_stop_vm', ". - $veid.", ". - "'pending', ". - "''". - ")"; - $app->db->query($sql); + "VALUES (?, UNIX_TIMESTAMP(), 'openvz_stop_vm', ?, 'pending', '')"; + $app->db->query($sql, $server_id, $veid); $app->tpl->setVar('msg', $wb['stop_exec_txt']); $options['stop_option_enabled'] = 'checked="checked"'; @@ -81,15 +67,8 @@ if($action == 'show') { //* Restart the virtual machine $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$server_id . ", ". - time() . ", ". - "'openvz_restart_vm', ". - $veid.", ". - "'pending', ". - "''". - ")"; - $app->db->query($sql); + "VALUES (?, UNIX_TIMESTAMP(), 'openvz_restart_vm', ?, 'pending', '')"; + $app->db->query($sql, $server_id, $veid); $app->tpl->setVar('msg', $wb['restart_exec_txt']); $options['restart_option_enabled'] = 'checked="checked"'; @@ -104,30 +83,22 @@ if($action == 'show') { } //* Quote name - $ostemplate_name = $app->db->quote($ostemplate_name); //* Check for duplicates - $tmp = $app->db->queryOneRecord("SELECT count(ostemplate_id) as number FROM openvz_ostemplate WHERE template_file = '$ostemplate_name'"); + $tmp = $app->db->queryOneRecord("SELECT count(ostemplate_id) as number FROM openvz_ostemplate WHERE template_file = ?", $ostemplate_name); if($tmp['number'] > 0) $error_msg .= $wb['ostemplate_name_unique_error'].'
'; unset($tmp); if($error_msg == '') { //* Create ostemplate action $sql = "INSERT INTO sys_remoteaction (server_id, tstamp, action_type, action_param, action_state, response) " . - "VALUES (". - (int)$server_id . ", ". - time() . ", ". - "'openvz_create_ostpl', ". - "'".$veid.":".$ostemplate_name."', ". - "'pending', ". - "''". - ")"; - $app->db->query($sql); + "VALUES (?, UNIX_TIMESTAMP(), 'openvz_create_ostpl', ?, 'pending', '')"; + $app->db->query($sql, $server_id, $veid.":".$ostemplate_name); //* Create a record in the openvz_ostemplate table $sql = "INSERT INTO `openvz_ostemplate` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `template_name`, `template_file`, `server_id`, `allservers`, `active`, `description`) - VALUES(1, 1, 'riud', 'riud', '', '$ostemplate_name', '$ostemplate_name', $server_id, 'n', 'y', '')"; - $app->db->query($sql); + VALUES(1, 1, 'riud', 'riud', '', ?, ?, ?, 'n', 'y', '')"; + $app->db->query($sql, $ostemplate_name, $ostemplate_name, $server_id); $app->tpl->setVar('msg', $wb['ostemplate_exec_txt']); $options['ostemplate_option_enabled'] = 'checked="checked"'; diff --git a/interface/web/vm/openvz_template_edit.php b/interface/web/vm/openvz_template_edit.php index ec520d04d4768effc3f46839e0148ea6a731de22..097e55bb800873983b5ce79ce966230f469c4e08 100644 --- a/interface/web/vm/openvz_template_edit.php +++ b/interface/web/vm/openvz_template_edit.php @@ -54,10 +54,7 @@ class page_action extends tform_actions { function onAfterInsert() { global $app, $conf; - $guar_ram = $app->functions->intval($this->dataRecord['ram']*256); - $burst_ram = $app->functions->intval($this->dataRecord['ram_burst']*256); - $sql = "UPDATE openvz_template SET shmpages = '$guar_ram:$guar_ram',vmguarpages = '$guar_ram:$guar_ram', oomguarpages = '$guar_ram:$guar_ram',privvmpages = '$burst_ram:$burst_ram' WHERE template_id = $this->id"; - $app->db->query($sql); + $this->onAfterUpdate(); } function onAfterUpdate() { @@ -65,8 +62,8 @@ class page_action extends tform_actions { $guar_ram = $app->functions->intval($this->dataRecord['ram']*256); $burst_ram = $app->functions->intval($this->dataRecord['ram_burst']*256); - $sql = "UPDATE openvz_template SET shmpages = '$guar_ram:$guar_ram',vmguarpages = '$guar_ram:$guar_ram', oomguarpages = '$guar_ram:$guar_ram',privvmpages = '$burst_ram:$burst_ram' WHERE template_id = $this->id"; - $app->db->query($sql); + $sql = "UPDATE openvz_template SET shmpages = ?,vmguarpages = ?, oomguarpages = ?,privvmpages = ? WHERE template_id = ?"; + $app->db->query($sql, $guar_ram . ':' . $guar_ram, $guar_ram . ':' . $guar_ram, $guar_ram . ':' . $guar_ram, $burst_ram . ':' . $burst_ram, $this->id); } } diff --git a/interface/web/vm/openvz_vm_edit.php b/interface/web/vm/openvz_vm_edit.php index bd7c1d2158f13134faf660d318544cbb53a8d7de..07f6aaa530f414a171209649eb6e2c43a5e4bce6 100644 --- a/interface/web/vm/openvz_vm_edit.php +++ b/interface/web/vm/openvz_vm_edit.php @@ -74,15 +74,15 @@ class page_action extends tform_actions { //* Get the limits of the client $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]); - $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); //* Fill the template_id field if($client['limit_openvz_vm_template_id'] == 0) { $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name'; } else { - $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$app->functions->intval($client['limit_openvz_vm_template_id']).' ORDER BY template_name'; + $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = ? ORDER BY template_name'; } - $records = $app->db->queryAllRecords($sql); + $records = $app->db->queryAllRecords($sql, $client['limit_openvz_vm_template_id']); if(is_array($records)) { foreach( $records as $rec) { $selected = @($rec["template_id"] == $this->dataRecord["template_id"])?'SELECTED':''; @@ -96,13 +96,13 @@ class page_action extends tform_actions { //* 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, client.limit_openvz_vm_template_id, 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"); + $client = $app->db->queryOneRecord("SELECT client.client_id, client.contact_name, client.limit_openvz_vm_template_id, 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 = ".$app->functions->intval($client['client_id'])." ORDER BY client.company_name, client.contact_name, sys_group.name"; - $records = $app->db->queryAllRecords($sql); - $tmp = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ".$app->functions->intval($client['client_id'])); + $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 = ? ORDER BY client.company_name, client.contact_name, sys_group.name"; + $records = $app->db->queryAllRecords($sql, $client['client_id']); + $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($records)) { @@ -117,9 +117,9 @@ class page_action extends tform_actions { if($client['limit_openvz_vm_template_id'] == 0) { $sql = 'SELECT template_id,template_name FROM openvz_template WHERE 1 ORDER BY template_name'; } else { - $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = '.$app->functions->intval($client['limit_openvz_vm_template_id']).' ORDER BY template_name'; + $sql = 'SELECT template_id,template_name FROM openvz_template WHERE template_id = ? ORDER BY template_name'; } - $records = $app->db->queryAllRecords($sql); + $records = $app->db->queryAllRecords($sql, $client['limit_openvz_vm_template_id']); if(is_array($records)) { foreach( $records as $rec) { $selected = @($rec["template_id"] == $this->dataRecord["template_id"])?'SELECTED':''; @@ -166,8 +166,8 @@ class page_action extends tform_actions { $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE vserver_server = 1 AND mirror_server_id = 0 ORDER BY server_name LIMIT 0,1'); $vm_server_id = $app->functions->intval($tmp['server_id']); } - $sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = '".$this->id."') AND server_id = ".$app->functions->intval($vm_server_id)." ORDER BY ip_address"; - $ips = $app->db->queryAllRecords($sql); + $sql = "SELECT ip_address FROM openvz_ip WHERE reserved = 'n' AND (vm_id = 0 or vm_id = ?) AND server_id = ? ORDER BY ip_address"; + $ips = $app->db->queryAllRecords($sql, $this->id, $vm_server_id); $ip_select = ""; if(is_array($ips)) { foreach( $ips as $ip) { @@ -193,6 +193,7 @@ class page_action extends tform_actions { $trans = array("d" => "dd", "m" => "mm", "Y" => "yy"); $date_format = strtr($date_format, $trans); $app->tpl->setVar("date_format", $date_format); + $app->tpl->setVar("conf_format_datetime_js", strtr($app->lng('conf_format_dateshort'), array('d' => 'dd', 'm' => 'mm', 'Y' => 'yyyy', 'y' => 'yy', 'H' => 'hh', 'h' => 'HH', 'i' => 'ii'))); $app->tpl->setVar("daynamesmin_su", $app->lng('daynamesmin_su')); $app->tpl->setVar("daynamesmin_mo", $app->lng('daynamesmin_mo')); diff --git a/interface/web/vm/templates/openvz.conf.tpl b/interface/web/vm/templates/openvz.conf.tpl index 5bdd385a46d1a0455c261aa16625e871f03bfd46..1cb4dc06198ec0ea84cf8d72dd87578a6b547764 100644 --- a/interface/web/vm/templates/openvz.conf.tpl +++ b/interface/web/vm/templates/openvz.conf.tpl @@ -48,3 +48,5 @@ MEMINFO="privvmpages:1" # SWAPPAGES="{tmpl_var name='swappages'}" CAPABILITY="{tmpl_var name='capability'}" +FEATURES="{tmpl_var name='features'}" +IPTABLES="{tmpl_var name='iptables'}" diff --git a/interface/web/vm/templates/openvz_action.htm b/interface/web/vm/templates/openvz_action.htm index 00bb65e077dcd4a5584b778440c71faae5b141d6..2d95f9cb0f8bd421081117ba0365b6d6c1282d2f 100644 --- a/interface/web/vm/templates/openvz_action.htm +++ b/interface/web/vm/templates/openvz_action.htm @@ -1,53 +1,42 @@ -

+

-
- -
-
{tmpl_var name="head_txt"} {tmpl_var name='veid'} + + {tmpl_var name="head_txt"} {tmpl_var name='veid'}

-

ERROR

+

-
-

{tmpl_var name='start_txt'}

-
- -
+
+ +
-
-

{tmpl_var name='stop_txt'}

-
- -
+
+ +
-
-

{tmpl_var name='restart_txt'}

-
- -
+
+ +
-
-

{tmpl_var name='ostemplate_txt'}

-
- -  {tmpl_var name='ostemplate_desc_txt'} +
+ +
 {tmpl_var name='ostemplate_desc_txt'}
-
+ -
- - -
-
- -
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/vm/templates/openvz_ip_edit.htm b/interface/web/vm/templates/openvz_ip_edit.htm index ef0537d9d9a5e18391bb03e488c3955b315da4d2..279066978411376ef1dd61ad9175aaa32f89be90 100644 --- a/interface/web/vm/templates/openvz_ip_edit.htm +++ b/interface/web/vm/templates/openvz_ip_edit.htm @@ -1,43 +1,39 @@ -

+

-
-
-
IP address -
- - {tmpl_var name='server_id'} - -
-
- - +
-
- -
+
+ +
+
-
-

{tmpl_var name='reserved_txt'}

-
+
+ +
{tmpl_var name='reserved'}
-
+ -
- - -
-
- -
+
+ + +
\ No newline at end of file +
+ + +
\ No newline at end of file diff --git a/interface/web/vm/templates/openvz_vm_list.htm b/interface/web/vm/templates/openvz_vm_list.htm index d525f382761b14ca7f2dafc70a66c09a95542e88..516b536bb39fb4077e22e25fb000f64b0a830749 100644 --- a/interface/web/vm/templates/openvz_vm_list.htm +++ b/interface/web/vm/templates/openvz_vm_list.htm @@ -1,57 +1,55 @@ -

+ -
-
-
{tmpl_var name="toolsarea_head_txt"} -
- -
-
-
+

{tmpl_var name="toolsarea_head_txt"}

+ + + + -
-
- - - - - - - - - - - + +

+
+
{tmpl_var name='search_limit'}
+ + + + + + + + + + - - - - - - - - - + + + + + + + + - - - - - - - - - + + + + + + + + @@ -63,11 +61,10 @@ - +
{tmpl_var name='search_limit'}
- +
+
{tmpl_var name="veid"}{tmpl_var name="active"}{tmpl_var name="server_id"}{tmpl_var name="ostemplate_id"}{tmpl_var name="template_id"}{tmpl_var name="hostname"}{tmpl_var name="ip_address"} - Action - {tmpl_var name='delete_txt'} +
{tmpl_var name="veid"}{tmpl_var name="active"}{tmpl_var name="server_id"}{tmpl_var name="ostemplate_id"}{tmpl_var name="template_id"}{tmpl_var name="hostname"}{tmpl_var name="ip_address"} + +
-
-
- -
\ No newline at end of file +
+ + \ No newline at end of file diff --git a/remoting_client/API-docs/mail_user_backup.html b/remoting_client/API-docs/mail_user_backup.html new file mode 100644 index 0000000000000000000000000000000000000000..896ed9219097e5687964c1ad72c2b6bfcb3051af --- /dev/null +++ b/remoting_client/API-docs/mail_user_backup.html @@ -0,0 +1,26 @@ + +ISCPConfig 3 API Functions + + + + + + + + + + +
+

mail_user_backup($session_id, $primary_id, $action_type);

+
+

Description:

+

Adds a new backup / restore task. Please note: $action_type must be backup_restore_mail

+
+

Input Variables:

+

$session_id, $primary_id, $action_type

+

Output:

+

Returns TRUE if successfull or FALSE if failure.

+
+ + diff --git a/remoting_client/API-docs/mail_user_backup_list.html b/remoting_client/API-docs/mail_user_backup_list.html new file mode 100644 index 0000000000000000000000000000000000000000..9ad9db8806060d6bb1ff470a3be754e5fe79ab18 --- /dev/null +++ b/remoting_client/API-docs/mail_user_backup_list.html @@ -0,0 +1,26 @@ + +ISCPConfig 3 API Functions + + + + + + + + + + +
+

mail_user_backup_list($session_id, $primary_id);

+
+

Description:

+

Gets list of all available mail backups. If no $primary_id (mail-domain-id) is given, all mail backups available on this server are read.

+
+

Input Variables:

+

$session_id, $primary_id (mail-domain-id)

+

Output:

+

Returns array of all available backups.

+
+ + diff --git a/remoting_client/API-docs/navigation.html b/remoting_client/API-docs/navigation.html index e0eebb000eaa73a80d86a910d108edb3b99e2e26..917c6ba44581454c96d50cd3830c1561cc5996a3 100644 --- a/remoting_client/API-docs/navigation.html +++ b/remoting_client/API-docs/navigation.html @@ -169,6 +169,8 @@

mail_user_filter_delete

mail_user_filter_get

mail_user_filter_update

+

mail_user_backup_list

+

mail_user_backup

mail_whitelist_add

mail_whitelist_delete

mail_whitelist_get

@@ -196,6 +198,15 @@

S

server_get

server_get_serverid_by_ip

+

sites_aps_available_packages_list

+

sites_aps_get_package_details

+

sites_aps_get_package_file

+

sites_aps_get_package_settings

+

sites_aps_install_package

+

sites_aps_instance_get

+

sites_aps_instance_delete

+

sites_aps_instance_settings_get

+

sites_aps_update_package_list

sites_cron_add

sites_cron_delete

sites_cron_get

@@ -226,7 +237,7 @@

sites_web_domain_get

sites_web_domain_set_status

sites_web_domain_update

- p>sites_web_domain_backup_list

+

sites_web_domain_backup_list

sites_web_domain_backup

sites_web_subdomain_add

sites_web_subdomain_delete

diff --git a/remoting_client/API-docs/sites_aps_available_packages_list.html b/remoting_client/API-docs/sites_aps_available_packages_list.html new file mode 100644 index 0000000000000000000000000000000000000000..1d069debc9e4a3807d922bcac3d21501ce666bf3 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_available_packages_list.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_available_packages_list($session_id, $params);

+
+

Description:

+

Reads all available packages with state PACKAGE_ENABLED. If set param all_packages to true, also includes PACKAGE_LOCKED.


+

Input Variables:

+

$session_id, $params

+

Parameters (in $params):

+

all_packages  (boolean)

+

Output:

+

Returns array with all selected package records.

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_get_package_details.html b/remoting_client/API-docs/sites_aps_get_package_details.html new file mode 100644 index 0000000000000000000000000000000000000000..56049d8b13901b1c33e752d9d36f6657c65c48a0 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_get_package_details.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_get_package_details($session_id, $primary_id);

+
+

Description:

+

Gets all possible details for selected package.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns array with all details of selected package.

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_get_package_file.html b/remoting_client/API-docs/sites_aps_get_package_file.html new file mode 100644 index 0000000000000000000000000000000000000000..9a6472db07616a91483d8fb894d97a4555036c2f --- /dev/null +++ b/remoting_client/API-docs/sites_aps_get_package_file.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_get_package_file($session_id, $primary_id, $filename);

+
+

Description:

+

Gets the file with given name (like screenshots or icon) of the selected package. Use sites_aps_get_package_details to get all available files of this package.


+

Input Variables:

+

$session_id, $primary_id, $filename

+

Parameters (in $params):

+

None

+

Output:

+

Returns base64_encoded file content of selected file.
Use the followoing example code to save file content over remote api:
file_put_contents($file, base64_decode(sites_aps_get_package_file($session_id, $primary_id, $filename)));

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_get_package_settings.html b/remoting_client/API-docs/sites_aps_get_package_settings.html new file mode 100644 index 0000000000000000000000000000000000000000..4a47c9b9dd9715c3b0a8b714cf23be0d280c50d6 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_get_package_settings.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_get_package_settings($session_id, $primary_id);

+
+

Description:

+

Gets all possible settings for selected package.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns array with all settings of selected package.

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_install_package.html b/remoting_client/API-docs/sites_aps_install_package.html new file mode 100644 index 0000000000000000000000000000000000000000..340dc8253f84cedd4258c620d179b7917998ea55 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_install_package.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_install_package($session_id, $primary_id, $params);

+
+

Description:

+

Starts installation of the selected package in given main_domains webfolder.


+

Input Variables:

+

$session_id, $primary_id, $params

+

Parameters (in $params):

+

main_domain  (varchar(255))

+

Output:

+

Returns new instance id or false.

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_instance_delete.html b/remoting_client/API-docs/sites_aps_instance_delete.html new file mode 100644 index 0000000000000000000000000000000000000000..654a3c5df9235e838be97738f4bfd4019b252805 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_instance_delete.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_instance_delete($session_id, $primary_id, $params);

+
+

Description:

+

Starts deletion of the selected APS instance. If param keep_database is set true, database will not be deleted.


+

Input Variables:

+

$session_id, $primary_id, $params

+

Parameters (in $params):

+

keep_database  (boolean)

+

Output:

+

Returns true if deletion is started.

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_instance_get.html b/remoting_client/API-docs/sites_aps_instance_get.html new file mode 100644 index 0000000000000000000000000000000000000000..64bfbe51e813eb77face9b944205531423ad50e1 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_instance_get.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_instance_get($session_id, $primary_id);

+
+

Description:

+

Gets record of given instance id.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns record of APS instance.

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_instance_settings_get.html b/remoting_client/API-docs/sites_aps_instance_settings_get.html new file mode 100644 index 0000000000000000000000000000000000000000..bf793d892d69d1f2d3c77b3dd165ad5da14a3e24 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_instance_settings_get.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_instance_settings_get($session_id, $primary_id);

+
+

Description:

+

Gets record of given instance ids settings.


+

Input Variables:

+

$session_id, $primary_id

+

Parameters (in $params):

+

None

+

Output:

+

Returns record of APS instance settings.

+ +
+ + diff --git a/remoting_client/API-docs/sites_aps_update_package_list.html b/remoting_client/API-docs/sites_aps_update_package_list.html new file mode 100644 index 0000000000000000000000000000000000000000..e581a723008927ce5e1f2512ef1c27603f221ef3 --- /dev/null +++ b/remoting_client/API-docs/sites_aps_update_package_list.html @@ -0,0 +1,29 @@ + +ISPCOnfig 3 remote API documentation + + + + + + + + + + +
+

sites_aps_update_package_list($session_id);

+
+

Description:

+

Update available package list. Starts the ApsCrawler in server mode. May take a while.


+

Input Variables:

+

$session_id

+

Parameters (in $params):

+

None

+

Output:

+

always true

+ +
+ + diff --git a/remoting_client/examples/dns_a_add.php b/remoting_client/examples/dns_a_add.php index 6bcb33c6680ad55f82e38582a501495242f196d5..b669daaa1c745ff4cd3917141b8d3bb179e15d73 100644 --- a/remoting_client/examples/dns_a_add.php +++ b/remoting_client/examples/dns_a_add.php @@ -23,7 +23,7 @@ try { 'type' => 'a', 'data' => '192.168.1.88', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_aaaa_add.php b/remoting_client/examples/dns_aaaa_add.php index 4ee460b5be90a5f9a04653d600519e7bf8d53ee9..eff4148f2881785206439fcda3a98b8ddb406648 100644 --- a/remoting_client/examples/dns_aaaa_add.php +++ b/remoting_client/examples/dns_aaaa_add.php @@ -23,7 +23,7 @@ try { 'type' => 'aaaa', 'data' => '3ffe:b00:c18:3::a', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_alias_add.php b/remoting_client/examples/dns_alias_add.php index 5b1c684cef0743704581e52d58c8b370388e3284..dd8a4da4b0b6349e203b5ff89c5524fca74e2a39 100644 --- a/remoting_client/examples/dns_alias_add.php +++ b/remoting_client/examples/dns_alias_add.php @@ -23,7 +23,7 @@ try { 'type' => 'alias', 'data' => 'hostmachine', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_cname_add.php b/remoting_client/examples/dns_cname_add.php index 2d70ca65b4a40c3dcd732ba585ca7867ea752350..7731a5473035106e2939416bf064f9996c07eccf 100644 --- a/remoting_client/examples/dns_cname_add.php +++ b/remoting_client/examples/dns_cname_add.php @@ -23,7 +23,7 @@ try { 'type' => 'cname', 'data' => 'hostmachine', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_hinfo_add.php b/remoting_client/examples/dns_hinfo_add.php index a0a8c47b3c1f90035974ad3c204ac3554a65cc82..106c79083e8014eae72ed765ffb064541defd3b6 100644 --- a/remoting_client/examples/dns_hinfo_add.php +++ b/remoting_client/examples/dns_hinfo_add.php @@ -23,7 +23,7 @@ try { 'type' => 'hinfo', 'data' => '"Pentium Pro" Linux', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_mx_add.php b/remoting_client/examples/dns_mx_add.php index b1e961780973cd069393091c4fd34114262e6de5..d0838216cde06cdec84bb792d5c6151ce7d40142 100644 --- a/remoting_client/examples/dns_mx_add.php +++ b/remoting_client/examples/dns_mx_add.php @@ -23,7 +23,7 @@ try { 'type' => 'mx', 'data' => 'mail', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_ns_add.php b/remoting_client/examples/dns_ns_add.php index d650d2a99990e1b49ce440e7d7c6ec8cf6edd7fe..381041addf3099d1264afeb7ac075f774d329ba9 100644 --- a/remoting_client/examples/dns_ns_add.php +++ b/remoting_client/examples/dns_ns_add.php @@ -23,7 +23,7 @@ try { 'type' => 'ns', 'data' => 'ns1', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_ptr_add.php b/remoting_client/examples/dns_ptr_add.php index 6d4ccab9faeaa3b7d26a684cf7a9f97cfa92ba8a..a2dbdf54f58da90198f324c8a7f50f43b7dbe8ba 100644 --- a/remoting_client/examples/dns_ptr_add.php +++ b/remoting_client/examples/dns_ptr_add.php @@ -23,7 +23,7 @@ try { 'type' => 'ptr', 'data' => 'webmaster.test.int.', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_rp_add.php b/remoting_client/examples/dns_rp_add.php index a30b70370137c66294b2e77d0db123b69cc82850..27329bbe75aa8dd91f95192618d999a1229487b8 100644 --- a/remoting_client/examples/dns_rp_add.php +++ b/remoting_client/examples/dns_rp_add.php @@ -23,7 +23,7 @@ try { 'type' => 'rp', 'data' => 'webmaster.test.int. contactinfo.test.int', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_srv_add.php b/remoting_client/examples/dns_srv_add.php index 75c7df4817f092f56c1a6d2af1bf2522d41190b7..6270db75a45f3b6c77f7e17b7455e417a22c631c 100644 --- a/remoting_client/examples/dns_srv_add.php +++ b/remoting_client/examples/dns_srv_add.php @@ -23,7 +23,7 @@ try { 'type' => 'srv', 'data' => '0 9 server.test.int.', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_txt_add.php b/remoting_client/examples/dns_txt_add.php index 4ce025e64fcd7247bc60c51af131c366e2231bc7..90f06095ecbd770b130e5914c274c94c662d4af9 100644 --- a/remoting_client/examples/dns_txt_add.php +++ b/remoting_client/examples/dns_txt_add.php @@ -23,7 +23,7 @@ try { 'type' => 'txt', 'data' => 'any text can go here', 'aux' => '0', - 'ttl' => '86400', + 'ttl' => '3600', 'active' => 'y', 'stamp' => 'CURRENT_TIMESTAMP', 'serial' => '1', diff --git a/remoting_client/examples/dns_zone_add.php b/remoting_client/examples/dns_zone_add.php index 677240968266fe66f7869f09204da45f9f20bb4d..62937c0bd3c4db126e4607dbc56e7fb144217564 100644 --- a/remoting_client/examples/dns_zone_add.php +++ b/remoting_client/examples/dns_zone_add.php @@ -25,8 +25,8 @@ try { 'refresh' => '28800', 'retry' => '7200', 'expire' => '604800', - 'minimum' => '86400', - 'ttl' => '86400', + 'minimum' => '3600', + 'ttl' => '3600', 'active' => 'y', 'xfer' => '', 'also_notify' => '', diff --git a/server/conf/apache_apps.vhost.master b/server/conf/apache_apps.vhost.master index bc6c6bcfb087906df401e6298a1eaca022c97599..7d6d66590aa1c593525bb0faeafc34ee88d56526 100644 --- a/server/conf/apache_apps.vhost.master +++ b/server/conf/apache_apps.vhost.master @@ -10,11 +10,17 @@ ServerAdmin webmaster@localhost {tmpl_var name='apps_vhost_servername'} - + SetHandler None - + + {tmpl_if name="enable_spdy" op="==" value="y"} + + SpdyEnabled on + + {/tmpl_if} + DocumentRoot {tmpl_var name='apps_vhost_dir'} AddType application/x-httpd-php .php diff --git a/server/conf/bastille-firewall.cfg.master b/server/conf/bastille-firewall.cfg.master index b2b65362538bf23d83c325189c3c531ca6ef03e7..9080f4e291d3e1c0e8fce8e2a113b6461fc498c9 100644 --- a/server/conf/bastille-firewall.cfg.master +++ b/server/conf/bastille-firewall.cfg.master @@ -75,7 +75,7 @@ DNS_SERVERS="{DNS_SERVERS}" # use the "\" continuation character (so Bastille can change the # values if it is run more than once) TRUSTED_IFACES="lo" # MINIMAL/SAFEST -PUBLIC_IFACES="eth+ ppp+ slip+ venet+ bond+" # SAFEST +PUBLIC_IFACES="eth+ ppp+ slip+ venet+ bond+ en+" # SAFEST INTERNAL_IFACES="" # SAFEST diff --git a/server/conf/hhvm_monit.master b/server/conf/hhvm_monit.master new file mode 100644 index 0000000000000000000000000000000000000000..91642c535a7e084ba51758e687c7dec057966a21 --- /dev/null +++ b/server/conf/hhvm_monit.master @@ -0,0 +1,3 @@ +check process hhvm_{SYSTEM_USER} with pidfile /var/run/hhvm/hhvm_{SYSTEM_USER}.pid + start program = "/etc/init.d/hhvm_{SYSTEM_USER} restart" + stop program = "/etc/init.d/hhvm_{SYSTEM_USER} stop" \ No newline at end of file diff --git a/server/conf/hhvm_starter.master b/server/conf/hhvm_starter.master index 57f9324a3686daf61615ac928c5fb55107895a0d..a4cac46423891f58faff6d28e908ba1dfd88cb94 100644 --- a/server/conf/hhvm_starter.master +++ b/server/conf/hhvm_starter.master @@ -31,17 +31,35 @@ do_start() esac fi + if [[ -S /var/run/mysqld/mysqld.sock && ! -S /tmp/mysql.sock ]] ; then + ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock ; + fi + umask 017 sudo -u {SYSTEM_USER} touch /var/run/hhvm/hhvm_{SYSTEM_USER}.pid + + BASEINIFILE="" + if [[ -e "/etc/hhvm/php.ini" ]] ; then + BASEINIFILE="--config /etc/hhvm/php.ini" ; + fi + INIFILE="" if [[ -e "/var/www/conf/{SYSTEM_USER}/php.ini" ]] ; then - INIFILE="-vServer.IniFile=/var/www/conf/{SYSTEM_USER}/php.ini" ; + INIFILE="--config /var/www/conf/{SYSTEM_USER}/php.ini" ; elif [[ -e "/etc/php5/hhvm/php.ini" ]] ; then - INIFILE="-vServer.IniFile=/etc/php5/hhvm/php.ini" ; + INIFILE="--config /etc/php5/hhvm/php.ini" ; + elif [[ -e "/etc/php5/fpm/php.ini" ]] ; then + INIFILE="--config /etc/php5/fpm/php.ini" ; elif [[ -e "/etc/php5/cgi/php.ini" ]] ; then - INIFILE="-vServer.IniFile=/etc/php5/cgi/php.ini" ; + INIFILE="--config /etc/php5/cgi/php.ini" ; + fi + + CUSTOMINIFILE="" + if [[ -e "/etc/hhvm/{SYSTEM_USER}.ini" ]] ; then + CUSTOMINIFILE="--config /etc/hhvm/{SYSTEM_USER}.ini" ; fi - /usr/bin/hhvm --mode daemon -vServer.Type=fastcgi --user {SYSTEM_USER} -vServer.FileSocket=/var/run/hhvm/hhvm.{SYSTEM_USER}.sock -vLog.Level=Warning -vLog.UseLogFile=false -vRepo.Central.Path=/var/run/hhvm/hhvm.{SYSTEM_USER}.hhbc -vServer.FixPathInfo=true $INIFILE -vPidFile=/var/run/hhvm/hhvm_{SYSTEM_USER}.pid & echo $! > /var/run/hhvm/hhvm_{SYSTEM_USER}.pid + + /usr/bin/hhvm --mode daemon -vServer.Type=fastcgi --user {SYSTEM_USER} -vServer.FileSocket=/var/run/hhvm/hhvm.{SYSTEM_USER}.sock -vLog.Level=Warning -vLog.UseLogFile=false -vRepo.Central.Path=/var/run/hhvm/hhvm.{SYSTEM_USER}.hhbc -vServer.FixPathInfo=false $BASEINIFILE $INIFILE $CUSTOMINIFILE -vPidFile=/var/run/hhvm/hhvm_{SYSTEM_USER}.pid & echo $! > /var/run/hhvm/hhvm_{SYSTEM_USER}.pid } do_stop() diff --git a/server/conf/metronome_conf_global.master b/server/conf/metronome_conf_global.master new file mode 100644 index 0000000000000000000000000000000000000000..71920caea101408f7c1cf8f0e77f2bf5a7c89763 --- /dev/null +++ b/server/conf/metronome_conf_global.master @@ -0,0 +1,48 @@ +pidfile = "/var/run/metronome/metronome.pid"; +metronome_max_files_soft = 200000; +metronome_max_files_hard = 300000; +plugin_paths = { + "/usr/lib/metronome/isp-modules", +}; +use_libevent = true; +log = { + debug = "/var/log/metronome/metronome.dbg", + info = "/var/log/metronome/metronome.log", + error = "/var/log/metronome/metronome.err", +}; +use_ipv6 = {tmpl_var name='ipv6'}; +http_ports = { + {tmpl_var name='port_http'}, +}; +https_ports = { + {tmpl_var name='port_https'}, +}; +pastebin_ports = { + {tmpl_var name='port_pastebin'}, +}; +bosh_ports = { + {tmpl_var name='port_bosh'}, +}; +admins = { +{tmpl_var name='server_admins'} +}; +modules_enabled = { +{tmpl_var name='modules_enabled'} +}; +modules_disabled = { +}; +bosh_max_inactivity = {tmpl_var name='bosh_timeout'}; +consider_bosh_secure = true; +cross_domain_bosh = true; +allow_registration = true; +-- TODO generate ssl key during setup +ssl = { + key = "/etc/metronome/certs/localhost.key", + certificate = "/etc/metronome/certs/localhost.cert", +}; +c2s_require_encryption = false; +s2s_secure = true; +s2s_insecure_domains = { + "gmail.com", +}; +authentication = "internal_plain"; \ No newline at end of file diff --git a/server/conf/metronome_conf_host.master b/server/conf/metronome_conf_host.master new file mode 100644 index 0000000000000000000000000000000000000000..179d533e19c532bdc498d938406a962cf877c437 --- /dev/null +++ b/server/conf/metronome_conf_host.master @@ -0,0 +1,135 @@ +VirtualHost "{tmpl_var name='domain'}" + enabled = {tmpl_var name='active'}; + authentication = "external"; + external_auth_command = "/usr/lib/metronome/isp-modules/mod_auth_external/authenticate_isp.sh"; + allow_registration = {tmpl_var name='public_registration'}; + + registration_url = "{tmpl_var name='registration_url'}"; + registration_text = "{tmpl_var name='registration_message'}"; + + no_registration_whitelist = true; + + modules_enabled = { + "roster", + "private", + "vcard", + "privacy", + "pep", + + "register", + + "register_redirect", + + "admin_adhoc", + }; + disco_items = { + + { + "muc.{tmpl_var name='domain'}", + "{tmpl_var name='muc_name'}", + }, + + + { + "pubsub.{tmpl_var name='domain'}", + "{tmpl_var name='domain'} Publish/Subscribe", + }, + + + { + "proxy.{tmpl_var name='domain'}", + "{tmpl_var name='domain'} Bytestream Proxy", + }, + + + { + "vjud.{tmpl_var name='domain'}", + "{tmpl_var name='domain'} User Directory", + }, + + }; + + admins = { +{tmpl_var name='domain_admins'} + }; + + ssl = { + key = "/etc/metronome/certs/{tmpl_var name='domain'}.key", + certificate = "/etc/metronome/certs/{tmpl_var name='domain'}.cert", + }; + + + +VirtualHost "anon.{tmpl_var name='domain'}" + enabled = true; + authentication = "anonymous"; + allow_anonymous_multiresourcing = true; + anonymous_jid_gentoken = "{tmpl_var name='domain'} Anonymous User"; + admins = { + }; + + + + +Component "muc.{tmpl_var name='domain'}" "muc" + modules_enabled = { + "muc_limits", + "muc_log", + + "muc_log_http", + + + "pastebin", + + }; + muc_event_rate = 0.7; + muc_burst_factor = 13; + muc_log_presences = false; + + muc_log_http_config = { + show_join = {tmpl_var name='archive_join'}, + show_status = {tmpl_var name='archive_status'}, + theme = "metronome", + url_base = "logs", + }; + + + pastebin_path = "/pastes/"; + pastebin_expire_after = {tmpl_var name='pastebin_expire'}; + pastebin_trigger = "{tmpl_var name='pastebin_trigger'}"; + + name = "{tmpl_var name='muc_name'}"; + restrict_room_creation = "{tmpl_var name='muc_restrict_room_creation'}"; + admins = { +{tmpl_var name='muc_admins'} + }; + + + + +Component "pubsub.{tmpl_var name='domain'}" "pubsub" + name = "{tmpl_var name='domain'} Publish/Subscribe"; + unrestricted_node_creation = false; + + + +Component "proxy.{tmpl_var name='domain'}" "proxy65" + proxy65_acl = { + "{tmpl_var name='domain'}", + }; + proxy65_interfaces = { + "*", + "::", + }; + proxy65_ports = { + 5000, + }; + + + + +Component "vjud.{tmpl_var name='domain'}" "vjud" + ud_disco_name = "{tmpl_var name='domain'} User Directory"; + synchronize_to_host_vcards = "{tmpl_var name='domain'}"; + vjud_mode = "{tmpl_var name='vjud_opt_mode'}"; + \ No newline at end of file diff --git a/server/conf/metronome_conf_main.master b/server/conf/metronome_conf_main.master new file mode 100644 index 0000000000000000000000000000000000000000..1103ca4d9cac30365ecdee92496a3424b98b3bfe --- /dev/null +++ b/server/conf/metronome_conf_main.master @@ -0,0 +1,3 @@ +Include "/etc/metronome/global.cfg.lua" +Include "/etc/metronome/hosts/*.lua" +Include "/etc/metronome/status.cfg.lua" diff --git a/server/conf/metronome_conf_ssl.master b/server/conf/metronome_conf_ssl.master new file mode 100644 index 0000000000000000000000000000000000000000..73ab3a8a3580313f9879c5e50ccd6a01c6e71547 --- /dev/null +++ b/server/conf/metronome_conf_ssl.master @@ -0,0 +1,72 @@ +oid_section = new_oids + +[ new_oids ] + +# RFC 3920 section 5.1.1 defines this OID +xmppAddr = 1.3.6.1.5.5.7.8.5 + +# RFC 4985 defines this OID +SRVName = 1.3.6.1.5.5.7.8.7 + +[ req ] + +default_bits = 4096 +default_keyfile = {tmpl_var name='domain'}.key +distinguished_name = distinguished_name +req_extensions = v3_extensions +x509_extensions = v3_extensions + +# ask about the DN? +prompt = no + +[ distinguished_name ] + +commonName = {tmpl_var name='domain'} +countryName = {tmpl_var name='ssl_country'} +localityName = {tmpl_var name='ssl_locality'} +organizationName = {tmpl_var name='ssl_organisation'} +organizationalUnitName = {tmpl_var name='ssl_organisation_unit'} +emailAddress = {tmpl_var name='ssl_email'} + +[ v3_extensions ] + +# for certificate requests (req_extensions) +# and self-signed certificates (x509_extensions) + +basicConstraints = CA:FALSE +keyUsage = digitalSignature,keyEncipherment +extendedKeyUsage = serverAuth,clientAuth +subjectAltName = @subject_alternative_name + +[ subject_alternative_name ] + +# See http://tools.ietf.org/html/draft-ietf-xmpp-3920bis#section-13.7.1.2 for more info. + +DNS.0 = {tmpl_var name='domain'} +otherName.0 = xmppAddr;FORMAT:UTF8,UTF8:{tmpl_var name='domain'} +otherName.1 = SRVName;IA5STRING:_xmpp-client.{tmpl_var name='domain'} +otherName.2 = SRVName;IA5STRING:_xmpp-server.{tmpl_var name='domain'} + +DNS.1 = muc.{tmpl_var name='domain'} +otherName.3 = xmppAddr;FORMAT:UTF8,UTF8:muc.{tmpl_var name='domain'} +otherName.4 = SRVName;IA5STRING:_xmpp-server.muc.{tmpl_var name='domain'} + +DNS.2 = pubsub.{tmpl_var name='domain'} +otherName.5 = xmppAddr;FORMAT:UTF8,UTF8:pubsub.{tmpl_var name='domain'} +otherName.6 = SRVName;IA5STRING:_xmpp-server.pubsub.{tmpl_var name='domain'} + +DNS.3 = anon.{tmpl_var name='domain'} +otherName.7 = xmppAddr;FORMAT:UTF8,UTF8:anon.{tmpl_var name='domain'} +otherName.8 = SRVName;IA5STRING:_xmpp-server.anon.{tmpl_var name='domain'} + +DNS.4 = xmpp.{tmpl_var name='domain'} +otherName.9 = xmppAddr;FORMAT:UTF8,UTF8:xmpp.{tmpl_var name='domain'} +otherName.10= SRVName;IA5STRING:_xmpp-server.xmpp.{tmpl_var name='domain'} + +DNS.5 = proxy.{tmpl_var name='domain'} +otherName.11= xmppAddr;FORMAT:UTF8,UTF8:proxy.{tmpl_var name='domain'} +otherName.12= SRVName;IA5STRING:_xmpp-server.proxy.{tmpl_var name='domain'} + +DNS.6 = vjud.{tmpl_var name='domain'} +otherName.13= xmppAddr;FORMAT:UTF8,UTF8:vjud.{tmpl_var name='domain'} +otherName.14= SRVName;IA5STRING:_xmpp-server.vjud.{tmpl_var name='domain'} \ No newline at end of file diff --git a/server/conf/metronome_conf_status.master b/server/conf/metronome_conf_status.master new file mode 100644 index 0000000000000000000000000000000000000000..daa82054915da514e053059180ff4da34a5b929e --- /dev/null +++ b/server/conf/metronome_conf_status.master @@ -0,0 +1,12 @@ +Component "xmpp.{tmpl_var name='domain'}" "http" + modules_enabled = { + "server_status", + "webpresence" + }; + server_status_basepath = "/xmppd/"; + server_status_show_hosts = { +{tmpl_var name='status_hosts'} + }; + server_status_show_comps = { +{tmpl_var name='status_comps'} + }; \ No newline at end of file diff --git a/server/conf/nginx_vhost.conf.master b/server/conf/nginx_vhost.conf.master index 222bf2989e3419568a602f7d1961749bbc09d59f..040af2151e3e35aab3226872f85d741ec03a2c05 100644 --- a/server/conf/nginx_vhost.conf.master +++ b/server/conf/nginx_vhost.conf.master @@ -5,10 +5,10 @@ server { - listen :443 ssl; + listen :443 ssl{tmpl_if name='enable_spdy' op='==' value='y'} spdy{/tmpl_if}; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; - listen []:443 ssl; + listen []:443 ssl{tmpl_if name='enable_spdy' op='==' value='y'} spdy{/tmpl_if}; ssl_certificate /ssl/.crt; ssl_certificate_key /ssl/.key; @@ -192,6 +192,54 @@ server { + + pagespeed on; + pagespeed FileCachePath /var/ngx_pagespeed_cache; + pagespeed FetchHttps enable,allow_self_signed; + + + # let's speed up PageSpeed by storing it in the super duper fast memcached + pagespeed MemcachedThreads 1; + pagespeed MemcachedServers "localhost:11211"; + + # Filter settings + pagespeed RewriteLevel CoreFilters; + pagespeed EnableFilters collapse_whitespace,remove_comments; + + # Ensure requests for pagespeed optimized resources go to the pagespeed + # handler and no extraneous headers get set. + location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { + add_header "" ""; + access_log off; + } + location ~ "^/ngx_pagespeed_static/" { + access_log off; + } + location ~ "^/ngx_pagespeed_beacon$" { + access_log off; + } + location /ngx_pagespeed_statistics { + allow 127.0.0.1; + deny all; + access_log off; + } + location /ngx_pagespeed_global_statistics { + allow 127.0.0.1; + deny all; + access_log off; + } + location /ngx_pagespeed_message { + allow 127.0.0.1; + deny all; + access_log off; + } + location /pagespeed_console { + allow 127.0.0.1; + deny all; + access_log off; + } + + location { ##merge## auth_basic "Members Only"; @@ -242,4 +290,4 @@ server { } } - \ No newline at end of file + diff --git a/server/conf/php-cgi-starter.master b/server/conf/php-cgi-starter.master index be309932210ff16b8540e960b208a8562db50a77..03d0554a5754ddf8c80ecdfef9a3dfcbf6994a02 100644 --- a/server/conf/php-cgi-starter.master +++ b/server/conf/php-cgi-starter.master @@ -4,6 +4,10 @@ export PHPRC="" +export TMP=/tmp +export TMPDIR=/tmp +export TEMP=/tmp + exec \ -d open_basedir= \ -d upload_tmp_dir=/tmp \ diff --git a/server/conf/php-fcgi-starter.master b/server/conf/php-fcgi-starter.master index 92edf86c53089898fcd1805bf0d8f4424a7dd60e..679f1b21ab8931f800fe0ee319cbc70d49630a8c 100644 --- a/server/conf/php-fcgi-starter.master +++ b/server/conf/php-fcgi-starter.master @@ -9,6 +9,9 @@ export PHP_DOCUMENT_ROOT # export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS= export PHP_FCGI_MAX_REQUESTS +export TMP=/tmp +export TMPDIR=/tmp +export TEMP=/tmp exec \ -d open_basedir="" \ -d disable_functions="" \ diff --git a/server/conf/php_fpm_pool.conf.master b/server/conf/php_fpm_pool.conf.master index 7f5c8e13c77261d941052dd34e452f36200f32e1..d7a34786f1f54531aa893abd6aa40c251f65148f 100644 --- a/server/conf/php_fpm_pool.conf.master +++ b/server/conf/php_fpm_pool.conf.master @@ -28,6 +28,10 @@ pm.max_requests = chdir = / +env[TMP] = /tmp +env[TMPDIR] = /tmp +env[TEMP] = /tmp + php_admin_value[open_basedir] = php_admin_value[session.save_path] = /tmp diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master index 955b18a31add0733c928eccfbc9bb4b9d52c16aa..279cbc52f1f4ca181ca2c6d4cc7f1254a6babb3f 100644 --- a/server/conf/vhost.conf.master +++ b/server/conf/vhost.conf.master @@ -53,12 +53,22 @@ SSLEngine on SSLProtocol All -SSLv2 -SSLv3 + SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA + SSLHonorCipherOrder on + + Header always add Strict-Transport-Security "max-age=15768000" + SSLCertificateFile /ssl/.crt SSLCertificateKeyFile /ssl/.key SSLCertificateChainFile /ssl/.bundle + + SSLUseStapling on + SSLStaplingResponderTimeout 5 + SSLStaplingReturnResponderErrors off + @@ -204,6 +214,9 @@ # mod_php enabled AddType application/x-httpd-php .php .php3 .php4 .php5 + SetEnv TMP /tmp + SetEnv TMPDIR /tmp + SetEnv TEMP /tmp php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@" php_admin_value upload_tmp_dir /tmp php_admin_value session.save_path /tmp @@ -336,14 +349,14 @@ Alias /php5-fcgi {tmpl_var name='document_root'}/cgi-bin/php5-fcgi-{tmpl_var name='ip_address'}-{tmpl_var name='port'}-{tmpl_var name='domain'} FastCgiExternalServer {tmpl_var name='document_root'}/cgi-bin/php5-fcgi-{tmpl_var name='ip_address'}-{tmpl_var name='port'}-{tmpl_var name='domain'} -idle-timeout 300 -host 127.0.0.1: -pass-header Authorization + + ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://127.0.0.1:/$1 + FastCgiExternalServer {tmpl_var name='document_root'}/cgi-bin/php5-fcgi-{tmpl_var name='ip_address'}-{tmpl_var name='port'}-{tmpl_var name='domain'} -idle-timeout 300 -socket -pass-header Authorization - - ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ fcgi://127.0.0.1:/$1 - diff --git a/server/cron.php b/server/cron.php index 7a43d04905846e372e40cab9b3f15bfc823dc12d..c197da9516a8d73cc75c44f818be4449a34f2757 100644 --- a/server/cron.php +++ b/server/cron.php @@ -74,7 +74,7 @@ foreach($files as $f) { unset($cronjob); continue; } - print 'Included ' . $class_name . ' from ' . $file_path . ' -> will now run job.' . "\n"; + print 'Included ' . $class_name . ' from ' . $path . '/' . $f . ' -> will now run job.' . "\n"; $cronjob->run(); diff --git a/server/cron.sh b/server/cron.sh index 4aff859c3c6f13dc377b083a30a62eac6ef329d7..3670e68d463318742b1d73c132a4909feff23aab 100644 --- a/server/cron.sh +++ b/server/cron.sh @@ -10,4 +10,8 @@ if [ -f /usr/local/ispconfig/server/lib/php.ini ]; then fi cd /usr/local/ispconfig/server -/usr/bin/php -q /usr/local/ispconfig/server/cron.php +/usr/bin/php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + /usr/local/ispconfig/server/cron.php diff --git a/server/lib/app.inc.php b/server/lib/app.inc.php index a9d47a557869ca961a6ff1edc7f42b87735b0c32..dd8be5aa68791472b47fa90e76a32f6e4335b5e5 100755 --- a/server/lib/app.inc.php +++ b/server/lib/app.inc.php @@ -51,7 +51,7 @@ class app { */ if($conf['dbmaster_host'] != '' && ($conf['dbmaster_host'] != $conf['db_host'] || ($conf['dbmaster_host'] == $conf['db_host'] && $conf['dbmaster_database'] != $conf['db_database']))) { - $this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database']); + $this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port']); } else { $this->dbmaster = $this->db; } @@ -151,19 +151,18 @@ class app { if(isset($this->dbmaster)) { $server_id = $conf['server_id']; $loglevel = $priority; - $tstamp = time(); - $message = $this->dbmaster->quote($msg); + $message = $msg; $datalog_id = (isset($this->modules->current_datalog_id) && $this->modules->current_datalog_id > 0)?$this->modules->current_datalog_id:0; if($datalog_id > 0) { - $tmp_rec = $this->dbmaster->queryOneRecord("SELECT count(syslog_id) as number FROM sys_log WHERE datalog_id = $datalog_id AND loglevel = ".LOGLEVEL_ERROR); + $tmp_rec = $this->dbmaster->queryOneRecord("SELECT count(syslog_id) as number FROM sys_log WHERE datalog_id = ? AND loglevel = ?", $datalog_id, LOGLEVEL_ERROR); //* Do not insert duplicate errors into the web log. if($tmp_rec['number'] == 0) { - $sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ('$server_id',$datalog_id,'$loglevel','$tstamp','$message')"; - $this->dbmaster->query($sql); + $sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES (?, ?, ?, UNIX_TIMESTAMP(), ?)"; + $this->dbmaster->query($sql, $server_id, $datalog_id, $loglevel, $message); } } else { - $sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES ('$server_id',0,'$loglevel','$tstamp','$message')"; - $this->dbmaster->query($sql); + $sql = "INSERT INTO sys_log (server_id,datalog_id,loglevel,tstamp,message) VALUES (?, 0, ?, UNIX_TIMESTAMP(), ?)"; + $this->dbmaster->query($sql, $server_id, $loglevel, $message); } } diff --git a/server/lib/classes/aps_installer.inc.php b/server/lib/classes/aps_installer.inc.php index 089c7ab22a6535d2e437d1ba8fd20179c5fd8b57..5270a5ae9ed0b6d035a6b3aecc2155b36e65c7ca 100644 --- a/server/lib/classes/aps_installer.inc.php +++ b/server/lib/classes/aps_installer.inc.php @@ -259,18 +259,15 @@ class ApsInstaller extends ApsBase // Get the domain name to use for the installation // Would be possible in one query too, but we use 2 for easier debugging - $main_domain = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings - WHERE name = 'main_domain' AND instance_id = '".$app->db->quote($task['instance_id'])."';"); + $main_domain = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_domain' AND instance_id = ?", $task['instance_id']); $this->domain = $main_domain['value']; // Get the document root - $domain_res = $app->db->queryOneRecord("SELECT document_root, web_folder, type FROM web_domain - WHERE domain = '".$app->db->quote($this->domain)."';"); + $domain_res = $app->db->queryOneRecord("SELECT document_root, web_folder, type FROM web_domain WHERE domain = ?", $this->domain); $this->document_root = $domain_res['document_root']; // Get the sub location - $location_res = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings - WHERE name = 'main_location' AND instance_id = '".$app->db->quote($task['instance_id'])."';"); + $location_res = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_location' AND instance_id = ?", $task['instance_id']); $this->sublocation = $location_res['value']; // Make sure the document_root ends with / @@ -309,74 +306,26 @@ class ApsInstaller extends ApsBase $db_id = parent::getXPathValue($sxe, '//db:id'); if(empty($db_id)) return; // No database needed - /* WARNING: if this will ever be uncommented please check the updated prefix handling for user and db names!!! - * - // Set the database owner to the domain owner - // ISPConfig identifies the owner by the sys_groupid (not sys_userid!) - // so sys_userid can be set to any value - $perm = $app->db->queryOneRecord("SELECT sys_groupid, server_id FROM web_domain - WHERE domain = '".$this->domain."';"); - $task['sys_groupid'] = $perm['sys_groupid']; - $serverid = $perm['server_id']; - - // Get the database prefix and db user prefix - $app->uses('getconf'); - $global_config = $app->getconf->get_global_config('sites'); - $dbname_prefix = str_replace('[CLIENTID]', '', $global_config['dbname_prefix']); - $dbuser_prefix = str_replace('[CLIENTID]', '', $global_config['dbuser_prefix']); - $this->dbhost = DB_HOST; // Taken from config.inc.php - if(empty($this->dbhost)) $this->dbhost = 'localhost'; // Just to ensure any hostname... ;) - - $this->newdb_name = $dbname_prefix.$task['CustomerID'].'aps'.$task['InstanceID']; - $this->newdb_user = $dbuser_prefix.$task['CustomerID'].'aps'.$task['InstanceID']; - $dbpw_res = $app->db->queryOneRecord("SELECT Value FROM aps_instances_settings - WHERE Name = 'main_database_password' AND InstanceID = '".$app->db->quote($task['InstanceID'])."';"); - $newdb_pw = $dbpw_res['Value']; - - // In any case delete an existing database (install and removal procedure) - $app->db->query('DROP DATABASE IF EXISTS `'.$app->db->quote($this->newdb_name).'`;'); - // Delete an already existing database with this name - $app->db->query("DELETE FROM web_database WHERE database_name = '".$app->db->quote($this->newdb_name)."';"); - - - // Create the new database and assign it to a user - if($this->handle_type == 'install') - { - $app->db->query('CREATE DATABASE IF NOT EXISTS `'.$app->db->quote($this->newdb_name).'`;'); - $app->db->query('GRANT ALL PRIVILEGES ON '.$app->db->quote($this->newdb_name).'.* TO '.$app->db->quote($this->newdb_user).'@'.$app->db->quote($this->dbhost).' IDENTIFIED BY \'password\';'); - $app->db->query('SET PASSWORD FOR '.$app->db->quote($this->newdb_user).'@'.$app->db->quote($this->dbhost).' = PASSWORD(\''.$newdb_pw.'\');'); - $app->db->query('FLUSH PRIVILEGES;'); - - // Add the new database to the customer databases - // Assumes: charset = utf8 - $app->db->query('INSERT INTO web_database (sys_userid, sys_groupid, sys_perm_user, sys_perm_group, sys_perm_other, server_id, - type, database_name, database_user, database_password, database_charset, remote_access, remote_ips, active) - VALUES ('.$task['sys_userid'].', '.$task['sys_groupid'].', "'.$task['sys_perm_user'].'", "'.$task['sys_perm_group'].'", - "'.$task['sys_perm_other'].'", '.$app->db->quote($serverid).', "mysql", "'.$app->db->quote($this->newdb_name).'", - "'.$app->db->quote($this->newdb_user).'", "'.$app->db->quote($newdb_pw).'", "utf8", "n", "", "y");'); - } - */ - $mysqlver_res = $app->db->queryOneRecord('SELECT VERSION() as ver;'); $mysqlver = $mysqlver_res['ver']; - $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_password' AND instance_id = '".$app->db->quote($task['instance_id'])."';"); + $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_password' AND instance_id = ?", $task['instance_id']); $newdb_pw = $tmp['value']; - $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_host' AND instance_id = '".$app->db->quote($task['instance_id'])."';"); + $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_host' AND instance_id = ?", $task['instance_id']); $newdb_host = $tmp['value']; - $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_name' AND instance_id = '".$app->db->quote($task['instance_id'])."';"); + $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_name' AND instance_id = ?", $task['instance_id']); $newdb_name = $tmp['value']; - $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_login' AND instance_id = '".$app->db->quote($task['instance_id'])."';"); + $tmp = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_database_login' AND instance_id = ?", $task['instance_id']); $newdb_login = $tmp['value']; /* Test if the new mysql connection is laready working to ensure that db servers in multiserver setups get enough time to create the database */ if($this->handle_type == 'install') { for($n = 1; $n < 15; $n++) { - $link = mysql_connect($newdb_host, $newdb_login, $newdb_pw); + $link = mysqli_connect($newdb_host, $newdb_login, $newdb_pw); if (!$link) { unset($link); sleep(5); @@ -470,10 +419,8 @@ class ApsInstaller extends ApsBase $this->processMappings($mapping, $mapping_url, $this->local_installpath); // Set the appropriate file owner - $main_domain = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings - WHERE name = 'main_domain' AND instance_id = '".$app->db->quote($task['instance_id'])."';"); - $owner_res = $app->db->queryOneRecord("SELECT system_user, system_group FROM web_domain - WHERE domain = '".$app->db->quote($main_domain['value'])."';"); + $main_domain = $app->db->queryOneRecord("SELECT value FROM aps_instances_settings WHERE name = 'main_domain' AND instance_id = ?", $task['instance_id']); + $owner_res = $app->db->queryOneRecord("SELECT system_user, system_group FROM web_domain WHERE domain = ?", $main_domain['value']); $this->file_owner_user = $owner_res['system_user']; $this->file_owner_group = $owner_res['system_group']; exec('chown -R '.$this->file_owner_user.':'.$this->file_owner_group.' '.escapeshellarg($this->local_installpath)); @@ -486,8 +433,7 @@ class ApsInstaller extends ApsBase } catch(Exception $e) { - $app->dbmaster->query('UPDATE aps_instances SET instance_status = "'.INSTANCE_ERROR.'" - WHERE id = "'.$app->db->quote($task['instance_id']).'";'); + $app->dbmaster->query('UPDATE aps_instances SET instance_status = ? WHERE id = ?', INSTANCE_ERROR, $task['instance_id']); $app->log($e->getMessage(), 1); return false; } @@ -506,8 +452,7 @@ class ApsInstaller extends ApsBase { global $app; - $userdata = $app->db->queryAllRecords("SELECT name, value FROM aps_instances_settings - WHERE instance_id = '".$app->db->quote($task['instance_id'])."';"); + $userdata = $app->db->queryAllRecords("SELECT name, value FROM aps_instances_settings WHERE instance_id = ?", $task['instance_id']); if(empty($userdata)) return false; foreach($userdata as $data) @@ -555,6 +500,7 @@ class ApsInstaller extends ApsBase curl_setopt($conn[$i], CURLOPT_TIMEOUT, 0); curl_setopt($conn[$i], CURLOPT_FAILONERROR, 1); curl_setopt($conn[$i], CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($conn[$i], CURLOPT_SSL_VERIFYPEER, 0); curl_multi_add_handle($mh, $conn[$i]); } @@ -627,15 +573,13 @@ class ApsInstaller extends ApsBase exec('chown -R root:root '.escapeshellarg($this->local_installpath.'stats')); } - $app->dbmaster->query('UPDATE aps_instances SET instance_status = "'.INSTANCE_SUCCESS.'" - WHERE id = "'.$app->db->quote($task['instance_id']).'";'); + $app->dbmaster->query('UPDATE aps_instances SET instance_status = ? WHERE id = ?', INSTANCE_SUCCESS, $task['instance_id']); } } catch(Exception $e) { - $app->dbmaster->query('UPDATE aps_instances SET instance_status = "'.INSTANCE_ERROR.'" - WHERE id = "'.$app->db->quote($task['instance_id']).'";'); + $app->dbmaster->query('UPDATE aps_instances SET instance_status = ? WHERE id = ?', INSTANCE_ERROR, $task['instance_id']); $app->log($e->getMessage(), 1); return false; } @@ -674,15 +618,7 @@ class ApsInstaller extends ApsBase else return false; // Get all instance metadata - /* - $task = $app->db->queryOneRecord("SELECT * FROM aps_instances AS i - INNER JOIN aps_packages AS p ON i.package_id = p.id - INNER JOIN client AS c ON i.customer_id = c.client_id - WHERE i.id = ".$instanceid.";"); - */ - $task = $app->db->queryOneRecord("SELECT * FROM aps_instances AS i - INNER JOIN aps_packages AS p ON i.package_id = p.id - WHERE i.id = ".$instanceid.";"); + $task = $app->db->queryOneRecord("SELECT * FROM aps_instances AS i INNER JOIN aps_packages AS p ON i.package_id = p.id WHERE i.id = ?", $instanceid); if(!$task) return false; // formerly: throw new Exception('The InstanceID doesn\'t exist.'); if(!isset($task['instance_id'])) $task['instance_id'] = $instanceid; @@ -697,6 +633,7 @@ class ApsInstaller extends ApsBase curl_setopt($ch, CURLOPT_TIMEOUT, 0); curl_setopt($ch, CURLOPT_FAILONERROR, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); if(curl_exec($ch) === false) $app->log(curl_error($ch), 1); fclose($fh); curl_close($ch); @@ -719,8 +656,7 @@ class ApsInstaller extends ApsBase // Check if the meta file is existing if(!$metafile) { - $app->dbmaster->query('UPDATE aps_instances SET instance_status = "'.INSTANCE_ERROR.'" - WHERE id = "'.$app->db->quote($task['instance_id']).'";'); + $app->dbmaster->query('UPDATE aps_instances SET instance_status = ? WHERE id = ?', INSTANCE_ERROR, $task['instance_id']); $app->log('Unable to find the meta data file of package '.$task['path'], 1); return false; } @@ -753,11 +689,11 @@ class ApsInstaller extends ApsBase // Finally delete the instance entry + settings if($this->handle_type == 'delete') { - $app->db->query('DELETE FROM aps_instances WHERE id = "'.$app->db->quote($task['instance_id']).'";'); - $app->db->query('DELETE FROM aps_instances_settings WHERE instance_id = "'.$app->db->quote($task['instance_id']).'";'); + $app->db->query('DELETE FROM aps_instances WHERE id = ?', $task['instance_id']); + $app->db->query('DELETE FROM aps_instances_settings WHERE instance_id = ?', $task['instance_id']); if ($app->dbmaster != $app->db) { - $app->dbmaster->query('DELETE FROM aps_instances WHERE id = "'.$app->db->quote($task['instance_id']).'";'); - $app->dbmaster->query('DELETE FROM aps_instances_settings WHERE instance_id = "'.$app->db->quote($task['instance_id']).'";'); + $app->dbmaster->query('DELETE FROM aps_instances WHERE id = ?', $task['instance_id']); + $app->dbmaster->query('DELETE FROM aps_instances_settings WHERE instance_id = ?', $task['instance_id']); } } diff --git a/server/lib/classes/cron.d/100-mailbox_stats.inc.php b/server/lib/classes/cron.d/100-mailbox_stats.inc.php index 750849055f6a13cca8e00582b0cff84cceb58bec..9778b2fc579f35bc5a9b79c8300fb961ab45b9f7 100644 --- a/server/lib/classes/cron.d/100-mailbox_stats.inc.php +++ b/server/lib/classes/cron.d/100-mailbox_stats.inc.php @@ -32,6 +32,9 @@ class cronjob_mailbox_stats extends cronjob { // job schedule protected $_schedule = '0 0 * * *'; + protected $mailbox_traffic = array(); + protected $mail_boxes = array(); + protected $mail_rewrites = array(); /* this function is optional if it contains no custom code */ public function onPrepare() { @@ -57,8 +60,8 @@ class cronjob_mailbox_stats extends cronjob { //###################################################################################################### $parse_mail_log = false; - $sql = "SELECT mailuser_id,maildir FROM mail_user WHERE server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT mailuser_id,maildir FROM mail_user WHERE server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); if(count($records) > 0) $parse_mail_log = true; foreach($records as $rec) { @@ -82,16 +85,17 @@ class cronjob_mailbox_stats extends cronjob { // Save the traffic stats in the sql database $tstamp = date('Y-m'); - $sql = "SELECT * FROM mail_traffic WHERE month = '$tstamp' AND mailuser_id = ".$rec['mailuser_id']; - $tr = $app->dbmaster->queryOneRecord($sql); + $sql = "SELECT * FROM mail_traffic WHERE month = '$tstamp' AND mailuser_id = ?"; + $tr = $app->dbmaster->queryOneRecord($sql, $rec['mailuser_id']); $mail_traffic += $tr['traffic']; if($tr['traffic_id'] > 0) { - $sql = "UPDATE mail_traffic SET traffic = $mail_traffic WHERE traffic_id = ".$tr['traffic_id']; + $sql = "UPDATE mail_traffic SET traffic = ? WHERE traffic_id = ?"; + $app->dbmaster->query($sql, $mail_traffic, $tr['traffic_id']); } else { - $sql = "INSERT INTO mail_traffic (month,mailuser_id,traffic) VALUES ('$tstamp',".$rec['mailuser_id'].",$mail_traffic)"; + $sql = "INSERT INTO mail_traffic (month,mailuser_id,traffic) VALUES (?,?,?)"; + $app->dbmaster->query($sql, $tstamp, $rec['mailuser_id'], $mail_traffic); } - $app->dbmaster->query($sql); //echo $sql; } @@ -140,13 +144,13 @@ class cronjob_mailbox_stats extends cronjob { } } - $sql = "SELECT email FROM mail_user WHERE server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT email FROM mail_user WHERE server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); foreach($records as $record) { $mail_boxes[] = $record['email']; } - $sql = "SELECT source, destination FROM mail_forwarding WHERE server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT source, destination FROM mail_forwarding WHERE server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); foreach($records as $record) { $targets = preg_split('/[\n,]+/', $record['destination']); foreach($targets as $target) { @@ -163,7 +167,7 @@ class cronjob_mailbox_stats extends cronjob { $cur_line = false; if(file_exists($state_file)) { - $prev_line = parse_mail_log_line(trim(file_get_contents($state_file))); + $prev_line = $this->parse_mail_log_line(trim(file_get_contents($state_file))); //if($prev_line) echo "continuing from previous run, log position: " . $prev_line['message-id'] . " at " . strftime('%d.%m.%Y %H:%M:%S', $prev_line['timestamp']) . "\n"; } @@ -174,7 +178,8 @@ class cronjob_mailbox_stats extends cronjob { while($line = fgets($fp, 8192)) { $l++; //if($l % 1000 == 0) echo "\rline $l"; - $cur_line = parse_mail_log_line($line); + $cur_line = $this->parse_mail_log_line($line); + //print_r($cur_line); if(!$cur_line) continue; if($prev_line) { @@ -189,9 +194,13 @@ class cronjob_mailbox_stats extends cronjob { } } - add_mailbox_traffic($mailbox_traffic, $cur_line['from'], $cur_line['size']); + $this->add_mailbox_traffic($cur_line['from'], $cur_line['size']); + //echo "1\n"; + //print_r($this->mailbox_traffic); foreach($cur_line['to'] as $to) { - add_mailbox_traffic($mailbox_traffic, $to, $cur_line['size']); + $this->add_mailbox_traffic($to, $cur_line['size']); + //echo "2\n"; + //print_r($this->mailbox_traffic); } $last_line = $line; // store for the state file } @@ -206,7 +215,7 @@ class cronjob_mailbox_stats extends cronjob { while($line = fgets($fp, 8192)) { $l++; //if($l % 1000 == 0) echo "\rline $l"; - $cur_line = parse_mail_log_line($line); + $cur_line = $this->parse_mail_log_line($line); if(!$cur_line) continue; if($prev_line) { @@ -231,20 +240,21 @@ class cronjob_mailbox_stats extends cronjob { // Save the traffic stats in the sql database $tstamp = date('Y-m'); - $sql = "SELECT mailuser_id,email FROM mail_user WHERE server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT mailuser_id,email FROM mail_user WHERE server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); foreach($records as $rec) { if(array_key_exists($rec['email'], $mailbox_traffic)) { - $sql = "SELECT * FROM mail_traffic WHERE month = '$tstamp' AND mailuser_id = ".$rec['mailuser_id']; - $tr = $app->dbmaster->queryOneRecord($sql); + $sql = "SELECT * FROM mail_traffic WHERE month = ? AND mailuser_id = ?"; + $tr = $app->dbmaster->queryOneRecord($sql, $tstamp, $rec['mailuser_id']); $mail_traffic = $tr['traffic'] + $mailbox_traffic[$rec['email']]; if($tr['traffic_id'] > 0) { - $sql = "UPDATE mail_traffic SET traffic = $mail_traffic WHERE traffic_id = ".$tr['traffic_id']; + $sql = "UPDATE mail_traffic SET traffic = ? WHERE traffic_id = ?"; + $app->dbmaster->query($sql, $mail_traffic, $tr['traffic_id']); } else { - $sql = "INSERT INTO mail_traffic (month,mailuser_id,traffic) VALUES ('$tstamp',".$rec['mailuser_id'].",$mail_traffic)"; + $sql = "INSERT INTO mail_traffic (month,mailuser_id,traffic) VALUES (?,?,?)"; + $app->dbmaster->query($sql, $tstamp, $rec['mailuser_id'], $mail_traffic); } - $app->dbmaster->query($sql); //echo $sql; } } @@ -263,6 +273,41 @@ class cronjob_mailbox_stats extends cronjob { parent::onAfterRun(); } + + private function parse_mail_log_line($line) { + //Oct 31 17:35:48 mx01 amavis[32014]: (32014-05) Passed CLEAN, [IPv6:xxxxx] [IPv6:xxxxx] -> , Message-ID: , mail_id: xxxxxx, Hits: -1.89, size: 1591, queued_as: xxxxxxx, 946 ms + + if(preg_match('/^(\w+\s+\d+\s+\d+:\d+:\d+)\s+[^ ]+\s+amavis.* <([^>]+)>\s+->\s+((<[^>]+>,)+) .*Message-ID:\s+<([^>]+)>.* size:\s+(\d+),.*$/', $line, $matches) == false) return false; + + $timestamp = strtotime($matches[1]); + if(!$timestamp) return false; + + $to = array(); + $recipients = explode(',', $matches[3]); + foreach($recipients as $recipient) { + $recipient = substr($recipient, 1, -1); + if(!$recipient || $recipient == $matches[2]) continue; + $to[] = $recipient; + } + return array('line' => $line, 'timestamp' => $timestamp, 'size' => $matches[6], 'from' => $matches[2], 'to' => $to, 'message-id' => $matches[5]); + } + + private function add_mailbox_traffic($address, $traffic) { + + $address = strtolower($address); + + if(in_array($address, $this->mail_boxes) == true) { + if(!isset($this->mailbox_traffic[$address])) $this->mailbox_traffic[$address] = 0; + $this->mailbox_traffic[$address] += $traffic; + } elseif(array_key_exists($address, $this->mail_rewrites)) { + foreach($this->mail_rewrites[$address] as $address) { + if(!isset($this->mailbox_traffic[$address])) $this->mailbox_traffic[$address] = 0; + $this->mailbox_traffic[$address] += $traffic; + } + } else { + // this is not a local address - skip it + } + } } diff --git a/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php b/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php index 25f7448cbec87929786babe151db5e482cac60f6..208161cc0f1b0570b136abc98778a76bf56a3ed7 100644 --- a/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php +++ b/server/lib/classes/cron.d/100-monitor_clamav_log.inc.php @@ -82,14 +82,8 @@ class cronjob_monitor_clamav_log extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); @@ -158,14 +152,8 @@ class cronjob_monitor_clamav_log extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_cpu.inc.php b/server/lib/classes/cron.d/100-monitor_cpu.inc.php index 3cbf5b1f32f92ddcfbba213796be0730d7cc57b3..f570eeb81913110d1d40482febee8879c02fd2d1 100644 --- a/server/lib/classes/cron.d/100-monitor_cpu.inc.php +++ b/server/lib/classes/cron.d/100-monitor_cpu.inc.php @@ -111,14 +111,8 @@ class cronjob_monitor_cpu extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_database_size.inc.php b/server/lib/classes/cron.d/100-monitor_database_size.inc.php index c03b82de026a620fa8b65234a925e70f2c7869ed..3e9cecf465df68745bbb74e96c79214243cb314f 100644 --- a/server/lib/classes/cron.d/100-monitor_database_size.inc.php +++ b/server/lib/classes/cron.d/100-monitor_database_size.inc.php @@ -78,7 +78,7 @@ class cronjob_monitor_database_size extends cronjob { $state = 'ok'; /** Fetch the data of all databases into an array */ - $databases = $app->db->queryAllRecords("SELECT database_name, sys_groupid FROM web_database WHERE server_id = $server_id GROUP BY sys_groupid, database_name ASC"); + $databases = $app->db->queryAllRecords("SELECT database_name, sys_groupid FROM web_database WHERE server_id = ? GROUP BY sys_groupid, database_name ASC", $server_id); if(is_array($databases) && !empty($databases)) { @@ -98,14 +98,8 @@ class cronjob_monitor_database_size extends cronjob { //* Insert the data into the database $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); //* The new data is written, now we can delete the old one $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_disk_usage.inc.php b/server/lib/classes/cron.d/100-monitor_disk_usage.inc.php index 2af40411e12ad01874609f98473ea0ec573d2bba..eb92c2de9dda64a9be93723830696fe70fd00c41 100644 --- a/server/lib/classes/cron.d/100-monitor_disk_usage.inc.php +++ b/server/lib/classes/cron.d/100-monitor_disk_usage.inc.php @@ -142,14 +142,8 @@ class cronjob_monitor_disk_usage extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_email_quota.inc.php b/server/lib/classes/cron.d/100-monitor_email_quota.inc.php index 5d0c7a0bc4dc03750cba6ce1790d278698589f56..75014c347def49072f048b235c5afadaa976feb5 100644 --- a/server/lib/classes/cron.d/100-monitor_email_quota.inc.php +++ b/server/lib/classes/cron.d/100-monitor_email_quota.inc.php @@ -75,7 +75,7 @@ class cronjob_monitor_email_quota extends cronjob { //* The state of the email_quota. $state = 'ok'; - $mailboxes = $app->db->queryAllRecords("SELECT email,maildir FROM mail_user WHERE server_id = $server_id"); + $mailboxes = $app->db->queryAllRecords("SELECT email,maildir FROM mail_user WHERE server_id = ?", $server_id); if(is_array($mailboxes)) { //* with dovecot we can use doveadm instead of 'du -s' @@ -134,14 +134,8 @@ class cronjob_monitor_email_quota extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_fail2ban.inc.php b/server/lib/classes/cron.d/100-monitor_fail2ban.inc.php index ffc93a45cde82fe239383713b321c3e6ebb1daeb..5c4ba80561b222b6be12a1dc5f8f02951a91ab64 100644 --- a/server/lib/classes/cron.d/100-monitor_fail2ban.inc.php +++ b/server/lib/classes/cron.d/100-monitor_fail2ban.inc.php @@ -102,14 +102,8 @@ class cronjob_monitor_fail2ban extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_hd_quota.inc.php b/server/lib/classes/cron.d/100-monitor_hd_quota.inc.php index 888dd153eaf7cd3e5e0c3a68c21dd26683d94a51..a4971eb532df3a99c231c90d2e3952b334bed323 100644 --- a/server/lib/classes/cron.d/100-monitor_hd_quota.inc.php +++ b/server/lib/classes/cron.d/100-monitor_hd_quota.inc.php @@ -134,14 +134,8 @@ class cronjob_monitor_hd_quota extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_iptables.inc.php b/server/lib/classes/cron.d/100-monitor_iptables.inc.php index a5a1c260293bec83acc20dec0bce561545fb5bf3..1ad11d9ecccdcbf690c3337524221aee62b431f8 100644 --- a/server/lib/classes/cron.d/100-monitor_iptables.inc.php +++ b/server/lib/classes/cron.d/100-monitor_iptables.inc.php @@ -107,14 +107,8 @@ class cronjob_monitor_iptables extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_ispconfig_log.inc.php b/server/lib/classes/cron.d/100-monitor_ispconfig_log.inc.php index 1df3b02e029802657adc7c429f8e9f7b03712540..0f29b0c489e8028dadf4541f7cf5dd4cc468e59d 100644 --- a/server/lib/classes/cron.d/100-monitor_ispconfig_log.inc.php +++ b/server/lib/classes/cron.d/100-monitor_ispconfig_log.inc.php @@ -82,14 +82,8 @@ class cronjob_monitor_ispconfig_log extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); @@ -123,14 +117,8 @@ class cronjob_monitor_ispconfig_log extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_ispconfig_version.inc.php b/server/lib/classes/cron.d/100-monitor_ispconfig_version.inc.php index e24a4cb206a47fcb063867d6119fea488f125ba8..0b44065b2b4a251b5d7163b468c15443abb0d19c 100644 --- a/server/lib/classes/cron.d/100-monitor_ispconfig_version.inc.php +++ b/server/lib/classes/cron.d/100-monitor_ispconfig_version.inc.php @@ -85,14 +85,8 @@ class cronjob_monitor_ispconfig_version extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_mail_log.inc.php b/server/lib/classes/cron.d/100-monitor_mail_log.inc.php index d5613a137bb4973d8c512628d824def94bffdfd0..5c41105d3c7aadf3765f39b68beb5217d104c578 100644 --- a/server/lib/classes/cron.d/100-monitor_mail_log.inc.php +++ b/server/lib/classes/cron.d/100-monitor_mail_log.inc.php @@ -88,14 +88,8 @@ class cronjob_monitor_mail_log extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); @@ -122,14 +116,8 @@ class cronjob_monitor_mail_log extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); @@ -156,14 +144,8 @@ class cronjob_monitor_mail_log extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_mail_queue.inc.php b/server/lib/classes/cron.d/100-monitor_mail_queue.inc.php index b1f7089abe5a612e71589f5f966083c02fd096b7..b259904d55752c36407517f87aed98863161ba4c 100644 --- a/server/lib/classes/cron.d/100-monitor_mail_queue.inc.php +++ b/server/lib/classes/cron.d/100-monitor_mail_queue.inc.php @@ -113,14 +113,8 @@ class cronjob_monitor_mail_queue extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_mem_usage.inc.php b/server/lib/classes/cron.d/100-monitor_mem_usage.inc.php index 05b196a39509a4789511aabbe1833d6997919981..73567478dc33cb2aee8f903ffe8358f45e460648 100644 --- a/server/lib/classes/cron.d/100-monitor_mem_usage.inc.php +++ b/server/lib/classes/cron.d/100-monitor_mem_usage.inc.php @@ -99,14 +99,8 @@ class cronjob_monitor_mem_usage extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_mongodb.inc.php b/server/lib/classes/cron.d/100-monitor_mongodb.inc.php index 23f31718c6ac3dba9616fa5eafe2bd281e33a193..244cb65eb1056380308540a5bf9e6fa306f608fe 100644 --- a/server/lib/classes/cron.d/100-monitor_mongodb.inc.php +++ b/server/lib/classes/cron.d/100-monitor_mongodb.inc.php @@ -102,14 +102,8 @@ class cronjob_monitor_mongodb extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_openvz.inc.php b/server/lib/classes/cron.d/100-monitor_openvz.inc.php index 08d155fae776e6887b196ab9356cdbdb5e3ab8e5..30b51b4b5fb50242648f9b66be66c08d9a01ea6e 100644 --- a/server/lib/classes/cron.d/100-monitor_openvz.inc.php +++ b/server/lib/classes/cron.d/100-monitor_openvz.inc.php @@ -86,14 +86,8 @@ class cronjob_monitor_openvz extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); @@ -158,14 +152,8 @@ class cronjob_monitor_openvz extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_os_version.inc.php b/server/lib/classes/cron.d/100-monitor_os_version.inc.php index b9978eaeb27644b21fabe1992c02925233116bdc..38766210212b46df93df725dab2cc201ad606f90 100644 --- a/server/lib/classes/cron.d/100-monitor_os_version.inc.php +++ b/server/lib/classes/cron.d/100-monitor_os_version.inc.php @@ -87,14 +87,8 @@ class cronjob_monitor_os_version extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_raid.inc.php b/server/lib/classes/cron.d/100-monitor_raid.inc.php index 86a6908ab44afb32fbace36ec2946a154fadb108..439ab8ce528d9cdae81a5f2af0b58c93c2ccbafa 100644 --- a/server/lib/classes/cron.d/100-monitor_raid.inc.php +++ b/server/lib/classes/cron.d/100-monitor_raid.inc.php @@ -240,14 +240,8 @@ class cronjob_monitor_raid extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_rkhunter.inc.php b/server/lib/classes/cron.d/100-monitor_rkhunter.inc.php index 5d99d7f4e470a6288b0fdd549834cbefdc0503f6..d5beee70bcf1dac36ac38f1f2bf7108bd9c4e5a2 100644 --- a/server/lib/classes/cron.d/100-monitor_rkhunter.inc.php +++ b/server/lib/classes/cron.d/100-monitor_rkhunter.inc.php @@ -102,14 +102,8 @@ class cronjob_monitor_rkhunter extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_server.inc.php b/server/lib/classes/cron.d/100-monitor_server.inc.php index 6ceb584cf5e6d6189343a1997ecebdc13410d7d8..5a053f430e2cd317bcf90cd66644c96ef0c4923f 100644 --- a/server/lib/classes/cron.d/100-monitor_server.inc.php +++ b/server/lib/classes/cron.d/100-monitor_server.inc.php @@ -108,14 +108,8 @@ class cronjob_monitor_server extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_services.inc.php b/server/lib/classes/cron.d/100-monitor_services.inc.php index 3235ee781fb0af71e0553e0d3982a21597cdc051..2c169a2de837f73c0a46628bea68f873565a33f1 100644 --- a/server/lib/classes/cron.d/100-monitor_services.inc.php +++ b/server/lib/classes/cron.d/100-monitor_services.inc.php @@ -67,14 +67,8 @@ class cronjob_monitor_services extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_syslog.inc.php b/server/lib/classes/cron.d/100-monitor_syslog.inc.php index b62112179c23895f0dd37a2253b5981cb79f4f61..c101de0087d566884999a0ca1fa02e2d307739dd 100644 --- a/server/lib/classes/cron.d/100-monitor_syslog.inc.php +++ b/server/lib/classes/cron.d/100-monitor_syslog.inc.php @@ -70,7 +70,7 @@ class cronjob_monitor_syslog extends cronjob { * is there any warning or error for this server? */ $state = 'ok'; - $dbData = $app->dbmaster->queryAllRecords('SELECT loglevel FROM sys_log WHERE server_id = ' . $server_id . ' AND loglevel > 0'); + $dbData = $app->dbmaster->queryAllRecords('SELECT loglevel FROM sys_log WHERE server_id = ? AND loglevel > 0', $server_id); if (is_array($dbData)) { foreach ($dbData as $item) { if ($item['loglevel'] == 1) @@ -93,14 +93,8 @@ class cronjob_monitor_syslog extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); @@ -127,14 +121,8 @@ class cronjob_monitor_syslog extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/100-monitor_system_update.inc.php b/server/lib/classes/cron.d/100-monitor_system_update.inc.php index 33c5c1f02fd018af5dbc38d0e6d53176a5788f58..35338dc21d04efc318c44f5fa9551f09e2fc5e98 100644 --- a/server/lib/classes/cron.d/100-monitor_system_update.inc.php +++ b/server/lib/classes/cron.d/100-monitor_system_update.inc.php @@ -187,14 +187,8 @@ class cronjob_monitor_system_update extends cronjob { * Insert the data into the database */ $sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' . - 'VALUES (' . - $res['server_id'] . ', ' . - "'" . $app->dbmaster->quote($res['type']) . "', " . - 'UNIX_TIMESTAMP(), ' . - "'" . $app->dbmaster->quote(serialize($res['data'])) . "', " . - "'" . $res['state'] . "'" . - ')'; - $app->dbmaster->query($sql); + 'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)'; + $app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']); /* The new data is written, now we can delete the old one */ $this->_tools->delOldRecords($res['type'], $res['server_id']); diff --git a/server/lib/classes/cron.d/150-awstats.inc.php b/server/lib/classes/cron.d/150-awstats.inc.php index 9803a89f13f4724a3f45accc4e879d4416998d6e..ea0c64f67a6de621b3b1482803e49394233c92bc 100644 --- a/server/lib/classes/cron.d/150-awstats.inc.php +++ b/server/lib/classes/cron.d/150-awstats.inc.php @@ -54,8 +54,8 @@ class cronjob_awstats extends cronjob { // Create awstats statistics //###################################################################################################### - $sql = "SELECT domain_id, domain, document_root, web_folder, type, system_user, system_group, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') and stats_type = 'awstats' AND server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT domain_id, domain, document_root, web_folder, type, system_user, system_group, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') and stats_type = 'awstats' AND server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); @@ -65,7 +65,7 @@ class cronjob_awstats extends cronjob { $log_folder = 'log'; if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') { - $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($rec['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $rec['parent_domain_id']); $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $rec['domain']); if($subdomain_host == '') $subdomain_host = 'web'.$rec['domain_id']; $log_folder .= '/' . $subdomain_host; @@ -89,8 +89,8 @@ class cronjob_awstats extends cronjob { if(is_file($awstats_website_conf_file)) unlink($awstats_website_conf_file); - $sql = "SELECT domain FROM web_domain WHERE (type = 'alias' OR type = 'subdomain') AND parent_domain_id = ".$rec['domain_id']; - $aliases = $app->db->queryAllRecords($sql); + $sql = "SELECT domain FROM web_domain WHERE (type = 'alias' OR type = 'subdomain') AND parent_domain_id = ?"; + $aliases = $app->db->queryAllRecords($sql, $rec['domain_id']); $aliasdomain = ''; if(is_array($aliases)) { diff --git a/server/lib/classes/cron.d/150-webalizer.inc.php b/server/lib/classes/cron.d/150-webalizer.inc.php index 1f9a921f0d383f04cea5676789ba5afcfc9b0749..b85000320059ce4da949f7c640dcf584c485a107 100644 --- a/server/lib/classes/cron.d/150-webalizer.inc.php +++ b/server/lib/classes/cron.d/150-webalizer.inc.php @@ -79,8 +79,8 @@ class cronjob_webalizer extends cronjob { } - $sql = "SELECT domain_id, domain, document_root, web_folder, type, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') and stats_type = 'webalizer' AND server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT domain_id, domain, document_root, web_folder, type, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') and stats_type = 'webalizer' AND server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); foreach($records as $rec) { //$yesterday = date('Ymd',time() - 86400); @@ -88,7 +88,7 @@ class cronjob_webalizer extends cronjob { $log_folder = 'log'; if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') { - $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($rec['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $rec['parent_domain_id']); $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $rec['domain']); if($subdomain_host == '') $subdomain_host = 'web'.$rec['domain_id']; $log_folder .= '/' . $subdomain_host; diff --git a/server/lib/classes/cron.d/200-logfiles.inc.php b/server/lib/classes/cron.d/200-logfiles.inc.php index a802ff9eee3132aed204bf69ec3545ec9d0a208e..98dd662f696f636e6e33a217e39ba19894284fc2 100644 --- a/server/lib/classes/cron.d/200-logfiles.inc.php +++ b/server/lib/classes/cron.d/200-logfiles.inc.php @@ -60,8 +60,8 @@ class cronjob_logfiles extends cronjob { // Manage and compress web logfiles and create traffic statistics //###################################################################################################### - $sql = "SELECT domain_id, domain, type, document_root, web_folder, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') AND server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT domain_id, domain, type, document_root, web_folder, parent_domain_id FROM web_domain WHERE (type = 'vhost' or type = 'vhostsubdomain' or type = 'vhostalias') AND server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); foreach($records as $rec) { //* create traffic statistics based on yesterdays access log file @@ -69,7 +69,7 @@ class cronjob_logfiles extends cronjob { $log_folder = 'log'; if($rec['type'] == 'vhostsubdomain' || $rec['type'] == 'vhostalias') { - $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($rec['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $rec['parent_domain_id']); $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $rec['domain']); if($subdomain_host == '') $subdomain_host = 'web'.$rec['domain_id']; $log_folder .= '/' . $subdomain_host; @@ -89,16 +89,14 @@ class cronjob_logfiles extends cronjob { //* Insert / update traffic in master database $traffic_date = date('Y-m-d', time() - 86400); - $tmp = $app->dbmaster->queryOneRecord("select hostname from web_traffic where hostname='".$rec['domain']."' and traffic_date='".$traffic_date."'"); + $tmp = $app->dbmaster->queryOneRecord("select hostname from web_traffic where hostname=? and traffic_date=?", $rec['domain'], $traffic_date); if(is_array($tmp) && count($tmp) > 0) { - $sql = "update web_traffic set traffic_bytes=traffic_bytes+" - . $total_bytes - . " where hostname='" . $rec['domain'] - . "' and traffic_date='" . $traffic_date . "'"; + $sql = "UPDATE web_traffic SET traffic_bytes=traffic_bytes + ? WHERE hostname = ? AND traffic_date = ?"; + $app->dbmaster->query($sql, $total_bytes, $rec['domain'], $traffic_date); } else { - $sql = "insert into web_traffic (hostname, traffic_date, traffic_bytes) values ('".$rec['domain']."', '".$traffic_date."', '".$total_bytes."')"; + $sql = "INSERT INTO web_traffic (hostname, traffic_date, traffic_bytes) VALUES (?, ?, ?)"; + $app->dbmaster->query($sql, $rec['domain'], $traffic_date, $total_bytes); } - $app->dbmaster->query($sql); fclose($handle); } @@ -197,8 +195,8 @@ class cronjob_logfiles extends cronjob { // Cleanup website tmp directories //###################################################################################################### - $sql = "SELECT domain_id, domain, document_root, system_user FROM web_domain WHERE server_id = ".$conf['server_id']; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT domain_id, domain, document_root, system_user FROM web_domain WHERE server_id = ?"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); $app->uses('system'); if(is_array($records)) { foreach($records as $rec){ @@ -225,8 +223,8 @@ class cronjob_logfiles extends cronjob { * if they are NOT ok, the server will try to process them in 1 minute and so the * error appears again after 1 minute. So it is no problem to delete the old one! */ - $sql = "DELETE FROM sys_log WHERE tstamp < " . $tstamp . " AND server_id != 0"; - $app->dbmaster->query($sql); + $sql = "DELETE FROM sys_log WHERE tstamp < ? AND server_id != 0"; + $app->dbmaster->query($sql, $tstamp); /* * Delete all remote-actions "done" and older than 7 days @@ -236,11 +234,8 @@ class cronjob_logfiles extends cronjob { $sql = "SELECT max(action_id) FROM sys_remoteaction"; $res = $app->dbmaster->queryOneRecord($sql); $maxId = $res['max(action_id)']; - $sql = "DELETE FROM sys_remoteaction " . - "WHERE tstamp < " . $tstamp . " " . - " AND action_state = 'ok' " . - " AND action_id <" . intval($maxId); - $app->dbmaster->query($sql); + $sql = "DELETE FROM sys_remoteaction WHERE tstamp < ? AND action_state = 'ok' AND action_id < ?"; + $app->dbmaster->query($sql, $tstamp, $maxId); /* * The sys_datalog is more difficult. @@ -270,14 +265,10 @@ class cronjob_logfiles extends cronjob { foreach($records as $server) { $tmp_server_id = intval($server['server_id']); if($tmp_server_id > 0) { - $sql = "DELETE FROM sys_datalog " . - "WHERE tstamp < " . $tstamp . - " AND server_id = " . intval($server['server_id']) . - " AND datalog_id < " . intval($server['updated']) . - " AND datalog_id < " . intval($maxId); + $sql = "DELETE FROM sys_datalog WHERE tstamp < ? AND server_id = ? AND datalog_id < ? AND datalog_id < ?"; + // echo $sql . "\n"; + $app->dbmaster->query($sql, $tstamp, $server['server_id'], $server['updated'], $maxId); } - // echo $sql . "\n"; - $app->dbmaster->query($sql); } } diff --git a/server/lib/classes/cron.d/300-quota_notify.inc.php b/server/lib/classes/cron.d/300-quota_notify.inc.php index f18394c58cdef45fdf51592742221e2c054cfe5e..d250fe74665897c632af5ca1bb85f269fd9cafd1 100644 --- a/server/lib/classes/cron.d/300-quota_notify.inc.php +++ b/server/lib/classes/cron.d/300-quota_notify.inc.php @@ -49,6 +49,11 @@ class cronjob_quota_notify extends cronjob { public function onRunJob() { global $app, $conf; + + /* used for all monitor cronjobs */ + $app->load('monitor_tools'); + $this->_tools = new monitor_tools(); + /* end global section for monitor cronjobs */ //###################################################################################################### // enforce traffic quota (run only on the "master-server") @@ -69,26 +74,12 @@ class cronjob_quota_notify extends cronjob { $web_traffic_quota = $rec['traffic_quota']; $domain = $rec['domain']; - // get the client - /* - $client_group_id = $rec["sys_groupid"]; - $client = $app->db->queryOneRecord("SELECT limit_traffic_quota,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_traffic_quota FROM client WHERE client_id = ".intval($client['parent_client_id'])); - - $client_traffic_quota = intval($client['limit_traffic_quota']); - $reseller_traffic_quota = intval($reseller['limit_traffic_quota']); - */ - //* get the traffic $tmp = $app->db->queryOneRecord("SELECT SUM(traffic_bytes) As total_traffic_bytes FROM web_traffic WHERE traffic_date like '$current_month%' AND hostname = '$domain'"); $web_traffic = round($tmp['total_traffic_bytes']/1024/1024); - //* Website is over quota, we will disable it - /*if( ($web_traffic_quota > 0 && $web_traffic > $web_traffic_quota) || - ($client_traffic_quota > 0 && $web_traffic > $client_traffic_quota) || - ($reseller_traffic_quota > 0 && $web_traffic > $reseller_traffic_quota)) {*/ if($web_traffic_quota > 0 && $web_traffic > $web_traffic_quota) { - $app->dbmaster->datalogUpdate('web_domain', "traffic_quota_lock = 'y',active = 'n'", 'domain_id', $rec['domain_id']); + $app->dbmaster->datalogUpdate('web_domain', array("traffic_quota_lock" => 'y', "active" => 'n'), 'domain_id', $rec['domain_id']); $app->log('Traffic quota for '.$rec['domain'].' exceeded. Disabling website.', LOGLEVEL_DEBUG); //* Send traffic notifications @@ -106,7 +97,7 @@ class cronjob_quota_notify extends cronjob { //* Send email to client if($web_config['overtraffic_notify_client'] == 'y') { $client_group_id = $rec["sys_groupid"]; - $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); if($client['email'] != '') { $recipients[] = $client['email']; } @@ -118,7 +109,7 @@ class cronjob_quota_notify extends cronjob { } else { //* unlock the website, if traffic is lower then quota if($rec['traffic_quota_lock'] == 'y') { - $app->dbmaster->datalogUpdate('web_domain', "traffic_quota_lock = 'n',active = 'y'", 'domain_id', $rec['domain_id']); + $app->dbmaster->datalogUpdate('web_domain', array("traffic_quota_lock" => 'n', "active" => 'y'), 'domain_id', $rec['domain_id']); $app->log('Traffic quota for '.$rec['domain'].' ok again. Re-enabling website.', LOGLEVEL_DEBUG); } } @@ -206,7 +197,7 @@ class cronjob_quota_notify extends cronjob { // send notifications only if 90% or more of the quota are used if($used_ratio < 0.9) { // reset notification date - if($rec['last_quota_notification']) $app->dbmaster->datalogUpdate('web_domain', "last_quota_notification = NULL", 'domain_id', $rec['domain_id']); + if($rec['last_quota_notification']) $app->dbmaster->datalogUpdate('web_domain', array("last_quota_notification" => null), 'domain_id', $rec['domain_id']); // send notification - everything ok again if($rec['last_quota_notification'] && $web_config['overquota_notify_onok'] == 'y' && ($web_config['overquota_notify_admin'] == 'y' || $web_config['overquota_notify_client'] == 'y')) { @@ -227,7 +218,7 @@ class cronjob_quota_notify extends cronjob { //* Send email to client if($web_config['overquota_notify_client'] == 'y') { $client_group_id = $rec["sys_groupid"]; - $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); if($client['email'] != '') { $recipients[] = $client['email']; } @@ -243,7 +234,7 @@ class cronjob_quota_notify extends cronjob { //* Send quota notifications if(($web_config['overquota_notify_admin'] == 'y' || $web_config['overquota_notify_client'] == 'y') && $send_notification == true) { - $app->dbmaster->datalogUpdate('web_domain', "last_quota_notification = CURDATE()", 'domain_id', $rec['domain_id']); + $app->dbmaster->datalogUpdate('web_domain', array("last_quota_notification" => array("SQL" => "CURDATE()")), 'domain_id', $rec['domain_id']); $placeholders = array('{domain}' => $rec['domain'], '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), @@ -262,7 +253,7 @@ class cronjob_quota_notify extends cronjob { //* Send email to client if($web_config['overquota_notify_client'] == 'y') { $client_group_id = $rec["sys_groupid"]; - $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); if($client['email'] != '') { $recipients[] = $client['email']; } @@ -335,7 +326,7 @@ class cronjob_quota_notify extends cronjob { // send notifications only if 90% or more of the quota are used if($used_ratio < 0.9) { // reset notification date - if($rec['last_quota_notification']) $app->dbmaster->datalogUpdate('mail_user', "last_quota_notification = NULL", 'mailuser_id', $rec['mailuser_id']); + if($rec['last_quota_notification']) $app->dbmaster->datalogUpdate('mail_user', array("last_quota_notification" => null), 'mailuser_id', $rec['mailuser_id']); // send notification - everything ok again if($rec['last_quota_notification'] && $mail_config['overquota_notify_onok'] == 'y' && ($mail_config['overquota_notify_admin'] == 'y' || $mail_config['overquota_notify_client'] == 'y')) { @@ -355,7 +346,7 @@ class cronjob_quota_notify extends cronjob { //* Send email to client if($mail_config['overquota_notify_client'] == 'y') { $client_group_id = $rec["sys_groupid"]; - $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); if($client['email'] != '') { $recipients[] = $client['email']; } @@ -372,7 +363,7 @@ class cronjob_quota_notify extends cronjob { elseif($mail_config['overquota_notify_freq'] > 0 && $rec['notified_before'] >= $mail_config['overquota_notify_freq']) $send_notification = true; if(($mail_config['overquota_notify_admin'] == 'y' || $mail_config['overquota_notify_client'] == 'y') && $send_notification == true) { - $app->dbmaster->datalogUpdate('mail_user', "last_quota_notification = CURDATE()", 'mailuser_id', $rec['mailuser_id']); + $app->dbmaster->datalogUpdate('mail_user', array("last_quota_notification" => array("SQL" => "CURDATE()")), 'mailuser_id', $rec['mailuser_id']); $placeholders = array('{email}' => $rec['email'], '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), @@ -390,7 +381,7 @@ class cronjob_quota_notify extends cronjob { //* Send email to client if($mail_config['overquota_notify_client'] == 'y') { $client_group_id = $rec["sys_groupid"]; - $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id"); + $client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id); if($client['email'] != '') { $recipients[] = $client['email']; } @@ -427,7 +418,7 @@ class cronjob_quota_notify extends cronjob { } //* get databases - $database_records = $app->db->queryAllRecords("SELECT database_id,sys_groupid,database_name,database_quota,last_quota_notification,DATEDIFF(CURDATE(), last_quota_notification) as `notified_before` FROM web_database;"); + $database_records = $app->db->queryAllRecords("SELECT database_id,sys_groupid,database_name,database_quota,last_quota_notification,DATEDIFF(CURDATE(), last_quota_notification) as `notified_before` FROM web_database"); if(is_array($database_records) && !empty($database_records) && is_array($monitor_data) && !empty($monitor_data)) { //* check database-quota @@ -442,7 +433,7 @@ class cronjob_quota_notify extends cronjob { if ($monitor['database_name'] == $database) { //* get the client - $client = $app->db->queryOneRecord("SELECT client.username, client.email FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name='".$database."'"); + $client = $app->db->queryOneRecord("SELECT client.username, client.email FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name=?", $database); //* check quota if ($quota > 0) $used_ratio = $monitor['size'] / $quota; @@ -452,9 +443,9 @@ class cronjob_quota_notify extends cronjob { if($used_ratio > 0.9) { //* reset notification date - if($rec['last_quota_notification']) $app->dbmaster->datalogUpdate('web_database', "last_quota_notification = NULL", 'database_id', $rec['database_id']); + if($rec['last_quota_notification']) $app->dbmaster->datalogUpdate('web_database', array("last_quota_notification" => null), 'database_id', $rec['database_id']); - $app->dbmaster->datalogUpdate('web_database', "last_quota_notification = CURDATE()", 'database_id', $rec['database_id']); + $app->dbmaster->datalogUpdate('web_database', array("last_quota_notification" => array("SQL" => "CURDATE()")), 'database_id', $rec['database_id']); // send notification - everything ok again if($rec['last_quota_notification'] && $web_config['overquota_notify_onok'] == 'y' && ($web_config['overquota_db_notify_admin'] == 'y' || $web_config['overquota_db_notify_client'] == 'y')) { @@ -489,7 +480,7 @@ class cronjob_quota_notify extends cronjob { //* Send quota notifications if(($web_config['overquota_db_notify_admin'] == 'y' || $web_config['overquota_db_notify_client'] == 'y') && $send_notification == true) { - $app->dbmaster->datalogUpdate('web_database', "last_quota_notification = CURDATE()", 'database_id', $rec['database_id']); + $app->dbmaster->datalogUpdate('web_database', array("last_quota_notification" => array("SQL" => "CURDATE()")), 'database_id', $rec['database_id']); $placeholders = array( '{database_name}' => $rec['database_name'], '{admin_mail}' => ($global_config['admin_mail'] != ''? $global_config['admin_mail'] : 'root'), diff --git a/server/lib/classes/cron.d/400-openvz.inc.php b/server/lib/classes/cron.d/400-openvz.inc.php index 18f4598be2e03dde3fb17cc45673cdaf0c5da5d7..5eba8d2081126d9ce5b2bc132a62ab813168946d 100644 --- a/server/lib/classes/cron.d/400-openvz.inc.php +++ b/server/lib/classes/cron.d/400-openvz.inc.php @@ -55,14 +55,12 @@ class cronjob_openvz extends cronjob { //###################################################################################################### if ($app->dbmaster == $app->db) { - $current_date = date('Y-m-d'); - //* Check which virtual machines have to be deactivated - $sql = "SELECT * FROM openvz_vm WHERE active = 'y' AND active_until_date != '0000-00-00' AND active_until_date < '$current_date'"; + $sql = "SELECT * FROM openvz_vm WHERE active = 'y' AND active_until_date != '0000-00-00' AND active_until_date < CURDATE()"; $records = $app->db->queryAllRecords($sql); if(is_array($records)) { foreach($records as $rec) { - $app->dbmaster->datalogUpdate('openvz_vm', "active = 'n'", 'vm_id', $rec['vm_id']); + $app->dbmaster->datalogUpdate('openvz_vm', array("active" => 'n'), 'vm_id', $rec['vm_id']); $app->log('Virtual machine active date expired. Disabling VM '.$rec['veid'], LOGLEVEL_DEBUG); } } diff --git a/server/lib/classes/cron.d/500-backup.inc.php b/server/lib/classes/cron.d/500-backup.inc.php index abca144f4043207bb0fde7dcff5d7188b470f267..a9fa3f91fe06553045750d1079b3f396868a97ce 100644 --- a/server/lib/classes/cron.d/500-backup.inc.php +++ b/server/lib/classes/cron.d/500-backup.inc.php @@ -51,6 +51,7 @@ class cronjob_backup extends cronjob { global $app, $conf; $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); + $global_config = $app->getconf->get_global_config('sites'); $backup_dir = $server_config['backup_dir']; $backup_mode = $server_config['backup_mode']; if($backup_mode == '') $backup_mode = 'userzip'; @@ -71,22 +72,15 @@ class cronjob_backup extends cronjob { } else { chmod(escapeshellcmd($backup_dir), $backup_dir_permissions); } - - //* mount backup directory, if necessary - $run_backups = true; - $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); - if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ - if(!$app->system->is_mounted($backup_dir)){ - exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); - sleep(1); - if(!$app->system->is_mounted($backup_dir)) $run_backups = false; - } - } - + $run_backups = true; + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $run_backups = false; if($run_backups){ + $web_array = array(); + //* backup only active domains - $sql = "SELECT * FROM web_domain WHERE server_id = '".$conf['server_id']."' AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND active = 'y'"; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM web_domain WHERE server_id = ? AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND active = 'y'"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); if(is_array($records)) { foreach($records as $rec) { @@ -97,6 +91,7 @@ class cronjob_backup extends cronjob { $web_user = $rec['system_user']; $web_group = $rec['system_group']; $web_id = $rec['domain_id']; + if(!in_array($web_id, $web_array)) $web_array[] = $web_id; $web_backup_dir = $backup_dir.'/web'.$web_id; if(!is_dir($web_backup_dir)) mkdir($web_backup_dir, 0750); chmod($web_backup_dir, 0750); @@ -131,16 +126,19 @@ class cronjob_backup extends cronjob { } if($retval == 0 || ($backup_mode != 'userzip' && $retval == 1) || ($backup_mode == 'userzip' && $retval == 12)) { // tar can return 1, zip can return 12(due to harmless warings) and still create valid backups if(is_file($web_backup_dir.'/'.$web_backup_file)){ - chown($web_backup_dir.'/'.$web_backup_file, 'root'); - chgrp($web_backup_dir.'/'.$web_backup_file, 'root'); + $backupusername = ($global_config['backups_include_into_web_quota'] == 'y') ? $web_user : 'root'; + $backupgroup = ($global_config['backups_include_into_web_quota'] == 'y') ? $web_group : 'root'; + chown($web_backup_dir.'/'.$web_backup_file, $backupusername); + chgrp($web_backup_dir.'/'.$web_backup_file, $backupgroup); chmod($web_backup_dir.'/'.$web_backup_file, 0750); //* Insert web backup record in database - //$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')"; - //$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id'); - $sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $filesize = filesize($web_backup_dir.'/'.$web_backup_file); + $sql = "INSERT INTO web_backup (server_id, parent_domain_id, backup_type, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)"; + $app->db->query($sql, $conf['server_id'], $web_id, 'web', $backup_mode, time(), $web_backup_file, $filesize); + if($app->db->dbHost != $app->dbmaster->dbHost) + $app->dbmaster->query($sql, $conf['server_id'], $web_id, 'web', $backup_mode, time(), $web_backup_file, $filesize); + unset($filesize); } } else { if(is_file($web_backup_dir.'/'.$web_backup_file)) unlink($web_backup_dir.'/'.$web_backup_file); @@ -162,14 +160,10 @@ class cronjob_backup extends cronjob { for ($n = $backup_copies; $n <= 10; $n++) { if(isset($files[$n]) && is_file($web_backup_dir.'/'.$files[$n])) { - unlink($web_backup_dir.'/'.$files[$n]); - //$sql = "SELECT backup_id FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = $web_id AND filename = '".$app->db->quote($files[$n])."'"; - //$tmp = $app->dbmaster->queryOneRecord($sql); - //$app->dbmaster->datalogDelete('web_backup', 'backup_id', $tmp['backup_id']); - //$sql = "DELETE FROM web_backup WHERE backup_id = ".intval($tmp['backup_id']); - $sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = $web_id AND filename = '".$app->db->quote($files[$n])."'"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?"; + $app->db->query($sql, $conf['server_id'], $web_id, $files[$n]); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $web_id, $files[$n]); + @unlink($web_backup_dir.'/'.$files[$n]); } } @@ -199,16 +193,15 @@ class cronjob_backup extends cronjob { $web_backup_dir = realpath($backup_dir.'/web'.$web_id); if(is_dir($web_backup_dir)) { exec('sudo -u '.escapeshellarg($web_user).' rm -f '.escapeshellarg($web_backup_dir.'/*')); - $sql = "DELETE FROM web_backup WHERE server_id = ".intval($conf['server_id'])." AND parent_domain_id = ".intval($web_id); - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ?"; + $app->db->query($sql, $conf['server_id'], $web_id); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $web_id); } } } } - $sql = "SELECT * FROM web_database WHERE server_id = ".$conf['server_id']." AND backup_interval != 'none' AND backup_interval != ''"; - $records = $app->db->queryAllRecords($sql); + $records = $app->db->queryAllRecords("SELECT * FROM web_database WHERE server_id = ? AND backup_interval != 'none' AND backup_interval != ''", $conf['server_id']); if(is_array($records)) { include 'lib/mysql_clientdb.conf'; @@ -219,18 +212,27 @@ class cronjob_backup extends cronjob { if($rec['backup_interval'] == 'daily' or ($rec['backup_interval'] == 'weekly' && date('w') == 0) or ($rec['backup_interval'] == 'monthly' && date('d') == '01')) { $web_id = $rec['parent_domain_id']; + if(!in_array($web_id, $web_array)) $web_array[] = $web_id; $db_backup_dir = $backup_dir.'/web'.$web_id; if(!is_dir($db_backup_dir)) mkdir($db_backup_dir, 0750); chmod($db_backup_dir, 0750); - chown($db_backup_dir, 'root'); - chgrp($db_backup_dir, 'root'); + $backupusername = 'root'; + $backupgroup = 'root'; + if ($global_config['backups_include_into_web_quota'] == 'y') { + $sql = "SELECT * FROM web_domain WHERE domain_id = ".$rec['parent_domain_id']; + $webdomain = $app->db->queryOneRecord($sql); + $backupusername = $webdomain['system_user']; + $backupgroup = $webdomain['system_group']; + } + chown($db_backup_dir, $backupusername); + chgrp($db_backup_dir, $backupgroup); //* Do the mysql database backup with mysqldump $db_id = $rec['database_id']; $db_name = $rec['database_name']; $db_backup_file = 'db_'.$db_name.'_'.date('Y-m-d_H-i').'.sql'; //$command = "mysqldump -h '".escapeshellcmd($clientdb_host)."' -u '".escapeshellcmd($clientdb_user)."' -p'".escapeshellcmd($clientdb_password)."' -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'"; - $command = "mysqldump -h ".escapeshellarg($clientdb_host)." -u ".escapeshellarg($clientdb_user)." -p".escapeshellarg($clientdb_password)." -c --add-drop-table --create-options --quick --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'"; + $command = "mysqldump -h ".escapeshellarg($clientdb_host)." -u ".escapeshellarg($clientdb_user)." -p".escapeshellarg($clientdb_password)." -c --add-drop-table --create-options --quick --max_allowed_packet=512M --result-file='".$db_backup_dir.'/'.$db_backup_file."' '".$db_name."'"; exec($command, $tmp_output, $retval); //* Compress the backup with gzip @@ -243,11 +245,12 @@ class cronjob_backup extends cronjob { chgrp($db_backup_dir.'/'.$db_backup_file.'.gz', filegroup($db_backup_dir)); //* Insert web backup record in database - //$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')"; - //$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id'); - $sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $filesize = filesize($db_backup_dir.'/'.$db_backup_file.'.gz'); + $sql = "INSERT INTO web_backup (server_id, parent_domain_id, backup_type, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)"; + $app->db->query($sql, $conf['server_id'], $web_id, 'mysql', 'sqlgz', time(), $db_backup_file.'.gz', $filesize); + if($app->db->dbHost != $app->dbmaster->dbHost) + $app->dbmaster->query($sql, $conf['server_id'], $web_id, 'mysql', 'sqlgz', time(), $db_backup_file.'.gz', $filesize); + unset($filesize); } } else { if(is_file($db_backup_dir.'/'.$db_backup_file.'.gz')) unlink($db_backup_dir.'/'.$db_backup_file.'.gz'); @@ -261,7 +264,7 @@ class cronjob_backup extends cronjob { $dir_handle = dir($db_backup_dir); $files = array(); while (false !== ($entry = $dir_handle->read())) { - if($entry != '.' && $entry != '..' && preg_match('/^db_(.*?)_\d{4}-\d{2}-\d{2}_\d{2}-\d{2}\.sql.gz$/', $entry, $matches) && is_file($db_backup_dir.'/'.$entry)) { + if($entry != '.' && $entry != '..' && preg_match('/^db_('.$db_name.')_\d{4}-\d{2}-\d{2}_\d{2}-\d{2}\.sql.gz$/', $entry, $matches) && is_file($db_backup_dir.'/'.$entry)) { if(array_key_exists($matches[1], $files) == false) $files[$matches[1]] = array(); $files[$matches[1]][] = $entry; } @@ -273,13 +276,10 @@ class cronjob_backup extends cronjob { rsort($filelist); for ($n = $backup_copies; $n <= 10; $n++) { if(isset($filelist[$n]) && is_file($db_backup_dir.'/'.$filelist[$n])) { - unlink($db_backup_dir.'/'.$filelist[$n]); - //$sql = "SELECT backup_id FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = $web_id AND filename = '".$app->db->quote($filelist[$n])."'"; - //$tmp = $app->dbmaster->queryOneRecord($sql); - //$sql = "DELETE FROM web_backup WHERE backup_id = ".intval($tmp['backup_id']); - $sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = $web_id AND filename = '".$app->db->quote($filelist[$n])."'"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?"; + $app->db->query($sql, $conf['server_id'], $web_id, $filelist[$n]); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $web_id, $filelist[$n]); + @unlink($db_backup_dir.'/'.$filelist[$n]); } } } @@ -296,17 +296,63 @@ class cronjob_backup extends cronjob { } // remove non-existing backups from database - $backups = $app->db->queryAllRecords("SELECT * FROM web_backup WHERE server_id = ".$conf['server_id']); + $backups = $app->db->queryAllRecords("SELECT * FROM web_backup WHERE server_id = ?", $conf['server_id']); if(is_array($backups) && !empty($backups)){ foreach($backups as $backup){ $backup_file = $backup_dir.'/web'.$backup['parent_domain_id'].'/'.$backup['filename']; if(!is_file($backup_file)){ - $sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$backup['parent_domain_id']." AND filename = '".$backup['filename']."'"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?"; + $app->db->query($sql, $conf['server_id'], $backup['parent_domain_id'], $backup['filename']); + } + } + } + if($app->db->dbHost != $app->dbmaster->dbHost){ + $backups = $app->dbmaster->queryAllRecords("SELECT * FROM web_backup WHERE server_id = ?", $conf['server_id']); + if(is_array($backups) && !empty($backups)){ + foreach($backups as $backup){ + $backup_file = $backup_dir.'/web'.$backup['parent_domain_id'].'/'.$backup['filename']; + if(!is_file($backup_file)){ + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?"; + $app->dbmaster->query($sql, $conf['server_id'], $backup['parent_domain_id'], $backup['filename']); + } + } + } + } + + // garbage collection (non-existing databases) + if(is_array($web_array) && !empty($web_array)){ + foreach($web_array as $tmp_web_id){ + $tmp_backup_dir = $backup_dir.'/web'.$tmp_web_id; + if(is_dir($tmp_backup_dir)){ + $dir_handle = dir($tmp_backup_dir); + $files = array(); + while (false !== ($entry = $dir_handle->read())) { + if($entry != '.' && $entry != '..' && preg_match('/^db_(.*?)_\d{4}-\d{2}-\d{2}_\d{2}-\d{2}\.sql.gz$/', $entry, $matches) && is_file($tmp_backup_dir.'/'.$entry)) { + + $tmp_db_name = $matches[1]; + $tmp_database = $app->db->queryOneRecord("SELECT * FROM web_database WHERE server_id = ? AND parent_domain_id = ? AND database_name = ?", $conf['server_id'], $tmp_web_id, $tmp_db_name); + + if(is_array($tmp_database) && !empty($tmp_database)){ + if($tmp_database['backup_interval'] == 'none' || intval($tmp_database['backup_copies']) == 0){ + @unlink($tmp_backup_dir.'/'.$entry); + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?"; + $app->db->query($sql, $conf['server_id'], $tmp_web_id, $entry); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $tmp_web_id, $entry); + } + } else { + @unlink($tmp_backup_dir.'/'.$entry); + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?"; + $app->db->query($sql, $conf['server_id'], $tmp_web_id, $entry); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $tmp_web_id, $entry); + } + } + } + $dir_handle->close(); } } } + //* end run_backups + if( $server_config['backup_dir_is_mount'] == 'y' ) $app->system->umount_backup_dir($backup_dir); } else { //* send email to admin that backup directory could not be mounted $global_config = $app->getconf->get_global_config('mail'); @@ -317,6 +363,27 @@ class cronjob_backup extends cronjob { } } } + + // delete files from backup download dir (/var/www/example.com/backup) + unset($records, $entry, $files); + $sql = "SELECT * FROM web_domain WHERE server_id = ? AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND active = 'y'"; + $records = $app->db->queryAllRecords($sql, $conf['server_id']); + if(is_array($records)) { + foreach($records as $rec) { + $backup_download_dir = $rec['document_root'].'/backup'; + if(is_dir($backup_download_dir)){ + $dir_handle = dir($backup_download_dir); + $files = array(); + while (false !== ($entry = $dir_handle->read())) { + if($entry != '.' && $entry != '..' && is_file($backup_download_dir.'/'.$entry)) { + // delete files older than 3 days + if(time() - filemtime($backup_download_dir.'/'.$entry) >= 60*60*24*3) @unlink($backup_download_dir.'/'.$entry); + } + } + $dir_handle->close(); + } + } + } parent::onRunJob(); } diff --git a/server/lib/classes/cron.d/500-backup_mail.inc.php b/server/lib/classes/cron.d/500-backup_mail.inc.php index 8740c5512f884f9dbf8dce0afe844fdc4b78606b..89cb1673b45530cc28bd6ffe71d4a322ba11409d 100644 --- a/server/lib/classes/cron.d/500-backup_mail.inc.php +++ b/server/lib/classes/cron.d/500-backup_mail.inc.php @@ -31,6 +31,7 @@ class cronjob_backup_mail extends cronjob { // job schedule protected $_schedule = '0 0 * * *'; + private $tmp_backup_dir = ''; /* this function is optional if it contains no custom code */ public function onPrepare() { @@ -51,7 +52,8 @@ class cronjob_backup_mail extends cronjob { $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); - + $global_config = $app->getconf->get_global_config('sites'); + $backup_dir = $server_config['backup_dir']; $backup_dir_permissions =0750; @@ -59,19 +61,11 @@ class cronjob_backup_mail extends cronjob { if($backup_mode == '') $backup_mode = 'userzip'; if($backup_dir != '') { - //* mount backup directory, if necessary $run_backups = true; - $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); - if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ - if(!$app->system->is_mounted($backup_dir)){ - exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); - sleep(1); - if(!$app->system->is_mounted($backup_dir)) $run_backups = false; - } - } + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $run_backups = false; - $sql = "SELECT * FROM mail_user WHERE server_id = '".intval($conf['server_id'])."' AND maildir <> ''"; - $records = $app->db->queryAllRecords($sql); + $records = $app->db->queryAllRecords("SELECT * FROM mail_user WHERE server_id = ? AND maildir != ''", intval($conf['server_id'])); if(is_array($records) && $run_backups) { if(!is_dir($backup_dir)) { @@ -83,45 +77,98 @@ class cronjob_backup_mail extends cronjob { foreach($records as $rec) { //* Do the mailbox backup if($rec['backup_interval'] == 'daily' or ($rec['backup_interval'] == 'weekly' && date('w') == 0) or ($rec['backup_interval'] == 'monthly' && date('d') == '01')) { - $email = $rec['email'][1]; - $sql="SELECT * FROM mail_domain WHERE domain = ?" . $app->db->quote(explode("@",$email))."'"; - unset($email); - $domain_rec=$app->db->queryOneRecord($sql); + $email = $rec['email']; + $temp = explode("@",$email); + $domain = $temp[1]; + unset($temp);; + $domain_rec=$app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain = ?", $domain); + + $backupusername = 'root'; + $backupgroup = 'root'; + if ($global_config['backups_include_into_web_quota'] == 'y') { + // this only works, if mail and webdomains are on the same server + // find webdomain fitting to maildomain + $sql = "SELECT * FROM web_domain WHERE domain = ?"; + $webdomain = $app->db->queryOneRecord($sql, $domain_rec['domain']); + // if this is not also the website, find website now + if ($webdomain && ($webdomain['parent_domain_id'] != 0)) { + do { + $sql = "SELECT * FROM web_domain WHERE domain_id = ?"; + $webdomain = $app->db->queryOneRecord($sql, $webdomain['parent_domain_id']); + } while ($webdomain && ($webdomain['parent_domain_id'] != 0)); + } + // if webdomain is found, change username/group now + if ($webdomain) { + $backupusername = $webdomain['system_user']; + $backupgroup = $webdomain['system_group']; + } + } $mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id']; if(!is_dir($mail_backup_dir)) mkdir($mail_backup_dir, 0750); chmod($mail_backup_dir, $backup_dir_permissions); + chown($mail_backup_dir, $backupusername); + chgrp($mail_backup_dir, $backupgroup); $mail_backup_file = 'mail'.$rec['mailuser_id'].'_'.date('Y-m-d_H-i'); - $domain_dir=explode('/',$rec['maildir']); - $_temp=array_pop($domain_dir);unset($_temp); - $domain_dir=implode('/',$domain_dir); - - $parts=explode('/',$rec['maildir']); - $source_dir=array_pop($parts); - unset($parts); - - //* create archives - if($backup_mode == 'userzip') { - $mail_backup_file.='.zip'; - exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/nul', $tmp_output, $retval); - } else { - /* Create a tar.gz backup */ - $mail_backup_file.='.tar.gz'; - exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval); + // in case of mdbox -> create backup with doveadm before zipping + if ($rec['maildir_format'] == 'mdbox') { + if (empty($this->tmp_backup_dir)) $this->tmp_backup_dir = $rec['maildir']; + // Create temporary backup-mailbox + exec("su -c 'dsync backup -u \"".$rec["email"]."\" mdbox:".$this->tmp_backup_dir."/backup'", $tmp_output, $retval); + + if($backup_mode == 'userzip') { + $mail_backup_file.='.zip'; + exec('cd '.$this->tmp_backup_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r backup > /dev/null && rm -rf backup', $tmp_output, $retval); + } + else { + $mail_backup_file.='.tar.gz'; + exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$this->tmp_backup_dir.' backup && rm -rf '.$this->tmp_backup_dir.'/backup'), $tmp_output, $retval); + } + + if ($retval != 0) { + // Cleanup + if (file_exists($this->tmp_backup_dir.'/backup')) exec('rm -rf '.$this->tmp_backup_dir.'/backup'); + } } + else { + $domain_dir=explode('/',$rec['maildir']); + $_temp=array_pop($domain_dir);unset($_temp); + $domain_dir=implode('/',$domain_dir); + + $parts=explode('/',$rec['maildir']); + $source_dir=array_pop($parts); + unset($parts); + + //* create archives + if($backup_mode == 'userzip') { + $mail_backup_file.='.zip'; + exec('cd '.$domain_dir.' && zip '.$mail_backup_dir.'/'.$mail_backup_file.' -b /tmp -r '.$source_dir.' > /dev/null', $tmp_output, $retval); + } else { + /* Create a tar.gz backup */ + $mail_backup_file.='.tar.gz'; + exec(escapeshellcmd('tar pczf '.$mail_backup_dir.'/'.$mail_backup_file.' --directory '.$domain_dir.' '.$source_dir), $tmp_output, $retval); + } + } + if($retval == 0){ - chown($mail_backup_dir.'/'.$mail_backup_file, 'root'); - chgrp($mail_backup_dir.'/'.$mail_backup_file, 'root'); + chown($mail_backup_dir.'/'.$mail_backup_file, $backupusername); + chgrp($mail_backup_dir.'/'.$mail_backup_file, $backupgroup); chmod($mail_backup_dir.'/'.$mail_backup_file, 0640); /* Insert mail backup record in database */ - $sql = "INSERT INTO mail_backup (server_id,parent_domain_id,mailuser_id,backup_mode,tstamp,filename,filesize) VALUES (".$conf['server_id'].",".$domain_rec['domain_id'].",".$rec['mailuser_id'].",'".$backup_mode."',".time().",'".$app->db->quote($mail_backup_file)."','".$app->functions->formatBytes(filesize($mail_backup_dir.'/'.$mail_backup_file))."')"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $filesize = filesize($mail_backup_dir.'/'.$mail_backup_file); + $sql = "INSERT INTO mail_backup (server_id, parent_domain_id, mailuser_id, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)"; + $app->db->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id'], $backup_mode, time(), $mail_backup_file, $filesize); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id'], $backup_mode, time(), $mail_backup_file, $filesize); + unset($filesize); } else { /* Backup failed - remove archive */ if(is_file($mail_backup_dir.'/'.$mail_backup_file)) unlink($mail_backup_dir.'/'.$mail_backup_file); + // And remove backup-mdbox + if ($rec['maildir_format'] == 'mdbox') { + if(file_exists($rec['maildir'].'/backup')) exec("su -c 'rm -rf ".$rec['maildir']."/backup'"); + } $app->log($mail_backup_file.' NOK:'.implode('',$tmp_output), LOGLEVEL_DEBUG); } /* Remove old backups */ @@ -138,9 +185,9 @@ class cronjob_backup_mail extends cronjob { for ($n = $backup_copies; $n <= 10; $n++) { if(isset($files[$n]) && is_file($mail_backup_dir.'/'.$files[$n])) { unlink($mail_backup_dir.'/'.$files[$n]); - $sql = "DELETE FROM mail_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$domain_rec['domain_id']." AND filename = '".$app->db->quote($files[$n])."'"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?"; + $app->db->query($sql, $conf['server_id'], $domain_rec['domain_id'], $files[$n]); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $domain_rec['domain_id'], $files[$n]); } } unset($files); @@ -149,9 +196,9 @@ class cronjob_backup_mail extends cronjob { /* Remove inactive backups */ if($rec['backup_interval'] == 'none') { /* remove backups from db */ - $sql = "DELETE FROM mail_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$domain_rec['domain_id']." AND mailuser_id = ".$rec['mailuser_id']; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ? AND mailuser_id = ?"; + $app->db->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id']); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $domain_rec['domain_id'], $rec['mailuser_id']); /* remove archives */ $mail_backup_dir = $backup_dir.'/mail'.$rec['domain_id']; $mail_backup_file = 'mail'.$rec['mailuser_id'].'_*'; @@ -162,7 +209,8 @@ class cronjob_backup_mail extends cronjob { } } } - } + if( $server_config['backup_dir_is_mount'] == 'y' ) $app->system->umount_backup_dir($backup_dir); + } //* end run_backups } parent::onRunJob(); diff --git a/server/lib/classes/cron.d/600-cleanup.inc.php b/server/lib/classes/cron.d/600-cleanup.inc.php index 8222fe54d0e59524ff3e5e9e494982cf21f1ecd2..e55c2599b959dda4fe0994c36b301625744732a2 100644 --- a/server/lib/classes/cron.d/600-cleanup.inc.php +++ b/server/lib/classes/cron.d/600-cleanup.inc.php @@ -58,8 +58,8 @@ class cronjob_cleanup extends cronjob { $records = $app->db->queryAllRecords("SELECT s.instance_id, s.name, s.value FROM `aps_instances_settings` as s INNER JOIN `aps_instances` as i ON (i.id = s.instance_id) WHERE s.value != '' AND s.name IN ('main_database_password', 'admin_password') AND i.instance_status > 1"); if(is_array($records)) { foreach($records as $rec) { - $tmp = $app->db->queryOneRecord("SELECT id FROM aps_instances_settings WHERE instance_id = '".$app->db->quote($rec['instance_id'])."' AND name = '".$app->db->quote($rec['name'])."'"); - $app->db->datalogUpdate('aps_instances_settings', "value = ''", 'id', $tmp['id']); + $tmp = $app->db->queryOneRecord("SELECT id FROM aps_instances_settings WHERE instance_id = ? AND name = ?", $rec['instance_id'], $rec['name']); + $app->db->datalogUpdate('aps_instances_settings', array("value" => ''), 'id', $tmp['id']); } } } diff --git a/server/lib/classes/cron.d/600-purge_mailboxes.inc.php b/server/lib/classes/cron.d/600-purge_mailboxes.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..181dd517f6af91cb3c2e7eff0ee5a6984c9d0ad2 --- /dev/null +++ b/server/lib/classes/cron.d/600-purge_mailboxes.inc.php @@ -0,0 +1,77 @@ +db->queryAllRecords($sql); + + if(is_array($records)) { + foreach($records as $rec){ + exec("su -c 'doveadm purge -u \"".$rec["email"]."\"'"); + } + } + + parent::onRunJob(); + } + + /* this function is optional if it contains no custom code */ + public function onAfterRun() { + global $app; + + parent::onAfterRun(); + } + +} + +?> diff --git a/server/lib/classes/cronjob.inc.php b/server/lib/classes/cronjob.inc.php index 7fe90c2fd66f664475dda125551ae5751a711ca9..03e36e774dde239a8836075da554368ee6923757 100644 --- a/server/lib/classes/cronjob.inc.php +++ b/server/lib/classes/cronjob.inc.php @@ -76,7 +76,7 @@ class cronjob { // check the run time and values for this job // get previous run data - $data = $app->db->queryOneRecord("SELECT `last_run`, `next_run`, `running` FROM `sys_cron` WHERE `name` = '" . $app->db->quote(get_class($this)) . "'"); + $data = $app->db->queryOneRecord("SELECT `last_run`, `next_run`, `running` FROM `sys_cron` WHERE `name` = ?", get_class($this)); if($data) { if($data['last_run']) $this->_last_run = $data['last_run']; if($data['next_run']) $this->_next_run = $data['next_run']; @@ -90,7 +90,7 @@ class cronjob { $next_run = $app->cron->getNextRun(ISPConfigDateTime::dbtime()); $this->_next_run = $next_run; - $app->db->query("REPLACE INTO `sys_cron` (`name`, `last_run`, `next_run`, `running`) VALUES ('" . $app->db->quote(get_class($this)) . "', " . ($this->_last_run ? "'" . $app->db->quote($this->_last_run) . "'" : "NULL") . ", " . ($next_run === false ? "NULL" : "'" . $app->db->quote($next_run) . "'") . ", " . ($this->_running == true ? "1" : "0") . ")"); + $app->db->query("REPLACE INTO `sys_cron` (`name`, `last_run`, `next_run`, `running`) VALUES (?, ?, ?, ?)", get_class($this), ($this->_last_run ? $this->_last_run : "#NULL#"), ($next_run === false ? "#NULL#" : $next_run . "'"), ($this->_running == true ? "1" : "0")); } } } @@ -131,7 +131,7 @@ class cronjob { print "Jobs next run is now " . $next_run . "\n"; - $app->db->query("REPLACE INTO `sys_cron` (`name`, `last_run`, `next_run`, `running`) VALUES ('" . $app->db->quote(get_class($this)) . "', NOW(), " . ($next_run === false ? "NULL" : "'" . $app->db->quote($next_run) . "'") . ", 1)"); + $app->db->query("REPLACE INTO `sys_cron` (`name`, `last_run`, `next_run`, `running`) VALUES (?, NOW(), ?, 1)", get_class($this), ($next_run === false ? "#NULL#" : $next_run)); return true; } @@ -154,7 +154,7 @@ class cronjob { global $app; print "Called onCompleted() for class " . get_class($this) . "\n"; - $app->db->query("UPDATE `sys_cron` SET `running` = 0 WHERE `name` = '" . $app->db->quote(get_class($this)) . "'"); + $app->db->query("UPDATE `sys_cron` SET `running` = 0 WHERE `name` = ?", get_class($this)); } } diff --git a/server/lib/classes/db_mysql.inc.php b/server/lib/classes/db_mysql.inc.php index 51cad86f04c8d2209c3a144d1c575f3245ea6ee1..bf4351974cda72b4efc7f335c827a08fef1ec767 100644 --- a/server/lib/classes/db_mysql.inc.php +++ b/server/lib/classes/db_mysql.inc.php @@ -36,6 +36,7 @@ class db extends mysqli private $_iConnId; private $dbHost = ''; // hostname of the MySQL server + private $dbPort = ''; // port of the MySQL server private $dbName = ''; // logical database name on that server private $dbUser = ''; // database authorized user private $dbPass = ''; // user's password @@ -54,17 +55,20 @@ class db extends mysqli private $autoCommit = 1; // Autocommit Transactions private $currentRow; // current row number public $errorNumber = 0; // last error number + */ public $errorMessage = ''; // last error message + /* private $errorLocation = '';// last error location private $isConnected = false; // needed to know if we have a valid mysqli object from the constructor //// */ // constructor - public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL) { + public function __construct($host = NULL , $user = NULL, $pass = NULL, $database = NULL, $port = NULL) { global $app, $conf; $this->dbHost = $host ? $host : $conf['db_host']; + $this->dbPort = $port ? $port : $conf['db_port']; $this->dbName = $database ? $database : $conf['db_database']; $this->dbUser = $user ? $user : $conf['db_user']; $this->dbPass = $pass ? $pass : $conf['db_password']; @@ -72,13 +76,13 @@ class db extends mysqli $this->dbNewLink = $conf['db_new_link']; $this->dbClientFlags = $conf['db_client_flags']; - $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass); + $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort); $try = 0; while((!is_object($this->_iConnId) || mysqli_connect_error()) && $try < 5) { if($try > 0) sleep(1); $try++; - $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass); + $this->_iConnId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, (int)$this->dbPort); } if(!is_object($this->_iConnId) || mysqli_connect_error()) { @@ -86,7 +90,7 @@ class db extends mysqli $this->_sqlerror('Zugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!'); return false; } - if(!((bool)mysqli_query( $this->_iConnId, "USE $this->dbName"))) { + if(!((bool)mysqli_query( $this->_iConnId, 'USE `' . $this->dbName . '`'))) { $this->close(); $this->_sqlerror('Datenbank nicht gefunden / Database not found'); return false; @@ -132,8 +136,10 @@ class db extends mysqli if($iPos2 !== false && ($iPos === false || $iPos2 <= $iPos)) { $sTxt = $this->escape($sValue); - if(strpos($sTxt, '.') !== false) $sTxt = preg_replace('/^(.+)\.(.+)$/', '`$1`.`$2`', $sTxt); - else $sTxt = '`' . $sTxt . '`'; + if(strpos($sTxt, '.') !== false) { + $sTxt = preg_replace('/^(.+)\.(.+)$/', '`$1`.`$2`', $sTxt); + $sTxt = str_replace('.`*`', '.*', $sTxt); + } else $sTxt = '`' . $sTxt . '`'; $sQuery = substr_replace($sQuery, $sTxt, $iPos2, 2); $iPos2 += strlen($sTxt); @@ -141,13 +147,17 @@ class db extends mysqli } else { if(is_int($sValue) || is_float($sValue)) { $sTxt = $sValue; - } elseif(is_string($sValue) && (strcmp($sValue, '#NULL#') == 0)) { + } elseif(is_null($sValue) || (is_string($sValue) && (strcmp($sValue, '#NULL#') == 0))) { $sTxt = 'NULL'; } elseif(is_array($sValue)) { - $sTxt = ''; - foreach($sValue as $sVal) $sTxt .= ',\'' . $this->escape($sVal) . '\''; - $sTxt = '(' . substr($sTxt, 1) . ')'; - if($sTxt == '()') $sTxt = '(0)'; + if(isset($sValue['SQL'])) { + $sTxt = $sValue['SQL']; + } else { + $sTxt = ''; + foreach($sValue as $sVal) $sTxt .= ',\'' . $this->escape($sVal) . '\''; + $sTxt = '(' . substr($sTxt, 1) . ')'; + if($sTxt == '()') $sTxt = '(0)'; + } } else { $sTxt = '\'' . $this->escape($sValue) . '\''; } @@ -176,7 +186,7 @@ class db extends mysqli private function _query($sQuery = '') { global $app; - if($this->isConnected == false) return false; + //if($this->isConnected == false) return false; if ($sQuery == '') { $this->_sqlerror('Keine Anfrage angegeben / No query given'); return false; @@ -187,7 +197,7 @@ class db extends mysqli $try++; $ok = mysqli_ping($this->_iConnId); if(!$ok) { - if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) { + if(!mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName, (int)$this->dbPort)) { if($this->errorNumber == '111') { // server is not available if($try > 9) { @@ -389,6 +399,35 @@ class db extends mysqli + /** + * check if a utf8 string is valid + * + * @access public + * @param string $string the string to check + * @return bool true if it is valid utf8, false otherwise + */ + private function check_utf8($str) { + $len = strlen($str); + for($i = 0; $i < $len; $i++){ + $c = ord($str[$i]); + if ($c > 128) { + if (($c > 247)) return false; + elseif ($c > 239) $bytes = 4; + elseif ($c > 223) $bytes = 3; + elseif ($c > 191) $bytes = 2; + else return false; + if (($i + $bytes) > $len) return false; + while ($bytes > 1) { + $i++; + $b = ord($str[$i]); + if ($b < 128 || $b > 191) return false; + $bytes--; + } + } + } + return true; + } // end of check_utf8 + /** * Escape a string for usage in a query * @@ -405,16 +444,16 @@ class db extends mysqli $sString = ''; } - /*$cur_encoding = mb_detect_encoding($sString); + $cur_encoding = mb_detect_encoding($sString); if($cur_encoding != "UTF-8") { if($cur_encoding != 'ASCII') { - $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_WARN); + $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_INFO); if($cur_encoding) $sString = mb_convert_encoding($sString, 'UTF-8', $cur_encoding); else $sString = mb_convert_encoding($sString, 'UTF-8'); } - } elseif(!PXBase::check_utf8($sString)) { + } elseif(!$this->check_utf8($sString)) { $sString = utf8_encode($sString); - }*/ + } if($this->_iConnId) return mysqli_real_escape_string($this->_iConnId, $sString); else return addslashes($sString); @@ -430,6 +469,7 @@ class db extends mysqli $mysql_error = (is_object($this->_iConnId) ? mysqli_error($this->_iConnId) : mysqli_connect_error()); $mysql_errno = (is_object($this->_iConnId) ? mysqli_errno($this->_iConnId) : mysqli_connect_errno()); + $this->errorMessage = $mysql_error; //$sAddMsg .= getDebugBacktrace(); @@ -586,20 +626,27 @@ class db extends mysqli if(is_array($insert_data)) { $key_str = ''; $val_str = ''; + $params = array($tablename); + $v_params = array(); foreach($insert_data as $key => $val) { - $key_str .= "`".$key ."`,"; - $val_str .= "'".$this->escape($val)."',"; + $key_str .= '??,'; + $params[] = $key; + + $val_str .= '?,'; + $v_params[] = $val; } $key_str = substr($key_str, 0, -1); $val_str = substr($val_str, 0, -1); $insert_data_str = '('.$key_str.') VALUES ('.$val_str.')'; + $this->query("INSERT INTO ?? $insert_data_str", true, $params + $v_params); } else { + /* TODO: deprecate this method! */ $insert_data_str = $insert_data; + $this->query("INSERT INTO ?? $insert_data_str", $tablename); + $app->log("deprecated use of passing values to datalogInsert() - table " . $tablename, 1); } - /* TODO: reduce risk of insert_data_str! */ - + $old_rec = array(); - $this->query("INSERT INTO ?? $insert_data_str", $tablename); $index_value = $this->insertID(); $new_rec = $this->queryOneRecord("SELECT * FROM ?? WHERE ? = ?", $tablename, $index_field, $index_value); $this->datalogSave($tablename, 'INSERT', $index_field, $index_value, $old_rec, $new_rec); @@ -614,17 +661,24 @@ class db extends mysqli $old_rec = $this->queryOneRecord("SELECT * FROM ?? WHERE ?? = ?", $tablename, $index_field, $index_value); if(is_array($update_data)) { + $params = array($tablename); $update_data_str = ''; foreach($update_data as $key => $val) { - $update_data_str .= "`".$key ."` = '".$this->escape($val)."',"; + $update_data_str .= '?? = ?,'; + $params[] = $key; + $params[] = $val; } + $params[] = $index_field; + $params[] = $index_value; $update_data_str = substr($update_data_str, 0, -1); + $this->query("UPDATE ?? SET $update_data_str WHERE ?? = ?", true, $params); } else { + /* TODO: deprecate this method! */ $update_data_str = $update_data; + $this->query("UPDATE ?? SET $update_data_str WHERE ?? = ?", $tablename, $index_field, $index_value); + $app->log("deprecated use of passing values to datalogUpdate() - table " . $tablename, 1); } - /* TODO: reduce risk of update_data_str */ - $this->query("UPDATE ?? SET $update_data_str WHERE ?? = ?", $tablename, $index_field, $index_value); $new_rec = $this->queryOneRecord("SELECT * FROM ?? WHERE ?? = ?", $tablename, $index_field, $index_value); $this->datalogSave($tablename, 'UPDATE', $index_field, $index_value, $old_rec, $new_rec, $force_update); @@ -647,7 +701,7 @@ class db extends mysqli public function datalogError($errormsg) { global $app; - if(isset($app->modules->current_datalog_id) && $app->modules->current_datalog_id > 0) $this->query("UPDATE sys_datalog set error = '".$this->quote($errormsg)."' WHERE datalog_id = ".$app->modules->current_datalog_id); + if(isset($app->modules->current_datalog_id) && $app->modules->current_datalog_id > 0) $this->query("UPDATE sys_datalog set error = ? WHERE datalog_id = ?", $errormsg, $app->modules->current_datalog_id); return true; } diff --git a/server/lib/classes/functions.inc.php b/server/lib/classes/functions.inc.php index be555031fd5ddc297154745539796bc0dde39d1d..5632a58753dc8a99431e7f409e53b9fedd232bee 100644 --- a/server/lib/classes/functions.inc.php +++ b/server/lib/classes/functions.inc.php @@ -237,7 +237,7 @@ class functions { } $ips = array(); - $results = $app->db->queryAllRecords("SELECT ip_address AS ip FROM server_ip WHERE ip_type = '".$type."'"); + $results = $app->db->queryAllRecords("SELECT ip_address AS ip FROM server_ip WHERE ip_type = ?", $type); if(!empty($results) && is_array($results)){ foreach($results as $result){ if(preg_match($regex, $result['ip'])) $ips[] = $result['ip']; diff --git a/server/lib/classes/getconf.inc.php b/server/lib/classes/getconf.inc.php index 768ea2cabded44ab9ee56039d28ccc8fdaff7a89..2c20971adb3ead87e2b3893d4201176ab48e71c4 100644 --- a/server/lib/classes/getconf.inc.php +++ b/server/lib/classes/getconf.inc.php @@ -38,7 +38,7 @@ class getconf { if(!is_array($this->config[$server_id])) { $app->uses('ini_parser'); $server_id = intval($server_id); - $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id); + $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = ?', $server_id); $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config'])); } diff --git a/server/lib/classes/modules.inc.php b/server/lib/classes/modules.inc.php index 194bf4f51abc191c5e3072c1e7eddd5dd13f0061..e5ccaaf1141088685934c9f2dec7b4757df2b540 100644 --- a/server/lib/classes/modules.inc.php +++ b/server/lib/classes/modules.inc.php @@ -85,12 +85,12 @@ class modules { //* If its a multiserver setup if($app->db->dbHost != $app->dbmaster->dbHost || ($app->db->dbHost == $app->dbmaster->dbHost && $app->db->dbName != $app->dbmaster->dbName)) { if($conf['mirror_server_id'] > 0) { - $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf['server_id']." OR server_id = ".$conf['mirror_server_id']." OR server_id = 0) ORDER BY datalog_id LIMIT 0,1000"; + $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ? AND (server_id = ? OR server_id = ? OR server_id = 0) ORDER BY datalog_id LIMIT 0,1000"; } else { - $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf['server_id']." OR server_id = 0) ORDER BY datalog_id LIMIT 0,1000"; + $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ? AND (server_id = ? OR server_id = 0) ORDER BY datalog_id LIMIT 0,1000"; } - $records = $app->dbmaster->queryAllRecords($sql); + $records = $app->dbmaster->queryAllRecords($sql, $conf['last_datalog_id'], $conf['server_id'], $conf['mirror_server_id']); foreach($records as $d) { //** encode data to utf-8 and unserialize it @@ -133,46 +133,38 @@ class modules { $idx = explode(':', $d['dbidx']); $tmp_sql1 = ''; $tmp_sql2 = ''; + $f_params = array($d['dbtable']); + $params = array(); foreach($data['new'] as $fieldname => $val) { - $tmp_sql1 .= "`$fieldname`,"; - $tmp_sql2 .= "'".$app->db->quote($val)."',"; + $tmp_sql1 .= "??,"; + $tmp_sql2 .= "?,"; + $f_params[] = $fieldname; + $params[] = $val; } + $params = $f_params + $params; + unset($f_params); + $tmp_sql1 = substr($tmp_sql1, 0, -1); $tmp_sql2 = substr($tmp_sql2, 0, -1); //$tmp_sql1 .= "$idx[0]"; //$tmp_sql2 .= "$idx[1]"; - $sql = "REPLACE INTO $d[dbtable] ($tmp_sql1) VALUES ($tmp_sql2)"; + $sql = "REPLACE INTO ?? ($tmp_sql1) VALUES ($tmp_sql2)"; $app->db->errorNumber = 0; $app->db->errorMessage = ''; - $app->db->query($sql); + $app->db->query($sql, true, $params); + unset($params); if($app->db->errorNumber > 0) { $replication_error = true; $app->log("Replication failed. Error: (" . $d['dbtable'] . ") in MySQL server: (".$app->db->dbHost.") " . $app->db->errorMessage . " # SQL: " . $sql, LOGLEVEL_ERROR); } $app->log('Replicated from master: '.$sql, LOGLEVEL_DEBUG); } - /* - if($d["action"] == 'u') { - $sql = "UPDATE $d[dbtable] SET "; - foreach($data['new'] as $fieldname => $val) { - $sql .= "`$fieldname` = '$val',"; - } - $sql = substr($sql,0,-1); - $idx = explode(":",$d["dbidx"]); - $sql .= " WHERE $idx[0] = $idx[1]"; - $app->db->query($sql); - if($app->db->errorNumber > 0) { - $replication_error = true; - $app->log("Replication failed. Error: (" . $d[dbtable] . ") " . $app->db->errorMessage . " # SQL: " . $sql,LOGLEVEL_ERROR); - } - $app->log("Replicated from master: ".$sql,LOGLEVEL_DEBUG); - } - */ + if($d['action'] == 'd') { $idx = explode(':', $d['dbidx']); - $sql = "DELETE FROM $d[dbtable] "; - $sql .= " WHERE $idx[0] = $idx[1]"; - $app->db->query($sql); + $sql = "DELETE FROM ?? "; + $sql .= " WHERE ?? = ?"; + $app->db->query($sql, $d['dbtable'], $idx[0], $idx[1]); if($app->db->errorNumber > 0) { $replication_error = true; $app->log("Replication failed. Error: (" . $d[dbtable] . ") " . $app->db->errorMessage . " # SQL: " . $sql, LOGLEVEL_ERROR); @@ -183,12 +175,12 @@ class modules { if($replication_error == false) { if(is_array($data['old']) || is_array($data['new'])) { - $app->db->query("UPDATE server SET updated = ".$d["datalog_id"]." WHERE server_id = ".$conf['server_id']); + $app->db->query("UPDATE server SET updated = ? WHERE server_id = ?", $d["datalog_id"], $conf['server_id']); $this->raiseTableHook($d['dbtable'], $d['action'], $data); } else { $app->log('Data array was empty for datalog_id '.$d['datalog_id'], LOGLEVEL_WARN); } - $app->dbmaster->query("UPDATE server SET updated = ".$d["datalog_id"]." WHERE server_id = ".$conf['server_id']); + $app->dbmaster->query("UPDATE server SET updated = ? WHERE server_id = ?", $d["datalog_id"], $conf['server_id']); $app->log('Processed datalog_id '.$d['datalog_id'], LOGLEVEL_DEBUG); } else { $app->log('Error in Replication, changes were not processed.', LOGLEVEL_ERROR); @@ -205,23 +197,14 @@ class modules { //* if we have a single server setup } else { - $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ".$conf['last_datalog_id']." AND (server_id = ".$conf['server_id']." OR server_id = 0) ORDER BY datalog_id LIMIT 0,1000"; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM sys_datalog WHERE datalog_id > ? AND (server_id = ? OR server_id = 0) ORDER BY datalog_id LIMIT 0,1000"; + $records = $app->db->queryAllRecords($sql, $conf['last_datalog_id'], $conf['server_id']); foreach($records as $d) { //** encode data to utf-8 to be able to unserialize it and then unserialize it if(!$data = unserialize(stripslashes($d['data']))) { $data = unserialize($d['data']); } - //** decode data back to current locale - /* - foreach($data['old'] as $key => $val) { - $data['old'][$key] = utf8_decode($val); - } - foreach($data['new'] as $key => $val) { - $data['new'][$key] = utf8_decode($val); - } - */ //* Data on a single server is never mirrored $data['mirrored'] = false; @@ -232,9 +215,7 @@ class modules { } else { $app->log('Data array was empty for datalog_id '.$d['datalog_id'], LOGLEVEL_WARN); } - //$app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]); - //$app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG); - $app->db->query("UPDATE server SET updated = ".$d['datalog_id']." WHERE server_id = ".$conf['server_id']); + $app->db->query("UPDATE server SET updated = ? WHERE server_id = ?", $d['datalog_id'], $conf['server_id']); $app->log('Processed datalog_id '.$d['datalog_id'], LOGLEVEL_DEBUG); } } @@ -251,11 +232,11 @@ class modules { //* SQL query to get all pending actions $sql = "SELECT action_id, action_type, action_param " . "FROM sys_remoteaction " . - "WHERE server_id = " . $server_id . " ". - " AND action_id > " . intval($maxid_remote_action) . " ". + "WHERE server_id = ? ". + " AND action_id > ? ". "ORDER BY action_id"; - $actions = $app->dbmaster->queryAllRecords($sql); + $actions = $app->dbmaster->queryAllRecords($sql, $server_id, $maxid_remote_action); if(is_array($actions)) { foreach($actions as $action) { @@ -265,9 +246,9 @@ class modules { //* Update the action state $sql = "UPDATE sys_remoteaction " . - "SET action_state = '" . $app->dbmaster->quote($state) . "' " . - "WHERE action_id = " . intval($action['action_id']); - $app->dbmaster->query($sql); + "SET action_state = ? " . + "WHERE action_id = ?"; + $app->dbmaster->query($sql, $state, $action['action_id']); /* * Then save the maxid for the next time... diff --git a/server/lib/classes/monitor_tools.inc.php b/server/lib/classes/monitor_tools.inc.php index 50eb45b0dd074bbd433b5fa1724c734be024b051..4e25d38691745000aac90c76068397fc805dd7de 100644 --- a/server/lib/classes/monitor_tools.inc.php +++ b/server/lib/classes/monitor_tools.inc.php @@ -62,6 +62,9 @@ class monitor_tools { $mainver = array_filter($mainver); $mainver = current($mainver).'.'.next($mainver); switch ($mainver){ + case "15.04": + $relname = "(Vivid Vervet)"; + break; case "14.10": $relname = "(Utopic Unicorn)"; break; @@ -149,6 +152,11 @@ class monitor_tools { $distver = 'Wheezy/Sid'; $distid = 'debian60'; $distbaseid = 'debian'; + } elseif(strstr(trim(file_get_contents('/etc/debian_version')), '8') || substr(trim(file_get_contents('/etc/debian_version')),0,1) == '8') { + $distname = 'Debian'; + $distver = 'Jessie'; + $distid = 'debian60'; + $distbaseid = 'debian'; } else { $distname = 'Debian'; $distver = 'Unknown'; @@ -259,7 +267,7 @@ class monitor_tools { $server_id = intval($conf['server_id']); /** get the "active" Services of the server from the DB */ - $services = $app->db->queryOneRecord('SELECT * FROM server WHERE server_id = ' . $server_id); + $services = $app->db->queryOneRecord('SELECT * FROM server WHERE server_id = ?', $server_id); /* * If the DB is down, we have to set the db to "yes". * If we don't do this, then the monitor will NOT monitor, that the db is down and so the @@ -670,12 +678,12 @@ class monitor_tools { */ $sql = 'DELETE FROM monitor_data ' . 'WHERE ' . - ' type =' . "'" . $app->dbmaster->quote($type) . "' " . + ' type = ?' . 'AND ' . - ' created < ' . $old . ' ' . + ' created < ? ' . 'AND ' . - ' server_id = ' . $serverId; - $app->dbmaster->query($sql); + ' server_id = ?'; + $app->dbmaster->query($sql, $type, $old, $serverId); } public function send_notification_email($template, $placeholders, $recipients) { diff --git a/server/lib/classes/system.inc.php b/server/lib/classes/system.inc.php index 952df1a4071deac4e7b2840fc9b442db2749efdb..98fc51fdef84cf4a018eb9a927224ad525608c6e 100644 --- a/server/lib/classes/system.inc.php +++ b/server/lib/classes/system.inc.php @@ -1801,6 +1801,36 @@ class system{ return $return_var == 0 ? true : false; } + function mount_backup_dir($backup_dir, $mount_cmd = '/usr/local/ispconfig/server/scripts/backup_dir_mount.sh'){ + $mounted = true; + if ( is_file($mount_cmd) && + is_executable($mount_cmd) && + fileowner($mount_cmd) === 0 + ) { + if (!$this->is_mounted($backup_dir)){ + exec($mount_cmd); + sleep(1); + if (!$this->is_mounted($backup_dir)) $mounted = false; + } + } else $mounted = false; + + return $mounted; + } + + function umount_backup_dir($backup_dir, $mount_cmd = '/usr/local/ispconfig/server/scripts/backup_dir_umount.sh'){ + if ( is_file($mount_cmd) && + is_executable($mount_cmd) && + fileowner($mount_cmd) === 0 + ) { + if ($this->is_mounted($backup_dir)){ + exec($mount_cmd); + sleep(1); + } + } + + return $this->is_mounted($backup_dir) == 0 ? true : false; + } + function getinitcommand($servicename, $action, $init_script_directory = ''){ global $conf; // upstart diff --git a/server/mods-available/remoteaction_core_module.inc.php b/server/mods-available/remoteaction_core_module.inc.php index 08649531b579fbc079a5614b7c6c165e2034c27f..807de5060ab28bfbee5257760b812e60ba65a655 100644 --- a/server/mods-available/remoteaction_core_module.inc.php +++ b/server/mods-available/remoteaction_core_module.inc.php @@ -62,10 +62,8 @@ class remoteaction_core_module { * First set the state */ global $app; - $sql = "UPDATE sys_remoteaction " . - "SET action_state = '" . $app->dbmaster->quote($state) . "' " . - "WHERE action_id = " . intval($id); - $app->dbmaster->query($sql); + $sql = "UPDATE sys_remoteaction SET action_state = ? WHERE action_id = ?"; + $app->dbmaster->query($sql, $state, $id); /* * Then save the maxid for the next time... @@ -103,12 +101,8 @@ class remoteaction_core_module { /* * Get all actions this server should execute */ - $sql = "SELECT action_id, action_type, action_param " . - "FROM sys_remoteaction " . - "WHERE server_id = " . $server_id . " ". - " AND action_id > " . intval($maxid_remote_action) . " ". - "ORDER BY action_id"; - $actions = $app->dbmaster->queryAllRecords($sql); + $sql = "SELECT action_id, action_type, action_param FROM sys_remoteaction WHERE server_id = ? AND action_id > ? ORDER BY action_id"; + $actions = $app->dbmaster->queryAllRecords($sql, $server_id, $maxid_remote_action); /* * process all actions diff --git a/server/mods-available/xmpp_module.inc.php b/server/mods-available/xmpp_module.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..aace2567d6bd29f7945526ea1c1a3b36d2646343 --- /dev/null +++ b/server/mods-available/xmpp_module.inc.php @@ -0,0 +1,130 @@ +plugins->announceEvents($this->module_name, $this->actions_available); + + /* + As we want to get notified of any changes on several database tables, + we register for them. + + The following function registers the function "functionname" + to be executed when a record for the table "dbtable" is + processed in the sys_datalog. "classname" is the name of the + class that contains the function functionname. + */ + + $app->modules->registerTableHook('xmpp_domain', 'xmpp_module', 'process'); + $app->services->registerService('metronome', 'xmpp_module', 'reloadXMPP'); + $app->services->registerService('metronome', 'xmpp_module', 'restartXMPP'); + + } + + /* + This function is called when a change in one of the registered tables is detected. + The function then raises the events for the plugins. + */ + + function process($tablename, $action, $data) { + global $app; + + switch ($tablename) { + case 'xmpp_domain': + if($action == 'i') $app->plugins->raiseEvent('xmpp_domain_insert', $data); + if($action == 'u') $app->plugins->raiseEvent('xmpp_domain_update', $data); + if($action == 'd') $app->plugins->raiseEvent('xmpp_domain_delete', $data); + break; + case 'xmpp_user': + if($action == 'i') $app->plugins->raiseEvent('xmpp_user_insert', $data); + if($action == 'u') $app->plugins->raiseEvent('xmpp_user_update', $data); + if($action == 'd') $app->plugins->raiseEvent('xmpp_user_delete', $data); + break; + } // end switch + } // end function + + + function restartXMPP($action = 'restart') { + global $app, $conf; + + // load the server configuration options + $app->uses('getconf,system'); + + $daemon = 'metronome'; + + $retval = array('output' => '', 'retval' => 0); + if($action == 'restart') { + $cmd = $app->system->getinitcommand($daemon, 'restart'); + } else { + $cmd = $app->system->getinitcommand($daemon, 'reload'); + } + exec($cmd.' 2>&1', $retval['output'], $retval['retval']); + $app->log("Restarting xmpp: $cmd", LOGLEVEL_DEBUG); + return $retval; + } +} // end class + +?> diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php index e6ca66fab88ead362850676840682a84eb221f32..e518f45cbf8235508dd69f54c77df602e195b878 100644 --- a/server/plugins-available/apache2_plugin.inc.php +++ b/server/plugins-available/apache2_plugin.inc.php @@ -108,23 +108,27 @@ class apache2_plugin { * php_version -> php ini path that changed (additional php versions) */ + $param = ''; $qrystr = "SELECT * FROM web_domain WHERE custom_php_ini != ''"; if($data['mode'] == 'mod') { $qrystr .= " AND php = 'mod'"; } elseif($data['mode'] == 'fast-cgi') { $qrystr .= " AND php = 'fast-cgi'"; if($data['php_version']) { - $qrystr .= " AND fastcgi_php_version LIKE '%:" . $app->db->quote($data['php_version']) . "'"; + $qrystr .= " AND fastcgi_php_version LIKE ?"; + $param = '%:' . $data['php_version']; } } elseif($data['mode'] == 'php-fpm') { $qrystr .= " AND php = 'php-fpm'"; if($data['php_version']) { - $qrystr .= " AND fastcgi_php_version LIKE '%:" . $app->db->quote($data['php_version']) . ":%'"; + $qrystr .= " AND fastcgi_php_version LIKE ?"; + $param = '%:' . $data['php_version'] . ':%'; } } elseif($data['mode'] == 'hhvm') { $qrystr .= " AND php = 'hhvm'"; if($data['php_version']) { - $qrystr .= " AND fastcgi_php_version LIKE '%:" . $app->db->quote($data['php_version']) . ":%'"; + $qrystr .= " AND fastcgi_php_version LIKE ?"; + $param = '%:' . $data['php_version'] . ':%'; } } else { $qrystr .= " AND php != 'mod' AND php != 'fast-cgi'"; @@ -132,7 +136,7 @@ class apache2_plugin { //** Get all the webs - $web_domains = $app->db->queryAllRecords($qrystr); + $web_domains = $app->db->queryAllRecords($qrystr, $param); foreach($web_domains as $web_data) { $custom_php_ini_dir = $web_config['website_basedir'].'/conf/'.$web_data['system_user']; $web_folder = 'web'; @@ -157,6 +161,26 @@ class apache2_plugin { if($master_php_ini_path != '' && substr($master_php_ini_path, -7) == 'php.ini' && is_file($master_php_ini_path)) { $php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n"; } + + if(intval($web_data['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($web_data['directive_snippets_id'])); + if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){ + $required_php_snippets = explode(',', trim($snippet['required_php_snippets'])); + if(is_array($required_php_snippets) && !empty($required_php_snippets)){ + foreach($required_php_snippets as $required_php_snippet){ + $required_php_snippet = intval($required_php_snippet); + if($required_php_snippet > 0){ + $php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet); + $php_snippet['snippet'] = trim($php_snippet['snippet']); + if($php_snippet['snippet'] != ''){ + $web_data['custom_php_ini'] .= "\n".$php_snippet['snippet']; + } + } + } + } + } + } + $php_ini_content .= str_replace("\r", '', trim($web_data['custom_php_ini'])); $app->system->file_put_contents($custom_php_ini_dir.'/php.ini', $php_ini_content); $app->log('Info: rewrote custom php.ini for web ' . $web_data['domain_id'] . ' (' . $web_data['domain'] . ').', LOGLEVEL_DEBUG); @@ -303,15 +327,15 @@ class apache2_plugin { $app->system->chmod($key_file2, 0400); @$app->system->unlink($config_file); @$app->system->unlink($rand_file); - $ssl_request = $app->db->quote($app->system->file_get_contents($csr_file)); - $ssl_cert = $app->db->quote($app->system->file_get_contents($crt_file)); - $ssl_key2 = $app->db->quote($app->system->file_get_contents($key_file2)); + $ssl_request = $app->system->file_get_contents($csr_file); + $ssl_cert = $app->system->file_get_contents($crt_file); + $ssl_key2 = $app->system->file_get_contents($key_file2); /* Update the DB of the (local) Server */ - $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert', ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'"); - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_request = ?, ssl_cert = ?, ssl_key = ? WHERE domain = ?", $ssl_request, $ssl_cert, $ssl_key2, $data['new']['domain']); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); /* Update also the master-DB of the Server-Farm */ - $app->dbmaster->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert', ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'"); - $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_request = ?, ssl_cert = ?, ssl_key = ? WHERE domain = ?", $ssl_request, $ssl_cert, $ssl_key2, $data['new']['domain']); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); } //* Save a SSL certificate to disk @@ -355,18 +379,18 @@ class apache2_plugin { $app->system->file_put_contents($key_file2, $data["new"]["ssl_key"]); $app->system->chmod($key_file2, 0400); } else { - $ssl_key2 = $app->db->quote($app->system->file_get_contents($key_file2)); + $ssl_key2 = $app->system->file_get_contents($key_file2); /* Update the DB of the (local) Server */ - $app->db->query("UPDATE web_domain SET ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_key = ? WHERE domain = ?", $ssl_key2, $data['new']['domain']); /* Update also the master-DB of the Server-Farm */ - $app->dbmaster->query("UPDATE web_domain SET ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_key = ? WHERE domain = ?", $ssl_key2, $data['new']['domain']); } /* Update the DB of the (local) Server */ - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); /* Update also the master-DB of the Server-Farm */ - $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); $app->log('Saving SSL Cert for: '.$domain, LOGLEVEL_DEBUG); } @@ -386,11 +410,11 @@ class apache2_plugin { $app->system->unlink($crt_file); $app->system->unlink($bundle_file); /* Update the DB of the (local) Server */ - $app->db->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = '".$data['new']['domain']."'"); - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = ?", $data['new']['domain']); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); /* Update also the master-DB of the Server-Farm */ - $app->dbmaster->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = '".$data['new']['domain']."'"); - $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = ?", $data['new']['domain']); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); $app->log('Deleting SSL Cert for: '.$domain, LOGLEVEL_DEBUG); } @@ -420,7 +444,7 @@ class apache2_plugin { // If the parent_domain_id has been changed, we will have to update the old site as well. if($this->action == 'update' && $data['new']['parent_domain_id'] != $data['old']['parent_domain_id']) { - $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$old_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ? AND active = ?', $old_parent_domain_id, 'y'); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -428,7 +452,7 @@ class apache2_plugin { } // This is not a vhost, so we need to update the parent record instead. - $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$new_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = ? AND active = ', $new_parent_domain_id, 'y'); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -466,7 +490,7 @@ class apache2_plugin { $old_log_folder = 'log'; if($data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias') { // new one - $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['new']['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $data['new']['parent_domain_id']); $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['new']['domain']); if($subdomain_host == '') $subdomain_host = 'web'.$data['new']['domain_id']; $web_folder = $data['new']['web_folder']; @@ -475,7 +499,7 @@ class apache2_plugin { if(isset($data['old']['parent_domain_id'])) { // old one - $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['old']['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $data['old']['parent_domain_id']); $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['old']['domain']); if($subdomain_host == '') $subdomain_host = 'web'.$data['old']['domain_id']; $old_web_folder = $data['old']['web_folder']; @@ -529,7 +553,7 @@ class apache2_plugin { if($this->action == 'update' && $data['new']['document_root'] != $data['old']['document_root']) { //* Get the old client ID - $old_client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid'])); + $old_client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = ?', $data['old']['sys_groupid']); $old_client_id = intval($old_client['client_id']); unset($old_client); @@ -671,7 +695,7 @@ class apache2_plugin { $app->system->web_folder_protection($data['new']['document_root'], true); // Get the client ID - $client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['new']['sys_groupid'])); + $client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = ?', $data['new']['sys_groupid']); $client_id = intval($client['client_id']); unset($client); @@ -1004,6 +1028,26 @@ class apache2_plugin { $php_ini_content .= $app->system->file_get_contents($master_php_ini_path)."\n"; } $php_ini_content .= str_replace("\r", '', trim($data['new']['custom_php_ini'])); + + if(intval($data['new']['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); + if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){ + $required_php_snippets = explode(',', trim($snippet['required_php_snippets'])); + if(is_array($required_php_snippets) && !empty($required_php_snippets)){ + foreach($required_php_snippets as $required_php_snippet){ + $required_php_snippet = intval($required_php_snippet); + if($required_php_snippet > 0){ + $php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet); + $php_snippet['snippet'] = trim($php_snippet['snippet']); + if($php_snippet['snippet'] != ''){ + $php_ini_content .= "\n".$php_snippet['snippet']; + } + } + } + } + } + } + $app->system->file_put_contents($custom_php_ini_dir.'/php.ini', $php_ini_content); } else { $has_custom_php_ini = false; @@ -1030,6 +1074,12 @@ class apache2_plugin { $vhost_data['custom_php_ini_dir'] = escapeshellcmd($custom_php_ini_dir); // Custom Apache directives + if(intval($data['new']['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'apache' AND active = 'y' AND customer_viewable = 'y'", $data['new']['directive_snippets_id']); + if(isset($snippet['snippet'])){ + $vhost_data['apache_directives'] = $snippet['snippet']; + } + } // Make sure we only have Unix linebreaks $vhost_data['apache_directives'] = str_replace("\r\n", "\n", $vhost_data['apache_directives']); $vhost_data['apache_directives'] = str_replace("\r", "\n", $vhost_data['apache_directives']); @@ -1131,7 +1181,7 @@ class apache2_plugin { $auto_alias = $web_config['website_autoalias']; if($auto_alias != '') { // get the client username - $client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = '" . intval($client_id) . "'"); + $client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = ?", $client_id); $aa_search = array('[client_id]', '[website_id]', '[client_username]', '[website_domain]'); $aa_replace = array($client_id, $data['new']['domain_id'], $client['username'], $data['new']['domain']); $auto_alias = str_replace($aa_search, $aa_replace, $auto_alias); @@ -1142,7 +1192,7 @@ class apache2_plugin { } // get alias domains (co-domains and subdomains) - $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND (type != 'vhostsubdomain' AND type != 'vhostalias')"); + $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ? AND active = 'y' AND (type != 'vhostsubdomain' AND type != 'vhostalias')", $data['new']['domain_id']); $alias_seo_redirects = array(); switch($data['new']['subdomain']) { case 'www': @@ -1373,6 +1423,7 @@ class apache2_plugin { } else { $pool_dir = $custom_php_fpm_pool_dir; } + $pool_dir = trim($pool_dir); if(substr($pool_dir, -1) != '/') $pool_dir .= '/'; $pool_name = 'web'.$data['new']['domain_id']; $socket_dir = escapeshellcmd($web_config['php_fpm_socket_dir']); @@ -1786,7 +1837,7 @@ class apache2_plugin { $log_folder = 'log'; $web_folder = ''; if($data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias') { - $tmp = $app->db->queryOneRecord('SELECT `domain`,`document_root` FROM web_domain WHERE domain_id = '.intval($data['old']['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain`,`document_root` FROM web_domain WHERE domain_id = ?', $data['old']['parent_domain_id']); if($tmp['domain'] != ''){ $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['old']['domain']); } else { @@ -1858,7 +1909,7 @@ class apache2_plugin { if($data['old']['type'] != 'vhost' && $data['old']['type'] != 'vhostsubdomain' && $data['old']['type'] != 'vhostalias' && $data['old']['parent_domain_id'] > 0) { //* This is a alias domain or subdomain, so we have to update the website instead $parent_domain_id = intval($data['old']['parent_domain_id']); - $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $parent_domain_id); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -1912,7 +1963,7 @@ class apache2_plugin { } else { // read all vhost subdomains and alias with same parent domain $used_paths = array(); - $tmp = $app->db->queryAllRecords("SELECT `web_folder` FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ".intval($data['old']['parent_domain_id'])." AND domain_id != ".intval($data['old']['domain_id'])); + $tmp = $app->db->queryAllRecords("SELECT `web_folder` FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ? AND domain_id != ?", $data['old']['parent_domain_id'], $data['old']['domain_id']); foreach($tmp as $tmprec) { // we normalize the folder entries because we need to compare them $tmp_folder = preg_replace('/[\/]{2,}/', '/', $tmprec['web_folder']); // replace / occuring multiple times @@ -1994,7 +2045,7 @@ class apache2_plugin { $app->log('Removing website: '.$docroot, LOGLEVEL_DEBUG); // Delete the symlinks for the sites - $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid'])); + $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = ?', $data['old']['sys_groupid']); $client_id = intval($client['client_id']); unset($client); $tmp_symlinks_array = explode(':', $web_config['website_symlinks']); @@ -2048,25 +2099,19 @@ class apache2_plugin { if($data['old']['type'] == 'vhost') { $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir']; - //* mount backup directory, if necessary $mount_backup = true; - $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); if($server_config['backup_dir'] != '' && $server_config['backup_delete'] == 'y') { - if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ - if(!$app->system->is_mounted($backup_dir)){ - exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); - sleep(1); - if(!$app->system->is_mounted($backup_dir)) $mount_backup = false; - } - } + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $mount_backup = false; + if($mount_backup){ $web_backup_dir = $backup_dir.'/web'.$data_old['domain_id']; //** do not use rm -rf $web_backup_dir because database(s) may exits exec(escapeshellcmd('rm -f '.$web_backup_dir.'/web'.$data_old['domain_id'].'_').'*'); //* cleanup database - $sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$data_old['domain_id']." AND filename LIKE 'web".$data_old['domain_id']."_%'"; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename LIKE ?"; + $app->db->query($sql, $conf['server_id'], $data_old['domain_id'], "web".$data_old['domain_id']."_%"); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $data_old['domain_id'], "web".$data_old['domain_id']."_%"); $app->log('Deleted the web backup files', LOGLEVEL_DEBUG); } @@ -2089,7 +2134,7 @@ class apache2_plugin { $tpl = new tpl(); $tpl->newTemplate('apache_ispconfig.conf.master'); $tpl->setVar('apache_version', $app->system->getapacheversion()); - $records = $app->db->queryAllRecords('SELECT * FROM server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'"); + $records = $app->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ? AND virtualhost = 'y'", $conf['server_id']); $records_out= array(); if(is_array($records)) { @@ -2135,8 +2180,8 @@ class apache2_plugin { $folder_id = $data['new']['web_folder_id']; } - $folder = $app->db->queryOneRecord("SELECT * FROM web_folder WHERE web_folder_id = ".intval($folder_id)); - $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($folder['parent_domain_id'])); + $folder = $app->db->queryOneRecord("SELECT * FROM web_folder WHERE web_folder_id = ?", $folder_id); + $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $folder['parent_domain_id']); if(!is_array($folder) or !is_array($website)) { $app->log('Not able to retrieve folder or website record.', LOGLEVEL_DEBUG); @@ -2172,19 +2217,6 @@ class apache2_plugin { $app->log('Created file '.$folder_path.'.htpasswd', LOGLEVEL_DEBUG); } - /* - $auth_users = $app->db->queryAllRecords("SELECT * FROM web_folder_user WHERE active = 'y' AND web_folder_id = ".intval($folder_id)); - $htpasswd_content = ''; - if(is_array($auth_users) && !empty($auth_users)){ - foreach($auth_users as $auth_user){ - $htpasswd_content .= $auth_user['username'].':'.$auth_user['password']."\n"; - } - } - $htpasswd_content = trim($htpasswd_content); - @file_put_contents($folder_path.'.htpasswd', $htpasswd_content); - $app->log('Changed .htpasswd file: '.$folder_path.'.htpasswd',LOGLEVEL_DEBUG); - */ - if(($data['new']['username'] != $data['old']['username'] || $data['new']['active'] == 'n') && $data['old']['username'] != '') { $app->system->removeLine($folder_path.'.htpasswd', $data['old']['username'].':'); $app->log('Removed user: '.$data['old']['username'], LOGLEVEL_DEBUG); @@ -2235,7 +2267,7 @@ class apache2_plugin { $folder_id = $data['old']['web_folder_id']; $folder = $data['old']; - $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($folder['parent_domain_id'])); + $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $folder['parent_domain_id']); if(!is_array($folder) or !is_array($website)) { $app->log('Not able to retrieve folder or website record.', LOGLEVEL_DEBUG); @@ -2290,7 +2322,7 @@ class apache2_plugin { function web_folder_update($event_name, $data) { global $app, $conf; - $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['new']['parent_domain_id'])); + $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); if(!is_array($website)) { $app->log('Not able to retrieve folder or website record.', LOGLEVEL_DEBUG); @@ -2450,7 +2482,7 @@ class apache2_plugin { /* * Get additional informations */ - $sitedata = $app->db->queryOneRecord('SELECT document_root, domain, system_user, system_group FROM web_domain WHERE domain_id = ' . $data['new']['parent_domain_id']); + $sitedata = $app->db->queryOneRecord('SELECT document_root, domain, system_user, system_group FROM web_domain WHERE domain_id = ?', $data['new']['parent_domain_id']); $documentRoot = $sitedata['document_root']; $domain = $sitedata['domain']; $user = $sitedata['system_user']; @@ -2538,7 +2570,7 @@ class apache2_plugin { /* * Get additional informations */ - $sitedata = $app->db->queryOneRecord('SELECT document_root, domain FROM web_domain WHERE domain_id = ' . $data['old']['parent_domain_id']); + $sitedata = $app->db->queryOneRecord('SELECT document_root, domain FROM web_domain WHERE domain_id = ?', $data['old']['parent_domain_id']); $documentRoot = $sitedata['document_root']; $domain = $sitedata['domain']; @@ -2768,23 +2800,70 @@ class apache2_plugin { } else { $content = file_get_contents($conf['rootpath'] . '/conf/hhvm_starter.master'); } + if(file_exists($conf['rootpath'] . '/conf-custom/hhvm_monit.master')) { + $monit_content = file_get_contents($conf['rootpath'] . '/conf-custom/hhvm_monit.master'); + } else { + $monit_content = file_get_contents($conf['rootpath'] . '/conf/hhvm_monit.master'); + } + + if($data['new']['php'] == 'hhvm' && $data['old']['php'] != 'hhvm' || $data['new']['custom_php_ini'] != $data['old']['custom_php_ini']) { - if($data['new']['php'] == 'hhvm' && $data['old']['php'] != 'hhvm') { + // Custom php.ini settings + $custom_php_ini_settings = trim($data['new']['custom_php_ini']); + if(intval($data['new']['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); + if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){ + $required_php_snippets = explode(',', trim($snippet['required_php_snippets'])); + if(is_array($required_php_snippets) && !empty($required_php_snippets)){ + foreach($required_php_snippets as $required_php_snippet){ + $required_php_snippet = intval($required_php_snippet); + if($required_php_snippet > 0){ + $php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet); + $php_snippet['snippet'] = trim($php_snippet['snippet']); + if($php_snippet['snippet'] != ''){ + $custom_php_ini_settings .= "\n".$php_snippet['snippet']; + } + } + } + } + } + } + if($custom_php_ini_settings != ''){ + // Make sure we only have Unix linebreaks + $custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings); + $custom_php_ini_settings = str_replace("\r", "\n", $custom_php_ini_settings); + file_put_contents('/etc/hhvm/'.$data['new']['system_user'].'.ini', $custom_php_ini_settings); + } else { + if(is_file('/etc/hhvm/'.$data['old']['system_user'].'.ini')) unlink('/etc/hhvm/'.$data['old']['system_user'].'.ini'); + } + $content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $content); file_put_contents('/etc/init.d/hhvm_' . $data['new']['system_user'], $content); exec('chmod +x /etc/init.d/hhvm_' . $data['new']['system_user'] . ' >/dev/null 2>&1'); exec('/usr/sbin/update-rc.d hhvm_' . $data['new']['system_user'] . ' defaults >/dev/null 2>&1'); exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' start >/dev/null 2>&1'); + + $monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content); + file_put_contents('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'], $monit_content); + exec('/etc/init.d/monit restart >/dev/null 2>&1'); + } elseif($data['new']['php'] != 'hhvm' && $data['old']['php'] == 'hhvm') { exec('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' stop >/dev/null 2>&1'); exec('/usr/sbin/update-rc.d hhvm_' . $data['old']['system_user'] . ' remove >/dev/null 2>&1'); - unlink('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' >/dev/null 2>&1'); + unlink('/etc/init.d/hhvm_' . $data['old']['system_user']); + if(is_file('/etc/hhvm/'.$data['old']['system_user'].'.ini')) unlink('/etc/hhvm/'.$data['old']['system_user'].'.ini'); + + if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){ + unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']); + exec('/etc/init.d/monit restart >/dev/null 2>&1'); + } } } //* Update the PHP-FPM pool configuration file private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name, $socket_dir) { global $app, $conf; + $pool_dir = trim($pool_dir); //$reload = false; if($data['new']['php'] == 'php-fpm'){ @@ -2873,6 +2952,26 @@ class apache2_plugin { // Custom php.ini settings $final_php_ini_settings = array(); $custom_php_ini_settings = trim($data['new']['custom_php_ini']); + + if(intval($data['new']['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'apache' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); + if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){ + $required_php_snippets = explode(',', trim($snippet['required_php_snippets'])); + if(is_array($required_php_snippets) && !empty($required_php_snippets)){ + foreach($required_php_snippets as $required_php_snippet){ + $required_php_snippet = intval($required_php_snippet); + if($required_php_snippet > 0){ + $php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet); + $php_snippet['snippet'] = trim($php_snippet['snippet']); + if($php_snippet['snippet'] != ''){ + $custom_php_ini_settings .= "\n".$php_snippet['snippet']; + } + } + } + } + } + } + if($custom_php_ini_settings != ''){ // Make sure we only have Unix linebreaks $custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings); @@ -2916,7 +3015,7 @@ class apache2_plugin { unset($tpl); // delete pool in all other PHP versions - $default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); + $default_pool_dir = trim(escapeshellcmd($web_config['php_fpm_pool_dir'])); if(substr($default_pool_dir, -1) != '/') $default_pool_dir .= '/'; if($default_pool_dir != $pool_dir){ if ( @is_file($default_pool_dir.$pool_name.'.conf') ) { @@ -2925,9 +3024,10 @@ class apache2_plugin { $app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); } } - $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$conf["server_id"]); + $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?", $conf["server_id"]); if(is_array($php_versions) && !empty($php_versions)){ foreach($php_versions as $php_version){ + $php_version['php_fpm_pool_dir'] = trim($php_version['php_fpm_pool_dir']); if(substr($php_version['php_fpm_pool_dir'], -1) != '/') $php_version['php_fpm_pool_dir'] .= '/'; if($php_version['php_fpm_pool_dir'] != $pool_dir){ if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) { @@ -2968,6 +3068,7 @@ class apache2_plugin { } else { $pool_dir = $custom_php_fpm_pool_dir; } + $pool_dir = trim($pool_dir); if(substr($pool_dir, -1) != '/') $pool_dir .= '/'; $pool_name = 'web'.$data['old']['domain_id']; @@ -2980,7 +3081,7 @@ class apache2_plugin { } // delete pool in all other PHP versions - $default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); + $default_pool_dir = trim(escapeshellcmd($web_config['php_fpm_pool_dir'])); if(substr($default_pool_dir, -1) != '/') $default_pool_dir .= '/'; if($default_pool_dir != $pool_dir){ if ( @is_file($default_pool_dir.$pool_name.'.conf') ) { @@ -2989,9 +3090,10 @@ class apache2_plugin { $app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); } } - $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$data['old']['server_id']); + $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?", $data['old']['server_id']); if(is_array($php_versions) && !empty($php_versions)){ foreach($php_versions as $php_version){ + $php_version['php_fpm_pool_dir'] = trim($php_version['php_fpm_pool_dir']); if(substr($php_version['php_fpm_pool_dir'], -1) != '/') $php_version['php_fpm_pool_dir'] .= '/'; if($php_version['php_fpm_pool_dir'] != $pool_dir){ if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) { diff --git a/server/plugins-available/backup_plugin.inc.php b/server/plugins-available/backup_plugin.inc.php index 42c1d772a8be0a08f10e049bfad08e6c07bfa49c..cb9911de2676c30f30310a5b6fab5a49ebbe94f3 100644 --- a/server/plugins-available/backup_plugin.inc.php +++ b/server/plugins-available/backup_plugin.inc.php @@ -53,7 +53,9 @@ class backup_plugin { //* Register for actions $app->plugins->registerAction('backup_download', $this->plugin_name, 'backup_action'); $app->plugins->registerAction('backup_restore', $this->plugin_name, 'backup_action'); - + //$app->plugins->registerAction('backup_download_mail', $this->plugin_name, 'backup_action_mail'); + $app->plugins->registerAction('backup_restore_mail', $this->plugin_name, 'backup_action_mail'); + } //* Do a backup action @@ -61,47 +63,25 @@ class backup_plugin { global $app, $conf; $backup_id = intval($data); - $backup = $app->dbmaster->queryOneRecord("SELECT * FROM web_backup WHERE backup_id = $backup_id"); - $mail_backup = $app->dbmaster->queryOneRecord("SELECT * FROM mail_backup WHERE backup_id = $backup_id"); + $backup = $app->dbmaster->queryOneRecord("SELECT * FROM web_backup WHERE backup_id = ?", $backup_id); if(is_array($backup)) { $app->uses('ini_parser,file,getconf,system'); - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$backup['parent_domain_id']); + $web = $app->dbmaster->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $backup['parent_domain_id']); $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir'].'/web'.$web['domain_id']; - //* mount backup directory, if necessary - /* - $backup_dir_is_ready = true; - $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); - if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ - if(!$app->system->is_mounted($server_config['backup_dir'])){ - exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); - sleep(1); - if(!$app->system->is_mounted($server_config['backup_dir'])) $backup_dir_is_ready = false; - } - }*/ $backup_dir_is_ready = true; - $backup_dir_mount_cmd = '/usr/local/ispconfig/server/scripts/backup_dir_mount.sh'; - if( $server_config['backup_dir_is_mount'] == 'y' && - is_file($backup_dir_mount_cmd) && - is_executable($backup_dir_mount_cmd) && - fileowner($backup_dir_mount_cmd) === 0 - ){ - if(!$app->system->is_mounted($backup_dir)){ - exec($backup_dir_mount_cmd); - sleep(1); - if(!$app->system->is_mounted($server_config['backup_dir'])) $backup_dir_is_ready = false; - } - } + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($server_config['backup_dir']) ) $backup_dir_is_ready = false; if($backup_dir_is_ready){ //* Make backup available for download if($action_name == 'backup_download') { //* Copy the backup file to the backup folder of the website - if(file_exists($backup_dir.'/'.$backup['filename']) && !stristr($backup_dir.'/'.$backup['filename'], '..') && !stristr($backup_dir.'/'.$backup['filename'], 'etc')) { + if(file_exists($backup_dir.'/'.$backup['filename']) && file_exists($web['document_root'].'/backup/') && !stristr($backup_dir.'/'.$backup['filename'], '..') && !stristr($backup_dir.'/'.$backup['filename'], 'etc')) { copy($backup_dir.'/'.$backup['filename'], $web['document_root'].'/backup/'.$backup['filename']); chgrp($web['document_root'].'/backup/'.$backup['filename'], $web['system_group']); $app->log('cp '.$backup_dir.'/'.$backup['filename'].' '.$web['document_root'].'/backup/'.$backup['filename'], LOGLEVEL_DEBUG); @@ -176,71 +156,120 @@ class backup_plugin { } } } + if( $server_config['backup_dir_is_mount'] == 'y' ) $app->system->umount_backup_dir($backup_dir); } else { $app->log('Backup directory not ready.', LOGLEVEL_DEBUG); } - //* Restore a mail backup - florian@schaal-24.de - } elseif (is_array($mail_backup) && $action_name == 'backup_restore') { - $app->uses('ini_parser,file,getconf'); + } else { + $app->log('No backup with ID '.$backup_id.' found.', LOGLEVEL_DEBUG); + } + + return 'ok'; + } + //* Restore a mail backup - florian@schaal-24.de + public function backup_action_mail($action_name, $data) { + global $app, $conf; + + $backup_id = intval($data); + $mail_backup = $app->dbmaster->queryOneRecord("SELECT * FROM mail_backup WHERE backup_id = ?", $backup_id); + + if (is_array($mail_backup) && $action_name == 'backup_restore_mail') { + $app->uses('ini_parser,file,getconf'); + $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir']; - - //* mount backup directory, if necessary $backup_dir_is_ready = true; - $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); - if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ - if(!$app->system->is_mounted($backup_dir)){ - exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); - sleep(1); - if(!$app->system->is_mounted($backup_dir)) $backup_dir_is_ready = false; - } - } - + + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $backup_dir_is_ready = false; + if($backup_dir_is_ready){ $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); - $domain_rec = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain_id = ".intval($mail_backup['parent_domain_id'])); - + $domain_rec = $app->db->queryOneRecord("SELECT * FROM mail_domain WHERE domain_id = ?", $mail_backup['parent_domain_id']); + $backup_dir = $server_config['backup_dir'].'/mail'.$domain_rec['domain_id']; $mail_backup_file = $backup_dir.'/'.$mail_backup['filename']; - - $sql = "SELECT * FROM mail_user WHERE server_id = '".$conf['server_id']."' AND mailuser_id = ".intval($mail_backup['mailuser_id']); - $record = $app->db->queryOneRecord($sql); - + + $sql = "SELECT * FROM mail_user WHERE server_id = ? AND mailuser_id = ?"; + $record = $app->db->queryOneRecord($sql, $conf['server_id'], $mail_backup['mailuser_id']); + //* strip mailbox from maildir $domain_dir=explode('/',$record['maildir']); $_temp=array_pop($domain_dir);unset($_temp); $domain_dir=implode('/',$domain_dir); - + if(!is_dir($domain_dir)) { mkdir($domain_dir, 0700); //* never create the full path chown($domain_dir, $mail_config['mailuser_name']); chgrp($domain_dir, $mail_config['mailuser_group']); } - - if(file_exists($mail_backup_file) && $record['homedir'] != '' && $record['homedir'] != '/' && !stristr($mail_backup_file,'..') && !stristr($mail_backup_file,'etc') && $mail_config['homedir_path'] == $record['homedir'] && is_dir($domain_dir)) { - if($mail_backup['backup_mode'] == 'userzip') { - copy($mail_backup_file, $domain_dir.'/'.$mail_backup['filename']); - chgrp($domain_dir.'/'.$mail_backup['filename'], $mail_config['mailuser_group']); - $command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o '.escapeshellarg($domain_dir.'/'.$mail_backup['filename']).' -d '.escapeshellarg($domain_dir).' 2> /dev/null'; - exec($command,$tmp_output, $retval); - unlink($domain_dir.'/'.$mail_backup['filename']); + if (!is_dir($record['maildir'])) { + mkdir($record['maildir'], 0700); //* never create the full path + chown($record['maildir'], $mail_config['mailuser_name']); + chgrp($record['maildir'], $mail_config['mailuser_group']); + } + + if(file_exists($mail_backup_file) && $record['homedir'] != '' && $record['homedir'] != '/' && !stristr($mail_backup_file,'..') && !stristr($mail_backup_file,'etc') && $mail_config['homedir_path'] == $record['homedir'] && is_dir($domain_dir) && is_dir($record['maildir'])) { + if ($record['maildir_format'] == 'mdbox') { + $retval = -1; + // First unzip backupfile to local backup-folder + if($mail_backup['backup_mode'] == 'userzip') { + copy($mail_backup_file, $record['maildir'].'/'.$mail_backup['filename']); + chgrp($record['maildir'].'/'.$mail_backup['filename'], $mail_config['mailuser_group']); + $command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o '.escapeshellarg($record['maildir'].'/'.$mail_backup['filename']).' -d '.escapeshellarg($record['maildir']).' 2> /dev/null'; + exec($command,$tmp_output, $retval); + unlink($record['maildir'].'/'.$mail_backup['filename']); + } + if($mail_backup['backup_mode'] == 'rootgz') { + $command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($record['maildir']); + exec($command,$tmp_output, $retval); + } + + if($retval == 0) { + // Now import backup-mailbox into special backup-folder + $backupname = "backup-".date("Y-m-d", $mail_backup['tstamp']); + exec("doveadm mailbox create -u \"".$record["email"]."\" $backupname"); + exec("doveadm import -u \"".$record["email"]."\" mdbox:".$record['maildir']."/backup $backupname all", $tmp_output, $retval); + exec("for f in `doveadm mailbox list -u \"".$record["email"]."\" $backupname*`; do doveadm mailbox subscribe -u \"".$record["email"]."\" \$f; done", $tmp_output, $retval); + exec('rm -rf '.$record['maildir'].'/backup'); + } + if($retval == 0){ $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG); } else { + // cleanup + if (file_exists($record['maildir'].'/'.$mail_backup['filename'])) unlink($record['maildir'].'/'.$mail_backup['filename']); + if (file_exists($record['maildir']."/backup")) exec('rm -rf '.$record['maildir']."/backup"); + $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR); } } - if($mail_backup['backup_mode'] == 'rootgz') { - $command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($domain_dir); - exec($command,$tmp_output, $retval); - if($retval == 0){ - $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG); - } else { - $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR); + else { + if($mail_backup['backup_mode'] == 'userzip') { + copy($mail_backup_file, $domain_dir.'/'.$mail_backup['filename']); + chgrp($domain_dir.'/'.$mail_backup['filename'], $mail_config['mailuser_group']); + $command = 'sudo -u '.$mail_config['mailuser_name'].' unzip -qq -o '.escapeshellarg($domain_dir.'/'.$mail_backup['filename']).' -d '.escapeshellarg($domain_dir).' 2> /dev/null'; + exec($command,$tmp_output, $retval); + unlink($domain_dir.'/'.$mail_backup['filename']); + if($retval == 0){ + $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG); + } else { + $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR); + } + } + if($mail_backup['backup_mode'] == 'rootgz') { + $command='tar xfz '.escapeshellarg($mail_backup_file).' --directory '.escapeshellarg($domain_dir); + exec($command,$tmp_output, $retval); + if($retval == 0){ + $app->log('Restored Mail backup '.$mail_backup_file,LOGLEVEL_DEBUG); + } else { + $app->log('Unable to restore Mail backup '.$mail_backup_file.' '.$tmp_output,LOGLEVEL_ERROR); + } } } } + if( $server_config['backup_dir_is_mount'] == 'y' ) $app->system->umount_backup_dir($backup_dir); } else { $app->log('Backup directory not ready.', LOGLEVEL_DEBUG); } @@ -250,7 +279,8 @@ class backup_plugin { return 'ok'; } - + + } // end class ?> diff --git a/server/plugins-available/bind_dlz_plugin.inc.php b/server/plugins-available/bind_dlz_plugin.inc.php index 63abcc48ced03d6874b8dc5bcab5e1b865985a60..89954ccabb2a5b210d5514e53e22da8d51b59b3c 100644 --- a/server/plugins-available/bind_dlz_plugin.inc.php +++ b/server/plugins-available/bind_dlz_plugin.inc.php @@ -34,7 +34,7 @@ TABLE STRUCTURE of the "named" database: CREATE TABLE IF NOT EXISTS `records` ( `id` int(10) unsigned NOT NULL auto_increment, `zone` varchar(255) NOT NULL, - `ttl` int(11) NOT NULL default '86400', + `ttl` int(11) NOT NULL default '3600', `type` varchar(255) NOT NULL, `host` varchar(255) NOT NULL default '@', `mx_priority` int(11) default NULL, @@ -121,7 +121,7 @@ class bind_dlz_plugin { $origin = substr($data["new"]["origin"], 0, -1); $ispconfig_id = $data["new"]["id"]; - $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id); + $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $ispconfig_id); $ttl = $data["new"]["ttl"]; @@ -129,8 +129,7 @@ class bind_dlz_plugin { //$_db->dbName = 'named'; $app->db->query("INSERT INTO named.records (zone, ttl, type, primary_ns, resp_contact, serial, refresh, retry, expire, minimum, ispconfig_id) VALUES ". - "('$origin', $ttl, 'SOA', '{$data["new"]["ns"]}', '{$data["new"]["mbox"]}', '{$serial["serial"]}', '{$serial["refresh"]}'," . - "'{$serial["retry"]}', '{$serial["expire"]}', '{$serial["minimum"]}', $ispconfig_id)"); + "(?, ?, 'SOA', ?, ?, ?, ?, ?, ?, ?, ?)", $origin, $ttl, $data["new"]["ns"], $data["new"]["mbox"], $serial["serial"], $serial["refresh"], $serial["retry"], $serial["expire"], $serial["minimum"], $ispconfig_id); //unset($_db); } @@ -149,16 +148,14 @@ class bind_dlz_plugin { { $origin = substr($data["new"]["origin"], 0, -1); $ispconfig_id = $data["new"]["id"]; - $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id); + $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $ispconfig_id); $ttl = $data["new"]["ttl"]; //$_db = clone $app->db; //$_db->dbName = 'named'; - $app->db->query("UPDATE named.records SET zone = '$origin', ttl = $ttl, primary_ns = '{$data["new"]["ns"]}', resp_contact = '{$data["new"]["mbox"]}', ". - "serial = '{$serial["serial"]}', refresh = '{$serial["refresh"]}', retry = '{$serial["retry"]}', expire = '{$serial["expire"]}', ". - "minimum = '{$serial["minimum"]}' WHERE ispconfig_id = ".$data["new"]["id"]." AND type = 'SOA'"); + $app->db->query("UPDATE named.records SET zone = ?, ttl = ?, primary_ns = ?, resp_contact = ?, serial = ?, refresh = ?, retry = ?, expire = ?, minimum = ? WHERE ispconfig_id = ? AND type = 'SOA'", $origin, $ttl, $data["new"]["ns"], $data["new"]["mbox"], $serial["serial"], $serial["refresh"], $serial["retry"], $serial["expire"], $serial["minimum"], $data["new"]["id"]); //unset($_db); } else @@ -166,7 +163,7 @@ class bind_dlz_plugin { $this->soa_insert($event_name, $data); $ispconfig_id = $data["new"]["id"]; - if ($records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = $ispconfig_id AND active = 'Y'")) + if ($records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ? AND active = 'Y'", $ispconfig_id)) { foreach($records as $record) { @@ -188,7 +185,7 @@ class bind_dlz_plugin { //$_db = clone $app->db; //$_db->dbName = 'named'; - $app->db->query( "DELETE FROM named.dns_records WHERE zone = '".substr($data['old']['origin'], 0, -1)."'"); + $app->db->query( "DELETE FROM named.dns_records WHERE zone = ?", substr($data['old']['origin'], 0, -1)); //unset($_db); } @@ -197,7 +194,7 @@ class bind_dlz_plugin { global $app, $conf; if($data["new"]["active"] != 'Y') return; - $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]); + $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data["new"]["zone"]); $origin = substr($zone["origin"], 0, -1); $ispconfig_id = $data["new"]["id"]; @@ -251,13 +248,13 @@ class bind_dlz_plugin { if ($type == 'MX') { $app->db->query("INSERT INTO named.records (zone, ttl, type, host, mx_priority, data, ispconfig_id)". - " VALUES ('$origin', $ttl, '$type', '$name', {$data["new"]["aux"]}, '$content', $ispconfig_id)"); + " VALUES (?, ?, ?, ?, ?, ?, ?)", $origin, $ttl, $type, $name, $data["new"]["aux"], $content, $ispconfig_id); } elseif ($type == 'SRV') { $app->db->query("INSERT INTO named.records (zone, ttl, type, data, ispconfig_id)". - " VALUES ('$origin', $ttl, '$type', '{$data["new"]["aux"]} $content', $ispconfig_id)"); + " VALUES (?, ?, ?, ?, ?)", $origin, $ttl, $type, $data["new"]["aux"] . ' ' . $content, $ispconfig_id); } else { $app->db->query("INSERT INTO named.records (zone, ttl, type, host, data, ispconfig_id)". - " VALUES ('$origin', $ttl, '$type', '$name', '$content', $ispconfig_id)"); + " VALUES (?, ?, ?, ?, ?, ?)", $origin, $ttl, $type, $name, $content, $ispconfig_id); } //unset($_db); @@ -276,7 +273,7 @@ class bind_dlz_plugin { { if ($data["old"]["active"] == 'Y') { - $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]); + $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data["new"]["zone"]); $origin = substr($zone["origin"], 0, -1); $ispconfig_id = $data["new"]["id"]; @@ -328,14 +325,11 @@ class bind_dlz_plugin { //$_db->dbName = 'named'; if ($type == 'MX') { - $app->db->query("UPDATE named.records SET zone = '$origin', ttl = $ttl, type = '$type', host = '$name', mx_priority = $prio, ". - "data = '$content' WHERE ispconfig_id = $ispconfig_id AND type != 'SOA'"); + $app->db->query("UPDATE named.records SET zone = ?, ttl = ?, type = ?, host = ?, mx_priority = ?, data = ? WHERE ispconfig_id = ? AND type != 'SOA'", $origin, $ttl, $type, $name, $prio, $content, $ispconfig_id); } elseif ($type == 'SRV') { - $app->db->query("UPDATE named.records SET zone = '$origin', ttl = $ttl, type = '$type', ". - "data = '$prio $content' WHERE ispconfig_id = $ispconfig_id AND type != 'SOA'"); + $app->db->query("UPDATE named.records SET zone = ?, ttl = ?, type = ?, data = ? WHERE ispconfig_id = ? AND type != 'SOA'", $origin, $ttl, $type, $prio . ' ' . $content, $ispconfig_id); } else { - $app->db->query("UPDATE named.records SET zone = '$origin', ttl = $ttl, type = '$type', host = '$name', ". - "data = '$content' WHERE ispconfig_id = $ispconfig_id AND type != 'SOA'"); + $app->db->query("UPDATE named.records SET zone = ?, ttl = ?, type = ?, host = ?, data = ? WHERE ispconfig_id = ? AND type != 'SOA'", $origin, $ttl, $type, $name, $content, $ispconfig_id); } //unset($_db); @@ -351,7 +345,7 @@ class bind_dlz_plugin { //$_db = clone $app->db; //$_db->dbName = 'named'; - $app->db->query( "DELETE FROM named.dns_records WHERE type != 'SOA' AND zone = '".substr($data['old']['origin'], 0, -1)."'"); + $app->db->query( "DELETE FROM named.dns_records WHERE type != 'SOA' AND zone = ?", substr($data['old']['origin'], 0, -1)); //unset($_db); } diff --git a/server/plugins-available/bind_plugin.inc.php b/server/plugins-available/bind_plugin.inc.php index 2f7f93222405fb91b98e9e981fda35880a9f5ddc..bb65eef45b141636decd1df4211dfa9b3db58eaa 100644 --- a/server/plugins-available/bind_plugin.inc.php +++ b/server/plugins-available/bind_plugin.inc.php @@ -102,7 +102,7 @@ class bind_plugin { $zone = $data['new']; $tpl->setVar($zone); - $records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ".$zone['id']." AND active = 'Y'"); + $records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ? AND active = 'Y'", $zone['id']); if(is_array($records) && !empty($records)){ for($i=0;$idb->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data['new']['zone']); + $tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data['new']['zone']); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; @@ -293,7 +293,7 @@ class bind_plugin { global $app, $conf; //* Get the data of the soa and call soa_update - $tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data['new']['zone']); + $tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data['new']['zone']); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; @@ -305,7 +305,7 @@ class bind_plugin { global $app, $conf; //* Get the data of the soa and call soa_update - $tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".intval($data['old']['zone'])); + $tmp = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data['old']['zone']); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; @@ -319,18 +319,10 @@ class bind_plugin { global $app, $conf; //* Only write the master file for the current server - $tmps = $app->db->queryAllRecords("SELECT origin, xfer, also_notify, update_acl FROM dns_soa WHERE active = 'Y' AND server_id=".$conf["server_id"]); + $tmps = $app->db->queryAllRecords("SELECT origin, xfer, also_notify, update_acl FROM dns_soa WHERE active = 'Y' AND server_id=?", $conf["server_id"]); $zones = array(); //* Check if the current zone that triggered this function has at least one NS record - /* Has been replaced by a better zone check - $rec_num = $app->db->queryOneRecord("SELECT count(id) as ns FROM dns_rr WHERE type = 'NS' AND zone = ".intval($data['new']['id'])." AND active = 'Y'"); - if($rec_num['ns'] == 0) { - $exclude_zone = $data['new']['origin']; - } else { - $exclude_zone = ''; - } - */ //TODO : change this when distribution information has been integrated into server record if (file_exists('/etc/gentoo-release')) { @@ -370,7 +362,7 @@ class bind_plugin { $tpl->setLoop('zones', $zones); //* And loop through the secondary zones, but only for the current server - $tmps_sec = $app->db->queryAllRecords("SELECT origin, xfer, ns FROM dns_slave WHERE active = 'Y' AND server_id=".$conf["server_id"]); + $tmps_sec = $app->db->queryAllRecords("SELECT origin, xfer, ns FROM dns_slave WHERE active = 'Y' AND server_id=?", $conf["server_id"]); $zones_sec = array(); foreach($tmps_sec as $tmp) { diff --git a/server/plugins-available/cron_jailkit_plugin.inc.php b/server/plugins-available/cron_jailkit_plugin.inc.php index 4c95b83c2bdb0d9fbbf798e71772c59cc9236f3b..c652f299ebc44dd87c5cc3f1c65f118cdbebb144 100644 --- a/server/plugins-available/cron_jailkit_plugin.inc.php +++ b/server/plugins-available/cron_jailkit_plugin.inc.php @@ -76,7 +76,7 @@ class cron_jailkit_plugin { } //* get data from web - $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `domain` FROM `web_domain` WHERE `domain_id` = ".intval($data["new"]["parent_domain_id"])); + $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `domain` FROM `web_domain` WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); if(!$parent_domain["domain_id"]) { $app->log("Parent domain not found", LOGLEVEL_WARN); return 0; @@ -155,7 +155,7 @@ class cron_jailkit_plugin { return 0; } //* get data from web - $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `domain` FROM `web_domain` WHERE `domain_id` = ".intval($data["new"]["parent_domain_id"])); + $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `domain` FROM `web_domain` WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); if(!$parent_domain["domain_id"]) { $app->log("Parent domain not found", LOGLEVEL_WARN); return 0; @@ -333,7 +333,7 @@ class cron_jailkit_plugin { $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); // Get the parent website of this shell user - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$this->data['new']['parent_domain_id']); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->data['new']['parent_domain_id']); //* If the security level is set to high if($web_config['security_level'] == 20 && is_array($web)) { diff --git a/server/plugins-available/cron_plugin.inc.php b/server/plugins-available/cron_plugin.inc.php index 9bda43345e5f8e41faca808599fb616bc322c908..7d3c1383e0de9b333f899e856af746c4ec305b32 100644 --- a/server/plugins-available/cron_plugin.inc.php +++ b/server/plugins-available/cron_plugin.inc.php @@ -92,7 +92,7 @@ class cron_plugin { } //* get data from web - $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `hd_quota` FROM `web_domain` WHERE `domain_id` = ".intval($data["new"]["parent_domain_id"])); + $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `hd_quota` FROM `web_domain` WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); if(!$parent_domain["domain_id"]) { $app->log("Parent domain not found", LOGLEVEL_WARN); return 0; @@ -105,7 +105,7 @@ class cron_plugin { } // Get the client ID - $client = $app->dbmaster->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"])); + $client = $app->dbmaster->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ?", $data["new"]["sys_groupid"]); $client_id = intval($client["client_id"]); unset($client); @@ -161,14 +161,14 @@ class cron_plugin { global $app, $conf; //* get data from web - $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `hd_quota` FROM `web_domain` WHERE `domain_id` = ".intval($data["old"]["parent_domain_id"])); + $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `hd_quota` FROM `web_domain` WHERE `domain_id` = ?", $data["old"]["parent_domain_id"]); if(!$parent_domain["domain_id"]) { $app->log("Parent domain not found", LOGLEVEL_WARN); return 0; } // Get the client ID - $client = $app->dbmaster->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["old"]["sys_groupid"])); + $client = $app->dbmaster->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ?", $data["old"]["sys_groupid"]); $client_id = intval($client["client_id"]); unset($client); @@ -196,7 +196,7 @@ class cron_plugin { $chr_cmd_count = 0; //* read all active cron jobs from database and write them to file - $cron_jobs = $app->db->queryAllRecords("SELECT c.`run_min`, c.`run_hour`, c.`run_mday`, c.`run_month`, c.`run_wday`, c.`command`, c.`type`, c.`log`, `web_domain`.`domain` as `domain` FROM `cron` as c INNER JOIN `web_domain` ON `web_domain`.`domain_id` = c.`parent_domain_id` WHERE c.`parent_domain_id` = ".intval($this->parent_domain["domain_id"]) . " AND c.`active` = 'y'"); + $cron_jobs = $app->db->queryAllRecords("SELECT c.`run_min`, c.`run_hour`, c.`run_mday`, c.`run_month`, c.`run_wday`, c.`command`, c.`type`, c.`log`, `web_domain`.`domain` as `domain` FROM `cron` as c INNER JOIN `web_domain` ON `web_domain`.`domain_id` = c.`parent_domain_id` WHERE c.`parent_domain_id` = ? AND c.`active` = 'y'", $this->parent_domain["domain_id"]); if($cron_jobs && count($cron_jobs) > 0) { foreach($cron_jobs as $job) { if($job['run_month'] == '@reboot') { @@ -210,7 +210,7 @@ class cron_plugin { $log_root = ''; if($job['log'] == 'y') { if($job['type'] != 'chrooted') $log_root = $this->parent_domain['document_root']; - $log_root .= '/log'; + $log_root .= '/private'; $log_target = '>>' . $log_root . '/cron.log 2>>' . $log_root . '/cron_error.log'; $log_wget_target = $log_root . '/cron_wget.log'; diff --git a/server/plugins-available/firewall_plugin.inc.php b/server/plugins-available/firewall_plugin.inc.php index 2cca769fd525bdced81f9a5698538eb0f375bab8..d3538cc010db958bc1c9b865f2171971921f3d3f 100644 --- a/server/plugins-available/firewall_plugin.inc.php +++ b/server/plugins-available/firewall_plugin.inc.php @@ -38,7 +38,7 @@ class firewall_plugin { public function onInstall() { global $conf; - if($conf['bastille']['installed'] = true && $conf['services']['firewall'] == true) { + if($conf['bastille']['installed'] == true && $conf['services']['firewall'] == true) { return true; } else { return false; diff --git a/server/plugins-available/ftpuser_base_plugin.inc.php b/server/plugins-available/ftpuser_base_plugin.inc.php index d46936100dea724e0f393dec7ba8f461ea4b4492..484a0f7da45dede95f3077bd3c0eeab380aaa86f 100644 --- a/server/plugins-available/ftpuser_base_plugin.inc.php +++ b/server/plugins-available/ftpuser_base_plugin.inc.php @@ -74,7 +74,7 @@ class ftpuser_base_plugin { if(!is_dir($data['new']['dir'])) { $app->log("FTP User directory '".$data['new']['dir']."' does not exist. Creating it now.", LOGLEVEL_DEBUG); - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['new']['parent_domain_id'])); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); //* Check if the resulting path is inside the docroot if(substr($data['new']['dir'], 0, strlen($web['document_root'])) != $web['document_root']) { @@ -100,7 +100,7 @@ class ftpuser_base_plugin { if(!is_dir($data['new']['dir'])) { $app->log("FTP User directory '".$data['new']['dir']."' does not exist. Creating it now.", LOGLEVEL_DEBUG); - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['new']['parent_domain_id'])); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); //* Check if the resulting path is inside the docroot if(substr($data['new']['dir'], 0, strlen($web['document_root'])) != $web['document_root']) { diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index 5ac0951e5f1d849a2ba6b53442442809301ef212..caec01aa2565ee2f4590440f3bb91664b672f369 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -98,10 +98,10 @@ class mail_plugin { if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') { $app->log('Map uid to linux-user',LOGLEVEL_DEBUG); $email_parts = explode('@',$data['new']['email']); - $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain = '".$app->db->quote($email_parts[1])."'"); + $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain = ?", $email_parts[1]); if ($webdomain) { while (($webdomain['system_user'] == null) && ($webdomain['parent_domain_id'] != 0)) { - $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain_id = '".$webdomain['parent_domain_id']."'"); + $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain_id = ?", $webdomain['parent_domain_id']); } $app->log($data['new']['server_id'].' == '.$webdomain['server_id'],LOGLEVEL_DEBUG); @@ -118,7 +118,7 @@ class mail_plugin { $app->log('Mailuser uid: '.$data['new']['uid'].', gid: '.$data['new']['gid'],LOGLEVEL_DEBUG); // update DB if values changed - $app->db->query("UPDATE mail_user SET uid = ".$data['new']['uid'].", gid = ".$data['new']['gid']." WHERE mailuser_id = ".$data['new']['mailuser_id']); + $app->db->query("UPDATE mail_user SET uid = ?, gid = ? WHERE mailuser_id = ?", $data['new']['uid'], $data['new']['gid'], $data['new']['mailuser_id']); // now get names of uid and gid $user = $app->system->getuser($data['new']['uid']); @@ -130,67 +130,80 @@ class mail_plugin { $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG); } - // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. - if($mail_config['pop3_imap_daemon'] == 'dovecot') { - //exec("su -c 'mkdir -p ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - $app->system->mkdirpath($maildomain_path, 0700, $user, $group); - $app->log('Created Directory: '.$maildomain_path, LOGLEVEL_DEBUG); - $maildomain_path .= '/Maildir'; + if ($data['new']['maildir_format'] == 'mdbox') { + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" INBOX'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Sent'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Trash'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Junk'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Drafts'"); + + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" INBOX'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Sent'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Trash'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Junk'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Drafts'"); } - - //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder - if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { - if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); - exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail"); - $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN); - } - - //* Create the maildir, if it doesn not exist, set permissions, set quota. - if(!empty($maildomain_path) && !is_dir($maildomain_path)) { - - //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - $app->system->maildirmake($maildomain_path, $user, '', $group); - - //* This is to fix the maildrop quota not being rebuilt after the quota is changed. - if($mail_config['pop3_imap_daemon'] != 'dovecot') { - if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911 - $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG); + else { + // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. + if($mail_config['pop3_imap_daemon'] == 'dovecot') { + $app->system->mkdirpath($maildomain_path, 0700, $user, $group); + $app->log('Created Directory: '.$maildomain_path, LOGLEVEL_DEBUG); + $maildomain_path .= '/Maildir'; } - } - - if(!is_dir($data['new']['maildir'].'/.Sent')) { - //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Sent', $group); - } - if(!is_dir($data['new']['maildir'].'/.Drafts')) { - //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group); - } - if(!is_dir($data['new']['maildir'].'/.Trash')) { - //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Trash', $group); - } - if(!is_dir($data['new']['maildir'].'/.Junk')) { - //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Junk', $group); - } - - // Set permissions now recursive - exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir'])); - $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG); - - //* Set the maildir quota - if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { - if($data['new']['quota'] > 0) { - if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user); - $app->log('Set Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG); + + //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder + if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { + if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); + exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail"); + $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN); + } + + //* Create the maildir, if it doesn not exist, set permissions, set quota. + if(!empty($maildomain_path) && !is_dir($maildomain_path)) { + + //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + $app->system->maildirmake($maildomain_path, $user, '', $group); + + //* This is to fix the maildrop quota not being rebuilt after the quota is changed. + if($mail_config['pop3_imap_daemon'] != 'dovecot') { + if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911 + $app->log('Created Maildir: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG); + } + } + + if(!is_dir($data['new']['maildir'].'/.Sent')) { + //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Sent', $group); + } + if(!is_dir($data['new']['maildir'].'/.Drafts')) { + //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group); + } + if(!is_dir($data['new']['maildir'].'/.Trash')) { + //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Trash', $group); + } + if(!is_dir($data['new']['maildir'].'/.Junk')) { + //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Junk', $group); + } + + // Set permissions now recursive + exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir'])); + $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG); + + //* Set the maildir quota + if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { + if($data['new']['quota'] > 0) { + if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user); + $app->log('Set Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG); + } } } - //* Send the welcome email message if(file_exists($conf['rootpath'].'/conf-custom/mail/welcome_email_'.$conf['language'].'.txt')) { @@ -252,6 +265,9 @@ class mail_plugin { } */ + // Maildir-Format must not be changed on this way !! + $data['new']['maildir_format'] = $data['old']['maildir_format']; + $maildomain_path = $data['new']['maildir']; $tmp_basepath = $data['new']['maildir']; $tmp_basepath_parts = explode('/', $tmp_basepath); @@ -264,10 +280,10 @@ class mail_plugin { if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') { $app->log('Map uid to linux-user',LOGLEVEL_DEBUG); $email_parts = explode('@',$data['new']['email']); - $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain = '".$app->db->quote($email_parts[1])."'"); + $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain = ?", $email_parts[1]); if ($webdomain) { while ($webdomain['parent_domain_id'] != 0) { - $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain_id = '".$webdomain['parent_domain_id']."'"); + $webdomain = $app->db->queryOneRecord("SELECT domain_id, server_id, system_user, parent_domain_id FROM web_domain WHERE domain_id = ?", $webdomain['parent_domain_id']); } $app->log($data['new']['server_id'].' == '.$webdomain['server_id'],LOGLEVEL_DEBUG); @@ -284,7 +300,7 @@ class mail_plugin { $app->log('Mailuser uid: '.$data['new']['uid'].', gid: '.$data['new']['gid'],LOGLEVEL_DEBUG); // update DB if values changed - $app->db->query("UPDATE mail_user SET uid = ".$data['new']['uid'].", gid = ".$data['new']['gid']." WHERE mailuser_id = ".$data['new']['mailuser_id']); + $app->db->query("UPDATE mail_user SET uid = ?, gid = ? WHERE mailuser_id = ?", $data['new']['uid'], $data['new']['gid'], $data['new']['mailuser_id']); $user = $app->system->getuser($data['new']['uid']); $group = $app->system->getgroup($data['new']['gid']); @@ -296,86 +312,117 @@ class mail_plugin { $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG); } - // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. - if($mail_config['pop3_imap_daemon'] == 'dovecot') { - $app->system->mkdirpath($maildomain_path, 0700, $user, $group); - $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG); - $maildomain_path .= '/Maildir'; - } - - //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder - if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { - if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); - exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail"); - $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN); + if ($data['new']['maildir_format'] == 'mdbox') { + // Move mailbox, if domain has changed and delete old mailbox + if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) { + if(is_dir($data['new']['maildir'])) { + exec("rm -fr ".escapeshellcmd($data['new']['maildir'])); + //rmdir($data['new']['maildir']); + } + exec('mv -f '.escapeshellcmd($data['old']['maildir']).' '.escapeshellcmd($data['new']['maildir'])); + // exec('mv -f '.escapeshellcmd($data['old']['maildir']).'/* '.escapeshellcmd($data['new']['maildir'])); + // if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir'])); + // rmdir($data['old']['maildir']); + $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG); + } + + //* Create the maildir, if it doesn not exist, set permissions, set quota. + if(!is_dir($data['new']['maildir'].'/mdbox')) { + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" INBOX'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Sent'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Trash'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Junk'"); + exec("su -c 'doveadm mailbox create -u \"".$data["new"]["email"]."\" Drafts'"); + + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" INBOX'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Sent'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Trash'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Junk'"); + exec("su -c 'doveadm mailbox subscribe -u \"".$data["new"]["email"]."\" Drafts'"); + } } - - //* Create the maildir, if it doesn not exist, set permissions, set quota. - if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) { - //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, '', $group); - - //* This is to fix the maildrop quota not being rebuilt after the quota is changed. - if($mail_config['pop3_imap_daemon'] != 'dovecot') { + else { + // Dovecot uses a different mail layout with a separate 'Maildir' subdirectory. + if($mail_config['pop3_imap_daemon'] == 'dovecot') { + $app->system->mkdirpath($maildomain_path, 0700, $user, $group); + $app->log('Created Directory: '.$base_path, LOGLEVEL_DEBUG); + $maildomain_path .= '/Maildir'; + } + + //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder + if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) { + if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); + exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail"); + $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN); + } + + //* Create the maildir, if it doesn not exist, set permissions, set quota. + if(!empty($maildomain_path) && !is_dir($maildomain_path.'/new')) { + //exec("su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log("Created Maildir "."su -c 'maildirmake ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, '', $group); + + //* This is to fix the maildrop quota not being rebuilt after the quota is changed. + if($mail_config['pop3_imap_daemon'] != 'dovecot') { + if($data['new']['quota'] > 0) { + if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911 + $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG); + } else { + if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize'); + $app->log('Set Maildir quota to unlimited.', LOGLEVEL_DEBUG); + } + } + } + + if(!is_dir($data['new']['maildir'].'/.Sent')) { + //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Sent', $group); + } + if(!is_dir($data['new']['maildir'].'/.Drafts')) { + //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group); + } + if(!is_dir($data['new']['maildir'].'/.Trash')) { + //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Trash', $group); + } + if(!is_dir($data['new']['maildir'].'/.Junk')) { + //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); + //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); + $app->system->maildirmake($maildomain_path, $user, 'Junk', $group); + } + + // Set permissions now recursive + exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir'])); + $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG); + + // Move mailbox, if domain has changed and delete old mailbox + if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) { + if(is_dir($data['new']['maildir'])) { + exec("rm -fr ".escapeshellcmd($data['new']['maildir'])); + //rmdir($data['new']['maildir']); + } + exec('mv -f '.escapeshellcmd($data['old']['maildir']).' '.escapeshellcmd($data['new']['maildir'])); + // exec('mv -f '.escapeshellcmd($data['old']['maildir']).'/* '.escapeshellcmd($data['new']['maildir'])); + // if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir'])); + // rmdir($data['old']['maildir']); + $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG); + } + //This is to fix the maildrop quota not being rebuilt after the quota is changed. + // Courier Layout + if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { if($data['new']['quota'] > 0) { - if(is_dir($maildomain_path)) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user); // Avoid maildirmake quota bug, see debian bug #214911 - $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($maildomain_path)."' ".$user, LOGLEVEL_DEBUG); + if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user); + $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG); } else { if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize'); $app->log('Set Maildir quota to unlimited.', LOGLEVEL_DEBUG); } } } - - if(!is_dir($data['new']['maildir'].'/.Sent')) { - //exec("su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Sent: '."su -c 'maildirmake -f Sent ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Sent', $group); - } - if(!is_dir($data['new']['maildir'].'/.Drafts')) { - //exec("su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Drafts: '."su -c 'maildirmake -f Drafts ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Drafts', $group); - } - if(!is_dir($data['new']['maildir'].'/.Trash')) { - //exec("su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Trash: '."su -c 'maildirmake -f Trash ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Trash', $group); - } - if(!is_dir($data['new']['maildir'].'/.Junk')) { - //exec("su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name']); - //$app->log('Created submaildir Junk: '."su -c 'maildirmake -f Junk ".escapeshellcmd($maildomain_path)."' ".$mail_config['mailuser_name'],LOGLEVEL_DEBUG); - $app->system->maildirmake($maildomain_path, $user, 'Junk', $group); - } - - // Set permissions now recursive - exec('chown -R '.$user.':'.$group.' '.escapeshellcmd($data['new']['maildir'])); - $app->log('Set ownership on '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_DEBUG); - - // Move mailbox, if domain has changed and delete old mailbox - if($data['new']['maildir'] != $data['old']['maildir'] && is_dir($data['old']['maildir'])) { - if(is_dir($data['new']['maildir'])) { - exec("rm -fr ".escapeshellcmd($data['new']['maildir'])); - //rmdir($data['new']['maildir']); - } - exec('mv -f '.escapeshellcmd($data['old']['maildir']).' '.escapeshellcmd($data['new']['maildir'])); - // exec('mv -f '.escapeshellcmd($data['old']['maildir']).'/* '.escapeshellcmd($data['new']['maildir'])); - // if(is_file($data['old']['maildir'].'.ispconfig_mailsize'))exec('mv -f '.escapeshellcmd($data['old']['maildir']).'.ispconfig_mailsize '.escapeshellcmd($data['new']['maildir'])); - // rmdir($data['old']['maildir']); - $app->log('Moved Maildir from: '.$data['old']['maildir'].' to '.$data['new']['maildir'], LOGLEVEL_DEBUG); - } - //This is to fix the maildrop quota not being rebuilt after the quota is changed. - // Courier Layout - if(is_dir($data['new']['maildir'].'/new') && $mail_config['pop3_imap_daemon'] != 'dovecot') { - if($data['new']['quota'] > 0) { - if(is_dir($data['new']['maildir'])) exec("su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user); - $app->log('Updated Maildir quota: '."su -c 'maildirmake -q ".$data['new']['quota']."S ".escapeshellcmd($data['new']['maildir'])."' ".$user, LOGLEVEL_DEBUG); - } else { - if(file_exists($data['new']['maildir'].'/maildirsize')) unlink($data['new']['maildir'].'/maildirsize'); - $app->log('Set Maildir quota to unlimited.', LOGLEVEL_DEBUG); - } - } } function user_delete($event_name, $data) { @@ -398,31 +445,24 @@ class mail_plugin { //* Delete the mail-backups $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir']; - //* mount backup directory, if necessary $mount_backup = true; - $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); if($server_config['backup_dir'] != '' && $maildir_path_deleted && $server_config['backup_delete'] == 'y') { - if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ - if(!$app->system->is_mounted($backup_dir)){ - exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); - sleep(1); - if(!$app->system->is_mounted($backup_dir)) $mount_backup = false; - } - } + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $mount_backup = false; if($mount_backup){ - $sql = "SELECT * FROM mail_domain WHERE domain = '".explode("@",$data['old']['email'])[1]."'"; - $domain_rec = $app->db->queryOneRecord($sql); - $mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id']; - $mail_backup_files = 'mail'.$data['old']['mailuser_id']; - exec(escapeshellcmd('rm -f '.$mail_backup_dir.'/'.$mail_backup_files).'*'); - //* cleanup database - $sql = "DELETE FROM mail_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$domain_rec['domain_id']." AND mailuser_id = ".$data['old']['mailuser_id']; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); - - $app->log('Deleted the mail backups for: '.$data['old']['email'], LOGLEVEL_DEBUG); - - + $sql = "SELECT * FROM mail_domain WHERE domain = ?"; + $domain_rec = $app->db->queryOneRecord($sql, explode("@",$data['old']['email'])[1]); + if (is_array($domain_rec)) { + $mail_backup_dir = $backup_dir.'/mail'.$domain_rec['domain_id']; + $mail_backup_files = 'mail'.$data['old']['mailuser_id']; + exec(escapeshellcmd('rm -f '.$mail_backup_dir.'/'.$mail_backup_files).'*'); + //* cleanup database + $sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ? AND mailuser_id = ?"; + $app->db->query($sql, $conf['server_id'], $domain_rec['domain_id'], $data['old']['mailuser_id']); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $domain_rec['domain_id'], $data['old']['mailuser_id']); + + $app->log('Deleted the mail backups for: '.$data['old']['email'], LOGLEVEL_DEBUG); + } } } } @@ -430,7 +470,6 @@ class mail_plugin { function domain_delete($event_name, $data) { global $app, $conf; - // get the config $app->uses("getconf"); $mail_config = $app->getconf->get_server_config($conf['server_id'], 'mail'); @@ -457,24 +496,17 @@ class mail_plugin { //* Delete the mail-backups $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); $backup_dir = $server_config['backup_dir']; - //* mount backup directory, if necessary $mount_backup = true; - $server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']); if($server_config['backup_dir'] != '' && $maildomain_path_deleted && $server_config['backup_delete'] == 'y'){ - if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){ - if(!$app->system->is_mounted($backup_dir)){ - exec(escapeshellcmd($server_config['backup_dir_mount_cmd'])); - sleep(1); - if(!$app->system->is_mounted($backup_dir)) $mount_backup = false; - } - } + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $mount_backup = false; if($mount_backup){ $mail_backup_dir = $backup_dir.'/mail'.$data['old']['domain_id']; exec(escapeshellcmd('rm -rf '.$mail_backup_dir)); //* cleanup database - $sql = "DELETE FROM mail_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$data['old']['domain_id']; - $app->db->query($sql); - if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql); + $sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ?"; + $app->db->query($sql, $conf['server_id'], $data['old']['domain_id']); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $domain_rec['domain_id']); $app->log('Deleted the mail backup directory: '.$mail_backup_dir, LOGLEVEL_DEBUG); } diff --git a/server/plugins-available/mail_plugin_dkim.inc.php b/server/plugins-available/mail_plugin_dkim.inc.php index 3e00ada4a99906ded7986f74a1869a82657c6f8b..7ded684ea2e69f415a361a344584e798b311202e 100755 --- a/server/plugins-available/mail_plugin_dkim.inc.php +++ b/server/plugins-available/mail_plugin_dkim.inc.php @@ -75,9 +75,9 @@ class mail_plugin_dkim { */ function get_amavis_config() { $pos_config=array( - '/etc/amavisd.conf', '/etc/amavisd.conf/50-user', '/etc/amavis/conf.d/50-user', + '/etc/amavisd.conf', '/etc/amavisd/amavisd.conf' ); $amavis_configfile=''; @@ -143,7 +143,12 @@ class mail_plugin_dkim { mkdir($mail_config['dkim_path'], 0755, true); $app->log('No user amavis or vscan found - using root for '.$mail_config['dkim_path'], LOGLEVEL_WARNING); } - } + } else { + if (!$app->system->checkpath($mail_config['dkim_path'])) { + $app->log('Unable to write DKIM settings - invalid DKIM-Path (symlink?)', LOGLEVEL_ERROR); + $check=false; + } + } if (!is_writeable($mail_config['dkim_path'])) { $app->log('DKIM Path '.$mail_config['dkim_path'].' not writeable.', LOGLEVEL_ERROR); @@ -320,7 +325,7 @@ class mail_plugin_dkim { $this->remove_dkim_key($mail_config['dkim_path']."/".$data['new']['domain'], $data['new']['domain']); } } else { - $app->log('Error saving the DKIM Private-key for '.$data['new']['domain'].' - DKIM is not enabled for the domain.', LOGLEVEL_ERROR); + $app->log('Error saving the DKIM Private-key for '.$data['new']['domain'].' - DKIM is not enabled for the domain.', LOGLEVEL_DEBUG); } } } @@ -364,45 +369,47 @@ class mail_plugin_dkim { */ function domain_dkim_update($event_name, $data) { global $app; - if ($this->check_system($data)) { - /* maildomain disabled */ - if ($data['new']['active'] == 'n' && $data['old']['active'] == 'y' && $data['new']['dkim']=='y') { - $app->log('Maildomain '.$data['new']['domain'].' disabled - remove DKIM-settings', LOGLEVEL_DEBUG); - $this->remove_dkim($data['new']); - } - /* maildomain re-enabled */ - if ($data['new']['active'] == 'y' && $data['old']['active'] == 'n' && $data['new']['dkim']=='y') - $this->add_dkim($data); - - /* maildomain active - only dkim changes */ - if ($data['new']['active'] == 'y' && $data['old']['active'] == 'y') { - /* dkim disabled */ - if ($data['new']['dkim'] != $data['old']['dkim'] && $data['new']['dkim'] == 'n') { + if($data['new']['dkim'] == 'y' || $data['old']['dkim'] == 'y'){ + if ($this->check_system($data)) { + /* maildomain disabled */ + if ($data['new']['active'] == 'n' && $data['old']['active'] == 'y' && $data['new']['dkim']=='y') { + $app->log('Maildomain '.$data['new']['domain'].' disabled - remove DKIM-settings', LOGLEVEL_DEBUG); $this->remove_dkim($data['new']); } - /* dkim enabled */ - elseif ($data['new']['dkim'] != $data['old']['dkim'] && $data['new']['dkim'] == 'y') { - $this->add_dkim($data); - } - /* new private-key */ - if ($data['new']['dkim_private'] != $data['old']['dkim_private'] && $data['new']['dkim'] == 'y') { - $this->add_dkim($data); - } - /* new selector */ - if ($data['new']['dkim_selector'] != $data['old']['dkim_selector'] && $data['new']['dkim'] == 'y') { + /* maildomain re-enabled */ + if ($data['new']['active'] == 'y' && $data['old']['active'] == 'n' && $data['new']['dkim']=='y') $this->add_dkim($data); + + /* maildomain active - only dkim changes */ + if ($data['new']['active'] == 'y' && $data['old']['active'] == 'y') { + /* dkim disabled */ + if ($data['new']['dkim'] != $data['old']['dkim'] && $data['new']['dkim'] == 'n') { + $this->remove_dkim($data['new']); + } + /* dkim enabled */ + elseif ($data['new']['dkim'] != $data['old']['dkim'] && $data['new']['dkim'] == 'y') { + $this->add_dkim($data); + } + /* new private-key */ + if ($data['new']['dkim_private'] != $data['old']['dkim_private'] && $data['new']['dkim'] == 'y') { + $this->add_dkim($data); + } + /* new selector */ + if ($data['new']['dkim_selector'] != $data['old']['dkim_selector'] && $data['new']['dkim'] == 'y') { + $this->add_dkim($data); + } + /* new domain-name */ + if ($data['new']['domain'] != $data['old']['domain']) { + $this->remove_dkim($data['old']); + $this->add_dkim($data); + } } - /* new domain-name */ - if ($data['new']['domain'] != $data['old']['domain']) { - $this->remove_dkim($data['old']); + + /* resync */ + if ($data['new']['active'] == 'y' && $data['new'] == $data['old'] && $data['new']['dkim']=='y') { $this->add_dkim($data); } } - - /* resync */ - if ($data['new']['active'] == 'y' && $data['new'] == $data['old']) { - $this->add_dkim($data); - } } } diff --git a/server/plugins-available/maildeliver_plugin.inc.php b/server/plugins-available/maildeliver_plugin.inc.php index 6e591a672e8decdaf28cd33f782e2f0e4d017402..a6f9ae567e324e39a1dba9127cddaf4d52e30e16 100644 --- a/server/plugins-available/maildeliver_plugin.inc.php +++ b/server/plugins-available/maildeliver_plugin.inc.php @@ -165,8 +165,8 @@ class maildeliver_plugin { $tpl->setVar('autoresponder_text', $data["new"]["autoresponder_text"]); //* Set alias addresses for autoresponder - $sql = "SELECT * FROM mail_forwarding WHERE type = 'alias' AND destination = '".$app->db->quote($data["new"]["email"])."'"; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_forwarding WHERE type = 'alias' AND destination = ?"; + $records = $app->db->queryAllRecords($sql, $data["new"]["email"]); $addresses = array(); $addresses[] = $data["new"]["email"]; @@ -181,8 +181,8 @@ class maildeliver_plugin { $alias_addresses = array(); $email_parts = explode('@', $data["new"]["email"]); - $sql = "SELECT * FROM mail_forwarding WHERE type = 'aliasdomain' AND destination = '@".$app->db->quote($email_parts[1])."'"; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_forwarding WHERE type = 'aliasdomain' AND destination = ?"; + $records = $app->db->queryAllRecords($sql, '@'.$email_parts[1]); if(is_array($records) && count($records) > 0) { $app->log("Found " . count($records) . " records (aliasdomains).", LOGLEVEL_DEBUG); foreach($records as $rec) { @@ -216,18 +216,22 @@ class maildeliver_plugin { if ( ! is_dir($data["new"]["maildir"].'/sieve/') ) { $app->system->mkdirpath($data["new"]["maildir"].'/sieve/', 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); } - file_put_contents($sieve_file, $tpl->grab()); - exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($sieve_file)); - chown($sieve_file_isp,$mail_config['mailuser_name']); - chgrp($sieve_file_isp,$mail_config['mailuser_group']); + file_put_contents($sieve_file_isp, $tpl->grab()) or $app->log("Unable to write sieve filter file", LOGLEVEL_WARN); + if ( is_file($sieve_file_isp) ) { + $app->system->chown($sieve_file_isp,$mail_config['mailuser_name'],false); + $app->system->chgrp($sieve_file_isp,$mail_config['mailuser_group'],false); + } chdir($data["new"]["maildir"]); //* create symlink to activate sieve script symlink("sieve/ispconfig.sieve", ".sieve") or $app->log("Unable to create symlink to active sieve filter", LOGLEVEL_WARN); if (is_link(".sieve")) { - lchown(".sieve",$mail_config['mailuser_name']); - lchgrp(".sieve",$mail_config['mailuser_group']); + $app->system->chown(".sieve",$mail_config['mailuser_name'],true); + $app->system->chgrp(".sieve",$mail_config['mailuser_group'],true); } + $app->system->chown($sieve_file,$mail_config['mailuser_name'],true); + $app->system->chgrp($sieve_file,$mail_config['mailuser_group'],true); + unset($tpl); } diff --git a/server/plugins-available/mailman_plugin.inc.php b/server/plugins-available/mailman_plugin.inc.php index acf4eb9363adb64cc5b61382a84c17cf77c76d8a..9ebb2aa9a73f326f48d2c7b7d97f33a0c40eb4a7 100644 --- a/server/plugins-available/mailman_plugin.inc.php +++ b/server/plugins-available/mailman_plugin.inc.php @@ -78,7 +78,7 @@ class mailman_plugin { if(is_file('/var/lib/mailman/data/transport-mailman')) exec('postmap /var/lib/mailman/data/transport-mailman'); exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); - $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ".$app->db->quote($data["new"]['mailinglist_id'])); + $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); } @@ -91,7 +91,7 @@ class mailman_plugin { if($data["new"]["password"] != $data["old"]["password"] && $data["new"]["password"] != '') { exec("nohup /usr/lib/mailman/bin/change_pw -l ".escapeshellcmd($data["new"]["listname"])." -p ".escapeshellcmd($data["new"]["password"])." >/dev/null 2>&1 &"); exec('nohup '.$conf['init_scripts'] . '/' . 'mailman reload >/dev/null 2>&1 &'); - $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ".$app->db->quote($data["new"]['mailinglist_id'])); + $app->db->query("UPDATE mail_mailinglist SET password = '' WHERE mailinglist_id = ?", $data["new"]['mailinglist_id']); } if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman'); diff --git a/server/plugins-available/mongo_clientdb_plugin.inc.php b/server/plugins-available/mongo_clientdb_plugin.inc.php index 2f381121d3fa58791323cc862c6b3d624c51332d..b4d274cba5ceed8868ea606374702667059224e1 100644 --- a/server/plugins-available/mongo_clientdb_plugin.inc.php +++ b/server/plugins-available/mongo_clientdb_plugin.inc.php @@ -500,8 +500,8 @@ class mongo_clientdb_plugin { return; } - $db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = '" . intval($data['new']['database_user_id']) . "'"); - $db_ro_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = '" . intval($data['new']['database_ro_user_id']) . "'"); + $db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = ?", $data['new']['database_user_id']); + $db_ro_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = ?", $data['new']['database_ro_user_id']); $user = $db_user['database_user']; $password = $db_user['database_password_mongo']; @@ -573,8 +573,8 @@ class mongo_clientdb_plugin { return; } - $db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = '" . intval($data['new']['database_user_id']) . "'"); - $db_ro_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = '" . intval($data['new']['database_ro_user_id']) . "'"); + $db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = ?", $data['new']['database_user_id']); + $db_ro_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = ?", $data['new']['database_ro_user_id']); $user = $db_user['database_user']; $password = $db_user['database_password_mongo']; @@ -600,7 +600,7 @@ class mongo_clientdb_plugin { } else { // selected user has changed -> drop old one if ($data['new']['database_user_id'] != $data['old']['database_user_id']) { - $old_db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = '" . intval($data['old']['database_user_id']) . "'"); + $old_db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = ?", $data['old']['database_user_id']); if ((bool) $old_db_user) { if ($old_db_user['database_user'] == 'root') { @@ -613,7 +613,7 @@ class mongo_clientdb_plugin { // selected read-only user has changed -> drop old one if ($data['new']['database_ro_user_id'] != $data['old']['database_ro_user_id']) { - $old_db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = '" . intval($data['old']['database_ro_user_id']) . "'"); + $old_db_user = $app->db->queryOneRecord("SELECT `database_user`, `database_password_mongo` FROM `web_database_user` WHERE `database_user_id` = ?", $data['old']['database_ro_user_id']); if ((bool) $old_db_user) { if ($old_db_user['database_user'] == 'root') { diff --git a/server/plugins-available/mysql_clientdb_plugin.inc.php b/server/plugins-available/mysql_clientdb_plugin.inc.php index 6145db00c7f37e225ce5a76e5f7193267e757a12..146e17a2ec4cf895896cbb64d3ee89be88adf12e 100644 --- a/server/plugins-available/mysql_clientdb_plugin.inc.php +++ b/server/plugins-available/mysql_clientdb_plugin.inc.php @@ -195,7 +195,7 @@ class mysql_clientdb_plugin { } //* Create the new database - if ($link->query('CREATE DATABASE '.$link->escape_string($data['new']['database_name']).$query_charset_table)) { + if ($link->query('CREATE DATABASE `'.$link->escape_string($data['new']['database_name']).'`'.$query_charset_table)) { $app->log('Created MySQL database: '.$data['new']['database_name'], LOGLEVEL_DEBUG); } else { $app->log('Unable to create the database: '.$link->error, LOGLEVEL_WARNING); diff --git a/server/plugins-available/network_settings_plugin.inc.php b/server/plugins-available/network_settings_plugin.inc.php index 46242d98407846a36ae20e2d4d285fd01f9a7621..13dbf3c8c1f0595515b72b1f211e2217f79d2e0c 100644 --- a/server/plugins-available/network_settings_plugin.inc.php +++ b/server/plugins-available/network_settings_plugin.inc.php @@ -101,7 +101,7 @@ class network_settings_plugin { $network_tpl->setVar('broadcast', $this->broadcast($server_config['ip_address'], $server_config['netmask'])); $network_tpl->setVar('network', $this->network($server_config['ip_address'], $server_config['netmask'])); - $records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf['server_id']) . ' ORDER BY server_ip_id ASC'); + $records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ? ORDER BY server_ip_id ASC", $conf['server_id']); $ip_records = array(); $additionl_ip_records = 0; $n = 0; @@ -179,7 +179,7 @@ class network_settings_plugin { $network_tpl->setVar('gateway', $server_config['gateway']); $network_tpl->setVar('broadcast', $this->broadcast($server_config['ip_address'], $server_config['netmask'])); - $records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ".intval($conf['server_id']) . " order by ip_address"); + $records = $app->db->queryAllRecords("SELECT ip_address FROM server_ip WHERE server_id = ? order by ip_address", $conf['server_id']); $ip_records = array(); $additionl_ip_records = 0; $n = 0; diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 77ac10a396260721848b615d0f00490323b2e483..ef48adbe81967f4807fd0764edecbb7de5578a88 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -208,15 +208,15 @@ class nginx_plugin { $app->system->chmod($key_file2, 0400); @$app->system->unlink($config_file); @$app->system->unlink($rand_file); - $ssl_request = $app->db->quote($app->system->file_get_contents($csr_file)); - $ssl_cert = $app->db->quote($app->system->file_get_contents($crt_file)); - $ssl_key2 = $app->db->quote($app->system->file_get_contents($key_file2)); + $ssl_request = $app->system->file_get_contents($csr_file); + $ssl_cert = $app->system->file_get_contents($crt_file); + $ssl_key2 = $app->system->file_get_contents($key_file2); /* Update the DB of the (local) Server */ - $app->db->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert', ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'"); - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_request = ?, ssl_cert = ?, ssl_key = ? WHERE domain = ?", $ssl_request, $ssl_cert, $ssl_key2, $data['new']['domain']); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); /* Update also the master-DB of the Server-Farm */ - $app->dbmaster->query("UPDATE web_domain SET ssl_request = '$ssl_request', ssl_cert = '$ssl_cert', ssl_key = '$ssl_key2' WHERE domain = '".$data['new']['domain']."'"); - $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_request = ?, ssl_cert = ?, ssl_key = ? WHERE domain = ?", $ssl_request, $ssl_cert, $ssl_key2, $data['new']['domain']); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); } //* Save a SSL certificate to disk @@ -263,10 +263,10 @@ class nginx_plugin { unset($crt_file_contents); } /* Update the DB of the (local) Server */ - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); /* Update also the master-DB of the Server-Farm */ - $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); $app->log('Saving SSL Cert for: '.$domain, LOGLEVEL_DEBUG); } @@ -286,11 +286,11 @@ class nginx_plugin { $app->system->unlink($crt_file); //$app->system->unlink($bundle_file); /* Update the DB of the (local) Server */ - $app->db->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = '".$data['new']['domain']."'"); - $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->db->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = ?", $data['new']['domain']); + $app->db->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); /* Update also the master-DB of the Server-Farm */ - $app->dbmaster->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = '".$data['new']['domain']."'"); - $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = '".$data['new']['domain']."'"); + $app->dbmaster->query("UPDATE web_domain SET ssl_request = '', ssl_cert = '' WHERE domain = ?", $data['new']['domain']); + $app->dbmaster->query("UPDATE web_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); $app->log('Deleting SSL Cert for: '.$domain, LOGLEVEL_DEBUG); } @@ -326,7 +326,7 @@ class nginx_plugin { // If the parent_domain_id has been changed, we will have to update the old site as well. if($this->action == 'update' && $data['new']['parent_domain_id'] != $data['old']['parent_domain_id']) { - $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$old_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $old_parent_domain_id); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -334,7 +334,7 @@ class nginx_plugin { } // This is not a vhost, so we need to update the parent record instead. - $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$new_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $new_parent_domain_id); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -374,7 +374,7 @@ class nginx_plugin { $old_log_folder = 'log'; if($data['new']['type'] == 'vhostsubdomain' || $data['new']['type'] == 'vhostalias') { // new one - $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['new']['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $data['new']['parent_domain_id']); $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['new']['domain']); if($subdomain_host == '') $subdomain_host = 'web'.$data['new']['domain_id']; $web_folder = $data['new']['web_folder']; @@ -383,7 +383,7 @@ class nginx_plugin { if(isset($data['old']['parent_domain_id'])) { // old one - $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = '.intval($data['old']['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain` FROM web_domain WHERE domain_id = ?', $data['old']['parent_domain_id']); $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['old']['domain']); if($subdomain_host == '') $subdomain_host = 'web'.$data['old']['domain_id']; $old_web_folder = $data['old']['web_folder']; @@ -437,7 +437,7 @@ class nginx_plugin { if($this->action == 'update' && $data['new']['document_root'] != $data['old']['document_root']) { //* Get the old client ID - $old_client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid'])); + $old_client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = ?', $data['old']['sys_groupid']); $old_client_id = intval($old_client['client_id']); unset($old_client); @@ -576,7 +576,7 @@ class nginx_plugin { $app->system->web_folder_protection($data['new']['document_root'], true); // Get the client ID - $client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['new']['sys_groupid'])); + $client = $app->dbmaster->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = ?', $data['new']['sys_groupid']); $client_id = intval($client['client_id']); unset($client); @@ -959,6 +959,7 @@ class nginx_plugin { } else { $pool_dir = $custom_php_fpm_pool_dir; } + $pool_dir = trim($pool_dir); if(substr($pool_dir, -1) != '/') $pool_dir .= '/'; $pool_name = 'web'.$data['new']['domain_id']; $socket_dir = escapeshellcmd($web_config['php_fpm_socket_dir']); @@ -1089,7 +1090,27 @@ class nginx_plugin { // Custom nginx directives $final_nginx_directives = array(); - $nginx_directives = $data['new']['nginx_directives']; + if(intval($data['new']['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", $data['new']['directive_snippets_id']); + if(isset($snippet['snippet'])){ + $nginx_directives = $snippet['snippet']; + } else { + $nginx_directives = $data['new']['nginx_directives']; + } + if($data['new']['enable_pagespeed'] == 'y'){ + // if PageSpeed is already enabled, don't add configuration again + if(stripos($nginx_directives, 'pagespeed') !== false){ + $vhost_data['enable_pagespeed'] = false; + } else { + $vhost_data['enable_pagespeed'] = true; + } + } else { + $vhost_data['enable_pagespeed'] = false; + } + } else { + $nginx_directives = $data['new']['nginx_directives']; + $vhost_data['enable_pagespeed'] = false; + } // Make sure we only have Unix linebreaks $nginx_directives = str_replace("\r\n", "\n", $nginx_directives); $nginx_directives = str_replace("\r", "\n", $nginx_directives); @@ -1327,7 +1348,7 @@ class nginx_plugin { $auto_alias = $web_config['website_autoalias']; if($auto_alias != '') { // get the client username - $client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = '" . intval($client_id) . "'"); + $client = $app->db->queryOneRecord("SELECT `username` FROM `client` WHERE `client_id` = ?", $client_id); $aa_search = array('[client_id]', '[website_id]', '[client_username]', '[website_domain]'); $aa_replace = array($client_id, $data['new']['domain_id'], $client['username'], $data['new']['domain']); $auto_alias = str_replace($aa_search, $aa_replace, $auto_alias); @@ -1347,7 +1368,7 @@ class nginx_plugin { } // get alias domains (co-domains and subdomains) - $aliases = $app->db->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND active = 'y' AND (type != 'vhostsubdomain' AND type != 'vhostalias')"); + $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ? AND active = 'y' AND (type != 'vhostsubdomain' AND type != 'vhostalias')", $data['new']['domain_id']); $alias_seo_redirects = array(); if(is_array($aliases)) { foreach($aliases as $alias) { @@ -1796,7 +1817,7 @@ class nginx_plugin { $log_folder = 'log'; $web_folder = ''; if($data['old']['type'] == 'vhostsubdomain' || $data['old']['type'] == 'vhostalias') { - $tmp = $app->db->queryOneRecord('SELECT `domain`,`document_root` FROM web_domain WHERE domain_id = '.intval($data['old']['parent_domain_id'])); + $tmp = $app->db->queryOneRecord('SELECT `domain`,`document_root` FROM web_domain WHERE domain_id = ?', $data['old']['parent_domain_id']); if($tmp['domain'] != ''){ $subdomain_host = preg_replace('/^(.*)\.' . preg_quote($tmp['domain'], '/') . '$/', '$1', $data['old']['domain']); } else { @@ -1868,7 +1889,7 @@ class nginx_plugin { if($data['old']['type'] != 'vhost' && $data['old']['type'] != 'vhostsubdomain' && $data['old']['type'] != 'vhostalias' && $data['old']['parent_domain_id'] > 0) { //* This is a alias domain or subdomain, so we have to update the website instead $parent_domain_id = intval($data['old']['parent_domain_id']); - $tmp = $app->db->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $parent_domain_id); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -1922,7 +1943,7 @@ class nginx_plugin { } else { // read all vhost subdomains with same parent domain $used_paths = array(); - $tmp = $app->db->queryAllRecords("SELECT `web_folder` FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ".intval($data['old']['parent_domain_id'])." AND domain_id != ".intval($data['old']['domain_id'])); + $tmp = $app->db->queryAllRecords("SELECT `web_folder` FROM web_domain WHERE (type = 'vhostsubdomain' OR type = 'vhostalias') AND parent_domain_id = ? AND domain_id != ?", $data['old']['parent_domain_id'], $data['old']['domain_id']); foreach($tmp as $tmprec) { // we normalize the folder entries because we need to compare them $tmp_folder = preg_replace('/[\/]{2,}/', '/', $tmprec['web_folder']); // replace / occuring multiple times @@ -2005,7 +2026,7 @@ class nginx_plugin { $app->log('Removing website: '.$docroot, LOGLEVEL_DEBUG); // Delete the symlinks for the sites - $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = '.intval($data['old']['sys_groupid'])); + $client = $app->db->queryOneRecord('SELECT client_id FROM sys_group WHERE sys_group.groupid = ?', $data['old']['sys_groupid']); $client_id = intval($client['client_id']); unset($client); $tmp_symlinks_array = explode(':', $web_config['website_symlinks']); @@ -2046,6 +2067,28 @@ class nginx_plugin { $this->awstats_delete($data, $web_config); } + //* Delete the web-backups + if($data['old']['type'] == 'vhost') { + $server_config = $app->getconf->get_server_config($conf['server_id'], 'server'); + $backup_dir = $server_config['backup_dir']; + $mount_backup = true; + if($server_config['backup_dir'] != '' && $server_config['backup_delete'] == 'y') { + //* mount backup directory, if necessary + if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $mount_backup = false; + if($mount_backup){ + $web_backup_dir = $backup_dir.'/web'.$data_old['domain_id']; + //** do not use rm -rf $web_backup_dir because database(s) may exits + exec(escapeshellcmd('rm -f '.$web_backup_dir.'/web'.$data_old['domain_id'].'_').'*'); + //* cleanup database + $sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename LIKE ?"; + $app->db->query($sql, $conf['server_id'], $data_old['domain_id'], "web".$data_old['domain_id']."_%"); + if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $data_old['domain_id'], "web".$data_old['domain_id']."_%"); + + $app->log('Deleted the web backup files', LOGLEVEL_DEBUG); + } + } + } + $app->services->restartServiceDelayed('httpd', 'reload'); } @@ -2071,8 +2114,8 @@ class nginx_plugin { $folder_id = $data['new']['web_folder_id']; } - $folder = $app->db->queryOneRecord("SELECT * FROM web_folder WHERE web_folder_id = ".intval($folder_id)); - $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($folder['parent_domain_id'])); + $folder = $app->db->queryOneRecord("SELECT * FROM web_folder WHERE web_folder_id = ?", $folder_id); + $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $folder['parent_domain_id']); if(!is_array($folder) or !is_array($website)) { $app->log('Not able to retrieve folder or website record.', LOGLEVEL_DEBUG); @@ -2108,19 +2151,6 @@ class nginx_plugin { $app->log('Created file '.$folder_path.'.htpasswd', LOGLEVEL_DEBUG); } - /* - $auth_users = $app->db->queryAllRecords("SELECT * FROM web_folder_user WHERE active = 'y' AND web_folder_id = ".intval($folder_id)); - $htpasswd_content = ''; - if(is_array($auth_users) && !empty($auth_users)){ - foreach($auth_users as $auth_user){ - $htpasswd_content .= $auth_user['username'].':'.$auth_user['password']."\n"; - } - } - $htpasswd_content = trim($htpasswd_content); - @file_put_contents($folder_path.'.htpasswd', $htpasswd_content); - $app->log('Changed .htpasswd file: '.$folder_path.'.htpasswd',LOGLEVEL_DEBUG); - */ - if(($data['new']['username'] != $data['old']['username'] || $data['new']['active'] == 'n') && $data['old']['username'] != '') { $app->system->removeLine($folder_path.'.htpasswd', $data['old']['username'].':'); $app->log('Removed user: '.$data['old']['username'], LOGLEVEL_DEBUG); @@ -2149,7 +2179,7 @@ class nginx_plugin { $folder_id = $data['old']['web_folder_id']; $folder = $data['old']; - $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($folder['parent_domain_id'])); + $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $folder['parent_domain_id']); if(!is_array($folder) or !is_array($website)) { $app->log('Not able to retrieve folder or website record.', LOGLEVEL_DEBUG); @@ -2186,7 +2216,7 @@ class nginx_plugin { function web_folder_update($event_name, $data) { global $app, $conf; - $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['new']['parent_domain_id'])); + $website = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); if(!is_array($website)) { $app->log('Not able to retrieve folder or website record.', LOGLEVEL_DEBUG); @@ -2255,7 +2285,7 @@ class nginx_plugin { //$app->load('tpl'); //$tpl = new tpl(); //$tpl->newTemplate('nginx_http_authentication.auth.master'); - $website_auth_locations = $app->db->queryAllRecords("SELECT * FROM web_folder WHERE active = 'y' AND parent_domain_id = ".intval($website['domain_id'])); + $website_auth_locations = $app->db->queryAllRecords("SELECT * FROM web_folder WHERE active = 'y' AND parent_domain_id = ?", $website['domain_id']); $basic_auth_locations = array(); if(is_array($website_auth_locations) && !empty($website_auth_locations)){ foreach($website_auth_locations as $website_auth_location){ @@ -2337,23 +2367,70 @@ class nginx_plugin { } else { $content = file_get_contents($conf['rootpath'] . '/conf/hhvm_starter.master'); } + if(file_exists($conf['rootpath'] . '/conf-custom/hhvm_monit.master')) { + $monit_content = file_get_contents($conf['rootpath'] . '/conf-custom/hhvm_monit.master'); + } else { + $monit_content = file_get_contents($conf['rootpath'] . '/conf/hhvm_monit.master'); + } + + if($data['new']['php'] == 'hhvm' && $data['old']['php'] != 'hhvm' || $data['new']['custom_php_ini'] != $data['old']['custom_php_ini']) { + + // Custom php.ini settings + $custom_php_ini_settings = trim($data['new']['custom_php_ini']); + if(intval($data['new']['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); + if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){ + $required_php_snippets = explode(',', trim($snippet['required_php_snippets'])); + if(is_array($required_php_snippets) && !empty($required_php_snippets)){ + foreach($required_php_snippets as $required_php_snippet){ + $required_php_snippet = intval($required_php_snippet); + if($required_php_snippet > 0){ + $php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet); + $php_snippet['snippet'] = trim($php_snippet['snippet']); + if($php_snippet['snippet'] != ''){ + $custom_php_ini_settings .= "\n".$php_snippet['snippet']; + } + } + } + } + } + } + if($custom_php_ini_settings != ''){ + // Make sure we only have Unix linebreaks + $custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings); + $custom_php_ini_settings = str_replace("\r", "\n", $custom_php_ini_settings); + file_put_contents('/etc/hhvm/'.$data['new']['system_user'].'.ini', $custom_php_ini_settings); + } else { + if(is_file('/etc/hhvm/'.$data['old']['system_user'].'.ini')) unlink('/etc/hhvm/'.$data['old']['system_user'].'.ini'); + } - if($data['new']['php'] == 'hhvm' && $data['old']['php'] != 'hhvm') { $content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $content); file_put_contents('/etc/init.d/hhvm_' . $data['new']['system_user'], $content); exec('chmod +x /etc/init.d/hhvm_' . $data['new']['system_user'] . ' >/dev/null 2>&1'); exec('/usr/sbin/update-rc.d hhvm_' . $data['new']['system_user'] . ' defaults >/dev/null 2>&1'); - exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' start >/dev/null 2>&1'); + exec('/etc/init.d/hhvm_' . $data['new']['system_user'] . ' restart >/dev/null 2>&1'); + + $monit_content = str_replace('{SYSTEM_USER}', $data['new']['system_user'], $monit_content); + file_put_contents('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'], $monit_content); + exec('/etc/init.d/monit restart >/dev/null 2>&1'); + } elseif($data['new']['php'] != 'hhvm' && $data['old']['php'] == 'hhvm') { exec('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' stop >/dev/null 2>&1'); exec('/usr/sbin/update-rc.d hhvm_' . $data['old']['system_user'] . ' remove >/dev/null 2>&1'); - unlink('/etc/init.d/hhvm_' . $data['old']['system_user'] . ' >/dev/null 2>&1'); + unlink('/etc/init.d/hhvm_' . $data['old']['system_user']); + if(is_file('/etc/hhvm/'.$data['old']['system_user'].'.ini')) unlink('/etc/hhvm/'.$data['old']['system_user'].'.ini'); + + if(is_file('/etc/monit/conf.d/hhvm_' . $data['new']['system_user'])){ + unlink('/etc/monit/conf.d/hhvm_' . $data['new']['system_user']); + exec('/etc/init.d/monit restart >/dev/null 2>&1'); + } } } //* Update the PHP-FPM pool configuration file private function php_fpm_pool_update ($data, $web_config, $pool_dir, $pool_name, $socket_dir) { global $app, $conf; + $pool_dir = trim($pool_dir); /* if(trim($data['new']['fastcgi_php_version']) != ''){ $default_php_fpm = false; @@ -2443,6 +2520,26 @@ class nginx_plugin { // Custom php.ini settings $final_php_ini_settings = array(); $custom_php_ini_settings = trim($data['new']['custom_php_ini']); + + if(intval($data['new']['directive_snippets_id']) > 0){ + $snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'nginx' AND active = 'y' AND customer_viewable = 'y'", intval($data['new']['directive_snippets_id'])); + if(isset($snippet['required_php_snippets']) && trim($snippet['required_php_snippets']) != ''){ + $required_php_snippets = explode(',', trim($snippet['required_php_snippets'])); + if(is_array($required_php_snippets) && !empty($required_php_snippets)){ + foreach($required_php_snippets as $required_php_snippet){ + $required_php_snippet = intval($required_php_snippet); + if($required_php_snippet > 0){ + $php_snippet = $app->db->queryOneRecord("SELECT * FROM directive_snippets WHERE directive_snippets_id = ? AND type = 'php' AND active = 'y'", $required_php_snippet); + $php_snippet['snippet'] = trim($php_snippet['snippet']); + if($php_snippet['snippet'] != ''){ + $custom_php_ini_settings .= "\n".$php_snippet['snippet']; + } + } + } + } + } + } + if($custom_php_ini_settings != ''){ // Make sure we only have Unix linebreaks $custom_php_ini_settings = str_replace("\r\n", "\n", $custom_php_ini_settings); @@ -2486,7 +2583,7 @@ class nginx_plugin { unset($tpl); // delete pool in all other PHP versions - $default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); + $default_pool_dir = trim(escapeshellcmd($web_config['php_fpm_pool_dir'])); if(substr($default_pool_dir, -1) != '/') $default_pool_dir .= '/'; if($default_pool_dir != $pool_dir){ if ( @is_file($default_pool_dir.$pool_name.'.conf') ) { @@ -2495,9 +2592,10 @@ class nginx_plugin { $app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); } } - $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$conf["server_id"]); + $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?", $conf["server_id"]); if(is_array($php_versions) && !empty($php_versions)){ foreach($php_versions as $php_version){ + $php_version['php_fpm_pool_dir'] = trim($php_version['php_fpm_pool_dir']); if(substr($php_version['php_fpm_pool_dir'], -1) != '/') $php_version['php_fpm_pool_dir'] .= '/'; if($php_version['php_fpm_pool_dir'] != $pool_dir){ if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) { @@ -2534,6 +2632,7 @@ class nginx_plugin { } else { $pool_dir = $custom_php_fpm_pool_dir; } + $pool_dir = trim($pool_dir); if(substr($pool_dir, -1) != '/') $pool_dir .= '/'; $pool_name = 'web'.$data['old']['domain_id']; @@ -2544,7 +2643,7 @@ class nginx_plugin { } // delete pool in all other PHP versions - $default_pool_dir = escapeshellcmd($web_config['php_fpm_pool_dir']); + $default_pool_dir = trim(escapeshellcmd($web_config['php_fpm_pool_dir'])); if(substr($default_pool_dir, -1) != '/') $default_pool_dir .= '/'; if($default_pool_dir != $pool_dir){ if ( @is_file($default_pool_dir.$pool_name.'.conf') ) { @@ -2553,9 +2652,10 @@ class nginx_plugin { $app->services->restartService('php-fpm', 'reload:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); } } - $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ".$data['old']['server_id']); + $php_versions = $app->db->queryAllRecords("SELECT * FROM server_php WHERE php_fpm_init_script != '' AND php_fpm_ini_dir != '' AND php_fpm_pool_dir != '' AND server_id = ?", $data['old']['server_id']); if(is_array($php_versions) && !empty($php_versions)){ foreach($php_versions as $php_version){ + $php_version['php_fpm_pool_dir'] = trim($php_version['php_fpm_pool_dir']); if(substr($php_version['php_fpm_pool_dir'], -1) != '/') $php_version['php_fpm_pool_dir'] .= '/'; if($php_version['php_fpm_pool_dir'] != $pool_dir){ if ( @is_file($php_version['php_fpm_pool_dir'].$pool_name.'.conf') ) { diff --git a/server/plugins-available/nginx_reverseproxy_plugin.inc.php b/server/plugins-available/nginx_reverseproxy_plugin.inc.php index 1f68649fbfa885c32f990905212983320cd8b018..b5881dbf240886b5cc6127847a84f1e2dfa954de 100644 --- a/server/plugins-available/nginx_reverseproxy_plugin.inc.php +++ b/server/plugins-available/nginx_reverseproxy_plugin.inc.php @@ -70,7 +70,7 @@ class nginx_reverseproxy_plugin { // If the parent_domain_id has been chenged, we will have to update the old site as well. if($this->action == 'update' && $data['new']['parent_domain_id'] != $data['old']['parent_domain_id']) { - $tmp = $app->dbmaster->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$old_parent_domain_id." AND active = 'y'"); + $tmp = $app->dbmaster->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $old_parent_domain_id); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -78,7 +78,7 @@ class nginx_reverseproxy_plugin { } // This is not a vhost, so we need to update the parent record instead. - $tmp = $app->dbmaster->queryOneRecord('SELECT * FROM web_domain WHERE domain_id = '.$new_parent_domain_id." AND active = 'y'"); + $tmp = $app->dbmaster->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $new_parent_domain_id); $data['new'] = $tmp; $data['old'] = $tmp; $this->action = 'update'; @@ -130,7 +130,7 @@ class nginx_reverseproxy_plugin { // get alias domains (co-domains and subdomains) - $aliases = $app->dbmaster->queryAllRecords('SELECT * FROM web_domain WHERE parent_domain_id = '.$data['new']['domain_id']." AND (type != 'vhostsubdomain' OR type != 'vhostalias') AND active = 'y'"); + $aliases = $app->dbmaster->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ? AND (type != 'vhostsubdomain' OR type != 'vhostalias') AND active = 'y'", $data['new']['domain_id']); $server_alias = array(); switch($data['new']['subdomain']) { case 'www': @@ -243,7 +243,7 @@ class nginx_reverseproxy_plugin { //* Save a SSL certificate to disk if($data["new"]["ssl_action"] == 'save') { - $web = $app->masterdb->queryOneRecord("select wd.document_root, sp.ip_address from web_domain wd INNER JOIN server_ip sp USING(server_id) WHERE domain = '".$data['new']['domain']."'"); + $web = $app->masterdb->queryOneRecord("select wd.document_root, sp.ip_address from web_domain wd INNER JOIN server_ip sp USING(server_id) WHERE domain = ?", $data['new']['domain']); $src_ssl_dir = $web["document_root"]."/ssl"; //$domain = $data["new"]["ssl_domain"]; diff --git a/server/plugins-available/openvz_plugin.inc.php b/server/plugins-available/openvz_plugin.inc.php index a50c3def49e81d3df6e6d8d8cbaf32f9966aecf3..d6abced17f3d56fe448c9ea305f51d7a174f0430 100644 --- a/server/plugins-available/openvz_plugin.inc.php +++ b/server/plugins-available/openvz_plugin.inc.php @@ -85,7 +85,7 @@ class openvz_plugin { return; } - $tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ".$data['new']['ostemplate_id']); + $tmp = $app->db->queryOneRecord("SELECT template_file FROM openvz_ostemplate WHERE ostemplate_id = ?", $data['new']['ostemplate_id']); $ostemplate = escapeshellcmd($tmp['template_file']); unset($tmp); diff --git a/server/plugins-available/pma_symlink_plugin.inc.php b/server/plugins-available/pma_symlink_plugin.inc.php index db9b6f7f62613b781b67a96ef6d48cf1edc4e218..6b9b4fb2642f4b65dad4c511a851c5e6dc5ab857 100644 --- a/server/plugins-available/pma_symlink_plugin.inc.php +++ b/server/plugins-available/pma_symlink_plugin.inc.php @@ -81,7 +81,7 @@ class pma_symlink_plugin { // If the parent_domain_id has been chenged, we will have to update the old site as well. if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) { - $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $old_parent_domain_id); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; @@ -89,7 +89,7 @@ class pma_symlink_plugin { } // This is not a vhost, so we need to update the parent record instead. - $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $new_parent_domain_id); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; diff --git a/server/plugins-available/postfix_filter_plugin.inc.php b/server/plugins-available/postfix_filter_plugin.inc.php index 867df253a5f0e8117323e37e3a3215608f3f87cf..9c97ff1fa8c6bc14a327ebc782b1ac70026fd124 100644 --- a/server/plugins-available/postfix_filter_plugin.inc.php +++ b/server/plugins-available/postfix_filter_plugin.inc.php @@ -80,8 +80,8 @@ class postfix_filter_plugin { $type = $data["new"]["type"]; if($type != '') { - $sql = "SELECT * FROM mail_content_filter WHERE server_id = ".intval($conf["server_id"])." AND type = '".$app->db->quote($type)."' AND active = 'y'"; - $rules = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_content_filter WHERE server_id = ? AND type = ?' AND active = 'y'"; + $rules = $app->db->queryAllRecords($sql, $conf["server_id"], $type); $content = ''; foreach($rules as $rule) { $content .= $rule["pattern"]; @@ -111,8 +111,8 @@ class postfix_filter_plugin { $type = $data["old"]["type"]; if($type != '') { - $sql = "SELECT * FROM mail_content_filter WHERE server_id = ".intval($conf["server_id"])." AND type = '".$app->db->quote($type)."' AND active = 'y'"; - $rules = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_content_filter WHERE server_id = ? AND type = ? AND active = 'y'"; + $rules = $app->db->queryAllRecords($sql, $conf["server_id"], $type); $content = ''; foreach($rules as $rule) { $content .= $rule["pattern"]; diff --git a/server/plugins-available/postfix_server_plugin.inc.php b/server/plugins-available/postfix_server_plugin.inc.php index 474d10dc303a8f6d82ca6d5c06c5084516d5441e..94a576263d4593df35bb1c21bd70163b2da86f98 100644 --- a/server/plugins-available/postfix_server_plugin.inc.php +++ b/server/plugins-available/postfix_server_plugin.inc.php @@ -115,6 +115,7 @@ class postfix_server_plugin { $rbl_hosts = explode(",", $rbl_hosts); } $options = explode(", ", exec("postconf -h smtpd_recipient_restrictions")); + $new_options = array(); foreach ($options as $key => $value) { if (!preg_match('/reject_rbl_client/', $value)) { $new_options[] = $value; @@ -138,6 +139,24 @@ class postfix_server_plugin { exec("postconf -e 'smtpd_recipient_restrictions = ".implode(", ", $new_options)."'"); } + if($mail_config['reject_sender_login_mismatch'] != $old_ini_data['mail']['reject_sender_login_mismatch']) { + $options = explode(", ", exec("postconf -h smtpd_sender_restrictions")); + $new_options = array(); + foreach ($options as $key => $value) { + if (!preg_match('/reject_authenticated_sender_login_mismatch/', $value)) { + $new_options[] = $value; + } + } + + if ($mail_config['reject_sender_login_mismatch'] == 'y') { + reset($new_options); $i = 0; + // insert after check_sender_access but before permit_... + while (isset($new_options[$i]) && substr($new_options[$i], 0, 19) == 'check_sender_access') ++$i; + array_splice($new_options, $i, 0, array('reject_authenticated_sender_login_mismatch')); + } + exec("postconf -e 'smtpd_sender_restrictions = ".implode(", ", $new_options)."'"); + } + if ($mail_config["mailbox_virtual_uidgid_maps"] == 'y') { // If dovecot switch to lmtp if($app->system->is_installed('dovecot')) { diff --git a/server/plugins-available/powerdns_plugin.inc.php b/server/plugins-available/powerdns_plugin.inc.php index 14c244714b608853c1cba95597cf67c7be58b9d8..412050d009225126e08fba0f3d39b6f1c2e998cb 100644 --- a/server/plugins-available/powerdns_plugin.inc.php +++ b/server/plugins-available/powerdns_plugin.inc.php @@ -132,9 +132,9 @@ class powerdns_plugin { $origin = substr($data["new"]["origin"], 0, -1); $ispconfig_id = $data["new"]["id"]; - $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$ispconfig_id); + $serial = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $ispconfig_id); $serial_id = $serial["serial"]; - $app->db->query("INSERT INTO powerdns.domains (name, type, notified_serial, ispconfig_id) VALUES ('$origin', 'MASTER', $serial_id, $ispconfig_id)"); + $app->db->query("INSERT INTO powerdns.domains (name, type, notified_serial, ispconfig_id) VALUES (?, ?, ?, ?)", $origin, 'MASTER', $serial_id, $ispconfig_id); $zone_id = $app->db->insertID(); if(substr($data["new"]["ns"], -1) == '.'){ $ns = substr($data["new"]["ns"], 0, -1); @@ -147,7 +147,7 @@ class powerdns_plugin { $content = $ns.' '.$hostmaster.' '.$data["new"]["serial"].' '.$data["new"]["refresh"].' '.$data["new"]["retry"].' '.$data["new"]["expire"].' '.$data["new"]["minimum"]; $ttl = $data["new"]["ttl"]; - $app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES ($zone_id, '$origin', 'SOA', '$content', $ttl, 0, ".time().", $ispconfig_id)"); + $app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES (?, ?, 'SOA', ?, ?, 0, UNIX_TIMESTAMP(), ?)", $zone_id, $origin, $content, $ttl, $ispconfig_id); //* tell pdns to rediscover zones in DB $this->zoneRediscover(); @@ -164,7 +164,7 @@ class powerdns_plugin { if($data["old"]["active"] != 'Y') return; $this->soa_delete($event_name, $data); } else { - $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["new"]["id"]); + $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ?", $data["new"]["id"]); if($data["old"]["active"] == 'Y' && is_array($exists)){ $origin = substr($data["new"]["origin"], 0, -1); $ispconfig_id = $data["new"]["id"]; @@ -179,7 +179,7 @@ class powerdns_plugin { $hostmaster = substr($data["new"]["mbox"], 0, -1); $content = $ns.' '.$hostmaster.' '.$data["new"]["serial"].' '.$data["new"]["refresh"].' '.$data["new"]["retry"].' '.$data["new"]["expire"].' '.$data["new"]["minimum"]; $ttl = $data["new"]["ttl"]; - $app->db->query("UPDATE powerdns.records SET name = '$origin', content = '$content', ttl = $ttl, change_date = ".time()." WHERE ispconfig_id = ".$data["new"]["id"]." AND type = 'SOA'"); + $app->db->query("UPDATE powerdns.records SET name = ?, content = ?, ttl = ?, change_date = UNIX_TIMESTAMP() WHERE ispconfig_id = ? AND type = 'SOA'", $origin, $content, $ttl, $data["new"]["id"]); //* tell pdns to use 'pdnssec rectify' on the new zone $this->rectifyZone($data); @@ -188,7 +188,7 @@ class powerdns_plugin { } else { $this->soa_insert($event_name, $data); $ispconfig_id = $data["new"]["id"]; - if($records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = $ispconfig_id AND active = 'Y'")){ + if($records = $app->db->queryAllRecords("SELECT * FROM dns_rr WHERE zone = ? AND active = 'Y'", $ispconfig_id)){ foreach($records as $record){ foreach($record as $key => $val){ $data["new"][$key] = $val; @@ -207,10 +207,10 @@ class powerdns_plugin { function soa_delete($event_name, $data) { global $app, $conf; - $zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["old"]["id"]." AND type = 'MASTER'"); + $zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ? AND type = 'MASTER'", $data["old"]["id"]); $zone_id = $zone["id"]; - $app->db->query("DELETE FROM powerdns.records WHERE domain_id = $zone_id"); - $app->db->query("DELETE FROM powerdns.domains WHERE id = $zone_id"); + $app->db->query("DELETE FROM powerdns.records WHERE domain_id = ?", $zone_id); + $app->db->query("DELETE FROM powerdns.domains WHERE id = ?", $zone_id); } function slave_insert($event_name, $data) { @@ -222,7 +222,7 @@ class powerdns_plugin { $ispconfig_id = $data["new"]["id"]; $master_ns = $data["new"]["ns"]; - $app->db->query("INSERT INTO powerdns.domains (name, type, master, ispconfig_id) VALUES ('$origin', 'SLAVE', '$master_ns', $ispconfig_id)"); + $app->db->query("INSERT INTO powerdns.domains (name, type, master, ispconfig_id) VALUES (?, ?, ?, ?)", $origin, 'SLAVE', $master_ns, $ispconfig_id); $zone_id = $app->db->insertID(); @@ -243,12 +243,12 @@ class powerdns_plugin { $ispconfig_id = $data["new"]["id"]; $master_ns = $data["new"]["ns"]; - $app->db->query("UPDATE powerdns.domains SET name = '$origin', type = 'SLAVE', master = '$master_ns' WHERE ispconfig_id=$ispconfig_id AND type = 'SLAVE'"); + $app->db->query("UPDATE powerdns.domains SET name = ?, type = 'SLAVE', master = ? WHERE ispconfig_id=? AND type = 'SLAVE'", $origin, $master_ns, $ispconfig_id); $zone_id = $app->db->insertID(); - $zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$ispconfig_id." AND type = 'SLAVE'"); + $zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ? AND type = 'SLAVE'", $ispconfig_id); $zone_id = $zone["id"]; - $app->db->query("DELETE FROM powerdns.records WHERE domain_id = $zone_id AND ispconfig_id = 0"); + $app->db->query("DELETE FROM powerdns.records WHERE domain_id = ? AND ispconfig_id = 0", $zone_id); //* tell pdns to fetch zone from master server $this->fetchFromMaster($data); @@ -264,21 +264,21 @@ class powerdns_plugin { function slave_delete($event_name, $data) { global $app, $conf; - $zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["old"]["id"]." AND type = 'SLAVE'"); + $zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ? AND type = 'SLAVE'", $data["old"]["id"]); $zone_id = $zone["id"]; - $app->db->query("DELETE FROM powerdns.records WHERE domain_id = $zone_id"); - $app->db->query("DELETE FROM powerdns.domains WHERE id = $zone_id"); + $app->db->query("DELETE FROM powerdns.records WHERE domain_id = ?", $zone_id); + $app->db->query("DELETE FROM powerdns.domains WHERE id = ?", $zone_id); } function rr_insert($event_name, $data) { global $app, $conf; if($data["new"]["active"] != 'Y') return; - $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ".$data["new"]["id"]); + $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ?", $data["new"]["id"]); if ( is_array($exists) ) return; - $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]); + $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data["new"]["zone"]); $origin = substr($zone["origin"], 0, -1); - $powerdns_zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["new"]["zone"]." AND type = 'MASTER'"); + $powerdns_zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ? AND type = 'MASTER'", $data["new"]["zone"]); $zone_id = $powerdns_zone["id"]; $type = $data["new"]["type"]; @@ -327,7 +327,7 @@ class powerdns_plugin { $change_date = time(); $ispconfig_id = $data["new"]["id"]; - $app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES ($zone_id, '$name', '$type', '$content', $ttl, $prio, $change_date, $ispconfig_id)"); + $app->db->query("INSERT INTO powerdns.records (domain_id, name, type, content, ttl, prio, change_date, ispconfig_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", $zone_id, $name, $type, $content, $ttl, $prio, $change_date, $ispconfig_id); //* tell pdns to use 'pdnssec rectify' on the new zone $this->rectifyZone($data); @@ -340,11 +340,11 @@ class powerdns_plugin { if($data["old"]["active"] != 'Y') return; $this->rr_delete($event_name, $data); } else { - $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ".$data["new"]["id"]); + $exists = $app->db->queryOneRecord("SELECT * FROM powerdns.records WHERE ispconfig_id = ?", $data["new"]["id"]); if($data["old"]["active"] == 'Y' && is_array($exists)){ - $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ".$data["new"]["zone"]); + $zone = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ?", $data["new"]["zone"]); $origin = substr($zone["origin"], 0, -1); - $powerdns_zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ".$data["new"]["zone"]." AND type = 'MASTER'"); + $powerdns_zone = $app->db->queryOneRecord("SELECT * FROM powerdns.domains WHERE ispconfig_id = ? AND type = 'MASTER'", $data["new"]["zone"]); $zone_id = $powerdns_zone["id"]; $type = $data["new"]["type"]; @@ -392,7 +392,7 @@ class powerdns_plugin { $prio = $data["new"]["aux"]; $change_date = time(); $ispconfig_id = $data["new"]["id"]; - $app->db->query("UPDATE powerdns.records SET name = '$name', type = '$type', content = '$content', ttl = $ttl, prio = $prio, change_date = ".time()." WHERE ispconfig_id = $ispconfig_id AND type != 'SOA'"); + $app->db->query("UPDATE powerdns.records SET name = ?, type = ?, content = ?, ttl = ?, prio = ?, change_date = UNIX_TIMESTAMP() WHERE ispconfig_id = ? AND type != 'SOA'", $name, $type, $content, $ttl, $prio, $ispconfig_id); //* tell pdns to use 'pdnssec rectify' on the new zone $this->rectifyZone($data); @@ -406,7 +406,7 @@ class powerdns_plugin { global $app, $conf; $ispconfig_id = $data["old"]["id"]; - $app->db->query("DELETE FROM powerdns.records WHERE ispconfig_id = $ispconfig_id AND type != 'SOA'"); + $app->db->query("DELETE FROM powerdns.records WHERE ispconfig_id = ? AND type != 'SOA'", $ispconfig_id); } function find_pdns_control() { @@ -475,7 +475,7 @@ class powerdns_plugin { exec($pdns_pdnssec . ' rectify-zone ' . rtrim($data["new"]["origin"],".")); } else { // get origin from DB for all other recordtypes - $zn = $app->db->queryOneRecord("SELECT d.name AS name FROM powerdns.domains d, powerdns.records r WHERE r.ispconfig_id=".$data["new"]["id"]." AND r.domain_id = d.id"); + $zn = $app->db->queryOneRecord("SELECT d.name AS name FROM powerdns.domains d, powerdns.records r WHERE r.ispconfig_id=? AND r.domain_id = d.id", $data["new"]["id"]); exec($pdns_pdnssec . ' rectify-zone ' . trim($zn["name"])); } } diff --git a/server/plugins-available/shelluser_base_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php index e19796cfca45778e8a9522ab8167e041306fd381..a0ae9a51f1eec6e3fb54a115627cb34a72ec3aef 100755 --- a/server/plugins-available/shelluser_base_plugin.inc.php +++ b/server/plugins-available/shelluser_base_plugin.inc.php @@ -79,7 +79,7 @@ class shelluser_base_plugin { } //* Check if the resulting path is inside the docroot - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['new']['parent_domain_id'])); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); if(substr($data['new']['dir'],0,strlen($web['document_root'])) != $web['document_root']) { $app->log('Directory of the shell user is outside of website docroot.',LOGLEVEL_WARN); return false; @@ -96,6 +96,8 @@ class shelluser_base_plugin { return false; } + if($data['new']['active'] != 'y') $data['new']['shell'] = '/bin/false'; + if($app->system->is_user($data['new']['puser'])) { // Get the UID of the parent user @@ -103,14 +105,27 @@ class shelluser_base_plugin { if($uid > $this->min_uid) { //* Remove webfolder protection $app->system->web_folder_protection($web['document_root'], false); - - if(!is_dir($data['new']['dir'])){ - $app->file->mkdirs(escapeshellcmd($data['new']['dir']), '0700'); - $app->system->chown(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['username'])); - $app->system->chgrp(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['pgroup'])); + + //* Home directory of the new shell user + if($data['new']['chroot'] == 'jailkit') { + $homedir = $data['new']['dir']; + } else { + $homedir = $data['new']['dir'].'/home/'.$data['new']['username']; + } + + if(!is_dir($data['new']['dir'].'/home')){ + $app->file->mkdirs(escapeshellcmd($data['new']['dir'].'/home'), '0750'); + $app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['puser'])); + $app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['pgroup'])); + } + + if(!is_dir($homedir)){ + $app->file->mkdirs(escapeshellcmd($homedir), '0750'); + $app->system->chown(escapeshellcmd($homedir),escapeshellcmd($data['new']['puser'])); + $app->system->chgrp(escapeshellcmd($homedir),escapeshellcmd($data['new']['pgroup'])); } $command = 'useradd'; - $command .= ' -d '.escapeshellcmd($data['new']['dir']); + $command .= ' -d '.escapeshellcmd($homedir); $command .= ' -g '.escapeshellcmd($data['new']['pgroup']); $command .= ' -o '; // non unique if($data['new']['password'] != '') $command .= ' -p '.escapeshellcmd($data['new']['password']); @@ -129,10 +144,10 @@ class shelluser_base_plugin { $this->_setup_ssh_rsa(); //* Create .bash_history file - $app->system->touch(escapeshellcmd($data['new']['dir']).'/.bash_history'); - $app->system->chmod(escapeshellcmd($data['new']['dir']).'/.bash_history', 0755); - $app->system->chown(escapeshellcmd($data['new']['dir']).'/.bash_history', $data['new']['username']); - $app->system->chgrp(escapeshellcmd($data['new']['dir']).'/.bash_history', $data['new']['pgroup']); + $app->system->touch(escapeshellcmd($homedir).'/.bash_history'); + $app->system->chmod(escapeshellcmd($homedir).'/.bash_history', 0755); + $app->system->chown(escapeshellcmd($homedir).'/.bash_history', $data['new']['username']); + $app->system->chgrp(escapeshellcmd($homedir).'/.bash_history', $data['new']['pgroup']); //* Disable shell user temporarily if we use jailkit if($data['new']['chroot'] == 'jailkit') { @@ -163,7 +178,7 @@ class shelluser_base_plugin { } //* Check if the resulting path is inside the docroot - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['new']['parent_domain_id'])); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); if(substr($data['new']['dir'],0,strlen($web['document_root'])) != $web['document_root']) { $app->log('Directory of the shell user is outside of website docroot.',LOGLEVEL_WARN); return false; @@ -181,10 +196,22 @@ class shelluser_base_plugin { return false; } + if($data['new']['active'] != 'y') $data['new']['shell'] = '/bin/false'; + if($app->system->is_user($data['new']['puser'])) { // Get the UID of the parent user $uid = intval($app->system->getuid($data['new']['puser'])); if($uid > $this->min_uid) { + + //* Home directory of the shell user + if($data['new']['chroot'] == 'jailkit') { + $homedir = $data['new']['dir']; + $homedir_old = $data['old']['dir']; + } else { + $homedir = $data['new']['dir'].'/home/'.$data['new']['username']; + $homedir_old = $data['old']['dir'].'/home/'.$data['old']['username']; + } + // Check if the user that we want to update exists, if not, we insert it if($app->system->is_user($data['old']['username'])) { /* @@ -202,12 +229,32 @@ class shelluser_base_plugin { $app->log("Executed command: $command ",LOGLEVEL_DEBUG); */ //$groupinfo = $app->system->posix_getgrnam($data['new']['pgroup']); - if($data['new']['dir'] != $data['old']['dir'] && !is_dir($data['new']['dir'])){ - $app->file->mkdirs(escapeshellcmd($data['new']['dir']), '0700'); - $app->system->chown(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['username'])); - $app->system->chgrp(escapeshellcmd($data['new']['dir']),escapeshellcmd($data['new']['pgroup'])); + if($homedir != $homedir_old && !is_dir($homedir)){ + $app->system->web_folder_protection($web['document_root'], false); + if(!is_dir($data['new']['dir'].'/home')){ + $app->file->mkdirs(escapeshellcmd($data['new']['dir'].'/home'), '0750'); + $app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['puser'])); + $app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['pgroup'])); + } + $app->file->mkdirs(escapeshellcmd($homedir), '0750'); + $app->system->chown(escapeshellcmd($homedir),escapeshellcmd($data['new']['username'])); + $app->system->chgrp(escapeshellcmd($homedir),escapeshellcmd($data['new']['pgroup'])); + $app->system->web_folder_protection($web['document_root'], true); + } else { + if(!is_dir($homedir)){ + $app->system->web_folder_protection($web['document_root'], false); + if(!is_dir($data['new']['dir'].'/home')){ + $app->file->mkdirs(escapeshellcmd($data['new']['dir'].'/home'), '0750'); + $app->system->chown(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['puser'])); + $app->system->chgrp(escapeshellcmd($data['new']['dir'].'/home'),escapeshellcmd($data['new']['pgroup'])); + } + $app->file->mkdirs(escapeshellcmd($homedir), '0750'); + $app->system->chown(escapeshellcmd($homedir),escapeshellcmd($data['new']['puser'])); + $app->system->chgrp(escapeshellcmd($homedir),escapeshellcmd($data['new']['pgroup'])); + $app->system->web_folder_protection($web['document_root'], true); + } } - $app->system->usermod($data['old']['username'], 0, $app->system->getgid($data['new']['pgroup']), $data['new']['dir'], $data['new']['shell'], $data['new']['password'], $data['new']['username']); + $app->system->usermod($data['old']['username'], 0, $app->system->getgid($data['new']['pgroup']), $homedir, $data['new']['shell'], $data['new']['password'], $data['new']['username']); $app->log("Updated shelluser: ".$data['old']['username'], LOGLEVEL_DEBUG); // call the ssh-rsa update function @@ -218,10 +265,10 @@ class shelluser_base_plugin { //* Create .bash_history file if(!is_file($data['new']['dir']).'/.bash_history') { - $app->system->touch(escapeshellcmd($data['new']['dir']).'/.bash_history'); - $app->system->chmod(escapeshellcmd($data['new']['dir']).'/.bash_history', 0755); - $app->system->chown(escapeshellcmd($data['new']['dir']).'/.bash_history', escapeshellcmd($data['new']['username'])); - $app->system->chgrp(escapeshellcmd($data['new']['dir']).'/.bash_history', escapeshellcmd($data['new']['pgroup'])); + $app->system->touch(escapeshellcmd($homedir).'/.bash_history'); + $app->system->chmod(escapeshellcmd($homedir).'/.bash_history', 0755); + $app->system->chown(escapeshellcmd($homedir).'/.bash_history', escapeshellcmd($data['new']['username'])); + $app->system->chgrp(escapeshellcmd($homedir).'/.bash_history', escapeshellcmd($data['new']['pgroup'])); } } else { @@ -239,7 +286,7 @@ class shelluser_base_plugin { function delete($event_name, $data) { global $app, $conf; - $app->uses('system,getconf'); + $app->uses('system,getconf,services'); $security_config = $app->getconf->get_security_config('permissions'); if($security_config['allow_shell_user'] != 'yes') { @@ -251,16 +298,22 @@ class shelluser_base_plugin { // Get the UID of the user $userid = intval($app->system->getuid($data['old']['username'])); if($userid > $this->min_uid) { + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['old']['parent_domain_id'])); + // check if we have to delete the dir - $check = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `dir` = \'' . $app->db->quote($data['old']['dir']) . '\''); + $check = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `dir` = ?', $data['old']['dir']); if(!$check && is_dir($data['old']['dir'])) { - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($data['old']['parent_domain_id'])); - + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['old']['parent_domain_id']); $app->system->web_folder_protection($web['document_root'], false); // delete dir - $homedir = $data['old']['dir']; + if($data['new']['chroot'] == 'jailkit') { + $homedir = $data['old']['dir']; + } else { + $homedir = $data['old']['dir'].'/home/'.$data['old']['username']; + } + if(substr($homedir, -1) !== '/') $homedir .= '/'; $files = array('.bash_logout', '.bash_history', '.bashrc', '.profile'); $dirs = array('.ssh', '.cache'); @@ -292,10 +345,33 @@ class shelluser_base_plugin { // We delete only non jailkit users, jailkit users will be deleted by the jailkit plugin. if ($data['old']['chroot'] != "jailkit") { + // if this web uses PHP-FPM, that PPH-FPM service must be stopped before we can delete this user + if($web['php'] == 'php-fpm'){ + if(trim($web['fastcgi_php_version']) != ''){ + $default_php_fpm = false; + list($custom_php_fpm_name, $custom_php_fpm_init_script, $custom_php_fpm_ini_dir, $custom_php_fpm_pool_dir) = explode(':', trim($web['fastcgi_php_version'])); + } else { + $default_php_fpm = true; + } + $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); + if(!$default_php_fpm){ + $app->services->restartService('php-fpm', 'stop:'.$custom_php_fpm_init_script); + } else { + $app->services->restartService('php-fpm', 'stop:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); + } + } $command = 'killall -u '.escapeshellcmd($data['old']['username']).' ; userdel -f'; $command .= ' '.escapeshellcmd($data['old']['username']).' &> /dev/null'; exec($command); $app->log("Deleted shelluser: ".$data['old']['username'], LOGLEVEL_DEBUG); + // start PHP-FPM again + if($web['php'] == 'php-fpm'){ + if(!$default_php_fpm){ + $app->services->restartService('php-fpm', 'start:'.$custom_php_fpm_init_script); + } else { + $app->services->restartService('php-fpm', 'start:'.$conf['init_scripts'].'/'.$web_config['php_fpm_init_script']); + } + } } } else { @@ -311,11 +387,11 @@ class shelluser_base_plugin { global $app; $this->app->log("ssh-rsa setup shelluser_base", LOGLEVEL_DEBUG); // Get the client ID, username, and the key - $domain_data = $this->app->db->queryOneRecord('SELECT sys_groupid FROM web_domain WHERE web_domain.domain_id = '.intval($this->data['new']['parent_domain_id'])); - $sys_group_data = $this->app->db->queryOneRecord('SELECT * FROM sys_group WHERE sys_group.groupid = '.intval($domain_data['sys_groupid'])); + $domain_data = $this->app->db->queryOneRecord('SELECT sys_groupid FROM web_domain WHERE web_domain.domain_id = ?', $this->data['new']['parent_domain_id']); + $sys_group_data = $this->app->db->queryOneRecord('SELECT * FROM sys_group WHERE sys_group.groupid = ?', $domain_data['sys_groupid']); $id = intval($sys_group_data['client_id']); $username= $sys_group_data['name']; - $client_data = $this->app->db->queryOneRecord('SELECT * FROM client WHERE client.client_id = '.$id); + $client_data = $this->app->db->queryOneRecord('SELECT * FROM client WHERE client.client_id = ?', $id); $userkey = $client_data['ssh_rsa']; unset($domain_data); unset($client_data); @@ -323,7 +399,7 @@ class shelluser_base_plugin { // ssh-rsa authentication variables //$sshrsa = $this->data['new']['ssh_rsa']; $sshrsa = ''; - $ssh_users = $app->db->queryAllRecords("SELECT ssh_rsa FROM shell_user WHERE parent_domain_id = ".intval($this->data['new']['parent_domain_id'])); + $ssh_users = $app->db->queryAllRecords("SELECT ssh_rsa FROM shell_user WHERE parent_domain_id = ?", $this->data['new']['parent_domain_id']); if(is_array($ssh_users)) { foreach($ssh_users as $sshu) { if($sshu['ssh_rsa'] != '') $sshrsa .= "\n".$sshu['ssh_rsa']; @@ -347,7 +423,7 @@ class shelluser_base_plugin { $userkey = $app->system->file_get_contents('/tmp/id_rsa.pub'); // save keypair in client table - $this->app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".$app->db->quote($app->system->file_get_contents('/tmp/id_rsa'))."', ssh_rsa = '".$app->db->quote($userkey)."' WHERE client_id = ".$id); + $this->app->db->query("UPDATE client SET created_at = UNIX_TIMESTAMP(), id_rsa = ?, ssh_rsa = ? WHERE client_id = ?", $app->system->file_get_contents('/tmp/id_rsa'), $userkey, $id); $app->system->unlink('/tmp/id_rsa'); $app->system->unlink('/tmp/id_rsa.pub'); diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php index 3c8e2948a1d6c5d5bb83e4006961fd2e7f29a2d3..aabbcde2343a5392447f789cebc4516706ed31b4 100755 --- a/server/plugins-available/shelluser_jailkit_plugin.inc.php +++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php @@ -80,7 +80,7 @@ class shelluser_jailkit_plugin { } - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['new']['parent_domain_id']); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); if(!$app->system->is_allowed_user($data['new']['username'], false, false) || !$app->system->is_allowed_user($data['new']['puser'], true, true) @@ -159,7 +159,7 @@ class shelluser_jailkit_plugin { return false; } - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['new']['parent_domain_id']); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); if(!$app->system->is_allowed_user($data['new']['username'], false, false) || !$app->system->is_allowed_user($data['new']['puser'], true, true) @@ -232,7 +232,7 @@ class shelluser_jailkit_plugin { return false; } - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$data['old']['parent_domain_id']); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['old']['parent_domain_id']); if ($data['old']['chroot'] == "jailkit") { @@ -284,7 +284,7 @@ class shelluser_jailkit_plugin { //add bash.bashrc script //we need to collect the domain name to be used as the HOSTNAME in the bashrc script - $web = $this->app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ".intval($this->data['new']["parent_domain_id"])); + $web = $this->app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ?", $this->data['new']["parent_domain_id"]); $this->app->load('tpl'); @@ -407,7 +407,7 @@ class shelluser_jailkit_plugin { $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); // Get the parent website of this shell user - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$this->data['new']['parent_domain_id']); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $this->data['new']['parent_domain_id']); //* If the security level is set to high if($web_config['security_level'] == 20 && is_array($web)) { @@ -431,11 +431,11 @@ class shelluser_jailkit_plugin { global $app; $this->app->log("ssh-rsa setup shelluser_jailkit", LOGLEVEL_DEBUG); // Get the client ID, username, and the key - $domain_data = $this->app->db->queryOneRecord('SELECT sys_groupid FROM web_domain WHERE web_domain.domain_id = '.intval($this->data['new']['parent_domain_id'])); - $sys_group_data = $this->app->db->queryOneRecord('SELECT * FROM sys_group WHERE sys_group.groupid = '.intval($domain_data['sys_groupid'])); + $domain_data = $this->app->db->queryOneRecord('SELECT sys_groupid FROM web_domain WHERE web_domain.domain_id = ?', $this->data['new']['parent_domain_id']); + $sys_group_data = $this->app->db->queryOneRecord('SELECT * FROM sys_group WHERE sys_group.groupid = ?', $domain_data['sys_groupid']); $id = intval($sys_group_data['client_id']); $username= $sys_group_data['name']; - $client_data = $this->app->db->queryOneRecord('SELECT * FROM client WHERE client.client_id = '.$id); + $client_data = $this->app->db->queryOneRecord('SELECT * FROM client WHERE client.client_id = ?', $id); $userkey = $client_data['ssh_rsa']; unset($domain_data); unset($client_data); @@ -459,7 +459,7 @@ class shelluser_jailkit_plugin { $userkey = $app->system->file_get_contents('/tmp/id_rsa.pub'); // save keypair in client table - $this->app->db->query("UPDATE client SET created_at = ".time().", id_rsa = '".$app->db->quote($app->system->file_get_contents('/tmp/id_rsa'))."', ssh_rsa = '".$app->db->quote($userkey)."' WHERE client_id = ".$id); + $this->app->db->query("UPDATE client SET created_at = UNIX_TIMESTAMP(), id_rsa = ? ssh_rsa = ? WHERE client_id = ?", $app->system->file_get_contents('/tmp/id_rsa'), $userkey, $id); $app->system->unlink('/tmp/id_rsa'); $app->system->unlink('/tmp/id_rsa.pub'); @@ -532,10 +532,10 @@ class shelluser_jailkit_plugin { global $app, $conf; // check if we have to delete the dir - $check = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `dir` = \'' . $app->db->quote($homedir) . '\''); + $check = $app->db->queryOneRecord('SELECT shell_user_id FROM `shell_user` WHERE `dir` = ?', $homedir); if(!$check && is_dir($homedir)) { - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($parent_domain_id)); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $parent_domain_id); $app->system->web_folder_protection($web['document_root'], false); // delete dir diff --git a/server/plugins-available/software_update_plugin.inc.php b/server/plugins-available/software_update_plugin.inc.php index 6f12bf890a96870f0240a4eb3ee45cf5bc26d755..ae6b79cfc4ac42bb6d68355290112f60e6bd53e2 100644 --- a/server/plugins-available/software_update_plugin.inc.php +++ b/server/plugins-available/software_update_plugin.inc.php @@ -67,8 +67,8 @@ class software_update_plugin { private function set_install_status($inst_id, $status) { global $app; - $app->db->query("UPDATE software_update_inst SET status = '{$status}' WHERE software_update_inst_id = '{$inst_id}'"); - $app->dbmaster->query("UPDATE software_update_inst SET status = '{$status}' WHERE software_update_inst_id = '{$inst_id}'"); + $app->db->query("UPDATE software_update_inst SET status = ? WHERE software_update_inst_id = ?", $status, $inst_id); + $app->dbmaster->query("UPDATE software_update_inst SET status = ? WHERE software_update_inst_id = ?", $status, $inst_id); } public function process($event_name, $data) { @@ -76,8 +76,8 @@ class software_update_plugin { //* Get the info of the package: $software_update_id = intval($data["new"]["software_update_id"]); - $software_update = $app->db->queryOneRecord("SELECT * FROM software_update WHERE software_update_id = '$software_update_id'"); - $software_package = $app->db->queryOneRecord("SELECT * FROM software_package WHERE package_name = '".$app->db->quote($software_update['package_name'])."'"); + $software_update = $app->db->queryOneRecord("SELECT * FROM software_update WHERE software_update_id = ?", $software_update_id); + $software_package = $app->db->queryOneRecord("SELECT * FROM software_package WHERE package_name = ?", $software_update['package_name']); if($software_package['package_type'] == 'ispconfig' && !$conf['software_updates_enabled'] == true) { $app->log('Software Updates not enabled on this server. To enable updates, set $conf["software_updates_enabled"] = true; in config.inc.php', LOGLEVEL_WARN); diff --git a/server/plugins-available/webmail_symlink_plugin.inc.php b/server/plugins-available/webmail_symlink_plugin.inc.php index 43cca9b357956e4fe65eefbc47046e21e006fb10..c64b706d7e4361d42919246c8e8804426ea2def9 100644 --- a/server/plugins-available/webmail_symlink_plugin.inc.php +++ b/server/plugins-available/webmail_symlink_plugin.inc.php @@ -81,7 +81,7 @@ class webmail_symlink_plugin { // If the parent_domain_id has been chenged, we will have to update the old site as well. if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) { - $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $old_parent_domain_id); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; @@ -89,7 +89,7 @@ class webmail_symlink_plugin { } // This is not a vhost, so we need to update the parent record instead. - $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'"); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ? AND active = 'y'", $new_parent_domain_id); $data["new"] = $tmp; $data["old"] = $tmp; $this->action = 'update'; diff --git a/server/plugins-available/webserver_plugin.inc.php b/server/plugins-available/webserver_plugin.inc.php index dd5a50b0561012f5fc072c391e08f4f30e7b0041..cca339ace01a5f123e6dd9167c568343d1906eed 100644 --- a/server/plugins-available/webserver_plugin.inc.php +++ b/server/plugins-available/webserver_plugin.inc.php @@ -107,7 +107,7 @@ class webserver_plugin { //** read additional php versions of this server - $php_versions = $app->db->queryAllRecords('SELECT server_php_id, php_fastcgi_ini_dir, php_fpm_ini_dir FROM server_php WHERE server_id = ' . intval($conf['server_id'])); + $php_versions = $app->db->queryAllRecords('SELECT server_php_id, php_fastcgi_ini_dir, php_fpm_ini_dir FROM server_php WHERE server_id = ?', $conf['server_id']); foreach($php_versions as $php) { if($php['php_fastcgi_ini_dir'] && $php['php_fastcgi_ini_dir'] . '/php.ini' != $web_config['php_ini_path_cgi']) { $check_files[] = array('file' => $php['php_fastcgi_ini_dir'] . '/php.ini', diff --git a/server/plugins-available/xmpp_plugin.inc.php b/server/plugins-available/xmpp_plugin.inc.php new file mode 100644 index 0000000000000000000000000000000000000000..128a88ebb47e76d9ce51dc1b05f578fc15a9ab2b --- /dev/null +++ b/server/plugins-available/xmpp_plugin.inc.php @@ -0,0 +1,397 @@ +plugins->registerEvent('server_insert', 'xmpp_plugin', 'insert'); + $app->plugins->registerEvent('server_update', 'xmpp_plugin', 'update'); + + $app->plugins->registerEvent('xmpp_domain_insert', 'xmpp_plugin', 'ssl'); + $app->plugins->registerEvent('xmpp_domain_update', 'xmpp_plugin', 'ssl'); + $app->plugins->registerEvent('xmpp_domain_delete', 'xmpp_plugin', 'ssl'); + + $app->plugins->registerEvent('xmpp_domain_insert', 'xmpp_plugin', 'domainInsert'); + $app->plugins->registerEvent('xmpp_domain_update', 'xmpp_plugin', 'domainUpdate'); + $app->plugins->registerEvent('xmpp_domain_delete', 'xmpp_plugin', 'domainDelete'); + $app->plugins->registerEvent('xmpp_user_insert', 'xmpp_plugin', 'userInsert'); + $app->plugins->registerEvent('xmpp_user_update', 'xmpp_plugin', 'userUpdate'); + $app->plugins->registerEvent('xmpp_user_delete', 'xmpp_plugin', 'userDelete'); + + } + + function insert($event_name, $data) { + global $app, $conf; + + $this->update($event_name, $data); + + } + + // The purpose of this plugin is to rewrite the main.cf file + function update($event_name, $data) { + global $app, $conf; + + // get the config + $app->uses("getconf,system,tpl"); + + + $old_ini_data = $app->ini_parser->parse_ini_string($data['old']['config']); + $xmpp_config = $app->getconf->get_server_config($conf['server_id'], 'xmpp'); + + // Global server config + $tpl = new tpl(); + $tpl->newTemplate('metronome_conf_global.master'); + $tpl->setVar('ipv6', $xmpp_config['xmpp_use_ipv6']=='y'?'true':'false'); + $tpl->setVar('bosh_timeout', intval($xmpp_config['xmpp_bosh_max_inactivity'])); + $tpl->setVar('port_http', intval($xmpp_config['xmpp_port_http'])); + $tpl->setVar('port_https', intval($xmpp_config['xmpp_port_https'])); + $tpl->setVar('port_pastebin', intval($xmpp_config['xmpp_port_pastebin'])); + $tpl->setVar('port_bosh', intval($xmpp_config['xmpp_port_bosh'])); + // Global server admins (for all hosted domains) + $admins = ''; + foreach(explode(',', $xmpp_config['xmpp_server_admins']) AS $a) + $admins.= "\t\"".trim($a)."\",\n"; + $tpl->setVar('server_admins', $admins); + unset($admins); + // enabled modules, so own modules or simmilar prosody-modules can easily be added + $modules = ''; + foreach(explode(',', $xmpp_config['xmpp_modules_enabled']) AS $m) + $modules.= "\t\"".trim($m)."\",\n"; + $tpl->setVar('modules_enabled', $modules); + unset($modules); + $app->system->file_put_contents($this->xmpp_config_dir.'/global.cfg.lua', $tpl->grab()); + unset($tpl); + + $app->services->restartServiceDelayed('metronome', 'restart'); + return; + } + + function domainInsert($event_name, $data) { + global $app, $conf; + + $this->domainUpdate($event_name, $data); + + } + + function domainUpdate($event_name, $data){ + global $app, $conf; + + // get the config + $app->uses("getconf,system,tpl"); + + // Collections + $status_hosts = array($data['new']['domain']); + $status_comps = array(); + + // Create main host file + $tpl = new tpl(); + $tpl->newTemplate('metronome_conf_host.master'); + $tpl->setVar('domain', $data['new']['domain']); + $tpl->setVar('active', $data['new']['active'] == 'y' ? 'true' : 'false'); + $tpl->setVar('public_registration', $data['new']['public_registration'] == 'y' ? 'true' : 'false'); + // Domain admins + $admins = array(); + foreach(explode(',',$data['new']['domain_admins']) AS $adm){ + $admins[] = trim($adm); + } + $tpl->setVar('domain_admins', "\t\t\"".implode("\",\n\t\t\"",$admins)."\"\n"); + + // Enable / Disable features + if($data['new']['use_pubsub']=='y'){ + $tpl->setVar('use_pubsub', 'true'); + $status_comps[] = 'pubsub.'.$data['new']['domain']; + }else{ + $tpl->setVar('use_pubsub', 'false'); + } + if($data['new']['use_proxy']=='y'){ + $tpl->setVar('use_proxy', 'true'); + $status_comps[] = 'proxy.'.$data['new']['domain']; + }else{ + $tpl->setVar('use_proxy', 'false'); + } + + if($data['new']['use_anon_host']=='y'){ + $tpl->setVar('use_anon_host', 'true'); + $status_hosts[] = 'anon.'.$data['new']['domain']; + }else{ + $tpl->setVar('use_anon_host', 'false'); + } + if($data['new']['use_vjud']=='y'){ + $tpl->setVar('use_vjud', 'true'); + $tpl->setVar('vjud_opt_mode', 'opt-'.$data['new']['vjud_opt_mode']); + $status_comps[] = 'vjud.'.$data['new']['domain']; + }else{ + $tpl->setVar('use_vjud', 'false'); + } + + $tpl->setVar('use_muc', $data['new']['use_muc_host']=='y'?'true':'false'); + if($data['new']['use_muc_host'] == 'y'){ + $status_comps[] = 'muc.'.$data['new']['domain']; + $tpl->setVar('muc_restrict_room_creation', $data['new']['muc_restrict_room_creation']); + $tpl->setVar('muc_name', strlen($data['new']['muc_name']) ? $data['new']['muc_name'] : $data['new']['domain'].' Chatrooms'); + // Admins for MUC channels + $admins = array(); + foreach(explode(',',$data['new']['muc_admins']) AS $adm){ + $admins[] = trim($adm); + } + $tpl->setVar('muc_admins', "\t\t\"".implode("\",\n\t\t\"",$admins)."\"\n"); + $tpl->setVar('use_pastebin', $data['new']['use_pastebin']=='y'?'true':'false'); + $tpl->setVar('pastebin_expire', intval($data['new']['pastebin_expire_after'])); + $tpl->setVar('pastebin_trigger', $data['new']['pastebin_trigger']); + $tpl->setVar('use_archive', $data['new']['use_http_archive']=='y'?'true':'false'); + $tpl->setVar('archive_join', $data['new']['http_archive_show_join']=='y'?'true':'false'); + $tpl->setVar('archive_status', $data['new']['http_archive_show_status']=='y'?'true':'false'); + + } + + // Check for SSL + if(strlen($data['new']['ssl_cert']) && strlen($data['new']['ssl_key']) && !$this->ssl_certificate_deleted || $this->ssl_certificate_changed) + $tpl->setVar('ssl_cert', true); + + $app->system->file_put_contents($this->xmpp_config_dir.'/hosts/'.$data['new']['domain'].'.cfg.lua', $tpl->grab()); + unset($tpl); + + // Create status host file + if($data['new']['use_status_host']=='y'){ + $tpl = new tpl; + $tpl->newTemplate('metronome_conf_status.master'); + $tpl->setVar('domain', $data['new']['domain']); + $tpl->setVar('status_hosts', "\t\t\"".implode("\",\n\t\t\"",$status_hosts)."\"\n"); + $tpl->setVar('status_comps', "\t\t\"".implode("\",\n\t\t\"",$status_comps)."\"\n"); + $app->system->file_put_contents($this->xmpp_config_dir.'/status/'.$data['new']['domain'].'.cfg.lua', $tpl->grab()); + unset($tpl); + } + + $app->services->restartServiceDelayed('metronome', 'reload'); + } + + function domainDelete($event_name, $data){ + global $app, $conf; + + // get the config + $app->uses("system"); + $domain = $data['old']['domain']; + $folder = str_replace('-', '%2d', str_replace('.', '%2e', $str = urlencode($domain))); + + // Remove config files + $app->system->unlink("/etc/metronome/hosts/$domain.cfg.lua"); + $app->system->unlink("/etc/metronome/status/$domain.cfg.lua"); + $app->system->unlink("/etc/metronome/certs/$domain.cert"); + $app->system->unlink("/etc/metronome/certs/$domain.key"); + $app->system->unlink("/etc/metronome/certs/$domain.csr"); + // Remove all stored data + var_dump('rm -rf /var/lib/metronome/'.$folder); + exec('rm -rf /var/lib/metronome/'.$folder); + exec('rm -rf /var/lib/metronome/*%2e'.$folder); + + $app->services->restartServiceDelayed('metronome', 'reload'); + } + + function userInsert($event_name, $data){ + //$data['new']['auth_method'] + // Check domain for auth settings + // Don't allow manual user creation for mailaccount controlled domains + + // maybe metronomectl adduser for new local users + } + function userUpdate($event_name, $data){ + // Check domain for auth settings + // Don't allow manual user update for mailaccount controlled domains + + // maybe metronomectl passwd for existing local users + } + function userDelete($event_name, $data){ + // Check domain for auth settings + // Don't allow manual user deletion for mailaccount controlled domains + + // Remove account from metronome + exec('metronomectl deluser '.$data['old']['jid']); + } + + // Handle the creation of SSL certificates + function ssl($event_name, $data) { + global $app, $conf; + + $app->uses('system,tpl'); + + // load the server configuration options + $app->uses('getconf'); + $web_config = $app->getconf->get_server_config($conf['server_id'], 'web'); + + $ssl_dir = '/etc/metronome/certs'; + $domain = $data['new']['domain']; + $cnf_file = $ssl_dir.'/'.$domain.'.cnf'; + $key_file = $ssl_dir.'/'.$domain.'.key'; + $csr_file = $ssl_dir.'/'.$domain.'.csr'; + $crt_file = $ssl_dir.'/'.$domain.'.cert'; + + //* Create a SSL Certificate, but only if this is not a mirror server. + if($data['new']['ssl_action'] == 'create' && $conf['mirror_server_id'] == 0) { + + $this->ssl_certificate_changed = true; + + //* Rename files if they exist + if(file_exists($cnf_file)) $app->system->rename($cnf_file, $cnf_file.'.bak'); + if(file_exists($key_file)){ + $app->system->rename($key_file, $key_file.'.bak'); + $app->system->chmod($key_file.'.bak', 0400); + $app->system->chown($key_file.'.bak', 'metronome'); + } + if(file_exists($csr_file)) $app->system->rename($csr_file, $csr_file.'.bak'); + if(file_exists($crt_file)) $app->system->rename($crt_file, $crt_file.'.bak'); + + // Write new CNF file + $tpl = new tpl(); + $tpl->newTemplate('metronome_conf_ssl.master'); + $tpl->setVar('domain', $domain); + $tpl->setVar('ssl_country', $data['new']['ssl_country']); + $tpl->setVar('ssl_locality', $data['new']['ssl_locality']); + $tpl->setVar('ssl_organisation', $data['new']['ssl_organisation']); + $tpl->setVar('ssl_organisation_unit', $data['new']['ssl_organisation_unit']); + $tpl->setVar('ssl_email', $data['new']['ssl_email']); + $app->system->file_put_contents($cnf_file, $tpl->grab()); + + // Generate new key, csr and cert + exec("(cd /etc/metronome/certs && make $domain.key)"); + exec("(cd /etc/metronome/certs && make $domain.csr)"); + exec("(cd /etc/metronome/certs && make $domain.cert)"); + + $ssl_key = $app->system->file_get_contents($key_file); + $app->system->chmod($key_file, 0400); + $app->system->chown($key_file, 'metronome'); + $ssl_request = $app->system->file_get_contents($csr_file); + $ssl_cert = $app->system->file_get_contents($crt_file); + /* Update the DB of the (local) Server */ + $app->db->query("UPDATE xmpp_domain SET ssl_request = ?, ssl_cert = ?, ssl_key = ? WHERE domain = ?", $ssl_request, $ssl_cert, $ssl_key, $data['new']['domain']); + $app->db->query("UPDATE xmpp_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); + /* Update also the master-DB of the Server-Farm */ + $app->dbmaster->query("UPDATE xmpp_domain SET ssl_request = ?, ssl_cert = ?, ssl_key = ? WHERE domain = ?", $ssl_request, $ssl_cert, $ssl_key, $data['new']['domain']); + $app->dbmaster->query("UPDATE xmpp_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); + $app->log('Creating XMPP SSL Cert for: '.$domain, LOGLEVEL_DEBUG); + } + + //* Save a SSL certificate to disk + if($data["new"]["ssl_action"] == 'save') { + $this->ssl_certificate_changed = true; + + //* Rename files if they exist + if(file_exists($cnf_file)) $app->system->rename($cnf_file, $cnf_file.'.bak'); + if(file_exists($key_file)){ + $app->system->rename($key_file, $key_file.'.bak'); + $app->system->chmod($key_file.'.bak', 0400); + $app->system->chown($key_file.'.bak', 'metronome'); + } + if(file_exists($csr_file)) $app->system->rename($csr_file, $csr_file.'.bak'); + if(file_exists($crt_file)) $app->system->rename($crt_file, $crt_file.'.bak'); + + //* Write new ssl files + if(trim($data["new"]["ssl_request"]) != '') + $app->system->file_put_contents($csr_file, $data["new"]["ssl_request"]); + if(trim($data["new"]["ssl_cert"]) != '') + $app->system->file_put_contents($crt_file, $data["new"]["ssl_cert"]); + + //* Write the key file, if field is empty then import the key into the db + if(trim($data["new"]["ssl_key"]) != '') { + $app->system->file_put_contents($key_file, $data["new"]["ssl_key"]); + $app->system->chmod($key_file, 0400); + $app->system->chown($key_file, 'metronome'); + } else { + $ssl_key = $app->system->file_get_contents($key_file); + /* Update the DB of the (local) Server */ + $app->db->query("UPDATE xmpp_domain SET ssl_key = ? WHERE domain = ?", $ssl_key, $data['new']['domain']); + /* Update also the master-DB of the Server-Farm */ + $app->dbmaster->query("UPDATE xmpp_domain SET ssl_key = '$ssl_key' WHERE domain = ?", $data['new']['domain']); + } + + /* Update the DB of the (local) Server */ + $app->db->query("UPDATE xmpp_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); + + /* Update also the master-DB of the Server-Farm */ + $app->dbmaster->query("UPDATE xmpp_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); + $app->log('Saving XMPP SSL Cert for: '.$domain, LOGLEVEL_DEBUG); + } + + //* Delete a SSL certificate + if($data['new']['ssl_action'] == 'del') { + $this->ssl_certificate_deleted = true; + $app->system->unlink($csr_file); + $app->system->unlink($crt_file); + $app->system->unlink($key_file); + $app->system->unlink($cnf_file); + $app->system->unlink($csr_file.'.bak'); + $app->system->unlink($crt_file.'.bak'); + $app->system->unlink($key_file.'.bak'); + $app->system->unlink($cnf_file.'.bak'); + /* Update the DB of the (local) Server */ + $app->db->query("UPDATE xmpp_domain SET ssl_request = '', ssl_cert = '', ssl_key = '' WHERE domain = ?", $data['new']['domain']); + $app->db->query("UPDATE xmpp_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); + /* Update also the master-DB of the Server-Farm */ + $app->dbmaster->query("UPDATE xmpp_domain SET ssl_request = '', ssl_cert = '', ssl_key = '' WHERE domain = ?", $data['new']['domain']); + $app->dbmaster->query("UPDATE xmpp_domain SET ssl_action = '' WHERE domain = ?", $data['new']['domain']); + $app->log('Deleting SSL Cert for: '.$domain, LOGLEVEL_DEBUG); + } + + } + +} // end class + +?> diff --git a/server/scripts/ispconfig_patch b/server/scripts/ispconfig_patch index 9376ba19fe8584c7ba11a1280041b9d22172d7f8..6ed2a3f5aebb078e787f726d95c1e10565025416 100644 --- a/server/scripts/ispconfig_patch +++ b/server/scripts/ispconfig_patch @@ -102,6 +102,7 @@ echo "Please enter the patch id that you want to be applied to your ISPConfig in if(!is_installed('patch')) { swriteln("The program 'patch' is missing on your server. Please install it and try again."); + exit; } $patch_id = simple_query('Enter patch id', false, ''); diff --git a/server/scripts/ispconfig_update.sh b/server/scripts/ispconfig_update.sh index e3689cf4e6e0211718315da4b140753eb9ede3c1..03c13c9aea52bc3d6bf0916e7c8d4cc597a24380 100644 --- a/server/scripts/ispconfig_update.sh +++ b/server/scripts/ispconfig_update.sh @@ -1,3 +1,7 @@ #!/bin/bash -php -q /usr/local/ispconfig/server/scripts/ispconfig_update.php \ No newline at end of file +php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + /usr/local/ispconfig/server/scripts/ispconfig_update.php diff --git a/server/scripts/update_from_dev.sh b/server/scripts/update_from_dev.sh index de93fd96728c5133fb7651f4b38a88107cf1d394..12f62aac77cdda36e5c52cc701c43d5cdfc59be9 100644 --- a/server/scripts/update_from_dev.sh +++ b/server/scripts/update_from_dev.sh @@ -4,7 +4,11 @@ cd /tmp wget -O ispconfig3-dev.tar.gz "http://git.ispconfig.org/ispconfig/ispconfig3/repository/archive.tar.gz?ref=master" tar xzf ispconfig3-dev.tar.gz cd ispconfig3.git/install -php -q update.php +php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + update.php cd /tmp rm -rf /tmp/ispconfig3.git /tmp/ispconfig3-dev.tar.gz diff --git a/server/scripts/update_from_tgz.sh b/server/scripts/update_from_tgz.sh index 09dddeb29919f2e80a846220e53cd207fdd51ff8..7d59e404f961029b3bb2731dd57860cbc8202bdf 100644 --- a/server/scripts/update_from_tgz.sh +++ b/server/scripts/update_from_tgz.sh @@ -12,7 +12,11 @@ if [ -f ISPConfig-3-stable.tar.gz ] then tar xvfz ISPConfig-3-stable.tar.gz cd ispconfig3_install/install/ - php -q update.php + php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + update.php rm -rf /tmp/ispconfig3_install/install rm -f ISPConfig-3-stable.tar.gz else diff --git a/server/server.php b/server/server.php index 4cf1d353b77ff87409d22fba8dc9c97ca3d4e3c3..4479b147c5504ef304ce1beb3fc5d2a00c19c2c1 100644 --- a/server/server.php +++ b/server/server.php @@ -43,14 +43,14 @@ $conf['server_id'] = intval($conf['server_id']); * Try to Load the server configuration from the master-db */ if ($app->dbmaster->connect_error == NULL) { - $server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']); + $server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = ?", $conf['server_id']); if(!is_array($server_db_record)) die('Unable to load the server configuration from database.'); //* Get the number of the last processed datalog_id, if the id of the local server //* is > then the one of the remote system, then use the local ID as we might not have //* reached the remote server during the last run then. - $local_server_db_record = $app->db->queryOneRecord("SELECT * FROM server WHERE server_id = " . $conf['server_id']); + $local_server_db_record = $app->db->queryOneRecord("SELECT * FROM server WHERE server_id = ?", $conf['server_id']); $conf['last_datalog_id'] = (int) max($server_db_record['updated'], $local_server_db_record['updated']); unset($local_server_db_record); @@ -73,7 +73,6 @@ if ($app->dbmaster->connect_error == NULL) { unset($server_db_record); // retrieve admin email address for notifications - //$sys_ini = $app->dbmaster->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1"); $sys_ini = $app->db->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1"); $conf['sys_ini'] = $app->ini_parser->parse_ini_string(stripslashes($sys_ini['config'])); $conf['admin_mail'] = $conf['sys_ini']['mail']['admin_mail']; @@ -156,9 +155,9 @@ if ($app->db->connect_error == NULL && $app->dbmaster->connect_error == NULL) { // Check if there is anything to update if ($conf['mirror_server_id'] > 0) { - $tmp_rec = $app->dbmaster->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE datalog_id > " . $conf['last_datalog_id'] . " AND (server_id = " . $conf['server_id'] . " OR server_id = " . $conf['mirror_server_id'] . " OR server_id = 0)"); + $tmp_rec = $app->dbmaster->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE datalog_id > ? AND (server_id = ? OR server_id = ? OR server_id = 0)", $conf['last_datalog_id'], $conf['server_id'], $conf['mirror_server_id']); } else { - $tmp_rec = $app->dbmaster->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE datalog_id > " . $conf['last_datalog_id'] . " AND (server_id = " . $conf['server_id'] . " OR server_id = 0)"); + $tmp_rec = $app->dbmaster->queryOneRecord("SELECT count(server_id) as number from sys_datalog WHERE datalog_id > ? AND (server_id = ? OR server_id = 0)", $conf['last_datalog_id'], $conf['server_id']); } $tmp_num_records = $tmp_rec['number']; diff --git a/server/server.sh b/server/server.sh index 522e0d5f74bb56cf9544d073f05c9d0ed893b978..2d05d4f0fd4a3e3720ed3a47e535cac407d30423 100755 --- a/server/server.sh +++ b/server/server.sh @@ -1,5 +1,6 @@ #!/bin/sh + PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin . /etc/profile @@ -14,7 +15,15 @@ if [ -f /usr/local/ispconfig/server/lib/php.ini ]; then fi cd /usr/local/ispconfig/server -/usr/bin/php -q /usr/local/ispconfig/server/server.php +/usr/bin/php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + /usr/local/ispconfig/server/server.php cd /usr/local/ispconfig/security -/usr/bin/php -q /usr/local/ispconfig/security/check.php +/usr/bin/php -q \ + -d disable_classes= \ + -d disable_functions= \ + -d open_basedir= \ + /usr/local/ispconfig/security/check.php