From dd99c15dfbb35652db57331c2db6b07088da2f3f Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Mon, 20 Apr 2020 11:02:13 +0200 Subject: ajout filtrage AJAX --- www/html/affiche-tab.py | 39 +++++++++++++++++++++++++++++++++++++++ www/html/filtre.js | 17 +++++++++++++++++ www/html/index.py | 5 +++++ 3 files changed, 61 insertions(+) create mode 100644 www/html/affiche-tab.py create mode 100644 www/html/filtre.js (limited to 'www/html') diff --git a/www/html/affiche-tab.py b/www/html/affiche-tab.py new file mode 100644 index 0000000..2f5a516 --- /dev/null +++ b/www/html/affiche-tab.py @@ -0,0 +1,39 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + +import mod_python +from fonctions import baseHTML, connexionBD, lien + +def index(req): + req.content_type="text/html" + content=str() + + condition=req.form["condition"] + + conn=connexionBD() + cur=conn.cursor() + sql="select * from paquet where {}".format(condition) + cur.execute(sql) + conn.commit() + data=cur.fetchall() + conn.close() + + for i in data: + content+=("""""" + +"""""" + str(i[1]) + """""" + +"""""" + str(i[2]) + """""" + +"""""" + str(i[3]) + """""" + +"""""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """""" + +"""""" + str(i[5]) + """""" + +"""""" + str(i[6]) + """""" + +"""""") + + req.write(""" +
+ +""" ++ content + +""" +
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
+""")) + diff --git a/www/html/filtre.js b/www/html/filtre.js new file mode 100644 index 0000000..b523360 --- /dev/null +++ b/www/html/filtre.js @@ -0,0 +1,17 @@ +function cherche(){ + + var condition = document.getElementById("condition"); + var url = "affiche-tab.py?condition=" + condition.value; + + var req = new XMLHttpRequest(); + req.open("GET", url, true); + + req.onreadystatechange = function(){ + if(req.readyState == 4 && req.status == 200) { + var tab=document.getElementById("tab"); + tab.innerHTML = req.responseText; + } + } + + req.send(); +} diff --git a/www/html/index.py b/www/html/index.py index f670a37..7e45dca 100755 --- a/www/html/index.py +++ b/www/html/index.py @@ -32,10 +32,15 @@ def index(req): #write the html page req.write(baseHTML("ATS-Project","""

ATS-Project

+Filtrage + +
""" + content + """
HeureProtocoleIP SourceIP DestinationPort SourcePort Destination
+
+ """)) -- cgit v1.2.3