#!/usr/bin/python print """Content-Type: text/html\n\n""" print """\n\n""" import cgi import cgitb; cgitb.enable() import os import Config try: from urllib.parse import quote except: from urllib import quote try: from ctf import teams except: import sys path = '/home/pflarr/repos/gctf/' sys.path.append(path) from ctf import teams teams.build_teams() head = open('head.html').read() % "Error Report" print head print open('links.html').read() def done(): print '' sys.exit(0) fields = cgi.FieldStorage() team = fields.getfirst('team', '').strip() passwd = fields.getfirst('passwd', '').strip() if team and passwd and \ team in teams.teams and passwd == teams.teams[team][0]: path = os.path.join(Config.DATA_PATH, 'errors', quote(team)) if os.path.isfile(path): errors = open(path).readlines() print '

Your latest errors:' print '

' if errors: print '
\n'.join(errors) else: print 'There were no errors.' print '
' else: print '

No error file found.' done() if team and team not in teams.teams: print '

Invalid team.' if team and team in teams.teams and passwd != teams.teams[team][0]: print '

Invalid password.' print '''

Error report request: Team:
Password:
''' done()