#!/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, 'ai/players', quote(team, safe='')) file = open(path, 'w') file.write(code) file.close() body = ("

    Submission successful.

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