root před 6 měsíci
rodič
revize
b0b09ceffd

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+__pycache__/
+*.pyc

binární
__pycache__/config.cpython-39.pyc


binární
core/__pycache__/dns_manager.cpython-39.pyc


binární
core/__pycache__/stats_manager.cpython-39.pyc


+ 22 - 4
templates/dashboard.html

@@ -261,10 +261,28 @@ function openAssignModal(d, o) { document.getElementById('assignDomainInput').va
 function closeAssignModal() { document.getElementById('assignZoneModal').classList.add('hidden'); }
 
 function toggleZoneFields() {
-    const type = document.getElementById('zoneType').value, domCont = document.getElementById('domainContainer'), domInp = document.getElementById('domainInput');
-    if(type === 'hint') { domCont.classList.add('hidden'); domInp.value = '.'; } 
-    else { domCont.classList.remove('hidden'); if(domInp.value === '.') domInp.value = ''; }
-    document.getElementById('masterFields').style.display = (type === 'master') ? 'block' : 'none';
+    const type = document.getElementById('zoneType').value;
+    const domCont = document.getElementById('domainContainer');
+    const domInp = document.getElementById('domainInput');
+    const tmplSelect = document.querySelector('select[name="template_name"]');
+    
+    if(type === 'hint') { 
+        domCont.classList.add('hidden'); 
+        domInp.value = '.'; 
+    } else { 
+        domCont.classList.remove('hidden'); 
+        if(domInp.value === '.') domInp.value = ''; 
+    }
+    
+    // Εμφάνιση/Απόκρυψη και προσθήκη/αφαίρεση του Required!
+    if (type === 'master') {
+        document.getElementById('masterFields').style.display = 'block';
+        if (tmplSelect) tmplSelect.required = true;
+    } else {
+        document.getElementById('masterFields').style.display = 'none';
+        if (tmplSelect) tmplSelect.required = false;
+    }
+    
     document.getElementById('slaveFields').style.display = (type === 'slave') ? 'block' : 'none';
     document.getElementById('forwardFields').style.display = (type === 'forward') ? 'block' : 'none';
 }

+ 12 - 3
templates/general_config.html

@@ -106,7 +106,12 @@
                             <td class="p-4 text-gray-400 font-mono text-xs">{{ t.ttl }}s</td>
                             <td class="p-4 text-gray-400 font-mono text-xs">{{ t.refresh }}s</td>
                             <td class="p-4 text-right pr-6 whitespace-nowrap">
-                                <button type="button" onclick="editTemplate('{{ name|e }}', '{{ idx }}')" class="text-blue-400 text-[10px] font-black uppercase mr-4">Edit</button>
+                                <button type="button" 
+                                        data-name="{{ name|e }}" 
+                                        data-idx="{{ idx }}" 
+                                        onclick="editTemplate(this.getAttribute('data-name'), this.getAttribute('data-idx'))" 
+                                        class="text-blue-400 text-[10px] font-black uppercase mr-4">Edit</button>
+                                
                                 <button type="button" onclick="this.closest('tr').remove()" class="text-red-500 text-[10px] font-black uppercase">Delete</button>
                                 
                                 <div class="hidden" id="data-container-{{ idx }}">
@@ -115,7 +120,7 @@
                                     <input type="hidden" name="t_retry[]" value="{{ t.retry }}">
                                     <input type="hidden" name="t_expire[]" value="{{ t.expire }}">
                                     <input type="hidden" name="t_ttl[]" value="{{ t.ttl }}">
-                                    <textarea name="t_content[]" class="hidden">{{ t.content }}</textarea>
+                                    <textarea name="t_content[]" class="hidden">{{ t.content|e }}</textarea>
                                     <div id="vars-storage-{{ idx }}">
                                         {% for vk, vv in t.custom_vars.items() %}
                                         <input type="hidden" name="custom_key_{{ idx }}[]" value="{{ vk|e }}">
@@ -242,12 +247,15 @@ function applyToTable() {
         }
     }
 
+    // Η ΔΙΟΡΘΩΣΗ ΕΔΩ: Ασφαλής περασμένη μεταβλητή μέσω data-attributes και για τα νέα templates!
+    const safeNameAttr = tName.replace(/"/g, '&quot;');
+    
     const trHtml = `
         <td class="p-4 pl-6 text-green-400 font-black">${tName}</td>
         <td class="p-4 text-gray-400 font-mono text-xs">${tTtl}s</td>
         <td class="p-4 text-gray-400 font-mono text-xs">${tRefresh}s</td>
         <td class="p-4 text-right pr-6 whitespace-nowrap">
-            <button type="button" onclick="editTemplate('${tName}', '${idx}')" class="text-blue-400 text-[10px] font-black uppercase mr-4">Edit</button>
+            <button type="button" data-name="${safeNameAttr}" data-idx="${idx}" onclick="editTemplate(this.getAttribute('data-name'), this.getAttribute('data-idx'))" class="text-blue-400 text-[10px] font-black uppercase mr-4">Edit</button>
             <button type="button" onclick="this.closest('tr').remove()" class="text-red-500 text-[10px] font-black uppercase">Delete</button>
             
             <div class="hidden" id="data-container-${idx}">
@@ -274,6 +282,7 @@ function applyToTable() {
         tr.innerHTML = trHtml;
     }
     
+    // Ασφαλής εισαγωγή του περιεχομένου στο textarea
     tr.querySelector('textarea[name="t_content[]"]').value = tContent;
     
     closeModal();