blob: e76c36a41f5a2341f3c54cd9b576f8c2fcedfc60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/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"
|