diff --git a/interface/lib/classes/validate_server_directive_snippets.inc.php b/interface/lib/classes/validate_server_directive_snippets.inc.php
index 0272166c40d7fced1cf84b225eaa81a05562fc39..751400766cfd78a0d8d67e7016dc81b04ad7d723 100755
--- a/interface/lib/classes/validate_server_directive_snippets.inc.php
+++ b/interface/lib/classes/validate_server_directive_snippets.inc.php
@@ -42,7 +42,10 @@ class validate_server_directive_snippets {
 
 	function validate_snippet($field_name, $field_value, $validator) {
 		global $app;
-		$check = $app->db->queryAllRecords('SELECT * FROM directive_snippets WHERE name = ? AND type = ?', $field_value, trim($_POST['type']));
+        $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);
 		if(!empty($check)) return $this->get_error('directive_snippets_name_error_unique');
 	}