#!/usr/bin/perl require "BrunchingHTML.pl"; my setup_brunching_vars( "author" => "fs", "section" => "toys", "title" => "C.Y.B.O.R.G.", "s_title" => "cyborger", "revision" => 2, ); use CGI; my $q; my $acname; my $myname; my $originalname = ""; my $template; my $letters; my $length; my $length1; my $wordtype; my $letter; my $startletter; my $firstword; my $secondword; my $tempword; my $highscore; my $score; my $goodname; my $firstletter; my $fullname; my $output; my @name = (); my %words = (); my %score = (); my %done = (); my %wordtype = (); my @letters = (); $q = new CGI; $myname = $q->param('acronym'); $myname = uc($myname); $myname =~ s/[^A-Z]//g; $acname = $myname; $originalname = $myname; $acname =~ s/([A-Z])/$1\./g; &PrintOut("Names must be at least two letters long. Pretty strange from a guy calling himself \"L.\", but there you go.") if (length $myname < 2); &PrintOut("Names can't be more than eleven letters, so use a nickname. How about \"Tiger\"?") if (length $myname > 11); if (length $myname > 8) { $length1 = 5; $name[0] = substr $myname, 0, $length1; $name[1] = substr $myname, $length1; } else { $name[0] = $myname; } foreach $myname (@name) { $words{2} = ([ "TYPEADJ TYPENOUN", "PURPOSENOUN TYPENOUN" ]); $words{3} = ([ "TYPENOUN ORIGVERB PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN", "TYPEADJ PURPOSENOUN TYPENOUN", "PURPOSENOUN and PURPOSENOUN TYPENOUN", "PURPOSEADJ PURPOSENOUN TYPENOUN" ]); $words{4} = ([ "TYPENOUN ORIGVERB PURPOSENOUN and PURPOSENOUN", "TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN", "TYPEADJ TYPEADJ PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSEADJ PURPOSENOUN TYPENOUN", "PURPOSENOUN and PURPOSEADJ PURPOSENOUN TYPENOUN", "PURPOSEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", ]); $words{5} = ([ "TYPENOUN ORIGVERB PURPOSENOUN and PURPOSEADJ PURPOSENOUN", "TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN", "TYPEADJ TYPEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", "TYPEADJ TYPEADJ PURPOSEADJ PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSENOUN and PURPOSEADJ PURPOSENOUN TYPENOUN", "TYPEADJ PURPOSEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", ]); $words{6} = ([ "TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPEADJ PURPOSENOUN and PURPOSEADJ PURPOSENOUN TYPENOUN", "TYPEADJ TYPEADJ PURPOSEADJ PURPOSENOUN and PURPOSENOUN TYPENOUN", ]); $words{7} = ([ "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSENOUN and PURPOSEADJ PURPOSENOUN", "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSENOUN", ]); $words{8} = ([ "TYPEADJ TYPEADJ TYPENOUN ORIGVERB PURPOSEADJ PURPOSENOUN and PURPOSEADJ PURPOSENOUN", ]); $wordtype{TYPENOUN}{A} = "Android+"; $wordtype{TYPENOUN}{B} = "Being+"; $wordtype{TYPENOUN}{C} = "Construct+"; $wordtype{TYPENOUN}{D} = "Device"; $wordtype{TYPENOUN}{E} = "Entity"; $wordtype{TYPENOUN}{F} = "Facsimile-"; $wordtype{TYPENOUN}{G} = "Guardian--"; $wordtype{TYPENOUN}{H} = "Humanoid"; $wordtype{TYPENOUN}{I} = "Individual"; $wordtype{TYPENOUN}{J} = "Judge--"; $wordtype{TYPENOUN}{K} = "Knight-"; $wordtype{TYPENOUN}{L} = "Lifeform+"; $wordtype{TYPENOUN}{M} = "Machine+"; $wordtype{TYPENOUN}{N} = "Neohuman--"; $wordtype{TYPENOUN}{O} = "Organism"; $wordtype{TYPENOUN}{P} = "Person"; $wordtype{TYPENOUN}{Q} = "Quadruplet--"; $wordtype{TYPENOUN}{R} = "Replicant"; $wordtype{TYPENOUN}{S} = "Soldier-"; $wordtype{TYPENOUN}{T} = "Technician-"; $wordtype{TYPENOUN}{U} = "Unit+"; $wordtype{TYPENOUN}{V} = "Variant-"; $wordtype{TYPENOUN}{W} = "Worker"; $wordtype{TYPENOUN}{X} = "Xenomorph"; $wordtype{TYPENOUN}{Y} = "Youth--"; $wordtype{TYPENOUN}{Z} = "Zombie-"; $wordtype{TYPEADJ}{A} = "Artificial+/Advanced"; $wordtype{TYPEADJ}{B} = "Biomechanical+/Bionic"; $wordtype{TYPEADJ}{C} = "Cybernetic+/Clockwork"; $wordtype{TYPEADJ}{D} = "Digital/Deadly"; $wordtype{TYPEADJ}{E} = "Electronic+/Engineered"; $wordtype{TYPEADJ}{F} = "Functional/Fusion-"; $wordtype{TYPEADJ}{G} = "General-/Genius--"; $wordtype{TYPEADJ}{H} = "Hydraulic-/Handcrafted-"; $wordtype{TYPEADJ}{I} = "Intelligent/Inhuman"; $wordtype{TYPEADJ}{J} = "Journeying-/Judicious--"; $wordtype{TYPEADJ}{K} = "Kinetic-/Knowledgable-"; $wordtype{TYPEADJ}{L} = "Lifelike/Lethal"; $wordtype{TYPEADJ}{M} = "Mechanical+/Model-"; $wordtype{TYPEADJ}{N} = "Networked/Nuclear"; $wordtype{TYPEADJ}{O} = "Obedient/Organic"; $wordtype{TYPEADJ}{P} = "Positronic/Patented"; $wordtype{TYPEADJ}{Q} = "Quantum/Quinessential"; $wordtype{TYPEADJ}{R} = "Robotic+/Radioactive"; $wordtype{TYPEADJ}{S} = "Synthetic+/Simulated"; $wordtype{TYPEADJ}{T} = "Transforming-/Thermodynamic--"; $wordtype{TYPEADJ}{U} = "Upgraded/Unique"; $wordtype{TYPEADJ}{V} = "Vigilant/Valuable-"; $wordtype{TYPEADJ}{W} = "Wireless/Watchful-"; $wordtype{TYPEADJ}{X} = "eXperimental+/eXtraterrestrial"; $wordtype{TYPEADJ}{Y} = "Ytterbium-/Youthful--"; $wordtype{TYPEADJ}{Z} = "Zeta--/Zircon--"; $wordtype{PURPOSENOUN}{A} = "Assassination/Analysis"; $wordtype{PURPOSENOUN}{B} = "Battle+/Botany-"; $wordtype{PURPOSENOUN}{C} = "Calculation/Capture-"; $wordtype{PURPOSENOUN}{D} = "Destruction/Deduction"; $wordtype{PURPOSENOUN}{E} = "Exploration+/Education"; $wordtype{PURPOSENOUN}{F} = "Fighting/Fornication-"; $wordtype{PURPOSENOUN}{G} = "Gratification-/Geophysics-"; $wordtype{PURPOSENOUN}{H} = "Harm-/Hunting-"; $wordtype{PURPOSENOUN}{I} = "Infiltration/Instruction-"; $wordtype{PURPOSENOUN}{J} = "Judo-/Jobs--"; $wordtype{PURPOSENOUN}{K} = "Killing+/Kindness--"; $wordtype{PURPOSENOUN}{L} = "Learning-/Law-"; $wordtype{PURPOSENOUN}{M} = "Mathematics/Murder"; $wordtype{PURPOSENOUN}{N} = "Nullification--/Negotiation-"; $wordtype{PURPOSENOUN}{O} = "Observation/Obliteration-"; $wordtype{PURPOSENOUN}{P} = "Peacekeeping/Patrol--"; $wordtype{PURPOSENOUN}{Q} = "Questioning-/Quantification-"; $wordtype{PURPOSENOUN}{R} = "Repair/Reasoning"; $wordtype{PURPOSENOUN}{S} = "Sabotage/Surveillance-"; $wordtype{PURPOSENOUN}{T} = "Troubleshooting/Tactics-"; $wordtype{PURPOSENOUN}{U} = "Utility-/Uplink-"; $wordtype{PURPOSENOUN}{V} = "Violence+/Vengance"; $wordtype{PURPOSENOUN}{W} = "Warfare/Wrecking--"; $wordtype{PURPOSENOUN}{X} = "Xenocide/eXecution"; $wordtype{PURPOSENOUN}{Y} = "Yelling-/Yardwork--"; $wordtype{PURPOSENOUN}{Z} = "Zoology-/Zymurgy--"; $wordtype{PURPOSEADJ}{A} = "Accurate"; $wordtype{PURPOSEADJ}{B} = "Basic"; $wordtype{PURPOSEADJ}{C} = "Ceaseless"; $wordtype{PURPOSEADJ}{D} = "Dangerous"; $wordtype{PURPOSEADJ}{E} = "Efficient+"; $wordtype{PURPOSEADJ}{F} = "Forbidden"; $wordtype{PURPOSEADJ}{G} = "Galactic"; $wordtype{PURPOSEADJ}{H} = "Hazardous"; $wordtype{PURPOSEADJ}{I} = "Intensive-"; $wordtype{PURPOSEADJ}{J} = "Justified-"; $wordtype{PURPOSEADJ}{K} = "Kamikaze-"; $wordtype{PURPOSEADJ}{L} = "Logical"; $wordtype{PURPOSEADJ}{M} = "Mandatory"; $wordtype{PURPOSEADJ}{N} = "Nocturnal-"; $wordtype{PURPOSEADJ}{O} = "Online"; $wordtype{PURPOSEADJ}{P} = "Potential"; $wordtype{PURPOSEADJ}{Q} = "Quick"; $wordtype{PURPOSEADJ}{R} = "Rational-"; $wordtype{PURPOSEADJ}{S} = "Scientific"; $wordtype{PURPOSEADJ}{T} = "Terran"; $wordtype{PURPOSEADJ}{U} = "Ultimate"; $wordtype{PURPOSEADJ}{V} = "Vigilant"; $wordtype{PURPOSEADJ}{W} = "Worldwide"; $wordtype{PURPOSEADJ}{X} = "eXpert"; $wordtype{PURPOSEADJ}{Y} = "Your--"; $wordtype{PURPOSEADJ}{Z} = "Zealous"; $wordtype{ORIGVERB}{A} = "Assembled for"; $wordtype{ORIGVERB}{B} = "Built for"; $wordtype{ORIGVERB}{C} = "Calibrated for"; $wordtype{ORIGVERB}{D} = "Designed for+"; $wordtype{ORIGVERB}{E} = "Engineered for+"; $wordtype{ORIGVERB}{F} = "Fabricated for"; $wordtype{ORIGVERB}{G} = "Generated for"; $wordtype{ORIGVERB}{H} = "Hardwired for"; $wordtype{ORIGVERB}{I} = "Intended for"; $wordtype{ORIGVERB}{J} = "Justified for--"; $wordtype{ORIGVERB}{K} = "Keen on"; $wordtype{ORIGVERB}{L} = "Limited to"; $wordtype{ORIGVERB}{M} = "Manufactured for"; $wordtype{ORIGVERB}{N} = "Normally for--"; $wordtype{ORIGVERB}{O} = "Optimized for+"; $wordtype{ORIGVERB}{P} = "Programmed for+"; $wordtype{ORIGVERB}{Q} = "Qualified for"; $wordtype{ORIGVERB}{R} = "Responsible for"; $wordtype{ORIGVERB}{S} = "Skilled in"; $wordtype{ORIGVERB}{T} = "Trained for"; $wordtype{ORIGVERB}{U} = "Used for"; $wordtype{ORIGVERB}{V} = "Viable for"; $wordtype{ORIGVERB}{W} = "Wanting--"; $wordtype{ORIGVERB}{X} = "eXperienced in"; $wordtype{ORIGVERB}{Y} = "Yearning for-"; $wordtype{ORIGVERB}{Z} = "Zoned for--"; #### Main Part $length = length $myname; @letters = split(//,$myname); $highscore = -99; $goodname = ""; foreach $template (@{$words{$length}}) { $score = 0; %done = (); foreach $letter (@letters) { if ($template =~ /(\b[A-Z]+\b)/) { $wordtype = $1; $tempword = $wordtype{$wordtype}{$letter}; if ($tempword =~ /(.*)\/(.*)/) { $firstword = $1; $secondword = $2; if (! $done{$firstword}) { $tempword = $firstword; $done{$firstword}++; } else { $tempword = $secondword; } } if ($fullname =~ /\b$tempword\b/) { $score--; } if ($tempword =~ s/\+\+$//) { $score += 2; } elsif ($tempword =~ s/\+$//) { $score++; } elsif ($tempword =~ s/\-\-$//) { $score -= 2; } elsif ($tempword =~ s/\-$//) { $score--; } $template =~ s/(\b[A-Z]+\b)/$tempword/; } } $score{$template} = $score; $score -= 100 if $template eq $fullname; if ($score > $highscore) { $goodname = $template; $highscore = $score; } } if ($fullname) { $fullname .= "/$goodname"; } else { $fullname = $goodname; } } $firstletter = substr($originalname,0,1); if (-e "../cybimages/$firstletter/cyb-$originalname.jpg") { `touch ../cybimages/$firstletter/cyb-$originalname.jpg`; } else { &StoreJpeg($originalname,$fullname); } $output .= "$acname: $fullname"; open(LOG,">>cyborger-log.txt"); print LOG "$output\n"; close(LOG); &PrintOut("
$output
Feel free to download the graphic and stick it where people will see it. Make sure you put it on your own server, though, because the local version will eventually be wiped.
$output
EOFILE } print &brunching_footer; exit; } sub StoreJpeg { use GD; use GD::Text; my $acronym = shift; my $fullname = shift; my $ttf = "/home/editor/public_html/cgi/impact.ttf"; my $jpg; my $word; my @words; my $maxlength; my $leftmargin; my $topmargin; my $img; my $black; my $white; my $red; my $leftmost; my $w; my $h; my $printx; my $printy; $jpg = "../images/50srobot-web.jpg"; $fullname =~ s#/#/ #; $fullname =~ s/Troubleshooting and/Troubleshooting &/; @words = split(/ (?=[A-Z])/,$fullname); for $word (@words) { $maxlength = length $word if length $word > $maxlength; } $leftmargin = 100 + ((17 - $maxlength) * 3); $img = GD::Image->trueColor(1); open(JPG,"$jpg") || die "Can't open $jpg: $!\n"; $img = newFromJpeg GD::Image(JPG); close(JPG); $black = $img->colorAllocate(40,40,40); $grey = $img->colorAllocate(125,125,125); $white = $img->colorAllocate(255,255,255); $red = $img->colorAllocate(255,75,75); ($w,$h) = (gdLargeFont->width,gdLargeFont->height); #$h-- if @words == 11; $h = $h + 3 if @words <= 5; $topmargin = ((90 + $h - 2) - ((@words * $h) / 2)); $printx = $leftmargin; $printy = $topmargin; foreach $word (@words) { $word = uc($word); $word =~ s/ FOR$/ for/; $word =~ s/ AND$/ and/; $word =~ s/ ON$/ on/; $word =~ s/ IN$/ in/; $word =~ s/ TO$/ to/; $startletter = $word; $startletter =~ s/(.).*/$1/; #$img->string(gdLargeFont,$printx + 1,$printy + 1,$word,$black); #$img->string(gdLargeFont,$printx + 1,$printy,$word,$grey); #$img->string(gdLargeFont,$printx,$printy,$word,$grey); #$img->stringFT($red,$ttf,4,$printx,$printy,$word); GD::Image::stringFT($img, $grey, $ttf, 12, 0, $printx, $printy, $word); GD::Image::stringFT($img, $black, $ttf, 12, 0, $printx, $printy, $startletter); #$img->string(gdLargeFont,$printx + 1,$printy,$startletter,$black); #$img->string(gdLargeFont,$printx,$printy,$startletter,$black); $printy += $h; } $leftmost = 15 + ((11 - length $originalname) * 3.5); #$img->string(gdLargeFont,$leftmost,110,$originalname,$red); my $firstletter = substr($acronym,0,1); open(JPG,">../cybimages/$firstletter/cyb-$acronym.jpg") or return; print JPG $img->jpeg(100); close JPG; return 1; }