Replies: 1 comment
-
I refer to the "using-function-callback" demo to successfully write the log to the db. Are there any error messages? Are events triggered? ... |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
But I am having problems with logging deleted files and rename files. Can anyone help? Thank you.
<script> $(document).ready(function () { var options = { baseUrl: "/wwwroot/Plugins/elfinder/", url: "/elfinder/connector", width: '100%', height: '95%', rememberLastDir: false, uiOptions: { toolbar: [ ['back', 'forward'], ['reload'], ['home', 'up'], ['mkdir', 'mkfile', 'upload'], ['open', 'download'], ['undo', 'redo'], ['info'], ['quicklook'], ['copy', 'cut', 'paste'], ['rm'], ['duplicate', 'rename', 'edit'], ['selectall', 'selectnone', 'selectinvert'], ['view', 'sort'], ['search'] ] }, lang: 'tr' }; var elf = $('#elfinder').elfinder(options).elfinder('instance'); // Sunucuya log gönderen fonksiyon function logToServer(action, fileName, oldName = null) { $.ajax({ type: "POST", url: "/Logs/LogOperation", data: JSON.stringify({ action: action, FileName: fileName, OldName: oldName }), contentType: "application/json", success: function (response) { console.log("✅ Log kaydedildi: ", response); }, error: function (xhr, status, error) { console.error("❌ Log kaydedilirken hata oluştu: ", xhr.responseText); } }); } // 📌 **Dosya yükleme olayını dinle** elf.bind('upload', function (event) { if (event.data && event.data.added) { event.data.added.forEach(function (file) { console.log("Yüklenen dosya: " + file.name); logToServer("Upload", file.name); }); } }); // 📌 **Dosya silme olayını dinle** // 📌 **Dosya silme olayını dinle** // 📌 **Dosya silme olayını dinle** // 📌 **Dosya silme olayını dinle** // 📌 **Dosya silme olayını dinle** // 📌 **Dosya silme olayını dinle** elf.bind('rm', function (event) { if (event.data && event.data.removed) { event.data.removed.forEach(function (file) { console.log("📂 Silinen dosya nesnesi:", file); // 🔍 Konsola detaylı veri yaz // Dosya adını al let fileName = file.name || "BilinmeyenDosya"; // Öncelikle file.name kullan if (!fileName && file.hash) { fileName = decodeHash(file.hash); // Eğer file.name yoksa, hash'ten çözümle } // Dosya yolunu al let filePath = "BilinmeyenKlasör"; if (file.phash) { filePath = decodeHash(file.phash); // Hash'ten çözümle } console.log("📌 Silinen dosya adı:", fileName); console.log("📂 Dosya yolu:", filePath); // Loglama işlemi logToServer("Delete", fileName, null); }); } }); // 📌 ElFinder hash'ini çözen fonksiyon function decodeHash(hash) { try { if (!hash) { console.warn("⚠ Hash değeri yok."); return null; } let base64 = hash.split("_")[1]; // `l1_` kısmını at if (!base64) { console.warn("⚠ Geçersiz hash formatı:", hash); return null; } let decoded = atob(base64); // Base64 çöz return decoded.split("/").pop(); // Sadece dosya adını al } catch (e) { console.warn("⚠ Hash çözümleme hatası:", e); return null; } } // 📌 ElFinder hash'ini çözen fonksiyon function decodeHash(hash) { try { if (!hash) { console.warn("⚠ Hash değeri yok."); return null; } let base64 = hash.split("_")[1]; // `l1_` kısmını at if (!base64) { console.warn("⚠ Geçersiz hash formatı:", hash); return null; } let decoded = atob(base64); // Base64 çöz return decoded.split("/").pop(); // Sadece dosya adını al } catch (e) { console.warn("⚠ Hash çözümleme hatası:", e); return null; } } // 📌 ElFinder hash'ini çözen fonksiyon function decodeHash(hash) { try { if (!hash) { console.warn("⚠ Hash değeri yok."); return null; } // Hash değerini çözümle let base64 = hash.split("_")[1]; // `l1_` kısmını at if (!base64) { console.warn("⚠ Geçersiz hash formatı:", hash); return null; } let decoded = atob(base64); // Base64 çöz return decoded.split("/").pop(); // Sadece dosya adını al } catch (e) { console.warn("⚠ Hash çözümleme hatası:", e); return null; } } // 📌 ElFinder hash'ini çözen fonksiyon function decodeHash(hash) { try { if (!hash) { console.warn("⚠ Hash değeri yok."); return null; } let base64 = hash.split("_")[1]; // `l1_` kısmını at if (!base64) { console.warn("⚠ Geçersiz hash formatı:", hash); return null; } let decoded = atob(base64); // Base64 çöz return decoded.split("/").pop(); // Sadece dosya adını al } catch (e) { console.warn("⚠ Hash çözümleme hatası:", e); return null; } } // 📌 ElFinder hash'ini çözen fonksiyon function decodeHash(hash) { try { let base64 = hash.split("_")[1]; // `l1_` kısmını at let decoded = atob(base64); // Base64 çöz return decoded.split("/").pop(); // Sadece dosya adını al } catch (e) { console.warn("⚠ Hash çözümleme hatası:", e); return null; } } // 📌 ElFinder hash'ini çözen fonksiyon function decodeHash(hash) { try { let base64 = hash.split("_")[1]; // `l1_` kısmını at let decoded = atob(base64); // Base64 çöz return decoded.split("/").pop(); // Sadece dosya adını al } catch (e) { console.warn("⚠ Hash çözümleme hatası:", e); return null; } } // 📌 **Dosya yeniden adlandırma olayını dinle** elf.bind('rename', function (event) { if (event.data && event.data.changed) { event.data.changed.forEach(function (file) { logToServer("Rename", file.name, file.oldName); }); } }); // 📌 **Dosya kopyalama/taşıma olayını dinle** elf.bind('paste', function (event) { if (event.data && event.data.added) { event.data.added.forEach(function (file) { logToServer("Move", file.name); }); } }); }); </script>soru.txt
Beta Was this translation helpful? Give feedback.
All reactions