SI520i

/usr/bin/perl w use strict use CGI use CGI::Carp qwfatalsToBrowser use GD use DBI if there is no text parameter, show the form, otherwise process and add to the db. ...............................................qqqqqqqqqqqqqqqqqqqqqqqqqqSSSSSSSSSSSSSSSSSSSSqqq qqqqqqqqqqqqqqqQQQQQQQQQQQQQQQUUUUUUUUTTTTTTT....qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq 1111111111111111111111111111111111111111111111111111177777777777777777777777qqqqqqqqqqqqqqqqqqqq 7777777777777777777777777777777777777777777777777qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq name:seth qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq professional interests:I write computer programs, these days for M PublishingZZZZZZZZZZZZZqqqq ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZxxxxxZZZZZZZZZZZZZZZZZZZZZZ ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZzzzzzzzzzzzzzzzzzzZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ111 software skills:I have a about 10 years of experience creating web applications. Ive used Photoshop, Flash, Illustrator, but its been a while. These days I write perl / php / javascriptjquery and so forth. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqZZZZZZZZZ ttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttKKttttttttttttttttttttttttttttKK ttttttttttttttttttttttttttttttttttttttttttttttttttKKttttttttttttttttttttttttttttKKtttttttttttttttttttttttt KKtttttttttttttttttttttttttttttKKttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttKK expectations: Id link to learn to make art that isnt so messy KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK this was created by the following program well, mostly which I wrote in 2004 GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGFFFFFFFFFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGFFFFFFFFFFFFGGGGGGGGGGGGGFFFFFFFFFFGGGGGGGGGGG ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX................................................................................ my dbh = DBIconnectdbi:mysql:serth:mysql.serth.org,username,password or die couldnt connnect to db: :nn my q = new CGI my debug = 0 get/set session info require session.pl my url = wtp.cgi my access = wtp.cgi my session = &session::testsessionq, url, access my modifier, image, readfile, colorhash, totalcount, height, width, invert, writechars, brightness, totalcolor, title, size the characters we can acknowledge my @letters = a .. z, , A .. Z, 0 .. 9, . make higher for bigger rectangles, 1 = 1 pixel if qparammodifier { modifier = qparammodifier modifier = 100 } else { modifier = 10 } my text = qparamtext if defined text { &showformq } else { text = substrtext, 0, 400 text =~ s/|||||||||||//g first we need to see if theyve made too many images today "aq invert = true if defined qparaminvert writechars = true if defined qparamwritechars dont even try to write text into a 1 pixel space undef writechars if modifier == 1 readfile = &createreadfile readfile = readfile..png totalcount = &totalcount@letters, text die You entered 3 or less characters or did something weird. sorry.n if totalcount 4 if qparamlayout =~ /vertical/ { height, width = &dimensionstotalcount } else { width, height = &dimensionstotalcount } if qparambrightness { brightness = qparambrightness } else { brightness = 85 default color offset value } colorhash, image = &buildhashheight, width, @letters, modifier, invert, brightness if debug { for keys %colorhash { print key: value: colorhash{} } } size = &writeimage, readfile, width, colorhash, text, modifier, writechars totalcolor = 64 Maybe someday we can change this to add more, but for now leave it. if qparamtitle { title = qparamtitle title =~ s/|||||||||| //g } else { title = readfile } &logq, readfile, text, invert, modifier, brightness, totalcolor, title, size, height, width, session forward them to the gallery why doesnt this work right print Location: ./gallery.cginn print qheader print qstarthtmlFinished print a href=gallery.cgigallery/a print /body/html print qredirectgallery.cgi } sub log { the image has been made. insert a new row into the db try to get their session, if not its ok. my q = shift my filename = shift my text = shift my invert = shift my modifer = shift my brightness = shift my totalcolor = shift my title = shift my size = shift my height = shift my width = shift my session = shift height and wdith may be reversed, but its okay. were really just using that to see if the image is a good size to be displayed in the gallery script. if session { session = nosession } my ip = ENV{REMOTEADDR} my date = time if defined invert { invert = y } else { invert = n } my qstr = insert into wtp filename, text, date, ip, type, invert, session, modifier, brightness, totalcolor, title, size, height, width values filename, text, date, ip, user, invert, session, modifier, brightness, totalcolor, title, size, height, width my sth = dbhdoqstr or die dbherrstr } sub quota { this sub tests to see if the user has already created too many images today. i think well limit it to 5 for now. my q = shift my now = time my yesterday = now 64800 64800 is the number of seconds in a day its all in the sql my ip = ENV{REMOTEADDR} my qstr = select ip, date from wtp where ip = ip and date now and date yesterday my sth = dbhprepareqstr sthexecute or die dbherrstr my rows = sthrows if rows = 20 { 20 for testing... 5 normally this user made 5 or more images in a 24 hour period, so thye have to quit. print qheader print qstarthtml print Sorry. It seems that there have been at least 5 images already made from your address, ip, in a 24 hour period. Please wait a while then come back. die } } sub createreadfile { i got this script from a post on slashdot i know, i know i added the timestamp part it just creates what will be the name of the file, the date + an 8 digit random use Time::localtime my t = localtime my year = tyear+1900 my month = tmon+1 my day = tmday my @chars = A .. Z, a .. z, 0 .. 9 my filename = join, @chars[ map { rand @chars } 1 .. 8 ] filename = year.month.day..filename return filename } sub buildhash { build a hash of letters=GD colorspace colors my height = shift my width = shift my letters = shift my modifier = shift my invert = shift my bright = shift create the image my image = new GD::Image width*modifier, height*modifier or die couldnt create image n each anon array in this hash represents the RBG values in an individual color. Later, we mutliply each of these by a number to get the actual values. For instance, [1,2,3] multiplied by 85 would give an RGB of [85,170,255]. You could also do a multiplier of say 20 to get [20,40,60]. This would result in a much darker final image then if you use 85. my @numbers = [0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 1, 0], [0, 1, 1], [0, 1, 2], [0, 1, 3], [0, 2, 0], [0, 2, 1], [0, 2, 2], [0, 2, 3], [0, 3, 0], [0, 3, 1], [0, 3, 2], [0, 3, 3], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 0, 3], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 2, 0], [1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 3, 0], [1, 3, 1], [1, 3, 2], [1, 3, 3], [2, 0, 0], [2, 0, 1], [2, 0, 2], [2, 0, 3], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 1, 3], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 3], [2, 3, 0], [2, 3, 1], [2, 3, 2], [2, 3, 3], [3, 0, 0], [3, 0, 1], [3, 0, 2], [3, 0, 3], [3, 1, 0], [3, 1, 1], [3, 1, 2], [3, 1, 3], [3, 2, 0], [3, 2, 1], [3, 2, 2], [3, 2, 3], [3, 3, 0], [3, 3, 1], [3, 3, 2], [3, 3, 3] my @colors create the GD color table if debug { print the numbers: } for @numbers { if debug { print [0], [1], [2] } multiply by 85 gives us values 0, 85, 170 and 255 for 0, 1, 2, and 3. a multiplier of say 63 makes the whole image a little darker... The user can set this within reason, it is the brightness value my color = imagecolorAllocate [0]*bright, [1]*bright, [2]*bright push @colors, color } if debug { print br the colors: @colorsbr } reverse the letters array if so desired if defined invert { @letters = reverse@letters } my %colorhash my i=0 build the letters=GD colorspace hash for @letters { colorhash{} = colors[i] i++ } return%colorhash, image } sub write { my image = shift the GD image object my readfile = shift name of the file to be created my width = shift image width my colorhash = shift the hash of characters = GD colorspace color my text = shift the text to process my m = shift the size modifier my writechars = shift param to write the character inside the rectangle graphic the plan is to write row by row depending on the width of the image. When weve reached the width, do it carrage retrun style and start the next row. All this depends on the size modifier too. my pngfile = readfile my x1 = 0 my y1 = 0 my @characters = split //, text for my char @characters { if defined colorhash{char} { my x2 = x1+m my y2 = y1+m my color = colorhash{char} imagefilledRectanglex1, y1, x2, y2, color if debug { print color: color char: charbr } if defined writechars { this is white... i guess need to make another table that makes the letters a color just slightly different then the rectangle color... which means a whole other color table... my letter = imagecolorAllocate255, 255, 255 GD::Image::stringimage, gdTinyFont, x1, y1, char, letter } x1 = x1+m if x2 == width*m { first row is done, go to the next y1 = y1+m x1 = 0 } } } print/create the image pngfile = ../pngs/.pngfile open OUTFILE , pngfile binmode OUTFILE whatever print OUTFILE imagepng close OUTFILE if debug { print brpngfilebr } get the size for the database my bytes = s pngfile my size = bytes/1024 size = intsize return size } sub factory { figure out the dimensions of the image based on character count my input = shift my %factors foreach my digit 1 ... input { if input % digit { ignore the float } else { my x = input / digit if x == 1 || digit == 1 { skip the 1s, too skinny } else { factors{x} = digit } } } if the hash is empty, that means input is PRIME. Maybe subtract the last number a n or a . probably and run it through again if %factors { return 0, 0 } my @ordered foreach my this sort { a = b } keys %factors { push@ordered, this } if debug { print possible dimensions: @orderedbrn } get the middle key to get the values from the hash. they are the height and width we will use. Later, we can give the user a choice of which dimensions factors they want, but for now just pick the middle. my low, high = 0, ordered 1 my middle = int low+high/2 my midkey = ordered[middle] this actually fails if the image is a perfect square.... well never get a sqaure image, but I guess thats ok. This sub needs some work... return factors{midkey}, midkey } ................................................................................................................................................................................................................................ 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000