This sux, a day wasted!

Status
Not open for further replies.

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
Really upset, spent the whole day yesterday working on a script to have 4 lvls of authority... admin, mod, usr, guest... It dont work when i upload it, but does locally? ? ?

If anyone could look at it and give me an idea as to why then just let me know so i can send the source code.

The error it spits out is

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@defectalisman.exofire.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/1.3.37 Server at www.defectalisman.exofire.net Port 80
? ? ?

Went back to a previouse version.
Please check it out and give me feedback:

http://www.defectalisman.exofire.net/

Taking note its the first page i have acctually bothered to upload.
 
Last edited:

The_Magistrate

New Member
Messages
1,118
Reaction score
0
Points
0
Usually a 500 Internal Server Error is caused by file permissions. Make sure that your files have a chmod of 755 and that your Perl scripts are placed in the cgi-bin directory and are executable. Check the file permissions on any other files (data logs, config files, etc.) that your scripts may read/write to.

Permissions on your computer are nothing like the premission requirements on a hosted environment.
 

sakuraguy

New Member
Messages
29
Reaction score
0
Points
0
Same goes for me, i reinstalled my phpbb few times already. Hope somebody from x10hosting can give an announcement.

Wen i check Cossacks is fine on the status .. but dunno wats happening.
 

Derek

Community Support Force
Community Support
Messages
12,882
Reaction score
186
Points
63
Was any of the services down like mysql?
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
uhm...

The server is fine i think...

more than likley my perl script.

When run locally on my PC, they both work and well at that.
When uploaded and set to 755, the old version works and the modified version doesn't.
The modified one goes about the task a little different and the only thing that i can think is the old version doesn't use
opendir(DIR, "");

Ok, bugger it!
Dont know if I am allowed to do this, but what the hell.
#!/usr/bin/perl -w
#
# This program is free software. You can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 1 or
# (at your option) any later version,



my ($r_adr,$r_hst,$r_rfr,$r_str) = ($ENV{'REMOTE_ADDR'},$ENV{'REMOTE_HOST'},$ENV{'HTTP_REFERER'},$ENV{'QUERY_STRING'});
#my ($r_rfr,$r_hst,$r_adr) = ('Host name','http://..','192.168.0.34');
#my $r_str = "link=about=++";
#my $r_str = "link=about=+e5+c5+t5+";
#my $cookie = new CGI::Cookie(-name=>'EXTID',-value=>'guest',-expires => '+3M');
use CGI qw/:standard/;
use CGI::Cookie;
my $time = localtime;
my $err_on = 1;
my $clk_on = 1;
my $test_p = 0;
#if ($test_p == 1) {}@tmp = undef;
my ($auth_lvl,$cmd,$loc,$content,$cnt_file);
my (@parm,@do_parm,@dir_list,@subdir_list,@allowed_dirs,@c);
my ($tmp,@tmp);

# reduce the $ENV
sub read_tag {
if ($r_str =~ /^(\w+)=(.+)=(.+)/) {
$cmd = $1 or &int_err('002');
$loc = $2 or &int_err('003');
$tmp = $3 or &int_err('004');
while ($tmp =~ /(\++)(\w+)/g) {
push(@parm,$2) or &int_err('004');
}

}
if ($test_p == 1) {print "The command : $cmd\nThe location : $loc\n";foreach (@parm) {print "Parm : $_\n"}}$tmp= undef;
}

