Gossamer Forum
Home : General : Perl Programming :

Please help me out

Quote Reply
Please help me out
Hello everyone,
I have downloaded a contest script, but the problem is that the script is a beta version and only supports veiwing and selecting a winner. It does not supports clearing database and deleting entries. Please any one out there can help me out. It would be of great help if any one can add this feature. I came here with a bright light. Please help me.Please please please!
Quote Reply
Re: Please help me out In reply to
First thing, is that we probably need to see where you got this contest script.

This is so we can take a look at it.

------------------
Robert Blackstone
Webmaster of Scato Search
www.scato.com
Quote Reply
Re: Please help me out In reply to
Thank you very much for replying to my post. I have downloaded the script from http://www.iqdesign.net/download.html. But the problem is that they have removed the contest script from thier download page. But i will paste all the script in this column.
The download contained 4 files. (1)iqcontest.cgi (2)contest_admin.cgi (3)data.db (4)config.pl. The following are the content of CONTEST_ADMIN.CGI------->>>>>

------------------
I was a game
Quote Reply
Re: Please help me out In reply to
This is the content of the config.pl file.
$version = '1.01 beta,';
################################################################
# Variables
#
# Change the variables below

# Enter the valid servers that may access this program
# this is for security purposes
@referers = ('www.iqdesign.net');

# Set this to the Web Site's Name
$web_site = 'IQ Design Contest Demo';

# Enter a valid email address of the Contest Administrator
$administrator = 'mlessar@iqdesign.net';

# Provide the location of sendmail
$mailprog = '/usr/lib/sendmail';

# Provide the path to the Main Database
$maindb = '/u/web/iqdesi/contest/data.db';

# URL to the index page
$index = 'http://www.iqdesign.net/iqcontest.html';

# Do not change
1;

------------------
I was a game
Quote Reply
Re: Please help me out In reply to
#!/usr/bin/perl

require '/full/path/to/config.pl';

################################################################
# DO NOT MAKE CHANGES BELOW THIS LINE
################################################################

$| = 1;
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser carpout);

my $script_url = url();
my $form = path_info();
$form =~ s!^/!!;

if (!$form) {
check_url();
admin_main();
}

elsif ($form eq 'winner') {
check_url();
pick_winner();
}

elsif ($form eq 'list') {
list_entrants();
}

elsif ($form eq 'delete') {
delete_entry();
}

elsif ($form eq 'clear') {
delete_database();
}

else {
error_page("<li>Illegal calling of script.");
}

################################################################
# Subtroutines

#######################
# Admin Main

sub admin_main {

print "Content-type: text/html\n\n";
print <<"eof";
<HTML>
<HEAD>
<TITLE>Contest Administration | Powered IQ Contest</TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffffff" TEXT="#000000">
<TABLE align="center" width="500" Border="0">
<TR>
<TD align="center" bgcolor="blue" colspan="2">
<FONT COLOR=#ffffff><B>Contest Administration</B></FONT>
</TD>
</TR>
<TD colspan="2"><BR>
Select the feature you wish to use:<BR><BR>
<DIV align="center">
<FORM ACTION="$script_url/winner" METHOD="POST"><INPUT TYPE="submit" VALUE="Pick the Winner"></FORM>
<FORM ACTION="$script_url/list" METHOD="POST"><INPUT TYPE="submit" VALUE="View all Entries "></FORM>
<FORM ACTION="$script_url/delete" METHOD="POST"><INPUT TYPE="submit" VALUE=" Delete Entry "></FORM>
<FORM ACTION="$script_url/clear" METHOD="POST"><INPUT TYPE="submit" VALUE="Clear Database"></FORM>
<hr color="blue">
</DIV>
</TD>
</TR>
<TR>
<TD align="right" colspan="2">
<FONT face ="verdana" size="1">powered by <a href="http://www.iqdesign.net/scripts/iqcontest.html" target="_blank">IQ Contest</a> v$version Copyright &copy; 2000</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
eof
}

#######################
# Pick Winner

