This repository has been archived on 2020-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
cgi-pw_manager/new.py

48 lines
1.0 KiB
Python
Executable File

#!/usr/bin/python3.5
import cgi
import cgitb
cgitb.enable()
import re
import configparser
from functions.headfoot import printheader,printfooter
# IMPORT DE LA CONFIGURATION
config = configparser.ConfigParser()
config.read('config.conf')
DOMAIN = config.get('general','domain')
TEMPLATEPATH = config.get('general','templatepath')
PROTO = config.get('general','proto')
# EXTRACTION DES VARIABLES
TEMPLATEFILE = open(TEMPLATEPATH, "r")
TEMPLATE = TEMPLATEFILE.read()
ALLVARIABLES = re.findall(r'\$\$\w+', TEMPLATE)
VARIABLES = ""
for i in ALLVARIABLES:
if VARIABLES.find(i) == -1:
VARIABLES = VARIABLES +" "+ i
VARIABLES = re.sub('[$$]', '', VARIABLES)
printheader()
# BODY
print('<form action="/create.py">')
print('Nom du VirtualHost : <input type="text" name="VHOSTNAME"><br>')
for i in VARIABLES.split():
print(i, ':')
print('<input type="text" name="', i , '"><br>', sep="")
print('<input type="submit" value="GO">')
print('</form>')
print('<br><a href="', PROTO , '://', DOMAIN , '/index.py">Retour</a>', sep='')
printfooter()