2009-10-07 10:50:18 -06:00
|
|
|
#!/usr/bin/python3
|
2009-10-06 12:47:36 -06:00
|
|
|
|
|
|
|
import cgi
|
|
|
|
import cgitb; cgitb.enable()
|
2009-10-07 10:50:18 -06:00
|
|
|
import sys
|
2009-10-06 12:47:36 -06:00
|
|
|
import os
|
|
|
|
|
|
|
|
import Config
|
|
|
|
|
|
|
|
try:
|
|
|
|
from urllib.parse import quote
|
|
|
|
except:
|
|
|
|
from urllib import quote
|
|
|
|
|
|
|
|
try:
|
|
|
|
from ctf import teams
|
|
|
|
except:
|
|
|
|
path = '/home/pflarr/repos/gctf/'
|
|
|
|
sys.path.append(path)
|
|
|
|
from ctf import teams
|
2009-10-09 08:47:19 -06:00
|
|
|
from ctf import config
|
2009-10-06 12:47:36 -06:00
|
|
|
teams.build_teams()
|
|
|
|
|
2009-10-09 08:47:19 -06:00
|
|
|
print(config.start_html('Tanks Errors',
|
|
|
|
links_title='Tanks',
|
|
|
|
links=[('docs.cgi', 'Docs'),
|
|
|
|
('results.cgi', 'Results'),
|
|
|
|
('submit.html', 'Submit'),
|
|
|
|
('errors.cgi', 'My Errors')]))
|
2009-10-06 12:47:36 -06:00
|
|
|
|
|
|
|
def done():
|
2009-10-09 08:47:19 -06:00
|
|
|
print(config.end_html())
|
2009-10-06 12:47:36 -06:00
|
|
|
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()
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>Your latest errors:')
|
|
|
|
print('<div class=errors>')
|
2009-10-06 12:47:36 -06:00
|
|
|
if errors:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<BR>\n'.join(errors))
|
2009-10-06 12:47:36 -06:00
|
|
|
else:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('There were no errors.')
|
|
|
|
print('</div>')
|
2009-10-06 12:47:36 -06:00
|
|
|
else:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>No error file found.')
|
2009-10-06 12:47:36 -06:00
|
|
|
|
|
|
|
done()
|
|
|
|
|
|
|
|
if team and team not in teams.teams:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>Invalid team.')
|
2009-10-06 12:47:36 -06:00
|
|
|
|
|
|
|
if team and team in teams.teams and passwd != teams.teams[team][0]:
|
2009-10-07 10:50:18 -06:00
|
|
|
print('<p>Invalid password.')
|
2009-10-06 12:47:36 -06:00
|
|
|
|
2009-10-07 10:50:18 -06:00
|
|
|
print('''
|
2009-10-06 12:47:36 -06:00
|
|
|
<form action="errors.cgi" method="get">
|
|
|
|
<fieldset>
|
|
|
|
<legend>Error report request:</legend>
|
|
|
|
Team: <input type="text" name="team"><BR>
|
|
|
|
Password: <input type="text" name="passwd"><BR>
|
|
|
|
<button type="get my errors">Submit</button>
|
|
|
|
</fieldset>
|
2009-10-07 10:50:18 -06:00
|
|
|
</form>''')
|
2009-10-06 12:47:36 -06:00
|
|
|
|
|
|
|
done()
|