From b56414ed0e54633cce72fe8b069637a09c8d8b82 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Wed, 21 Feb 2018 12:16:50 +0100 Subject: [PATCH] add sql-query of last statement to sql-debug for debugging purposes; fix default-ssl-ip setting and allow 'none' value Signed-off-by: Michael Kaufmann (d00p) --- lib/classes/database/class.Database.php | 6 ++-- .../function.getIpPortCombinations.php | 3 +- .../function.storeSettingDefaultIp.php | 30 +++++++++++++------ lng/english.lng.php | 1 + lng/german.lng.php | 1 + 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/lib/classes/database/class.Database.php b/lib/classes/database/class.Database.php index 7f6c7d46..350e71e3 100644 --- a/lib/classes/database/class.Database.php +++ b/lib/classes/database/class.Database.php @@ -71,7 +71,7 @@ class Database { try { $stmt->execute($params); } catch (PDOException $e) { - self::_showerror($e, $showerror, $json_response); + self::_showerror($e, $showerror, $json_response, $stmt); } } @@ -309,7 +309,7 @@ class Database { * @param PDOException $error * @param bool $showerror if set to false, the error will be logged but we go on */ - private static function _showerror($error, $showerror = true, $json_response = false) { + private static function _showerror($error, $showerror = true, $json_response = false, PDOStatement $stmt = null) { global $userinfo, $theme, $linker; // include userdata.inc.php @@ -374,6 +374,8 @@ class Database { if ($showerror) { if (empty($sql['debug'])) { $error_trace = ''; + } elseif (!is_null($stmt)) { + $error_trace .= "

".$stmt->queryString; } // fallback diff --git a/lib/functions/froxlor/function.getIpPortCombinations.php b/lib/functions/froxlor/function.getIpPortCombinations.php index f0043a74..1a0c75f6 100644 --- a/lib/functions/froxlor/function.getIpPortCombinations.php +++ b/lib/functions/froxlor/function.getIpPortCombinations.php @@ -64,5 +64,6 @@ function getIpPortCombinations($ssl = false) { } function getSslIpPortCombinations() { - return getIpPortCombinations(true); + global $lng; + return array('' => $lng['panel']['none_value']) + getIpPortCombinations(true); } diff --git a/lib/functions/settings/function.storeSettingDefaultIp.php b/lib/functions/settings/function.storeSettingDefaultIp.php index 5a8994c2..a3ca6b1f 100644 --- a/lib/functions/settings/function.storeSettingDefaultIp.php +++ b/lib/functions/settings/function.storeSettingDefaultIp.php @@ -95,23 +95,35 @@ function storeSettingDefaultSslIp($fieldname, $fielddata, $newfieldvalue) { if (count($ids) > 0) { $defaultips_new = explode(',', $newfieldvalue); + if (!empty($defaultips_old) && !empty($newfieldvalue)) + { + $in_value = $defaultips_old . ", " . $newfieldvalue; + } elseif (!empty($defaultips_old) && empty($newfieldvalue)) + { + $in_value = $defaultips_old; + } else { + $in_value = $newfieldvalue; + } + // Delete the existing mappings linking to default IPs $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_DOMAINTOIP . "` WHERE `id_domain` IN (" . implode(', ', $ids) . ") - AND `id_ipandports` IN (" . $defaultips_old . ", " . $newfieldvalue . ") + AND `id_ipandports` IN (" . $in_value . ") "); Database::pexecute($del_stmt); - // Insert the new mappings - $ins_stmt = Database::prepare(" - INSERT INTO `" . TABLE_DOMAINTOIP . "` - SET `id_domain` = :domainid, `id_ipandports` = :ipandportid - "); + if (count($defaultips_new) > 0) { + // Insert the new mappings + $ins_stmt = Database::prepare(" + INSERT INTO `" . TABLE_DOMAINTOIP . "` + SET `id_domain` = :domainid, `id_ipandports` = :ipandportid + "); - foreach ($ids as $id) { - foreach ($defaultips_new as $defaultip_new) { - Database::pexecute($ins_stmt, array('domainid' => $id, 'ipandportid' => $defaultip_new)); + foreach ($ids as $id) { + foreach ($defaultips_new as $defaultip_new) { + Database::pexecute($ins_stmt, array('domainid' => $id, 'ipandportid' => $defaultip_new)); + } } } } diff --git a/lng/english.lng.php b/lng/english.lng.php index f9ed0d54..8adc8a40 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -2119,3 +2119,4 @@ $lng['admin']['plans']['use_plan'] = 'Apply plan'; $lng['question']['plan_reallydelete'] = 'Do you really want to delete the hosting plan %s?'; $lng['admin']['notryfiles']['title'] = 'No autogenerated try_files'; $lng['admin']['notryfiles']['description'] = 'Say yes here if you want to specify a custom try_files directive in specialsettings (needed for some wordpress plugins for example).'; +$lng['panel']['none_value'] = 'None'; diff --git a/lng/german.lng.php b/lng/german.lng.php index a4567f2a..888303b1 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1769,3 +1769,4 @@ $lng['admin']['plans']['use_plan'] = 'Plan übernehmen'; $lng['question']['plan_reallydelete'] = 'Wollen Sie den Hosting-Plan "%s" wirklich löschen?'; $lng['admin']['notryfiles']['title'] = 'Keine generierte try_files Anweisung'; $lng['admin']['notryfiles']['description'] = 'Wähle "Ja", wenn eine eigene try_files Direktive in den "eigenen Vhost Einstellungen" angegeben werden soll (z.B. nötig für manche Wordpress Plugins).'; +$lng['panel']['none_value'] = 'Keine';