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/file.py
2017-12-19 23:39:22 +00:00

42 lines
945 B
Python
Executable File

#!/usr/bin/python3.5
# -*- coding: utf-8 -*-
import cgi
import cgitb
cgitb.enable()
import re
import configparser
from functions.headfoot import printheader,printfooter
from functions.htmlsyntaxfc import htmlsyntax
# IMPORT DE LA CONFIGURATION
config = configparser.ConfigParser()
config.read('config.conf')
DOMAIN = config.get('general','domain')
PROTO = config.get('general','proto')
# TRAITEMENT DES DATA
fs = cgi.FieldStorage()
VHOSTNAME = cgi.escape(fs.getvalue('file'))
VHOSTPATH = "/etc/apache2/sites-available/" + VHOSTNAME
VHOSTFILE = open(VHOSTPATH, "r")
VHOST = VHOSTFILE.read()
VHOST = htmlsyntax(VHOST)
#VHOST = re.sub('<', '&lt', VHOST)
#VHOST = re.sub('>', '&gt', VHOST)
# AFFICHAGE DES ENTETES
printheader()
# BODY
print('<b>', VHOSTNAME , '</b>')
print("<pre>")
print('<p>', VHOST, '</p>' )
print('</pre>')
print('<a href="', PROTO , '://', DOMAIN , '/index.py">Retour</a>', sep='')
# AFFICHAGE DU FOOTER
printfooter()