From 64f41d53728a966f10aef6d7ffbc00853d754300 Mon Sep 17 00:00:00 2001 From: yo mama Date: Fri, 13 Feb 2015 02:41:42 -0800 Subject: fixed some basics --- impattern/im/cgi-bin/.gallery.cgi.swo | Bin 20480 -> 0 bytes impattern/im/cgi-bin/.gallery.cgi.swp | Bin 36864 -> 0 bytes impattern/im/cgi-bin/.gallery.cgi.un~ | Bin 59038 -> 0 bytes impattern/im/cgi-bin/.imditherconf.cgi.swo | Bin 12288 -> 0 bytes impattern/im/cgi-bin/.imditherconf.cgi.swp | Bin 12288 -> 0 bytes impattern/im/cgi-bin/.imditherconf.cgi.un~ | Bin 51229 -> 0 bytes impattern/im/cgi-bin/.queryTest.cgi.un~ | Bin 7485 -> 0 bytes impattern/im/cgi-bin/.test.cgi.un~ | Bin 519 -> 0 bytes impattern/im/cgi-bin/1.png | Bin 2482 -> 0 bytes impattern/im/cgi-bin/db.py | 29 -- impattern/im/cgi-bin/db.pyc | Bin 1515 -> 0 bytes impattern/im/cgi-bin/downloader.py | 114 ------- impattern/im/cgi-bin/downloader.pyc | Bin 2923 -> 0 bytes impattern/im/cgi-bin/gallery.cgi | 474 ---------------------------- impattern/im/cgi-bin/imdither.cgi | 145 --------- impattern/im/cgi-bin/imditherconf.cgi | 23 -- impattern/im/cgi-bin/imweb/databaser.py | 24 -- impattern/im/cgi-bin/imweb/downImg | 55 ---- impattern/im/cgi-bin/imweb/downloader.py | 114 ------- impattern/im/cgi-bin/imweb/fieldstorager.py | 21 -- impattern/im/cgi-bin/imweb/filenamer.py | 115 ------- impattern/im/cgi-bin/imweb/hexdirer.py | 38 --- impattern/im/cgi-bin/imweb/saveImg | 48 --- impattern/im/cgi-bin/pythonhelloworld.cgi | 5 - impattern/im/cgi-bin/queryTest.cgi | 9 - impattern/im/cgi-bin/test.cgi | 49 --- impattern/im/cgi-bin/youtube-dl | 1 - 27 files changed, 1264 deletions(-) delete mode 100644 impattern/im/cgi-bin/.gallery.cgi.swo delete mode 100644 impattern/im/cgi-bin/.gallery.cgi.swp delete mode 100755 impattern/im/cgi-bin/.gallery.cgi.un~ delete mode 100644 impattern/im/cgi-bin/.imditherconf.cgi.swo delete mode 100644 impattern/im/cgi-bin/.imditherconf.cgi.swp delete mode 100755 impattern/im/cgi-bin/.imditherconf.cgi.un~ delete mode 100755 impattern/im/cgi-bin/.queryTest.cgi.un~ delete mode 100755 impattern/im/cgi-bin/.test.cgi.un~ delete mode 100755 impattern/im/cgi-bin/1.png delete mode 100755 impattern/im/cgi-bin/db.py delete mode 100755 impattern/im/cgi-bin/db.pyc delete mode 100755 impattern/im/cgi-bin/downloader.py delete mode 100755 impattern/im/cgi-bin/downloader.pyc delete mode 100755 impattern/im/cgi-bin/gallery.cgi delete mode 100755 impattern/im/cgi-bin/imdither.cgi delete mode 100755 impattern/im/cgi-bin/imditherconf.cgi delete mode 100755 impattern/im/cgi-bin/imweb/databaser.py delete mode 100755 impattern/im/cgi-bin/imweb/downImg delete mode 100755 impattern/im/cgi-bin/imweb/downloader.py delete mode 100755 impattern/im/cgi-bin/imweb/fieldstorager.py delete mode 100755 impattern/im/cgi-bin/imweb/filenamer.py delete mode 100755 impattern/im/cgi-bin/imweb/hexdirer.py delete mode 100755 impattern/im/cgi-bin/imweb/saveImg delete mode 100755 impattern/im/cgi-bin/pythonhelloworld.cgi delete mode 100755 impattern/im/cgi-bin/queryTest.cgi delete mode 100755 impattern/im/cgi-bin/test.cgi delete mode 160000 impattern/im/cgi-bin/youtube-dl (limited to 'impattern/im/cgi-bin') diff --git a/impattern/im/cgi-bin/.gallery.cgi.swo b/impattern/im/cgi-bin/.gallery.cgi.swo deleted file mode 100644 index 8e49f67..0000000 Binary files a/impattern/im/cgi-bin/.gallery.cgi.swo and /dev/null differ diff --git a/impattern/im/cgi-bin/.gallery.cgi.swp b/impattern/im/cgi-bin/.gallery.cgi.swp deleted file mode 100644 index f1e8117..0000000 Binary files a/impattern/im/cgi-bin/.gallery.cgi.swp and /dev/null differ diff --git a/impattern/im/cgi-bin/.gallery.cgi.un~ b/impattern/im/cgi-bin/.gallery.cgi.un~ deleted file mode 100755 index 0720bde..0000000 Binary files a/impattern/im/cgi-bin/.gallery.cgi.un~ and /dev/null differ diff --git a/impattern/im/cgi-bin/.imditherconf.cgi.swo b/impattern/im/cgi-bin/.imditherconf.cgi.swo deleted file mode 100644 index 1bbf2e2..0000000 Binary files a/impattern/im/cgi-bin/.imditherconf.cgi.swo and /dev/null differ diff --git a/impattern/im/cgi-bin/.imditherconf.cgi.swp b/impattern/im/cgi-bin/.imditherconf.cgi.swp deleted file mode 100644 index 7de91b5..0000000 Binary files a/impattern/im/cgi-bin/.imditherconf.cgi.swp and /dev/null differ diff --git a/impattern/im/cgi-bin/.imditherconf.cgi.un~ b/impattern/im/cgi-bin/.imditherconf.cgi.un~ deleted file mode 100755 index bef4dd6..0000000 Binary files a/impattern/im/cgi-bin/.imditherconf.cgi.un~ and /dev/null differ diff --git a/impattern/im/cgi-bin/.queryTest.cgi.un~ b/impattern/im/cgi-bin/.queryTest.cgi.un~ deleted file mode 100755 index 31f6494..0000000 Binary files a/impattern/im/cgi-bin/.queryTest.cgi.un~ and /dev/null differ diff --git a/impattern/im/cgi-bin/.test.cgi.un~ b/impattern/im/cgi-bin/.test.cgi.un~ deleted file mode 100755 index 769e9af..0000000 Binary files a/impattern/im/cgi-bin/.test.cgi.un~ and /dev/null differ diff --git a/impattern/im/cgi-bin/1.png b/impattern/im/cgi-bin/1.png deleted file mode 100755 index e98ec53..0000000 Binary files a/impattern/im/cgi-bin/1.png and /dev/null differ diff --git a/impattern/im/cgi-bin/db.py b/impattern/im/cgi-bin/db.py deleted file mode 100755 index 4da7b83..0000000 --- a/impattern/im/cgi-bin/db.py +++ /dev/null @@ -1,29 +0,0 @@ -import MySQLdb -import time - -def now (): - return int(time.mktime(time.localtime())) -class db: - def __init__ (self): - self.conn = None - self.cursor = None - self.connect() - - def connect (self): - self.conn = MySQLdb.connect (host = "127.0.0.1", - user = "asdfus", - passwd = "gTYgT&M6q", - db = "asdfus") - self.cursor = self.conn.cursor () - - def execute (self,sql,args=()): - try: - self.cursor.execute(sql,args) - except MySQLdb.Error, e: - print "Error %d: %s" % (e.args[0], e.args[1]) - # sys.exit (1) - self.connect() - self.cursor.execute(sql,args) - - def lastinsertid (self): - return DB.conn.insert_id() diff --git a/impattern/im/cgi-bin/db.pyc b/impattern/im/cgi-bin/db.pyc deleted file mode 100755 index 6347826..0000000 Binary files a/impattern/im/cgi-bin/db.pyc and /dev/null differ diff --git a/impattern/im/cgi-bin/downloader.py b/impattern/im/cgi-bin/downloader.py deleted file mode 100755 index 7083b11..0000000 --- a/impattern/im/cgi-bin/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/downloader.pyc b/impattern/im/cgi-bin/downloader.pyc deleted file mode 100755 index 91ba5b0..0000000 Binary files a/impattern/im/cgi-bin/downloader.pyc and /dev/null differ diff --git a/impattern/im/cgi-bin/gallery.cgi b/impattern/im/cgi-bin/gallery.cgi deleted file mode 100755 index 0f762eb..0000000 --- a/impattern/im/cgi-bin/gallery.cgi +++ /dev/null @@ -1,474 +0,0 @@ -#!/usr/bin/python -import os -import cgi -import re - -import random - -import db -db = db.db() - -BASE_HREF = "http://i.asdf.us/im/" -PARAMLIST = "addr start limit name interface random" -LIMIT = 20 - -def get_params (paramlist): - paramkeys = paramlist.split() - form = {} - try: - qs = os.environ['QUERY_STRING'] - except: - qs = "" - if len(qs): - pairs = qs.replace("&", "&").split("&") - for pair in pairs: - k,v = pair.split("=", 1) - form[k] = v - params = {} - for key in paramkeys: - if key in form: - params[key] = sanitize(form[key]) - else: - params[key] = None - return params -def sanitize (str): - return re.sub(r'\W+', '', str) -def get_files (params): - sql = "SELECT * FROM im_cmd " - args = [] - where = [] - - if params['start'] is not None: - where.append("id < %s") - args.append(params['start']) - if params['name'] is not None: - where.append("name=%s") - args.append(params['name']) - if len(where): - sql += "WHERE " - sql += " AND ".join(where) - sql += " " - - if params['random'] is not None: - sql += "ORDER BY RAND() " - else: - sql += "ORDER BY id DESC " - sql += "LIMIT %s" - - if params['limit'] is not None: - args.append( int(params['limit']) ) - else: - args.append( LIMIT ) - db.execute(sql, args) - rows = db.cursor.fetchall () - return rows - -def is_image (img): - if "jpeg" in img: - return True - if "jpg" in img: - return True - if "gif" in img: - return True - if "png" in img: - return True - return False - - -params = get_params(PARAMLIST) - -titlephrase = random.choice([ - 'Keep on pickin\' on..', - 'Pickolaus Pickleby by Charles Pickens!', - 'You pick potato and I pick potahto...', - 'Take your piq!', - 'Show em what you got', - 'I sure know how to pick \'em', - 'Jus pick somethin already!', - 'You can\'t pick your friends...', - 'Select your image my liege', - 'There\'s a time to choose...', - 'gimme a choice! gimme lil\' choice-a-that...', - 'You choose you lose', - 'novels by James CHOICE...', - 'Choose away, chooser-man...', - ]) - -print "Content-type: text/html" -print "Pragma: no-cache" -print -print """ - - - - -""" -print ""+titlephrase+"" -print""" - - - - -
- key controls -
- ESC toggle
- C clear
- R reverse
- BACKSPACE delete
- LEFT ARROW newer
- RIGHT ARROW older
-
-
-
-
- -
-
copy
-
- -
-
-""" - - -files = get_files(params) -count = 0 -for f in files: - # url = BASE_HREF + f.replace(" ","%20") - url = BASE_HREF + f[5] + "/" + f[7] - print "
" % (url) -print "
" - -lowest_id = files[-1][0] -previous_id = lowest_id + (LIMIT * 2) -back = ["start=%d" % lowest_id, "limit=%d" % LIMIT] -newer = ["start=%d" % previous_id, "limit=%d" % LIMIT] -random_time = [] -if params['name'] is not None: - back.append("name=%s" % params['name']) - newer.append("name=%s" % params['name']) - random_time.append("name=%s" % params['name']) - -newer_QS = "&".join(newer) -back_QS = "&".join(back) -random_time_QS = "&".join(back) -print "
" -print "← newer" % newer_QS; -print "|" -print "editor" -print "|" -print "random" % random_time_QS; -print "|" -print "older →" % back_QS; -print "
" -print """ - - - - - - - -""" - diff --git a/impattern/im/cgi-bin/imdither.cgi b/impattern/im/cgi-bin/imdither.cgi deleted file mode 100755 index 29837ed..0000000 --- a/impattern/im/cgi-bin/imdither.cgi +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/python - -import downloader -import time -import re -import cgi -from subprocess import Popen, PIPE, call -from os import stat, path, makedirs -import sys -import sha -BASE_DIR = "" -OTHER_BASE = "" -#BASE_DIR = "/var/www/asdf.us/httpdocs/im/" -#OTHER_BASE = "http://asdf.us/im/" - -print "Content-Type: text/html" -print "" -print "" - -NAMETAG = "imDither" - -MAIN_DIRECTORY = "" -#BIN_CONVERT = "/usr/bin/convert" -#BIN_IDENTIFY = "/usr/bin/identify" -#BIN_COMPOSITE = "/usr/bin/composite" -BIN_CONVERT = "convert" -BIN_IDENTIFY = "identify" -BIN_COMPOSITE = "composite" - -NOW = str(int(time.time())) -MAX_LENGTH_BEFORE_ABRIDGED = 30 -ABBREVIATION = "xx_abridged__" - -################################### -### DEFAULT VALUES HERE -params = { - "url" : "http://asdf.us/im/10/friedeggstresstoy_1321140711_1322282769_pepper.gif", - "ditherType" : "1.png", - "username" : "pepper", - "formatType" : "png", -} -################################### - -form = cgi.FieldStorage() -if form: - for key, value in form.iteritems(): - formValues[key] = params[key] #CHECKME - -class Utils: - def file_size (self, imgFile): - return stat(imgFile)[6] - - def imageDimensions(self, thefile): - ident = Popen([BIN_IDENTIFY, thefile], stdout=PIPE).communicate()[0] - parts = ident.split(" ") - return parts[2].split("x") - - def hash_dir(self, s): - """get a random number-letter pair""" - return sha.new(s).hexdigest()[:2] - - def hexdir(self): - """create a random path name""" - directoryName = utils.hash_dir(NOW) - - dirs = [ - BASE_DIR+directoryName+'/', - OTHER_BASE+directoryName+'/', - ] - ################################### - if not path.exists(directoryName): - makedirs(directoryName) - - - return dirs - - def makeOriginalName(self, params, canvas_type="", nametag_part=""): - if not nametag_part: - nametag_part = NAMETAG - if not canvas_type: - canvastype = params["formatType"] - filename = '%s_%s_%s.%s' % (nametag_part, NOW, params["username"], canvas_type) - return filename - - def sanitize (self,string): - """strip out all non-word characters""" - return re.sub(r'\W+', '', string) - - def makeNameFromFilename(self, params): - parts = params["url"].split("?")[0].split('/') - filename = parts[-1] - name, extension = filename.split('.') - if len(extension) >= 5: - sys.stdout.write('the file is not an image or any standard format') - sys.exit() - if len(name)> MAX_LENGTH_BEFORE_ABRIDGED: - name = ABBREVIATION - sanitized = self.sanitize(name) - thefilename = "%s_%s_%s_%s.%s" % (NAMETAG, NOW, sanitized, params["username"], extension) - return thefilename - -utils = Utils(); - - -class Dither: - def makeCanvas(self, thefile): - call([BIN_CONVERT,"-size", self.dimensions[0]+"x"+self.dimensions[1],"canvas:transparent", thefile]) - def makeMask(self, themask, thedither, thebackground): - """ composite -tile DITHERNAME BACKGROUNDNAME MASKNAME """ - call([BIN_COMPOSITE,"-tile",thedither,thebackground,themask]) - #convert thebg.gif -compose Dst_In null: thefile.gif -matte -layers composite new.gif - call([BIN_CONVERT,themask,"-compose","Dst_In","null:",self.privatepath+self.mainfile,"-matte","-layers","composite",themask]) - # os.system("rm "+thebackground) - def fuseMask(self, themask, theimage): - call([BIN_COMPOSITE,theimage,"-compose","Pin_Light",themask,theimage]) - # os.system("rm "+themask) - def __init__(self, url, thedither, username): - self.mainfile = utils.makeNameFromFilename(params) - filepaths = utils.hexdir() - self.privatepath = filepaths[0] - self.publicpath = filepaths[1] - downloader.download(url, self.mainfile, self.privatepath) - - parts = self.mainfile.split('.') - print parts - if "gif" in parts[-1]: - canvastype = "gif" - else: - canvastype = "png" - - self.canvasfile = "/tmp/"+utils.makeOriginalName(params, canvastype, "canvasfile") - self.dimensions = utils.imageDimensions(self.privatepath+self.mainfile) - self.makeCanvas(self.canvasfile) - self.theMask = "/tmp/"+utils.makeOriginalName(params, canvastype, "maskfile") - #good up to here - self.makeMask(self.theMask, thedither, self.canvasfile) - self.fuseMask(self.theMask, self.privatepath+self.mainfile) - #self.mainfile = self.mainfile.replace(, do something with s3) - print self.privatepath+self.mainfile - print utils.file_size(self.privatepath+self.mainfile) - print 'width: '+self.dimensions[0]+'px' - print 'height: '+self.dimensions[1]+'px' - -if __name__ == "__main__": - newImage = Dither(params["url"], params["ditherType"], params["username"]) diff --git a/impattern/im/cgi-bin/imditherconf.cgi b/impattern/im/cgi-bin/imditherconf.cgi deleted file mode 100755 index 8e7b7f2..0000000 --- a/impattern/im/cgi-bin/imditherconf.cgi +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env python - -from subprocess import * -import re -print "Content-type: text/html\n\n" -DITHERDIR = "/home/pepper/im/imdither/dithers"; - - -def get_ditherfiles(): - filesString = Popen(["ls", DITHERDIR], stdout=PIPE).communicate()[0] - files = filesString.split("\n"); - #javascript = "var ditherfiles = [" - javascript = "[" - for i in files: - if not i: - continue - javascript += "\"%s\", " % (i); - - javascript = javascript[:-2] - javascript += "]"; - return javascript -print get_ditherfiles(); - 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" diff --git a/impattern/im/cgi-bin/pythonhelloworld.cgi b/impattern/im/cgi-bin/pythonhelloworld.cgi deleted file mode 100755 index cede50f..0000000 --- a/impattern/im/cgi-bin/pythonhelloworld.cgi +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -print "Content-type: text/html\n\n" -print "Hello world!" - diff --git a/impattern/im/cgi-bin/queryTest.cgi b/impattern/im/cgi-bin/queryTest.cgi deleted file mode 100755 index 5e6d573..0000000 --- a/impattern/im/cgi-bin/queryTest.cgi +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/perl - -use CGI; -my $cgi = new CGI; -print $cgi->header('text/html'); -print "what's up doc"; -#print( $cgi->param( "test" )); - - diff --git a/impattern/im/cgi-bin/test.cgi b/impattern/im/cgi-bin/test.cgi deleted file mode 100755 index 1159090..0000000 --- a/impattern/im/cgi-bin/test.cgi +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/perl - -print "Content-Type: text/html\r\n\r\nHello, world!\n"; -open MYFILE, ">/home8/basedxco/public_html/TESTFILE" or die $!; - - - -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -print MYFILE "this is a test!!!!"; -close(MYFILE); diff --git a/impattern/im/cgi-bin/youtube-dl b/impattern/im/cgi-bin/youtube-dl deleted file mode 160000 index fc79158..0000000 --- a/impattern/im/cgi-bin/youtube-dl +++ /dev/null @@ -1 +0,0 @@ -Subproject commit fc79158de2779a9f2d3fb16ddfb2878b82693b79 -- cgit v1.2.3-70-g09d2