aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclyhtsuriva <clyhtsuriva@gmail.com>2020-05-09 10:35:49 +0200
committerclyhtsuriva <clyhtsuriva@gmail.com>2020-05-09 10:35:49 +0200
commitcb6a7852bf1015497aaaf40cc41050405f3f3f84 (patch)
tree143b0e5019a01404c271b8679d93a541ffdd147f
parent8b57e76f64cf5de3d0a810019a7fcff03d876544 (diff)
beaucoup de modifs
-rw-r--r--www/html/__pycache__/destination.cpython-37.pycbin0 -> 1537 bytes
-rw-r--r--www/html/__pycache__/fonctions.cpython-37.pycbin0 -> 1127 bytes
-rw-r--r--www/html/affiche-tab.py6
-rw-r--r--www/html/affiche-tas.py38
-rw-r--r--www/html/analyse.py21
-rwxr-xr-xwww/html/destination.py16
-rwxr-xr-xwww/html/filtrage.py9
-rwxr-xr-xwww/html/fonctions.py2
-rw-r--r--www/html/fonctions.pycbin0 -> 1200 bytes
-rwxr-xr-xwww/html/index.py30
-rwxr-xr-xwww/html/style.css24
-rwxr-xr-xwww/html/syntaxe.py4
-rw-r--r--www/html/tas.js16
-rw-r--r--www/html/tip.js4
14 files changed, 121 insertions, 49 deletions
diff --git a/www/html/__pycache__/destination.cpython-37.pyc b/www/html/__pycache__/destination.cpython-37.pyc
new file mode 100644
index 0000000..00128cf
--- /dev/null
+++ b/www/html/__pycache__/destination.cpython-37.pyc
Binary files differ
diff --git a/www/html/__pycache__/fonctions.cpython-37.pyc b/www/html/__pycache__/fonctions.cpython-37.pyc
new file mode 100644
index 0000000..2f6ccdf
--- /dev/null
+++ b/www/html/__pycache__/fonctions.cpython-37.pyc
Binary files differ
diff --git a/www/html/affiche-tab.py b/www/html/affiche-tab.py
index 5481d84..83512dc 100644
--- a/www/html/affiche-tab.py
+++ b/www/html/affiche-tab.py
@@ -12,7 +12,7 @@ def index(req):
conn=connexionBD()
cur=conn.cursor()
- sql="select * from paquet where {}".format(condition)
+ sql="select * from paquet where {} ORDER BY heure DESC;".format(condition)
cur.execute(sql)
conn.commit()
data=cur.fetchall()
@@ -29,9 +29,9 @@ def index(req):
"""</tr>""")
req.write("""
-<center><table>
+<table class="data_tab">
<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
"""
+ content +
"""
-</table></center>""")
+</table>""")
diff --git a/www/html/affiche-tas.py b/www/html/affiche-tas.py
new file mode 100644
index 0000000..726bed4
--- /dev/null
+++ b/www/html/affiche-tas.py
@@ -0,0 +1,38 @@
+#!/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()
+
+ conn=connexionBD()
+ cur=conn.cursor()
+
+ sql="SELECT * FROM paquet ORDER BY heure DESC;"
+
+ cur.execute(sql)
+ conn.commit()
+ data=cur.fetchall()
+
+ conn.close()
+
+ for i in data:
+ content+=("""<tr>""" +
+"""<td>""" + str(i[1]) + """</td>""" +
+"""<td>""" + str(i[2]) + """</td>""" +
+"""<td>""" + str(i[3]) + """</td>""" +
+"""<td>""" + lien('destination.py?ip=' + str(i[4]), str(i[4])) + """</td>""" +
+"""<td>""" + str(i[5]) + """</td>""" +
+"""<td>""" + str(i[6]) + """</td>""" +
+"""</tr>""")
+
+ req.write("""
+<table class="data_tab">
+<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
+"""
++ content +
+"""
+</table>""")
diff --git a/www/html/analyse.py b/www/html/analyse.py
index de55e47..57c0892 100644
--- a/www/html/analyse.py
+++ b/www/html/analyse.py
@@ -7,21 +7,22 @@ from fonctions import baseHTML, connexionBD, lien
def index(req):
req.content_type="text/html"
content=str()
-'''
+
#sql part
- conn=connexionBD()
- cur=conn.cursor()
- sql="select * from paquet;"
- cur.execute(sql)
- conn.commit()
- data=cur.fetchall()
- conn.close()
+# conn=connexionBD()
+# cur=conn.cursor()
+# sql="select * from paquet;"
+# cur.execute(sql)
+# conn.commit()
+# data=cur.fetchall()
+# conn.close()
#sql part
-'''
+
#write the html page
+
req.write(baseHTML("ATS-Project","""
-<center><h1>Analyse</h1></center>
+<h1>Analyse</h1>
"""
+ content
))
diff --git a/www/html/destination.py b/www/html/destination.py
index 4d37c22..032d797 100755
--- a/www/html/destination.py
+++ b/www/html/destination.py
@@ -25,14 +25,18 @@ def index(req):
#sql part
conn=connexionBD()
cur=conn.cursor()
- sql="select * from paquet where ip_destination='{}';".format(ip)
+
+ sql="select * from paquet where ip_destination='{}' ORDER BY heure DESC;".format(ip)
sql_count="select count(*) from paquet where ip_destination='{}';".format(ip)
+
cur.execute(sql)
conn.commit()
data=cur.fetchall()
+
cur.execute(sql_count)
conn.commit()
- rec=cur.fetchone()
+ count=cur.fetchone()
+
conn.close()
#sql part
@@ -49,12 +53,12 @@ def index(req):
#write the html page
req.write(baseHTML("Destination","""
-<center><h1>IP Destination : """ + ip + """</h1></center>
-<p>Nombre de paquets en destination de """+ ip + """ : <b>"""+ str(rec[0])+ """</b><p>
-<center><table>
+<h1>IP Destination : """ + ip + """</h1>
+<p>Nombre de paquets en destination de """+ ip + """ : <b>"""+ str(count[0])+ """</b></p>
+<table class="data_tab">
<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
"""
+ content +
"""
-</table></center>
+</table>
"""))
diff --git a/www/html/filtrage.py b/www/html/filtrage.py
index 8df0e27..2ec6a72 100755
--- a/www/html/filtrage.py
+++ b/www/html/filtrage.py
@@ -10,7 +10,7 @@ def index(req):
#write the html page
req.write(baseHTML("ATS-Project","""
-<center><h1>Filtrage</h1></center>
+<h1>Filtrage</h1>
<div id="tip" style="display:block;">
Pour voir le nombre de paquets en destination d'une adresse IP, cliquez sur cette dernière dans le tableau.<div id="ok" onclick="toggle_div(this,'tip');"><b>OK</b></div></div>
<b>Filtre</b>
@@ -18,10 +18,5 @@ Pour voir le nombre de paquets en destination d'une adresse IP, cliquez sur cett
<div id="tab">
</div>
<script src="filtre.js"></script>
-<script>
-function toggle_div(bouton, id) {
- var div = document.getElementById(id);
- div.style.display = "none";
-}
-</script>
+<script src="tip.js"></script>
"""))
diff --git a/www/html/fonctions.py b/www/html/fonctions.py
index a8d4c8b..3f44a31 100755
--- a/www/html/fonctions.py
+++ b/www/html/fonctions.py
@@ -4,7 +4,7 @@ import psycopg2
def baseHTML(title,body):
content=("""<!DOCTYPE html>
-<html>
+<html lang="fr">
<head>
<title>"""+ title +"""</title>
<meta charset="UTF-8">
diff --git a/www/html/fonctions.pyc b/www/html/fonctions.pyc
new file mode 100644
index 0000000..e644083
--- /dev/null
+++ b/www/html/fonctions.pyc
Binary files differ
diff --git a/www/html/index.py b/www/html/index.py
index 2cb7f7d..5563d13 100755
--- a/www/html/index.py
+++ b/www/html/index.py
@@ -11,10 +11,19 @@ def index(req):
#sql part
conn=connexionBD()
cur=conn.cursor()
- sql="select * from paquet;"
+
+ sql="SELECT * FROM paquet ORDER BY heure DESC LIMIT 20;"
+ sql_count="SELECT COUNT(*) FROM paquet;"
+
cur.execute(sql)
conn.commit()
data=cur.fetchall()
+
+ cur.execute(sql_count)
+ conn.commit()
+ count=cur.fetchone()
+ count=str(count[0])
+
conn.close()
#sql part
@@ -31,24 +40,19 @@ def index(req):
#write the html page
req.write(baseHTML("ATS-Project","""
-<center><h1>ATS-Project</h1></center>
+<h1>ATS-Project</h1>
<div id="tip" style="display:block;">
Pour voir le nombre de paquets en destination d'une adresse IP, cliquez sur cette dernière dans le tableau.<div id="ok" onclick="toggle_div(this,'tip');"><b>OK</b></div></div>
-<b>Filtre</b>
-<input type="text" id="condition" onkeyup="cherche()">
+<p>Nombre totale de paquets : <b>"""+ count +"""</b></p>
+<em><div id="ici" onclick="affiche_tas()">Pour afficher toute la table, cliquez sur ce texte.</div></em><br/>
<div id="tab">
-<center><table>
+<table class="data_tab">
<tr><th>Heure</th><th>Protocole</th><th>IP Source</th><th>IP Destination</th><th>Port Source</th><th>Port Destination</th></tr>
"""
+ content +
"""
-</table></center>
+</table>
</div>
-<script src="filtre.js"></script>
-<script>
-function toggle_div(bouton, id) {
- var div = document.getElementById(id);
- div.style.display = "none";
-}
-</script>
+<script src="tip.js"></script>
+<script src="tas.js"></script>
"""))
diff --git a/www/html/style.css b/www/html/style.css
index a826da5..827435a 100755
--- a/www/html/style.css
+++ b/www/html/style.css
@@ -3,28 +3,29 @@ body {
}
p,i,table,form {
- color:yellow;
+ color:#ffffff;
}
b {
- color : #e600e6;
+ color : #D42471;
}
-h1,h2,h3,h4,h5,h6 {
- color: #6666ff
+h1 {
+ color: #6666ff;
+ text-align: center
}
a {
- color: #00ff00;
+ color: #00ffff;
text-decoration: none;
}
a:hover {
- color: red;
+ color: #D42471;
}
table,th,td {
- border: 2px solid red;
+ border: 2px solid #D42471;
text-align: center;
}
@@ -37,3 +38,12 @@ table,th,td {
padding:10px;
background-color: black;
}
+
+.data_tab {
+ margin-left:auto;
+ margin-right:auto;
+}
+
+em{
+ color:#FF00FF;
+}
diff --git a/www/html/syntaxe.py b/www/html/syntaxe.py
index cdaf5f7..61ef7b3 100755
--- a/www/html/syntaxe.py
+++ b/www/html/syntaxe.py
@@ -10,8 +10,8 @@ def index(req):
#write the html page
req.write(baseHTML("ATS-Project","""
-<center><h1>Syntaxe</h1></center>
-<p>La """+lien('syntaxe.py','syntaxe')+""" pour utiliser les filtres disponibles sur l'"""+lien('index.py','index')+""" et """+lien('filtrage.py','filtrage')+""" est la suivante :</p>
+<h1>Syntaxe</h1>
+<p>La """+lien('syntaxe.py','syntaxe')+""" pour utiliser les filtres disponibles sur la page """+lien('filtrage.py','filtrage')+""" est la suivante :</p>
<p>&lt;colonne&gt;='&lt;valeur&gt;'</p><br/>
<table>
<tr><th>colonne</th><th>valeur</th><th>exemple</th></tr>
diff --git a/www/html/tas.js b/www/html/tas.js
new file mode 100644
index 0000000..e626768
--- /dev/null
+++ b/www/html/tas.js
@@ -0,0 +1,16 @@
+function affiche_tas(){
+
+ var url = "affiche-tas.py";
+
+ 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/tip.js b/www/html/tip.js
new file mode 100644
index 0000000..a69683f
--- /dev/null
+++ b/www/html/tip.js
@@ -0,0 +1,4 @@
+function toggle_div(bouton, id) {
+ var div = document.getElementById(id);
+ div.style.display = "none";
+}