summaryrefslogtreecommitdiff
path: root/impattern/im/cgi-bin/imweb
diff options
context:
space:
mode:
Diffstat (limited to 'impattern/im/cgi-bin/imweb')
-rwxr-xr-ximpattern/im/cgi-bin/imweb/databaser.py24
-rwxr-xr-ximpattern/im/cgi-bin/imweb/downImg55
-rwxr-xr-ximpattern/im/cgi-bin/imweb/downloader.py114
-rwxr-xr-ximpattern/im/cgi-bin/imweb/fieldstorager.py21
-rwxr-xr-ximpattern/im/cgi-bin/imweb/filenamer.py115
-rwxr-xr-ximpattern/im/cgi-bin/imweb/hexdirer.py38
-rwxr-xr-ximpattern/im/cgi-bin/imweb/saveImg48
7 files changed, 0 insertions, 415 deletions
diff --git a/impattern/im/cgi-bin/imweb/databaser.py b/impattern/im/cgi-bin/imweb/databaser.py
deleted file mode 100755
index 07b8723..0000000
--- a/impattern/im/cgi-bin/imweb/databaser.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/python
-
-from db import *
-import os
-DB = db ()
-
-PATH_TO_S3CMD = "/var/www/asdf.us/cgi-bin/im/s3/s3cmd-1.1.0-beta3/s3cmd"
-PATH_TO_IMAGES = "/var/www/asdf.us/docs/im"
-
-global idnumber
-
-function dbGet(idnumber):
- try:
- DB.cursor.execute('SELECT dir, newfile, id FROM im_cmd WHERE id='+id)
- #sql = "INSERT INTO im_cmd (date,remote_addr,name,dir,newfile,cmd) VALUES(%s,%s,%s,%s,%s,%s)"
- #args = (now(), remoteaddress, name, dir, newfile, cmd)
- data = cursor.fetchall
- print str(data)
- except ():
- return
-
-if __name__ == '__main__':
- sys.argv[1] = idnumber
- dbGet(idnumber) \ No newline at end of file
diff --git a/impattern/im/cgi-bin/imweb/downImg b/impattern/im/cgi-bin/imweb/downImg
deleted file mode 100755
index d029477..0000000
--- a/impattern/im/cgi-bin/imweb/downImg
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/python
-
-import cgi
-import downloader
-import fieldstorager
-import sys
-import os
-#import gifchooser
-
-#BASE_DIR = "/var/www/asdf.us/httpdocs/imweb/"
-BASE_DIR = ""
-PARAM_LIST = "texture heightmap"
-#BIN_CONVERT = "/usr/bin/convert"
-BIN_CONVERT = "convert"
-
-print "Content-type: text/plain"
-print ""
-
-form = cgi.FieldStorage()
-newvalues = fieldstorager.fieldstorage(PARAM_LIST, form)
-thekeys = PARAM_LIST.split()
-for key in thekeys:
- globals()[key] = newvalues[key]
-########################################################
-#test with values here
-texture = "http://i.asdf.us/im/f3/imBreak_1327641897_clifford_1327640637_pepper.png"
-heightmap = "http://dump.fm/images/20120127/1327645413657-dumpfm-pepper-topcomments.png"
-#######################################################
-def uploadit(pictureUrl):
- if len(pictureUrl) > 3 and "." in pictureUrl:
- imageparts = pictureUrl.split('.')
- filetype = imageparts[-1]
- if "?" in filetype:
- theparts = filetype.split('?')
- filetype = theparts[0]
- if pictureUrl == texture:
- imagename = "Texture"
- if pictureUrl == heightmap:
- imagename = "Heightmap"
- if "png" in pictureUrl.lower() or "jpg" in pictureUrl.lower() or "jpeg" in pictureUrl.lower() or "gif" in pictureUrl.lower():
- downloader.download(pictureUrl, (imagename+"."+filetype), BASE_DIR)
- firstfile = BASE_DIR+imagename+"."+filetype
- endfile = BASE_DIR+imagename+"."+"jpg"
- os.system(BIN_CONVERT+" -resize 256x256\! "+firstfile+" "+endfile)
- if pictureUrl == "Heightmap":
- os.system(BIN_CONVERT+" colorspace -gray "+" "+endfile+" "+endfile)
- os.system("rm heightmap.png heightmap.gif texture.png texture.gif")
- print "upload"+imagename+" successful"
- return endfile
- else:
- print "This is not an acceptable image format for "+imagename
- return
-uploadit(texture)
-uploadit(heightmap)
-sys.exit()
diff --git a/impattern/im/cgi-bin/imweb/downloader.py b/impattern/im/cgi-bin/imweb/downloader.py
deleted file mode 100755
index 7083b11..0000000
--- a/impattern/im/cgi-bin/imweb/downloader.py
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/python
-import random
-import urllib, urllib2
-urlopen = urllib2.urlopen
-Request = urllib2.Request
-import sys
-
-MAX_SIZE = 1024 * 1024 * 1.2
-
-###___this somewhat poorly written program basically performs a get request
-#you can specify three arguments, the url, the destination path and the filename#that you'll want your file to be called
-#these can be specified as argument values from the commandline or as
-#values in the mainfunction which is downloader.download(url,filename,destination)
-#the destination and filename arguments are optional
-
-
-
-url = ""
-destination = ""
-filename = ""
-
-def argval():
- global destination
- global url
- global filename
- stuff = sys.argv
- lenstuff = len(stuff)
- if lenstuff >= 4:
- getvalues()
- if lenstuff ==3:
- print str(lenstuff)
- url = sys.argv[-2]
- filename = sys.argv[-1]
- if lenstuff ==2:
- url = sys.argv[-1]
- destination = ""
- partz = url.split('/')
- filename = partz[-1]
- if lenstuff ==1:
- print 'please provide url'
- return None
- return url
-
-def getvalues():
- global url
- global destination
- global filename
- url = sys.argv[-3]
- destination = sys.argv[-1]
- filename = sys.argv[-2]
- if len(filename) == 0:
- partz = url.split('/')
- filename = partz[-1]
- if filename == "" or filename == None:
- partz = url.split('/')
- filename = partz[-1]
- return url
-
-def browser_request (url,data=None):
- headers = {
- 'User-Agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)',
- 'Accept': '*/*',
- }
- try:
- req = Request(url, data, headers)
- response = urlopen(req)
- return response
- except:
- print "ERROR"
- sys.stdout.write('there is a problem with the url or an I/O error')
- return None
- sys.exit()
-
-
-def download(url, filename="",destination=""):
- response = browser_request(url)
- rawimg = response.read()
- if len(rawimg) == 0:
- print error("got zero-length file")
- sys.stdout.write("file did not exist or was zero-length")
- sys.exit()
- if len(rawimg) > MAX_SIZE and "asdf.us" not in url:
- error = "file too big: max size " + str(MAX_SIZE/1024) + " KB / " + filename + " is " + str(len(rawimg)/1024) + " KB"
- print error
- sys.stdout.write(error)
- sys.exit()
- if filename == "":
- partz = url.split('/')
- filename = partz[-1]
- path = ""
- if destination == "" or destination == '':
- path = filename
- else:
- path = destination+filename
- f = open(path, "w")
- f.write(rawimg)
- print 'success'
- f.close()
- finalitems = {}
- finalitems['url'] = url
- finalitems['filename'] = filename
- finalitems['destination'] = destination
- return finalitems
-
-def downloader():
- global url
- global destination
- global filename
- argval()
- finalitems = download(url, filename, destination)
- return finalitems
-
-if __name__ == '__main__':
- downloader()
diff --git a/impattern/im/cgi-bin/imweb/fieldstorager.py b/impattern/im/cgi-bin/imweb/fieldstorager.py
deleted file mode 100755
index 55b00ad..0000000
--- a/impattern/im/cgi-bin/imweb/fieldstorager.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/python
-
-def fieldstorage(paramlist, form):
- theparams = paramlist.split()
- newvalues = {}
- for item in theparams:
- if item in form:
- newvalues[item] = form[item].value
- else:
- newvalues[item] = None
- for item in theparams:
- if newvalues[item] is not None:
- if 'true' in newvalues[item] or 'True' in newvalues[item]:
- if len(newvalues[item]) <= 6:
- newvalues[item] = True
- elif 'false' in newvalues[item] or 'False' in newvalues[item]:
- if len(newvalues[item]) <= 7:
- newvalues[item] = False
- return newvalues
-
-
diff --git a/impattern/im/cgi-bin/imweb/filenamer.py b/impattern/im/cgi-bin/imweb/filenamer.py
deleted file mode 100755
index 9b6ef32..0000000
--- a/impattern/im/cgi-bin/imweb/filenamer.py
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import os
-import re
-import time
-import string
-import urllib
-import sha
-
-#this program takes a url and makes a new filename for it. it also
-#splits out the extension. this is important for manipulating images
-#it returns a hash, part[0] is the filename and part[1] is the extension
-#called like this filenamer.filename(url, nametag, username)
-
-
-thefilename = ""
-extension = ""
-
-nametag = ""
-username = ""
-url = ""
-
-def getargs():
- global username
- global nametag
- global url
- args = sys.argv
- if len(args) < 2:
- return None
- if len(args) >= 4:
- username = args[-1]
- nametag = args[-2]
- url = args[-3]
- if len(args) == 3:
- nametag = args[-1]
- url = args[-2]
- if len(args) == 2:
- url = args[-1]
- thereturn = {}
- thereturn['url'] = url
- thereturn['nametag'] = nametag
- thereturn['username'] = username
- return thereturn
-
-def sanitize (str):#this removes pretty much everything but letters(and underscores) from a url
- return re.sub(r'\W+', '', str)
-#def sanitize (str):
-# tmp_str = urllib.unquote(str)
-# return re.sub(r'\W+', '', tmp_str)
-
-
-
-
-def now ():
- return int(time.mktime(time.localtime()))
-
-def spliturl(url):
- if len(url) < 3 or '/' not in url:
- sys.stdout.write('you have not provided a url')
- print 'you have not provided a url'
- sys.exit()
- parts = url.split('/')
- namepart = parts[-1]
- importantparts = namepart.split('.')
- extension = importantparts[-1]
- if "?" in extension:
- querysplit = extension.split('?')
- extension = querysplit[0]
- if len(extension) >= 5:
- sys.stdout.write('the file is not an image or any standard format')
- print 'the file is not an image or any standard format'
- sys.exit
- namepart = importantparts[-2]
- if len(namepart)>50:
- namepart = "xx_abridged__"
- sanitized = sanitize(namepart)
- salvaged = {}
- salvaged['extension'] = extension
- salvaged['namepart'] = sanitized
- return salvaged
-
-def prepare(url):
- global nametag
- global username
- time = now()
- datestamp = str(time)
- parts = spliturl(url)
- extension = parts['extension']
- original = parts['namepart']
- thefilename = nametag+'_'+datestamp+"_"+original+"_"+username+'.'+extension
- return thefilename
-
-def filename(url, tag="", usrname=""):
- global nametag
- global username
- if tag == None:
- tag = ""
- if usrname == None:
- usrname = ""
- nametag = tag
- username = usrname
- thefilename = prepare(url)
- print thefilename
- return thefilename
- sys.exit()
-
-
-if __name__ == '__main__':
- vars = getargs()
- url=vars['url']
- nametag=vars['nametag']
- username = vars['username']
- filename(url,nametag,username)
-
diff --git a/impattern/im/cgi-bin/imweb/hexdirer.py b/impattern/im/cgi-bin/imweb/hexdirer.py
deleted file mode 100755
index af6f60e..0000000
--- a/impattern/im/cgi-bin/imweb/hexdirer.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import os
-import time
-import string
-import sha
-BASE_DIR = "/var/www/asdf.us/httpdocs/im/"
-OTHER_BASE = "http://asdf.us/im/"
-
-#THIS MODULE RETURNS A COMPLETE PATH! ALL YOU HAVE TO DO IS
-#SPECIFY THE BASE DIRECTORY
-#the hash works like this:
-#0 is private path
-#1 is the public path
-
-
-
-def hash_dir (s):
- return sha.new(s).hexdigest()[:2]
-
-def now ():
- return int(time.mktime(time.localtime()))
-
-def hexdir():
- time = now()
- time = str(time)
- ending = hash_dir(time)
- dirs = []
- dirs.append(BASE_DIR+ending+'/')
- dirs.append(OTHER_BASE+ending+'/')
- print str(dirs)
- return dirs
- sys.exit()
-
-if __name__ == "__main__":
- hexdir()
-
diff --git a/impattern/im/cgi-bin/imweb/saveImg b/impattern/im/cgi-bin/imweb/saveImg
deleted file mode 100755
index e76c36a..0000000
--- a/impattern/im/cgi-bin/imweb/saveImg
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/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"