Приглашаем посетить
Бунин (bunin-lit.ru)

HTML-AUTH

#!/usr/local/bin/perl
############################################################
#                       HTML-AUTH.CGI
#
# This script was written by Gunther Birznieks
# Date Created: 5-28-96
#
#   You may copy this under the terms of the GNU General Public
#   License or the Artistic License which is distributed with
#   copies of Perl v5.x for UNIX
#
# To act as an add-on to the authentication library.  It allows
# you to make an HTML file with references to CGI programs
# that use the authentication library without having to have the
# users re-login to every page.
#
# Basically, if you have an HTML file that references a cgi
# program with authentication, you should add a "session" variable
# to it in the URL and the auth.cgi program will "filter" it
# into "session=[REAL SESSION ID HERE]".
#
# eg if you list the BBS forums as "Open Forum" and
# "Web Programming", and your forum identifier for "Web
# Programming" was "web", then the URL for the BBS cgi program
# would be
#
# bbs_forum.cgi?forum=web&session
#
# The "session" would automatically be assigned to a REAL
# session id if that HTML file is filtered by "auth.cgi".
#
# html-auth.cgi only needs ONE PARAMETER which is the file to 
# filter.  For example, if you have a file call bbs.html,
# you can filter it by calling "html-auth.cgi?file=bbs.html".
#
# The file= is set to a path that is relative to the 
# directory that auth.cgi is operating out of.
#
# Inputs:
#   Form Variables: 
#     file = File to Filter
#
# Outputs:
#   The Filtered HTML with the session id from running
#   authorization.
#
############################################################

$lib = ".";
require "$lib/cgi-lib.pl";
#
# The following should be a setup file with your
# authorization variables.  In this case,
# we use test.setup for testing purposes.
#
require "html-auth.setup";
require "$auth_lib/auth-lib.pl";

print &PrintHeader;
&ReadParse;

$session = $in{"session"};
 
($session, @fields) =
    &GetSessionInfo($session, "html-auth.cgi", *in);

$htmlfile = $in{'file'};

if ($htmlfile ne "") {
     open(HTMLFILE, "$htmlfile") ||
       &CgiDie("Could not open $htmlfile");

    while (<HTMLFILE>) {
        if (/session/) {
	    s/session/session=$session/;
        }
        print $_;
    }   

    close (HTMLFILE);
} else {


print <<__END_OF_HTML__;
<HTML>
<HEAD>
<TITLE>
Authentication HTML Filter
</TITLE>
</HEAD>
<BODY>
<H1>Authentication HTML Filter</H1>
<HR>
<BLOCKQUOTE>
<STRONG>Error: </STRONG> You forgot to include
a "file=" parameter on the URL of this CGI script.
You need this parameter to tell the
html-auth.cgi program which HTML Files 
to protect from viewing as well as filter 
session ids in the file.
<P>
For example, you may want to use
a URL in the form of:
<P>
http://www.foobar.com/cgi-bin/html-auth.cgi?file=html-auth.html 
</BLOCKQUOTE>
<HR>
</BODY>
</HTML>

__END_OF_HTML__
 

} # End of if $htmlfile is there