I have installed all the required mod and tested to be successful. I decided to add the autodelete mod and immediately after uploading Error 500 came out. I tried to figure out the problem for two days but was no avail. Anybody can help ?
I am using User-friendly html with format.pl. I have only done exactly what was mention in autodelm.text only. Could I missed out something else ?
ERROR 500
----------------------------------------------------
syntax error at conf.cgi line 277, near "next"
BEGIN not safe after errors--compilation aborted at conf.cgi line 1312.
-----------------------------------------------------
This is what I have added
AUTH.pl
-----------------------------------------------------
if (($in{'userid'} eq $userid) && (crypt($in{'pw'}, $pw) eq $pw)) { srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
$db_uid = "$userid." . time() . (int(rand(100000)) + 1);# Build User Id
open(AUTH, ">$auth_dir/$db_uid") or &cgierr("unable to open auth file: $auth_dir/$uid. Reason: $!\n");
print AUTH "$uid: $ENV{'REMOTE_HOST'}\n";
close AUTH;
&auto_delete; #### added for autodelete mod
foreach (0 .. 3) { $permissions[$_] = int($permissions[$_]); }
&auth_logging('logged on', $userid) if ($auth_logging);
return ('ok', $db_uid, $view, $add, $del, $mod, $admin);
}
}
CONFIG FILE (AUTOS.CFG)
-----------------------------------
Validated => [18, 'alpha', 0, 3, 1,'No', 'Yes|No'],
Modified => [19, 'alpha', 0, 3, 1,'No', 'Yes|No'],
Expires => [20, 'date',15, 15, 0, &get_date,'\d{2}\/\d{2}\/\d{4}'],
ADStart => [21,'date',15,15,0, &get_date, '\d{2}\/\d{2}\/\d{4}'],
Remove_by => [22,'date',20,15,0, &get_date(time + 172800), '\d{2}\/\d{2}\/\d{4}'] ## set for 1 day after expires date.
);
DB.CGI
-----------------------
sub main
--------------
elsif ($in{'forward_email'}){ &forward_email; }
elsif ($in{'auto_delete'}) { if ($per_admin) { &auto_delete; } else { &html_unauth; } } ### autodelete
elsif ($in{'logoff'}) { &auth_logging('logged off') if ($auth_logging);
------------and-------------
sub validate_records
--------------------------
print MAIL $email_message;
close (MAIL);
$rec{'Validated'} = "Yes";
$rec{'ADStart'} = &get_date(); ## change start date to date validated
$output .= &join_encode(%rec);}
else { $output .= $line . "\n" } }
foreach $key (keys %delete_list) {
------------and-----------
sub add_record
--------------------
(!$per_admin) and ($in{$db_validated_field} = "No");
$status = &validate_record;
&calc_expire_date; #### increment expires field
&calc_remove_date; #### increment removeby field
while ($status eq "duplicate key error" and $db_key_track) {
return "duplicate key error" if ($counter++ > 50);
---------and---------
sub modify_record
-----------------
if ($auth_user_field >= 0 and (!$per_admin or !$in{$db_cols[$auth_user_field]})) {
$in{$db_cols[$auth_user_field]} = $data[$auth_user_field];
}
&calc_expire_date; #### increment expires field
&calc_remove_date; #### increment removeby field
$output .= &join_encode(%in);
$found = 1; }
else { $output .= $line . "\n"; # else print regular line.
}}
------------and---------
ADDED new sub
sub calc_expire_date {
#---------------------------
# 24 hours =86400 30days=2592000
my ($temp_date);
$temp_date = &date_to_unix($in{'ADStart'});
$temp_date = $temp_date + ($in{'duration'}*86400);
$in{'Expires'} = &get_date($temp_date);
}
sub calc_remove_date {
#------------------------
my ($temp_date);
$temp_date = &date_to_unix($in{'Expires'});
$temp_date = $temp_date + ($in{'Expires'}+86400);
$in{'Remove_by'} = &get_date($temp_date);
}
sub auto_delete {
# ------------------------------------------
# Automatically removes entries older than a predetermined date
foreach $db (@autodelete) {
my ($removeby_field,$dateadded_field,$db_file_name) = split /\|/, $db;
my $today = &date_to_unix(&get_date);
my (@lines, @values);
print "Content-type: text/html\n\n <PRE>"; # Print headers.
open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
print "Comparing: '$today' vs '$values[$removeby_field]' ... \n";
if ($today > (&date_to_unix($values[$dateadded_field]) + (86400 * $values[$removeby_field]))) {
if ($today > ($today -(86400 * $values[$removeby_field])) {
print "Deleting\n";
next; #line 277
}
print DB $_, "\n"; }
close DB; }
}
----------------------END-------------
CHANGES
sub get_date {
# --------------------------------------------------------
my ($time1) = $_[0];
($time1) or ($time1 = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
++$mon;
($mon < 10) and ($mon = "0$mon");
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$mon/$day/$year"; }
sub date_to_unix {
# --------------------------------------------------------
my ($date) = $_[0];
my ($time);
my ($mon, $day, $year) = split(/\//, $_[0]);
unless ($min and $day and $year) { return undef; }
use Time::Local; #line 1312
eval {
$day = int($day); $year = int($year) - 1900; $mon = int($mon) - 1;
$time = timelocal(0,0,0,$day, $mon, $year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}
LASTLT I've add
FORMAT.PL
--------------------
# Autodelete Time
@autodelete[0] = '22|20|autos.db';
Please advise whether I've missed out anything ? I have search the forum and visited the require forum reference in http://gossamer-threads.com/perl/forum/showflat.pl?ubb=002837:Forum12
but I still can't solve the problem.
I am using User-friendly html with format.pl. I have only done exactly what was mention in autodelm.text only. Could I missed out something else ?
ERROR 500
----------------------------------------------------
syntax error at conf.cgi line 277, near "next"
BEGIN not safe after errors--compilation aborted at conf.cgi line 1312.
-----------------------------------------------------
This is what I have added
AUTH.pl
-----------------------------------------------------
if (($in{'userid'} eq $userid) && (crypt($in{'pw'}, $pw) eq $pw)) { srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
$db_uid = "$userid." . time() . (int(rand(100000)) + 1);# Build User Id
open(AUTH, ">$auth_dir/$db_uid") or &cgierr("unable to open auth file: $auth_dir/$uid. Reason: $!\n");
print AUTH "$uid: $ENV{'REMOTE_HOST'}\n";
close AUTH;
&auto_delete; #### added for autodelete mod
foreach (0 .. 3) { $permissions[$_] = int($permissions[$_]); }
&auth_logging('logged on', $userid) if ($auth_logging);
return ('ok', $db_uid, $view, $add, $del, $mod, $admin);
}
}
CONFIG FILE (AUTOS.CFG)
-----------------------------------
Validated => [18, 'alpha', 0, 3, 1,'No', 'Yes|No'],
Modified => [19, 'alpha', 0, 3, 1,'No', 'Yes|No'],
Expires => [20, 'date',15, 15, 0, &get_date,'\d{2}\/\d{2}\/\d{4}'],
ADStart => [21,'date',15,15,0, &get_date, '\d{2}\/\d{2}\/\d{4}'],
Remove_by => [22,'date',20,15,0, &get_date(time + 172800), '\d{2}\/\d{2}\/\d{4}'] ## set for 1 day after expires date.
);
DB.CGI
-----------------------
sub main
--------------
elsif ($in{'forward_email'}){ &forward_email; }
elsif ($in{'auto_delete'}) { if ($per_admin) { &auto_delete; } else { &html_unauth; } } ### autodelete
elsif ($in{'logoff'}) { &auth_logging('logged off') if ($auth_logging);
------------and-------------
sub validate_records
--------------------------
print MAIL $email_message;
close (MAIL);
$rec{'Validated'} = "Yes";
$rec{'ADStart'} = &get_date(); ## change start date to date validated
$output .= &join_encode(%rec);}
else { $output .= $line . "\n" } }
foreach $key (keys %delete_list) {
------------and-----------
sub add_record
--------------------
(!$per_admin) and ($in{$db_validated_field} = "No");
$status = &validate_record;
&calc_expire_date; #### increment expires field
&calc_remove_date; #### increment removeby field
while ($status eq "duplicate key error" and $db_key_track) {
return "duplicate key error" if ($counter++ > 50);
---------and---------
sub modify_record
-----------------
if ($auth_user_field >= 0 and (!$per_admin or !$in{$db_cols[$auth_user_field]})) {
$in{$db_cols[$auth_user_field]} = $data[$auth_user_field];
}
&calc_expire_date; #### increment expires field
&calc_remove_date; #### increment removeby field
$output .= &join_encode(%in);
$found = 1; }
else { $output .= $line . "\n"; # else print regular line.
}}
------------and---------
ADDED new sub
sub calc_expire_date {
#---------------------------
# 24 hours =86400 30days=2592000
my ($temp_date);
$temp_date = &date_to_unix($in{'ADStart'});
$temp_date = $temp_date + ($in{'duration'}*86400);
$in{'Expires'} = &get_date($temp_date);
}
sub calc_remove_date {
#------------------------
my ($temp_date);
$temp_date = &date_to_unix($in{'Expires'});
$temp_date = $temp_date + ($in{'Expires'}+86400);
$in{'Remove_by'} = &get_date($temp_date);
}
sub auto_delete {
# ------------------------------------------
# Automatically removes entries older than a predetermined date
foreach $db (@autodelete) {
my ($removeby_field,$dateadded_field,$db_file_name) = split /\|/, $db;
my $today = &date_to_unix(&get_date);
my (@lines, @values);
print "Content-type: text/html\n\n <PRE>"; # Print headers.
open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
print "Comparing: '$today' vs '$values[$removeby_field]' ... \n";
if ($today > (&date_to_unix($values[$dateadded_field]) + (86400 * $values[$removeby_field]))) {
if ($today > ($today -(86400 * $values[$removeby_field])) {
print "Deleting\n";
next; #line 277
}
print DB $_, "\n"; }
close DB; }
}
----------------------END-------------
CHANGES
sub get_date {
# --------------------------------------------------------
my ($time1) = $_[0];
($time1) or ($time1 = time());
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time1);
++$mon;
($mon < 10) and ($mon = "0$mon");
($day < 10) and ($day = "0$day");
$year = $year + 1900;
return "$mon/$day/$year"; }
sub date_to_unix {
# --------------------------------------------------------
my ($date) = $_[0];
my ($time);
my ($mon, $day, $year) = split(/\//, $_[0]);
unless ($min and $day and $year) { return undef; }
use Time::Local; #line 1312
eval {
$day = int($day); $year = int($year) - 1900; $mon = int($mon) - 1;
$time = timelocal(0,0,0,$day, $mon, $year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}
LASTLT I've add
FORMAT.PL
--------------------
# Autodelete Time
@autodelete[0] = '22|20|autos.db';
Please advise whether I've missed out anything ? I have search the forum and visited the require forum reference in http://gossamer-threads.com/perl/forum/showflat.pl?ubb=002837:Forum12
but I still can't solve the problem.