#!/usr/bin/python import cgi, re, time, os, string; import cgitb;cgitb.enable(display=0, logdir="/tmp"); #intimate objects server program #version 5 #by jofish #has three ways to use it: #returns seconds since file generated plus one. returns zero if no such file #/cgi-bin/io/gen5.py?me=me&you=you&shared=sharephrase&do=timesince #returns mytimesince /ntheytimesince #to leave a message for the other person #/cgi-bin/io/gen5.py?me=me&you=you&shared=sharephrase&do=post&content=contenthere #returns mytimesince /nOK | BAD #to see what message was left for me #/cgi-bin/io/gen5.py?me=me&you=you&shared=sharephrase&do=read #returns mytimesince /ncontent-of-me form=cgi.FieldStorage() print "Content-type: text/html\n" if ((re.search('[^a-zA-Z0-9\-]',form["me"].value+form["you"].value+form["shared"].value)==None)): if os.path.isfile('/var/www/io/inout/'+form["shared"].value+'/'+form["me"].value): #always print my time print (int(time.time())-os.stat('/var/www/io/inout/'+form["shared"].value+'/'+form["me"].value).st_mtime+1), else: print "0", if (form["do"].value=='timesince'): if os.path.isfile('/var/www/io/inout/'+form["shared"].value+'/'+form["you"].value): print (int(time.time())-os.stat('/var/www/io/inout/'+form["shared"].value+'/'+form["you"].value).st_mtime+1), else: print "0", elif (form["do"].value=='post'): if ((re.search('[^a-zA-Z0-9\- ]',form["content"].value)==None)): if not os.path.exists('/var/www/io/inout/'+form["shared"].value+'/'): os.mkdir('/var/www/io/inout/'+form["shared"].value+'/',755) myfile=open('/var/www/io/inout/'+form["shared"].value+'/'+form["you"].value,'w'); myfile.write(form["content"].value); myfile.close; print "OK", else: print "BADCONTENT", elif (form["do"].value=='read'): if os.path.isfile('/var/www/io/inout/'+form["shared"].value+'/'+form["me"].value): myfile=open('/var/www/io/inout/'+form["shared"].value+'/'+form["me"].value) for line in myfile: print line myfile.close() else:print "NOSUCHFILE", else:print "BADINSTRUCTION", else: #they had an invalid character in their names or sharephrase print "BADFILENAME",