# process parms
sub first_parms {
my $parm_file = 'DB/parms/list.txt'; # Swop external parameters for internal ones
my ($ext_parm,$int_parm);
open(PARMFILE, "<$parm_file") or &int_err('005');
my @p = <PARMFILE>;
foreach (@p) {
$_ =~ s/\s$//;
$_ =~ /(^\w+)=(.+)/;
($ext_parm,$int_parm) = ($1,$2);
foreach (@parm) {
$tmp = $_;
if ($tmp eq $ext_parm) {push(@do_parm,$int_parm)}
}
}
close(PARMFILE);
if ($test_p == 1 ) {foreach (@do_parm) {print "$_\n"}}$tmp= undef;
# this could get heavy ! ! ! define all paramters
foreach (@do_parm) {
if ($_ eq 'nocnt') {$clk_on = 0}
if ($_ eq 'noerr') {$err_on = 0}
if ($_ eq 'test') {$test_p = 1}
if ($_ eq 'no') {}
}
}
# fetch existing cookies
my($cookie1,$extid);
sub get_cookies {
%cookies = fetch CGI::Cookie;
if (! %cookies) {
my $gst_f = 'DB/accounts/guests_name.txt';
open(GSTFILE, "$gst_f") or &int_err('093');
@tmp = <GSTFILE>;
foreach (@tmp) {$_ =~ s/\s$//}
close(GSTFILE);
$a = $tmp[$#tmp];
$a =~ /(\d+)=/;
$tmp = $1;
$a = undef;
$tmp++;
$extid = 'nc'.$tmp;
open(GSTFILE, ">>$gst_f") or &int_err('093');
print GSTFILE "$extid=guest$tmp\n";
close(GSTFILE);
$cookie1 = new CGI::Cookie(-name=>'EXTID',-value=>"$extid",-expires => '+3M') or &int_err('001');
$auth_lvl = 0;
} else {
$extid = $cookies{'EXTID'}->value
}
if ($test_p == 1) {print "EXTID : $extid\n"}$tmp = undef;
}

# Check auth for restricted stuffs
sub check_auth {
my ($lvl0,$lvl1,$lvl2,$lvl3);
my $dir = 'DB/accounts/';
my ($usr_file,$mod_file,$admin_file) = ('usrs_name.txt','mods_name.txt','admin_name.txt');

# check users
#$extid = 'cmnr1';
open(USRFILE, "$dir"."$usr_file") or &int_err('097');
@tmp = <USRFILE>;
foreach (@tmp) {$_ =~ s/\s$//}
close(USRFILE);
foreach (@tmp) {
$_ =~ /(\w+)=/;
$tmp = $1;
if ($tmp eq $extid) {
$auth_lvl = 1;
}
}
# check mods
#$extid = 'mngr1';
open(MODFILE, "$dir"."$mod_file") or &int_err('098');
@tmp = <MODFILE>;
foreach (@tmp) {$_ =~ s/\s$//}
close(MODFILE);
foreach (@tmp) {
$_ =~ /(\w+)=/;
$tmp = $1;
if ($tmp eq $extid) {
$auth_lvl = 2;
}
}
# check admins
#$extid = 'daboss1';
open(ADMINFILE, "$dir"."$admin_file") or &int_err('099');
@tmp = <ADMINFILE>;
foreach (@tmp) {$_ =~ s/\s$//}
close(ADMINFILE);
foreach (@tmp) {
$_ =~ /(\w+)=/;
$tmp = $1;
if ($tmp eq $extid) {
$auth_lvl = 3;
}
}
if ($test_p == 1) {print "AUTH LVL : $auth_lvl\n"}$tmp = undef;
}

# run the command
sub run_cmd {
#cmd = link, mail, upld, dwld, dimg, lgin, lout
require "cmds/$cmd.pl" or &int_err('010');
&do_it($loc,$cookie1,$auth_lvl,@do_parm);
if ($cmd eq 'lgin') {
($loc) = @_ or &int_err('009');
}
if ($cmd eq 'lout') {
($loc,$cookie1) = @_ or &int_err('008');
#$loc = $y;
}
}

# prep dir for authorised content
sub prep_dir {
my $c_dir = 'content/';
opendir(DIR, $c_dir) || print "can't open $c_dir: $!";
@dir_list = grep { /^\w./ && "$c_dir/$_" } readdir(DIR);
closedir DIR;
foreach (@dir_list) {
if ($_ !~ /\.+/) {
push(@subdir_list,$_)
}
}
foreach (@subdir_list) {
if ($_ =~ /(\d+$)/) {
$tmp = $_;
if ($1 <= $auth_lvl) {
push(@allowed_dirs,$tmp);
}
}
}
if ($test_p == 1) {print "Access to : @allowed_dirs\n"}$tmp = undef;
}

# Try get content else return error (either unauth or not found)
sub get_content {
foreach (@allowed_dirs) {
$tmp = $_;
$dir = $tmp;
my $c_dir = 'content/'.$tmp.'/';
opendir(DIR, $c_dir) || print "can't open $c_dir: $!";
@dir = grep { /^\w./ && "$c_dir/$_" } readdir(DIR);
closedir DIR;
foreach (@dir) {
$tmp = $_;
if ($tmp =~ /$loc/) {
$cnt_file = "content/".$dir."/$tmp";
open(CONTENT, "$cnt_file");
@c = <CONTENT>;
close(CONTENT);
}
}
}
if (! @c) {
$cnt_file = "content/err/unauth.txt";
open(NOAUTH, "$cnt_file") or &int_err('014');
@c = <NOAUTH>;
close(NOAUTH);
}
if ($test_p == 1) {print "CONTENT : $cnt_file\n"}$tmp = undef;
}

# log as much info about this click as pos
sub log_click {
if ($clk_on == 1 ) {
my $clk_log = 'DB/logs/clicks/'.$loc.'.txt'; # log the users info and IP
open(CLKLOG, ">>$clk_log") or &int_err('091');
print CLKLOG "$extid = $r_hst = $time\n";
close(CLKLOG);
# counter
my $clk_count = 'DB/counters/content.txt'; # log the click counter
my $n;
open(COUNTFILE, "<$clk_count") or &int_err('092');
$n = <COUNTFILE>;
$n++;
close(COUNTFILE);
open(COUNTFILE, ">$clk_count") or &int_err('092');
print COUNTFILE $n;
close(COUNTFILE);
if ($test_p == 1) {print "LOGGED : $clk_log\nINCR : $clk_count\n"}$tmp = undef;
}
}

# print HTML
sub print_html {
print header(-cookie=>[$cookie]) or &int_err('013');
print <<ENDHTML;
<HTML>
<HEAD>
ENDHTML
foreach (@c) {
print "$_\n";
}
print <<ENDHTML;
</BODY>
</HTML>
ENDHTML
exit;
}

# internal errors
sub int_err {
my ($err_no) = @_;
if ($err_on == 1) {
my $err_file = 'DB/errors/int.txt';
open(ERRFILE, "$err_file");
my @e = <ERRFILE>;
foreach (@e) {
$_ =~ s/\s$//;
$_ =~ /(^\d+)=(\w.+)/;
if ($err_no == $1) {
my $e = $1; # some where here need to get error content from file
@c = $2; # $errorcode = $1 $error_explination = $2
}
&print_html;
}
close(ERRFILE);
my $err_log = 'DB/logs/errors.txt';
open(ERRLOG, ">>$err_log") or &int_err('090');
print ERRLOG "$err_no = $extid = $r_hst = $time\n";
close(ERRLOG);
if ($test_p == 1) {print "ERROR $err_no : @c\n"}$tmp = undef;
}
}

# run the subs
read_tag;
first_parms;
get_cookies;
check_auth;
run_cmd;
prep_dir;
get_content;
log_click;
if ($test_p == 0) {print_html}
Edit:
Is there a limit to how many file handels you can have?
 
Last edited:

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
There shouldn't be. I think you might have to go line by line from the old version to the modified one to figure out which line is causing your issue. Once you know which line for sure we can maybe look into why.

-Corey
 

DefecTalisman

Community Advocate
Community Support
Messages
4,148
Reaction score
5
Points
38
There shouldn't be. I think you might have to go line by line from the old version to the modified one to figure out which line is causing your issue. Once you know which line for sure we can maybe look into why.

-Corey

Found the problem. Had a missmatch on the cookie value and therfore when it found the cookie, it didnt make a new one. The old ones value was different so it spat out an error.

Working great, 4 lvls of authorisation and plenty commands it can accept.

Thanx for the time though.
 
Last edited:
Status
Not open for further replies.
Top