2010-03-02 20:45:21 -07:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
import cgi
|
|
|
|
import cgitb; cgitb.enable()
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from urllib import quote
|
|
|
|
|
|
|
|
from ctf import teams, html, paths
|
|
|
|
|
|
|
|
basedir = os.path.join(paths.VAR, 'tanks')
|
|
|
|
|
|
|
|
links = '''
|
|
|
|
<h3>Tanks</h3>
|
|
|
|
<li><a href="docs.html">Docs</a></li>
|
|
|
|
<li><a href="results.cgi">Results</a></li>
|
|
|
|
<li><a href="submit.html">Submit</a></li>
|
|
|
|
<li><a href="errors.cgi">My Errors</a></li>
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
fields = cgi.FieldStorage()
|
|
|
|
team = fields.getfirst('team', '').strip()
|
|
|
|
passwd = fields.getfirst('passwd', '').strip()
|
|
|
|
code = fields.getfirst('code', '')
|
|
|
|
if not teams.chkpasswd(team, passwd):
|
|
|
|
body = '<p>Authentication failed.</p>'
|
|
|
|
elif not code:
|
|
|
|
body = '<p>No program given.</p>'
|
|
|
|
else:
|
2010-05-17 23:24:41 -06:00
|
|
|
path = os.path.join(basedir, 'players', quote(team, safe=''))
|
2010-03-02 20:45:21 -07:00
|
|
|
file = open(path, 'w')
|
2010-05-18 09:03:36 -06:00
|
|
|
file.write('Team: %s\n' % team)
|
2010-05-17 23:11:30 -06:00
|
|
|
file.write('Color: #%s\n' % teams.color(team))
|
2010-05-17 23:41:26 -06:00
|
|
|
file.write('Content-Type: text/x-tanks-bullet\n')
|
2010-05-17 23:11:30 -06:00
|
|
|
file.write('\n')
|
2010-03-02 20:45:21 -07:00
|
|
|
file.write(code)
|
|
|
|
file.close()
|
|
|
|
|
|
|
|
body = ("<p>Submission successful.</p>")
|
|
|
|
|
|
|
|
html.serve('Tanks Submission', body, links=links)
|