#!/usr/bin/python import hexdirer import filenamer import cgi import fieldstorager import base64 import random import sys import databaser print "Content-type: text/plain" print "" nametag = "imWeb" #name is the image name PARAM_LIST = "name username picture" form = cgi.FieldStorage() newvalues = fieldstorager.fieldstorage(PARAM_LIST, form) thekeys = PARAM_LIST.split() for key in thekeys: globals()[key] = newvalues[key] if username == None: username = "" if name == None: name = str(random.randint(0,100)) ############################################################ #test here ########################################################### try: #the picture is first encoded so we have to decode it picture = base64.b64decode(picture) namepart = filenamer.filename(("/"+name+".png"),username,nametag) filepaths = hexdirer.hexdir() filepaths = ["",""] thefile = filepaths[0]+namepart f = open(thefile,'w') for line in picture: f.write(line) f.close() # databaser.database(filepaths[0],namepart,"imweb capture",username) print "capture successful" print filepaths[1]+namepart except: print "sorry, there is a problem with image capture"