#!/usr/bin/env python

import cgi

form = cgi.FieldStorage()
Prot = form.getfirst("Prot", "no")
OutIP = form.getfirst("OutIP", "no")
OutPort = form.getfirst("OutPort", "no")
InIP = form.getfirst("InIP", "no")
InPort = form.getfirst("InPort", "no")



print("Content-type: text/html\n")
print("""<!DOCTYPE HTML>
        <html>
        <head>
            <meta charset="utf-8">
            <title>Form processing</title>
        </head>
        <body>""")

print("<h1>Rule added!</h1>")

print("""</body>
        </html>""")
SRCFile = open("rules.txt", "a")
SRCFile.write(Prot + "," + OutIP + "," + OutPort + "," + InIP + "," + InPort + "\n")
SRCFile.close()
print("Done!")
print("""<p><a href="NatDisp.py">Return back</a></p>""")
print("""<meta http-equiv="refresh" content="5;NatDisp.py">""")

