in reply to Exists with DBM
I have made the suggested changes, but I haven't fixed all the problems. Now I get everything open, but on the server I get a software error with no information as to what the error is. On the CLI I get no error, but the output stops as soon as the script gets into the "if(exists ($allIPs{$userIP}))" loop, it prints the first line, and nothing else. The nested loop just doesn't seem to be activated at all. Any suggestions?
~~Guildencrantz#!/usr/bin/perl -wT # # Script: Dynamic Dungeon Siege IP Database Activate IP Script # Author: Guildencrantz # Version: 4-13-02 # use strict; use DB_File; use CGI; use CGI::Carp 'fatalsToBrowser'; my $q = new CGI; my $userIP = $q->remote_host; my $allIPsPath = "/var/www/cgi-bin/ds/database/allIPs.db"; my $activeIPsPath = "/var/www/cgi-bin/ds/database/activeIPs.db"; tie my %allIPs, "DB_File", $allIPsPath or die "Cannot open allIPs database: $!"; tie my %activeIPs, "DB_File", $activeIPsPath or die "Cannot open activeIPs database: $!"; print "userIP = $userIP\n"; print "userdata = $allIPs{$userIP}\n"; if( exists $allIPs{$userIP} ) { print "exists in allIPs\n"; if( exists $activeIPs{$userIP} ) { print "exists in activeIPs\n"; print "Content-type: html/text"; print <<END_OF_BLOCK; <HTML> <HEAD> <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/ds +-cgi/viewActive.pl"> <TITLE>ACTIVE</TITLE> </HEAD> <BODY> <H1>Your IP is already marked as active!</H1> <P> <A HREF="/ds-cgi/viewActive.pl"> You will be forwarded in 5 seconds </A> </P> </BODY> </HTML> END_OF_BLOCK } else { print "does not exist in activeIPs\n"; $activeIPs{$userIP} = $allIPs{$userIP}; print "active IPs= $activeIPs{$userIP}\n"; print "Content-type: html/text"; print <<END_OF_BLOCK; <HTML> <HEAD> <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/ds +-cgi/viewActive.pl"> <TITLE>Added!</TITLE> </HEAD> <BODY> <H1>Your IP has been activated!</H1> <P> <A HREF="/ds-cgi/viewActive.pl"> You will be forwarded in 5 seconds </A> </P> </BODY> </HTML> END_OF_BLOCK } } else { print "Content-type: text/html\n\n"; print <<END_OF_BLOCK; <HEAD> <META HTTP-EQUIV="Refresh" CONTENT="5; URL=/ds/submit. +html"> <TITLE>IP Not Registered</TITLE> </HEAD> <BODY> <H1>There is no entry in the database for this IP. You must regis +ter this IP and the associated server attributes</H1> <P> <A HREF="/ds/submit.html"> You will be forwarded in 5 seconds </A> </P> </BODY> </HTML> END_OF_BLOCK } untie %activeIPs; untie %allIPs;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Exists with DBM
by grep (Monsignor) on Apr 14, 2002 at 00:14 UTC |