From ca7216ef0777de4ea226c6d672c4862362f9e74c Mon Sep 17 00:00:00 2001 From: yo mama Date: Sun, 15 Feb 2015 18:21:14 -0800 Subject: finalizing --- im/cgi-bin/.gallery.cgi.swo | Bin 20480 -> 0 bytes im/cgi-bin/.gallery.cgi.swp | Bin 36864 -> 0 bytes im/cgi-bin/.gallery.cgi.un~ | Bin 59038 -> 0 bytes im/cgi-bin/.imditherconf.cgi.swo | Bin 12288 -> 0 bytes im/cgi-bin/.imditherconf.cgi.swp | Bin 12288 -> 0 bytes im/cgi-bin/.imditherconf.cgi.un~ | Bin 51229 -> 0 bytes im/cgi-bin/.queryTest.cgi.un~ | Bin 7485 -> 0 bytes im/cgi-bin/.test.cgi.un~ | Bin 519 -> 0 bytes im/cgi-bin/1.png | Bin 2482 -> 0 bytes im/cgi-bin/db.py | 29 --- im/cgi-bin/db.pyc | Bin 1515 -> 0 bytes im/cgi-bin/downloader.py | 114 ---------- im/cgi-bin/downloader.pyc | Bin 2923 -> 0 bytes im/cgi-bin/gallery.cgi | 474 --------------------------------------- im/cgi-bin/imdither.cgi | 145 ------------ im/cgi-bin/imditherconf.cgi | 23 -- im/cgi-bin/queryTest.cgi | 9 - im/cgi-bin/test.cgi | 49 ---- 18 files changed, 843 deletions(-) delete mode 100644 im/cgi-bin/.gallery.cgi.swo delete mode 100644 im/cgi-bin/.gallery.cgi.swp delete mode 100755 im/cgi-bin/.gallery.cgi.un~ delete mode 100644 im/cgi-bin/.imditherconf.cgi.swo delete mode 100644 im/cgi-bin/.imditherconf.cgi.swp delete mode 100755 im/cgi-bin/.imditherconf.cgi.un~ delete mode 100755 im/cgi-bin/.queryTest.cgi.un~ delete mode 100755 im/cgi-bin/.test.cgi.un~ delete mode 100755 im/cgi-bin/1.png delete mode 100755 im/cgi-bin/db.py delete mode 100755 im/cgi-bin/db.pyc delete mode 100755 im/cgi-bin/downloader.py delete mode 100755 im/cgi-bin/downloader.pyc delete mode 100755 im/cgi-bin/gallery.cgi delete mode 100755 im/cgi-bin/imdither.cgi delete mode 100755 im/cgi-bin/imditherconf.cgi delete mode 100755 im/cgi-bin/queryTest.cgi delete mode 100755 im/cgi-bin/test.cgi (limited to 'im/cgi-bin') diff --git a/im/cgi-bin/.gallery.cgi.swo b/im/cgi-bin/.gallery.cgi.swo deleted file mode 100644 index 8e49f67..0000000 Binary files a/im/cgi-bin/.gallery.cgi.swo and /dev/null differ diff --git a/im/cgi-bin/.gallery.cgi.swp b/im/cgi-bin/.gallery.cgi.swp deleted file mode 100644 index f1e8117..0000000 Binary files a/im/cgi-bin/.gallery.cgi.swp and /dev/null differ diff --git a/im/cgi-bin/.gallery.cgi.un~ b/im/cgi-bin/.gallery.cgi.un~ deleted file mode 100755 index 0720bde..0000000 Binary files a/im/cgi-bin/.gallery.cgi.un~ and /dev/null differ diff --git a/im/cgi-bin/.imditherconf.cgi.swo b/im/cgi-bin/.imditherconf.cgi.swo deleted file mode 100644 index 1bbf2e2..0000000 Binary files a/im/cgi-bin/.imditherconf.cgi.swo and /dev/null differ diff --git a/im/cgi-bin/.imditherconf.cgi.swp b/im/cgi-bin/.imditherconf.cgi.swp deleted file mode 100644 index 7de91b5..0000000 Binary files a/im/cgi-bin/.imditherconf.cgi.swp and /dev/null differ diff --git a/im/cgi-bin/.imditherconf.cgi.un~ b/im/cgi-bin/.imditherconf.cgi.un~ deleted file mode 100755 index bef4dd6..0000000 Binary files a/im/cgi-bin/.imditherconf.cgi.un~ and /dev/null differ diff --git a/im/cgi-bin/.queryTest.cgi.un~ b/im/cgi-bin/.queryTest.cgi.un~ deleted file mode 100755 index 31f6494..0000000 Binary files a/im/cgi-bin/.queryTest.cgi.un~ and /dev/null differ diff --git a/im/cgi-bin/.test.cgi.un~ b/im/cgi-bin/.test.cgi.un~ deleted file mode 100755 index 769e9af..0000000 Binary files a/im/cgi-bin/.test.cgi.un~ and /dev/null differ diff --git a/im/cgi-bin/1.png b/im/cgi-bin/1.png deleted file mode 100755 index e98ec53..0000000 Binary files a/im/cgi-bin/1.png and /dev/null differ diff --git a/im/cgi-bin/db.py b/im/cgi-bin/db.py deleted file mode 100755 index 4da7b83..0000000 --- a/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/im/cgi-bin/db.pyc b/im/cgi-bin/db.pyc deleted file mode 100755 index 6347826..0000000 Binary files a/im/cgi-bin/db.pyc and /dev/null differ diff --git a/im/cgi-bin/downloader.py b/im/cgi-bin/downloader.py deleted file mode 100755 index 7083b11..0000000 --- a/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/im/cgi-bin/downloader.pyc b/im/cgi-bin/downloader.pyc deleted file mode 100755 index 91ba5b0..0000000 Binary files a/im/cgi-bin/downloader.pyc and /dev/null differ diff --git a/im/cgi-bin/gallery.cgi b/im/cgi-bin/gallery.cgi deleted file mode 100755 index 0f762eb..0000000 --- a/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/im/cgi-bin/imdither.cgi b/im/cgi-bin/imdither.cgi deleted file mode 100755 index 29837ed..0000000 --- a/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/im/cgi-bin/imditherconf.cgi b/im/cgi-bin/imditherconf.cgi deleted file mode 100755 index 8e7b7f2..0000000 --- a/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/im/cgi-bin/queryTest.cgi b/im/cgi-bin/queryTest.cgi deleted file mode 100755 index 5e6d573..0000000 --- a/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/im/cgi-bin/test.cgi b/im/cgi-bin/test.cgi deleted file mode 100755 index 1159090..0000000 --- a/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); -- cgit v1.2.3-70-g09d2