#!/usr/bin/perl -w ################## # # Word Splat! # # Knocked together by Dave Pattern # If you spot any bugs, please let me know! # ############# # # version 1.00 - last updated 17/Feb/2006 # ######### # # (cc) 2006 # # http://creativecommons.org/licenses/by-nc-sa/2.5/ # ##### use strict; srand( ); use CGI; use CGI::Carp qw(fatalsToBrowser); my $cgi = new CGI; my $max = int(rand(7))+5; my $odbcServer = 'HORIZON'; # ODBC server name my $odbcUser = 'xxxx'; # ODBC username my $odbcPass = 'yyyy'; # ODBC password use DBI; my $dbhH = DBI->connect('dbi:ODBC:'.$odbcServer, $odbcUser, $odbcPass, { RaiseError => 1 }); print $cgi->header( ); print qq( $max books splatted for you viewing pleasure! \n); my $today = int( time / ( 60 * 60 * 24 ) ); $today--; my $cnt = 1; my $sthH = $dbhH->prepare( ' set rowcount 20' ); $sthH->execute( ); my $sthH = $dbhH->prepare( " select t.processed from circ_tran c, title t, item i where cko_date >= $today and i.item# = c.item# and i.bib# = t.bib# order by cko_date desc, cko_time desc " ); $sthH->execute( ); while ( my @rowH = $sthH->fetchrow_array ) { if( $cnt > $max ) { last } $cnt++; my @w = split(/ /, lc( $rowH[0] )); foreach my $w ( @w ) { my $top = int(rand(450))+75; my $left = int(rand(400))+100; my $blue = sprintf("%X", (int(rand(255)))); my $red = sprintf("%X", (int(rand(255)))); my $green = sprintf("%X", (int(rand(255)))); my $col = '#'.substr("00$red",-2).substr("00$green",-2).substr("00$blue",-2); my $fontSize = int(rand(60))+5; my $z = ($max+1) - $cnt; my $fontItalic = ''; my $fontBold = ''; if( rand(1) > .5 ) { $fontBold = ' font-weight: bold;'; } if( rand(1) > .5 ) { $fontItalic = ' font-style: italic;'; } my $font = 'Verdana'; my $rand = int(rand(120)); if( $rand > 100 ) { $font = 'Georgia' } elsif( $rand > 80 ) { $font = "'Courier New'" } elsif( $rand > 60 ) { $font = 'Arial' } elsif( $rand > 40 ) { $font = 'Tahoma' } elsif( $rand > 20 ) { $font = "'Times New Roman'" } my $pos = 'display: block; position: absolute; top: '.$top.'px; left: '.$left.'px;'; if( rand(20) > 18 ) { $pos = ''; $fontSize = 12; $fontBold = ' font-weight: bold;'; $fontItalic = ''; $col = '#000000'; $font = 'Verdana'; if(length($w) > 2 ) { $w = ucfirst($w) } } $fontSize .='px'; print qq($w\n); } } $dbhH->disconnect; print qq(\n\n);