htdig: REFERER


Frank Guangxin Liu (frank@ctcqnx2.ctc.cummins.com)
Sat, 7 Nov 1998 13:48:12 -0500


Wondering if the htsearch can be modified to support "referer"
tag. I want to restrict hosts to use the "htsearch" cgi.

Frank

sub check_url {
   @referers = ('http://site1.com','http://site2.com');

   if ($ENV{'HTTP_REFERER'}) {
      foreach $referer (@referers) {
         if ($ENV{'HTTP_REFERER'} =~ /$referer/i) {
            $check_referer = '1';
            last;
         }
      }
   }
   else {
      #for old browsers
      $check_referer = '1';
   }

   if ($check_referer != 1) {
           print "<TITLE>Bad Referrer - Access Denied</TITLE>\n";
           print "</HEAD>\n";
           print "<BODY BGCOLOR=\"#FFFFFF\">\n";
           print "<H1>";
           print "Bad Referrer - Access Denied";
           print "</H1>";
           print "The form that is trying to use cgi program\n";
           print "resides at: $ENV{'HTTP_REFERER'}, which is not ";
           print "allowed to access this cgi script.<p>\n";
           print "</BODY>\n";
           print "</HTML>\n";
           exit;
        }

}

----------------------------------------------------------------------
To unsubscribe from the htdig mailing list, send a message to
htdig-request@sdsu.edu containing the single word "unsubscribe" in
the body of the message.



This archive was generated by hypermail 2.0b3 on Sat Jan 02 1999 - 16:28:45 PST