sub pick_winner {

$cnt = 0;

print "Content-type: text/html\n\n";
print <<"eof";
<HTML>
<HEAD>
<TITLE>Winner Selection | Powered IQ Contest</TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffffff" TEXT="#000000">
<TABLE align="center" width="500" Border="0">
<TR>
<TD align="center" bgcolor="blue">
<FONT COLOR=#ffffff><B>Select Winner</B></FONT>
</TD>
</TR>
<TD><BR>
<font SIZE="+1"><b><u>The Winner is:</u></b></font><BR><BR>
eof

if (-e "$maindb") {
open (DATA, "$maindb") &#0124; &#0124; error_page("<li>Can't open Main Database");
while (!eof(DATA)){
$line = <DATA>;
$line =~ tr/\x0a\x0d//d;
($name,$email,$street,$city,$state,$zip,$phone) = split(/,/,$line);
@name[$cnt] = $name;
@email[$cnt] = $email;
@street[$cnt] = $street;
@city[$cnt] = $city;
@state[$cnt] = $state;
@zip[$cnt] = $zip;
@phone[$cnt] = $phone;
$cnt = $cnt + 1;
}
srand;

$choice = int(rand($#name));

$choice = $choice + 1;

print "<blockquote>\n";
print "<u>Entry # $choice</u><br><br>\n";
print "$name[$choice]<br>\n";
print "<a href=\"$email[$choice]\">$email[$choice]</a><br>\n";
print "$street[$choice]<br>\n";
print "$city[$choice], $state[$choice] $zip[$choice]<br>\n";
print "$phone[$choice]\n";
print "</blockquote>\n";

close(DATA);

print <<"eof";

</TD>
</TR>
<tr>
<td>
<hr color="blue">
</td>
</tr>
<TR>
<TD align="right">
<FONT face ="verdana" size="1">powered by <a href="http://www.iqdesign.net/scripts/iqcontest.html" target="_blank">IQ Contest</a> v$version Copyright &copy; 2000</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
eof
}
}

cont............


------------------
I was a game
Quote Reply
Re: Please help me out In reply to
contest_admin.cgi contd........
#######################
# List Entrants

sub list_entrants {

my (@all,$found,$line,$name,$email,$street,$city,$state,$zip,$phone);

print "Content-type: text/html\n\n";
print <<"eof";
<HTML>
<HEAD>
<TITLE>List Entrants | Powered IQ Contest</TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffffff" TEXT="#000000">
<TABLE align="center" width="500" Border="0">
<TR>
<TD align="center" bgcolor="blue" colspan="2">
<FONT COLOR=#ffffff><B>Contest Entrants</B></FONT>
</TD>
</TR>
<TD colspan="2"><BR>
The Following people have entered the contest<BR><BR>
</TD>
</TR>
<TD width="50%" align="center"><b>Name</b></TD><TD width="50%" align="center"><b>e-Mail</b></TD>

eof
if (-e "$maindb") {
open (DATA, "$maindb") &#0124; &#0124; error_page("<li>Can't open $maindb");
while(<DATA> ) {
@all = split(/\n/);
foreach $line (@all) {
($name,$email,$street,$city,$state,$zip,$phone) = split(/\,/, $line);

print "<tr>\n";
print "<td align=center><font face=\"arial\" size=2>$name</font></td>\n";
print "<td align=center><font face=\"arial\" size=2>$email</font></td>\n";
print "</tr>\n";
}
}
}

print <<"eof";
<tr>
<td colspan="2">
<hr color="blue">
</td>
</tr>
<TR>
<TD align="right" colspan="2">
<FONT face ="verdana" size="1">powered by <a href="http://www.iqdesign.net/scripts/iqcontest.html" target="_blank">IQ Contest</a> v$version Copyright &copy; 2000</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
eof
}



------------------
I was a game
Quote Reply
Re: Please help me out In reply to
contest_admin.cgi contd...................#######################
# Delete Entry

sub delete_entry {

print "Content-type: text/html\n\n";
print <<"eof";
<HTML>
<HEAD>
<TITLE>Delete Entry | Powered IQ Contest</TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffffff" TEXT="#000000">
<TABLE align="center" width="500" Border="0">
<TR>
<TD align="center" bgcolor="blue">
<FONT COLOR=#ffffff><B>Delete Entry</B></FONT>
</TD>
</TR>
<TD><BR>
That feature is not enabled in version 1.01 beta<BR><BR>
</TD>
</TR>
<tr>
<td>
<hr color="blue">
</td>
</tr>
<TR>
<TD align="right">
<FONT face ="verdana" size="1">powered by <a href="http://www.iqdesign.net/scripts/iqcontest.html" target="_blank">IQ Contest</a> v$version Copyright &copy; 2000</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
eof
}

#######################
# Check URL

sub check_url {
if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
} else {
$check_referer = 1;
}

if ($check_referer != 1) {
error_page("Illegal Operation. You're calling this script from another server");
}
}

#######################
# Error Page

sub error_page {
my $message = shift;

print "Content-type: text/html\n\n";
print <<"eof";
<HTML>
<HEAD>
<TITLE>Error! | Powered by IQ Contest</TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffffff" TEXT="#000000">
<TABLE align="center" width="500" Border="0">
<TR>
<TD align="center" bgcolor="blue">
<FONT COLOR=#ffffff><B>ERROR!</B></FONT>
</TD>
</TR>
<TD>
The following error has occurred:<br>
<B>$message</B><br><br>
<DIV align="center">Click <a href="$ENV{'HTTP_REFERER'}">HERE</a> to fix the problem.</DIV>
<hr color="blue">
</TD>
</TR>
<TR>
<TD align="right">
<FONT face ="verdana" size="1">powered by <a href="http://www.iqdesign.net/scripts/iqcontest.html" target="_blank">IQ Contest</a> v$version Copyright &copy; 2000</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
eof
exit(0);
}

#######################
# Clear Database

sub delete_database {

print "Content-type: text/html\n\n";
print <<"eof";
<HTML>
<HEAD>
<TITLE>Clear Database | Powered IQ Contest</TITLE>
</HEAD>
<BODY BACKGROUND="" BGCOLOR="#ffffff" TEXT="#000000">
<TABLE align="center" width="500" Border="0">
<TR>
<TD align="center" bgcolor="blue">
<FONT COLOR=#ffffff><B>Clear Database</B></FONT>
</TD>
</TR>
<TD><BR>
That feature is not enabled in version 1.01 beta<BR><BR>
</TD>
</TR>
<tr>
<td>
<hr color="blue">
</td>
</tr>
<TR>
<TD align="right">
<FONT face ="verdana" size="1">powered by <a href="http://www.iqdesign.net/scripts/iqcontest.html" target="_blank">IQ Contest</a> v$version Copyright &copy; 2000</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
eof
}


------------------
I was a game
Quote Reply
Re: Please help me out In reply to
Dear Robert,
The second reply contains config.pl and not contest_admin.cgi. the third reply contains contest_admin.cgi (half) and the rest of it is in 4th reply. i have not posted iqcontest.cgi as i think its got nothing to do with deleting database. Thanking you in advance. Thanks for helping me out
Jack


------------------
I was a game
Quote Reply
Re: Please help me out In reply to
I'm doing to take a look at it later today.
Hopefully some other people will read this post and have a look too.

------------------
Robert Blackstone
Webmaster of Scato Search
www.scato.com
Quote Reply
Re: Please help me out In reply to
Thank you once again. I am waiting for you.

Thank you very much cool guy
Quote Reply
Re: Please help me out In reply to
Hello Robert,
I haven't recieved your reply yet. I think that you are probably busy with your work. But it's ok. No body else had replied to the post yet, i beleive they know that u r working on it

Waiting for you,
Jack
Quote Reply
Re: Please help me out In reply to
I've looked over it a few times and....
They've made it a little confusing without having any code at all for the subs of clearing the database and deleting the entries.

We've now established that we have to write those 2 subs. I'll take a look at it later tonight and hopefully have something.

------------------
Robert Blackstone
Webmaster of Scato Search
www.scato.com
Quote Reply
Re: Please help me out In reply to
Thanks Again,
Waiting for your reply


Regards
Jack
Quote Reply
Re: Please help me out In reply to
Hello Robert,
I BELEIVE ITS REALLY TOUGH TO INCORPORATE THE STUFF WHICH I HAD MENTION TO YOU. BUT I REALLY APPRICIATE YOU AS YOU HAVE GIVEN SO MUCH TIME TO IT. ROBERT PLEASE KEEP ME POSTED.

THANKS AGAIN
JACK