#!/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 = '''

Tanks

  • Docs
  • Results
  • Submit
  • My Errors
  • ''' fields = cgi.FieldStorage() team = fields.getfirst('team', '').strip() passwd = fields.getfirst('passwd', '').strip() code = fields.getfirst('code', '') if not teams.chkpasswd(team, passwd): body = '

    Authentication failed.

    ' elif not code: body = '

    No program given.

    ' else: path = os.path.join(basedir, 'players', quote(team, safe='')) file = open(path, 'w') file.write('Team: %s\n' % quote(team)) file.write('Color: #%s\n' % teams.color(team)) file.write('Content-Type: text/x-tanks-bullet\n') file.write('\n') file.write(code) file.close() body = ("

    Submission successful.

    ") html.serve('Tanks Submission', body, links=links)