Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

Welcome to Webmaster Forums 101!

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Reply
 
Thread Tools Search this Thread Display Modes
Old 10th December 2004, 01:16 AM   #1

Username: bonnro
Rank: WF101 Newbie
Join Date: Dec 2004
Location: GTMO Cuba
Posts: 1
Points: 0.00
Default I need help with a coding error.

I have attempted to modify the below CGI script to include a mailto: option that will populate the subject line with the blocked URL. If anyone could help, I would appreciate it.

#! /usr/bin/perl
#
# Sample CGI to explain to the user that the URL is blocked and by which rule set
#
# By Pål Baltzersen 1998
#

$QUERY_STRING = $ENV{'QUERY_STRING'};
$DOCUMENT_ROOT = $ENV{'DOCUMENT_ROOT'};

$clientaddr = "";
$clientname = "";
$clientident = "";
$srcclass = "";
$targetclass = "";
$url = "";
$time = time;
@day = ("Sunday","Monday","Tuesday","Wednesday","Thursday ","Friday","Saturday");
@month = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"," Sep","Oct","Nov","Dec");

while ($QUERY_STRING =~ /^\&?([^&=]+)=([^&=]*)(.*)/) {
$key = $1;
$value = $2;
$QUERY_STRING = $3;
if ($key =~ /^(clientaddr|clientname|clientident|srcclass|targe tclass|url)$/) {
eval "\$$key = \$value";
}
if ($QUERY_STRING =~ /^url=(.*)/) {
$url = $1;
$QUERY_STRING = "";
}
}

if ($url =~ /\.(gif|jpg|jpeg|mpg|mpeg|avi|mov)$/i) {
print "Content-Type: image/gif\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isd st) = gmtime($time);
printf "Expires: %s, %02d-%s-%02d %02d:%02d:%02d GMT\n\n", $day[$wday],$mday,$month[$mon],$year,$hour,$min,$sec;
while (<GIF>) {
print;
}
close(GIF)
} else {
print "Content-type: text/html\n";
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isd st) = gmtime($time);
printf "Expires: %s, %02d-%s-%02d %02d:%02d:%02d GMT\n\n", $day[$wday],$mday,$month[$mon],$year,$hour,$min,$sec;
print "<HTML>\n\n <HEAD>\n <TITLE>302 Access denied</TITLE>\n </HEAD>\n\n";
print " <BODY BGCOLOR=\"#FFFFFF\">\n";
if ($srcclass eq "unknown") {
print " <P ALIGN=RIGHT>\n";
print " </P>\n\n";
print " <H1 ALIGN=CENTER>Access denied because<BR>this client is not<BR>defined on the proxy</H1>\n\n";
print " <TABLE BORDER=0 ALIGN=CENTER>\n";
print " <TR><TH ALIGN=RIGHT>Supplementary info<TH ALIGN=CENTER>:<TH ALIGN=LEFT>\n";
print " <TR><TH ALIGN=RIGHT>Client address<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$clientaddr\n";
print " <TR><TH ALIGN=RIGHT>Client name<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$clientname\n";
print " <TR><TH ALIGN=RIGHT>User ident<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$clientident\n";
print " <TR><TH ALIGN=RIGHT>Client group<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$srcclass\n";
print " </TABLE>\n\n";
print " <P ALIGN=CENTER>If this is wrong, contact the administrator.<BR>\n";
print " </P>\n\n";
} elsif ($targetclass eq "in-addr") {
print " <P ALIGN=RIGHT>\n";
print " </P>\n\n";
print " <H1 ALIGN=CENTER>IP address URLs<BR>are not allowed<BR>from this client</H1>\n\n";
print " <TABLE BORDER=0 ALIGN=CENTER>\n";
print " <TR><TH ALIGN=RIGHT>Supplementary info<TH ALIGN=CENTER>:<TH ALIGN=LEFT>\n";
print " <TR><TH ALIGN=RIGHT>Client address<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$clientaddr\n";
print " <TR><TH ALIGN=RIGHT>Client name<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$clientname\n";
print " <TR><TH ALIGN=RIGHT>User ident<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$clientident\n";
print " <TR><TH ALIGN=RIGHT>Client group<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$srcclass\n";
print " <TR><TH ALIGN=RIGHT>URL<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$url\n";
print " <TR><TH ALIGN=RIGHT>Target class<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$targetclass\n";
print " </TABLE>\n\n";
print " <P ALIGN=CENTER>Contact the <B>webmaster</B> of <B>$url</B><BR>\n";
print " and ask him to give the webserver a proper <U>domain name</U>\n";
print " </P>\n\n";
} else {
print " <P ALIGN=RIGHT>\n";
print " </P><p></p>\n\n";
print " <BR><BR><BR><BR><p align=\"center\"><font size=\"7\" face=\"arial\" color=\"#FF0000\"><b>ACCESS DENIED</font></b><BR>\n\n";
print " <TABLE BORDER=0 ALIGN=CENTER>\n";
print " <TR><BR><BR><TH ALIGN=RIGHT>Your Computer IP address<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$clientaddr\n";
print " <TR><TH ALIGN=RIGHT>Attempted URL<TH ALIGN=CENTER>=<TH ALIGN=LEFT>$url\n";
print " </TABLE>\n\n";
print " <p align=\"center\"><font size=\"3\" face=\"Arial\">If this website should be accessible...<BR><font>\n";
print " <p align=\"center\"><font size=\"3\" face=\"Arial\"><B><U>NAVSTA</U></B> personel contact <B><U>ISD Help Desk</U></B>. <BR><font>\n";
print " <p align=\"center\"><font size=\"3\" face=\"Arial\"><B><U>JTF</U></B> personel contact <B><U>JTF Help Desk</U></B>.<BR><BR><BR><font>\n";
print " <p align=\"center\"><font size=\"3\" face=\"Arial\">Provide the <B>URL</B> shown above and the reason the site should not be blocked.<BR><font>\n";
print " </P>\n\n";
print " <p align=\"center\"><font size=\"3\" face=\"Arial\"><a title="If this is a work related web site, please send email to your local network administrator." href="mailto:dikeRC@usnbgtmo.navy.mil?subject=$url ">
mail</a></p>
print " </P>\n\n";
}
print " </BODY>\n\n</HTML>\n";
}
exit 0;
bonnro is offline   Reply With Quote
Old 19th December 2004, 09:11 PM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Hi and welcome to the forums.

Could you please explain in more detail what you wish to do?

Cheers
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding Standards Peter Sinclair Webmaster Help 0 14th March 2005 12:49 PM
ASP Error Ben Server-Side Scripting & Databases 1 1st March 2005 08:58 AM
404 error page problems sredhead Website Design & Coding 2 27th October 2003 08:38 PM
Ride4Pain metguitarist Website Design Reviews 14 29th April 2003 11:41 AM
Parse error viper Server-Side Scripting & Databases 14 8th April 2003 09:56 AM

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 08:53 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore