Using widgetz's cool modify.cgi codes I have adapted them to work in the admin.cgi script. This may help people who do not have .htaccess or do not know how to configure NT to password protect directories:
Simply do the following:
1) Add the following codes in the load modules section in the admin.cgi script:
use Links::HTML_Templates;
use vars qw/%in $USER/;
&main();
2) Then replace all the codes after the module section and before the sub add_record routine with the following codes:
sub main {
#---------------------------------------------------
# Create our CGI, and DB objects.
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
%in = %{&cgi_to_hash ($in)};
my $db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/" . ($in->param('db') || "Links") . ".def";
&admin_html_init($in, $db);
# Get user information.
my $s = $in->param('s') || $in->cookie('s');
$USER = &authenticate ($s);
if (! defined $USER) {
my $encurl = "$ENV{'SCRIPT_NAME'}";
print $in->redirect("$LINKS{build_user_url}?to=$encurl") and return;
}
print $in->header() unless ($in->param('do') eq 'show_attach');
if ($USER->{Status} eq 'Administrator') {
if (defined $in->param('do')) {
my $sub = \&{$in->param('do')};
&{$sub} ($in, $db);
}
else {
&html_home ($in, $db);
}
}
else {
&site_html_error ({error => "You do not have permission to access this script."}, $in, $dynamic);
return;
}
}
3) Before installing the above codes, you will need to create a user in the Users table that has Administrator permissions. You will need to use this user account to access your admin.cgi in the future.
Hope this helps.
Regards,
Eliot Lee
Simply do the following:
1) Add the following codes in the load modules section in the admin.cgi script:
Code:
use Links::HTML_Templates;
use vars qw/%in $USER/;
&main();
2) Then replace all the codes after the module section and before the sub add_record routine with the following codes:
Code:
sub main {
#---------------------------------------------------
# Create our CGI, and DB objects.
my $in = new CGI;
my $dynamic = $in->param('d') ? $in : undef;
%in = %{&cgi_to_hash ($in)};
my $db = new Links::DBSQL $LINKS{admin_root_path} . "/defs/" . ($in->param('db') || "Links") . ".def";
&admin_html_init($in, $db);
# Get user information.
my $s = $in->param('s') || $in->cookie('s');
$USER = &authenticate ($s);
if (! defined $USER) {
my $encurl = "$ENV{'SCRIPT_NAME'}";
print $in->redirect("$LINKS{build_user_url}?to=$encurl") and return;
}
print $in->header() unless ($in->param('do') eq 'show_attach');
if ($USER->{Status} eq 'Administrator') {
if (defined $in->param('do')) {
my $sub = \&{$in->param('do')};
&{$sub} ($in, $db);
}
else {
&html_home ($in, $db);
}
}
else {
&site_html_error ({error => "You do not have permission to access this script."}, $in, $dynamic);
return;
}
}
3) Before installing the above codes, you will need to create a user in the Users table that has Administrator permissions. You will need to use this user account to access your admin.cgi in the future.
Hope this helps.
Regards,
Eliot Lee