"his/her name and title", "Person2" => "his/her name and title", "Person23" => "his/her name and title" ); function checkvoter($db, $addr) { $cursor = Ora_Open($db); if(!$cursor) die( "The Oracle refuses to speak to you" ); $sql_string = "select * from USERADDR where ID=1"; $try = Ora_Parse($cursor, $sql_string); if(!$try) die("Your programmer stuffed up the composition of the sql query + $sql_string"); $result = Ora_Exec($cursor); $last = ""; if( Ora_Fetch( $cursor) ) { $last = ora_getColumn($cursor, 0); } Ora_close($cursor); if($last == $addr) { print <<Script voter?

No more votes from you for a little while. Thank you.

NOVOTE; sleep(6); exit; } $cursor = Ora_Open($db); if(!$cursor) die( "The Oracle refuses to speak to you" ); $sql_string = "update USERADDR set ADDR='$addr' where ID=1"; $try = Ora_Parse($cursor, $sql_string); if(!$try) die("Your programmer stuffed up the composition of the sql query + $sql_string"); $result = Ora_Exec($cursor); if (!$result) die( "Error when running query $sqlstring " ); } function connect() { $user = "HSimpson"; $password = "Duh"; $db = Ora_Logon( $user, $password ); if (!$db) die( "The Oracle refuses to admit you" ); // switch on auto-commit mode Ora_CommitOn($db); return $db; } function update($person, $db) { $cursor = Ora_Open($db); if(!$cursor) die( "The Oracle refuses to speak to you" ); $sql_string = "update BigBrother set Votes=Votes+1 where Name='$person'"; $try = Ora_Parse($cursor, $sql_string); if(!$try) die("Your programmer stuffed up the composition of the sql query + $sql_string"); $result = Ora_Exec($cursor); if (!$result) die( "Error when running query $sqlstring " ); Ora_close($cursor); } function getdata($db) { $cursor = Ora_Open($db); if(!$cursor) die( "The Oracle refuses to speak to you" ); $sqlstring= "select * from BigBrother"; $try = Ora_Parse($cursor, $sqlstring); if(!$try) die("Your programmer stuffed up the composition of the sql query"); $result = Ora_Exec($cursor); if (!$result) die( "Error when running query $sqlstring " ); $data = array(); while( Ora_Fetch( $cursor) ) { $Name = ora_getColumn($cursor, 0); $Votes = ora_getColumn($cursor, 1); $data[$Name] = $Votes; } Ora_close($cursor); return $data; } function makeImage($data) { global $names; $num = count($data); $total = 0; $max = 0; foreach($data as $key=>$value) { $total += $value; $max = ($value > $max) ? $value : $max; } print "

Total votes cast $total

"; $imagewidth = 800; $imageheight = 20*$num; $w = (integer) $imagewidth * 0.9; $h = (integer) $imageheight * 0.9; $tempfile = "/tmp/afile" . $total . ".png"; print "

"; $image = ImageCreate ($imagewidth, $imageheight); $white = ImageColorAllocate ($image, 255, 255, 255); $text_color = ImageColorAllocate ($image, 233, 0 , 233); $fill_color = ImageColorAllocate($image, 255, 50, 50); $black = ImageColorAllocate($image,0,0,0); ImageLine($image, 0, 0, 0, $imageheight, $black); ImageLine($image, 0, $imageheight-2, $imagewdith-1, $imageheight-2, $black); ImageLine($image, 0, 0, $imagewidth, 0, $black); ImageLine($image, $imagewidth-1, 0, $imagewidth-1, $imageheight, $black); $x1 = 5; $x2 = 200; $y = 18; if($max<50) $max = 50; foreach($data as $key=>$value) { $fullname = $names[$key]; ImageString ($image, 2, $x1, $y-10, $fullname, $text_color); if($value==0) { ImageString($image, 2, $x2, $y-10, "Who?", $text_color); } else { $scaled = ($value*600)/$max; $scaled = (integer) $scaled; imagefilledrectangle($image, $x2, $y-12, $x2+$scaled, $y+2, $fill_color); } ImageLine($image, 0, $y+4, $imagewidth, $y+4, $black); $y+=20; } imagepng($image,$tempfile); imagedestroy($image); } setOracleEnvironment(); $db = connect(); $addr = $HTTP_SERVER_VARS["REMOTE_ADDR"]; checkvoter($db, $addr); print <<Another vote

Vote him/her out

Every vote counts! Vote early! Vote often! Get your friends to vote! WELCOME; foreach($HTTP_POST_VARS as $key=>$val) { if(preg_match("/_[xy]$/", $key)) { $temp = explode("_", $key); $identifier = $temp[0]; } else $identifier = $key; } if(isset($identifier)) update($identifier, $db); $voterecord = getdata($db); Ora_Logoff($db); makeImage($voterecord); print "

Your vote may make the difference

"; print "

Vote again soon!" ?>