From 34f460bcada0d4b3e399eea11f92d2ada3e0dabc Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Mon, 28 Sep 2020 10:16:01 +0200
Subject: [PATCH] Update
 interface/lib/classes/validate_server_directive_snippets.inc.php

---
 .../lib/classes/validate_server_directive_snippets.inc.php   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/interface/lib/classes/validate_server_directive_snippets.inc.php b/interface/lib/classes/validate_server_directive_snippets.inc.php
index 751400766c..b122f0106e 100755
--- a/interface/lib/classes/validate_server_directive_snippets.inc.php
+++ b/interface/lib/classes/validate_server_directive_snippets.inc.php
@@ -42,10 +42,11 @@ class validate_server_directive_snippets {
 
 	function validate_snippet($field_name, $field_value, $validator) {
 		global $app;
-        $type=(isset($app->remoting_lib->dataRecord['type']))?$app->remoting_lib->dataRecord['type']:$_POST['type'];
+        $id = (isset($app->remoting_lib->dataRecord['directive_snippets_id']))?$app->remoting_lib->dataRecord['directive_snippets_id']:$_POST['id'];
+		$type=(isset($app->remoting_lib->dataRecord['type']))?$app->remoting_lib->dataRecord['type']:$_POST['type'];
         $types = array('apache','nginx','php','proxy');
         if(!in_array($type,$types)) return $this->get_error('directive_snippets_invalid_type');
-		$check = $app->db->queryAllRecords('SELECT * FROM directive_snippets WHERE name = ? AND type = ?', $field_value, $type);
+		$check = $app->db->queryAllRecords('SELECT * FROM directive_snippets WHERE name = ? AND type = ? AND directive_snippets_id != ?', $field_value, $type, $id);
 		if(!empty($check)) return $this->get_error('directive_snippets_name_error_unique');
 	}
 
-- 
GitLab