#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser);
use DBI;
### The full path (NOT URL) to the wsr.conf file
$Conf = "/home/blurbler/docs/cgi-bin/wsr.conf";
### The full path (NOT URL) to the wsr-lib.pl file
$Library = "/home/blurbler/docs/cgi-bin/wsr-lib.pl";
##############################################################
# Prepare Page For Output #
##############################################################
require $Conf;
require $Library;
$template_file = "index.html";
#$ID = $ENV{'QUERY_STRING'};
$ID = $ENV{'PATH_INFO'};
$ID =~ s/\///;
$ID =~ s/select//isg;
$ID =~ s/sleep//isg;
$ID =~ s/from//isg;
print "Content-type: text/html\n\n";
print "ID $ID
\n";
if (!$ID) {
$ID = "$StartID";
}
##############################################################
# Open Database/Setup Database Variables #
##############################################################
$Newdata = join (', ', @UserFields);
$dbh = &connectToDB();
$sth = $dbh->prepare("SELECT $Newdata FROM $tablename WHERE USERNAME = '$ID'");
$sth->execute;
@MemberInfo = $sth->fetchrow;
$sth->finish;
#$sth = $dbh->prepare("SELECT count(*) FROM $tablename");
#$sth->execute;
#$count = $sth->fetchrow;
#$sth->finish;
#$sth = $dbh->prepare("SELECT id, phrase FROM rotatingphrases WHERE showed = 'N' AND status = 'Active' ORDER BY id LIMIT 1");
#$sth->execute;
#($defaultphrase, $selectedphrase) = $sth->fetchrow;
#$sth->finish;
#$sth = $dbh->do("UPDATE rotatingphrases SET showed = 'Y', views = views + '1' WHERE id = '$defaultphrase'");
#if (!$defaultphrase){
#$sth = $dbh->do("UPDATE rotatingphrases SET showed = 'N'");
#$sth = $dbh->prepare("SELECT id, phrase FROM rotatingphrases WHERE showed = 'N' AND status = 'Active' ORDER BY id LIMIT 1");
#$sth->execute;
#($defaultphrase, $selectedphrase) = $sth->fetchrow;
#$sth->finish;
#$sth = $dbh->do("UPDATE rotatingphrases SET showed = 'Y', views = views + '1' WHERE id = '$defaultphrase'");
#}
&closeDBConnection();
#if (!$MemberInfo[0]) { &ErrorMainSite('User ' . $ID . ' has been cancelled by the member, or terminated.', $StartID); }
#if ($MemberInfo[7] ne "Yes") {
# &ErrorMainSite('Member\'s account has been deactivated. Please try again in a few days', $StartID);
#}
##############################################################
# Parse Template #
##############################################################
print "Content-type: text/html\n\n";
open (IN,$template_file) || &error("TMPL");
while () {
$script .= $_;
}
close(IN);
# Handle Environment Variables
$x=0;
foreach $name (@UserFields) {
$script =~ s/~$name~/$MemberInfo[$x]/sg;
$x++;
}
$script =~ s/~COUNT~/$count/sg;
$script =~ s/~SELECTEDPHRASE~/$selectedphrase/sg;
print "$script";
exit;
##############################################################
# Error Messages #
##############################################################
sub error {
my %ERR;
$ERR{"DATABASE"} = "An error occurred while accessing the database file. If this persists, pleast
contact the site administrator";
$ERR{"TMPL"} = "An error occurred while accessing the template file. If this persists, pleast contact
the site administrator";
my $emsg = $ERR{$_[0]};
if (!emsg) {
$emsg = "The script suffered an unknown error.";
}
print "\n";
print "Replicating Site Script Error
\n";
print "$emsg";
print "";
exit;
}