开发者

Adding a custom login page to awstats

开发者 https://www.devze.com 2023-03-22 23:30 出处:网络
I am trying to setup a login page to be used with awstats, so that the content is only viewable by authenticated users.

I am trying to setup a login page to be used with awstats, so that the content is only viewable by authenticated users.

Ideally, I would like to create my own login page, and if a user is not logged in when the visit the stats page, they are redirected to the login page. (Right now there is n开发者_运维问答o authentication)

The problem is that I don't know how to implement this. I have tried googling this, but the only solutions I could find were to use .htaccess (which I would rather not use in this case if I don't have to)

Has anyone implemented something similar to this?


.htaccess is the right tool for this job, but if you insist, the ancient ancient ancient way

#!/usr/bin/perl --
use strict;
use warnings;
use CGI;
Main( @ARGV );
exit( 0 );
sub  Main {
    my ( $q ) = CGI->new;
    if( $q->param('password') eq 'secret' ){
        print ShowAWSTATS($q);
    } else {
        print ShowLoginForm($q);
    }
}

where ShowLoginForm() prints a content header $q->header along with the html for a login form, and ShowAWSTATS prints a content header, and say, some html as provided by awstats.pl

Like Len Jaffe says, there is much much much more that needs to be done, so you want to use .htaccess (its either 3min with .htaccess or hours with anything else)

0

精彩评论

暂无评论...
验证码 换一张
取 消