문제

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 no 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)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top