#!/usr/bin/perl use DBI; &parseForm; &loadCookie; my $docroot = "$ENV{DOCUMENT_ROOT}"; my $hostname = "sqlc0e.megasqlservers.com"; my $db = "focl_friendsofclearlake_com"; my $user = "dbm.friendsofclearlake.com"; my $password = "tslv01"; #pass for ssh is laurie my $senQuery = "SELECT * FROM senator ORDER BY lname"; my $repQuery = "SELECT * FROM representative ORDER BY lname"; my $dsn = "DBI:mysql:database=$db;host=$hostname"; $dbh = DBI->connect($dsn, $user, $password); if ($dbh) { print "Content-type: text/html\n\n"; &pageHeader; &mainDisplay; &pageFooter; $dbh->disconnect(); exit; } else { print "Content-type: text/html\n\n"; $legislator = 0; &pageHeader; print "

Sorry,

This section is under maintenance, please try again later.

"; &pageFooter; exit; } sub mainDisplay { $moreInfo = qq~

You can also find out more information about your legislators at www.legis.state.ia.us.

~; if ($input{wd} eq "sen") { $query = qq~ SELECT * FROM senator ORDER BY home_county ASC, lname ASC ~; $bgcolor = 0; $sth = $dbh->prepare_cached($query); $sth->execute(); while (my $senator = $sth->fetchrow_hashref()) { if (!$bgcolor) { $bg = qq~ bgcolor="#eeeeee"~; $bgcolor = 1; } else { $bg = qq~ bgcolor="#ffffff"~; $bgcolor = 0; } $senList .= qq~ $senator->{lname}, $senator->{fname} $senator->{home_county} $senator->{district} $senator->{party} ~; } $sth->finish; print qq~ $moreInfo

List of Senators:
The list below is sorted by Senators\' Home County and Last Name.

$senList
Last Name, First Name Home County District Party

Back to top

 

~; } elsif ($input{wd} eq "rep") { $query = qq~ SELECT * FROM representative ORDER BY home_county ASC, lname ASC ~; $bgcolor = 0; $sth = $dbh->prepare_cached($query); $sth->execute(); while (my $senator = $sth->fetchrow_hashref()) { if (!$bgcolor) { $bg = qq~ bgcolor="#eeeeee"~; $bgcolor = 1; } else { $bg = qq~ bgcolor="#ffffff"~; $bgcolor = 0; } $senList .= qq~ $senator->{lname}, $senator->{fname} $senator->{home_county} $senator->{district} $senator->{party} ~; } $sth->finish; print qq~ $moreInfo

List of Representatives:
The list below is sorted by Representatives\' Home County and Last Name.

$senList
Last Name, First Name Home County District Party

Back to top

 

~; } else { print qq~

You can view the list of all Senators or Representatives by clicking on the corresponding link below:

$moreInfo ~; } } sub pageHeader { if ($legislator) { $atLeg = qq~class="active"~; $atForm = "";} if (!$legislator) { $atLeg = qq~~; $atForm = qq~class="active"~; } print qq~ Registration Form - How can I help? - Friends of Clear Lake

Legislators

~; } sub pageFooter { print qq~
~; } sub loadCookie { foreach (split(/; /,$ENV{'HTTP_COOKIE'})) { $_ =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($key,$value) = split(/=/); $cookies{$key} = $value; } if ($cookies{userid} && $cookies{username}) { $cuid = "$cookies{userid}"; $cuname = "$cookies{username}"; $loggedIn = 1; } else { $cuid = ""; $cuname = ""; $loggedIn = 0; } } sub parseForm { if ($ENV{'REQUEST_METHOD'} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; } else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $input{$name} = $value; } } exit;