#!/usr/bin/perl # ### CHECK UBB SCRIPT - WRITE/DELETE FUNCTIONS ## # # Ultimate Bulletin Board is copyright Infopop Corporation (formerly Madrona Park, Inc.), 1997, 1998, 1999, 2000. # # ------------ testperms.cgi ------------- # # This script tests file user permissions # # T H I S I S A N U N S U P P O R T E D S C R I P T # # Infopop Corporation (formerly Madrona Park, Inc.) offers no # warranties on this script. The owner/licensee of the script is # solely responsible for any problems caused by installation of # the script or use of the script, including messages that may be # posted on the BB. # # All copyright notices regarding the Ultimate Bulletin Board # must remain intact on the scripts and in the HTML # for the scripts. # # For more info on the Ultimate BB, # see http://www.UltimateBB.com # ############################################################### # # I N S T R U C T I O N S # 1) transfer this script to your UBB CGI directory # 2) call it with your web browser i.e. http://www,mydomain.com/mycgi/ubb_test.cgi # 3) use the options to check standard function used by UBB # 4) you may test other directories by manually editing in a path # # ############################################################### # Do NOT modify anything below this line $ubb_help_url = 'http://www.ultimatebb.com/cgi-bin/ubbhelp00.cgi'; @filestocheck = ('UltBB.setup','Styles.file','mods.file','ubb_library.pl','ubb_library2.pl','Date.pl','mail-lib.pl'); @filestocheck_UBBFree = ('UltBB.setup','Styles.file','mods.file','ubb_library.pl','ubb_library2.pl','Date.pl'); @variablesfiles = ('UltBB.setup','Styles.file','mods.file','forums.cgi'); $this_script_name = "ubb_test.cgi"; $testversion= '1.7'; ############################################################### print ("Content-type: text/html\n\n"); use File::Basename; ($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX / or Windows / ($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \ if ($ENV{'REQUEST_METHOD'} !~ /POST/i) { if ($ENV{'QUERY_STRING'} ne '') { ($in{'action'},$DirToCheck,$commandtype) = &decode_query($ENV{'QUERY_STRING'}); # check for q and p commands $DirToCheck =~ s/\\/\//g; # leaning toothpicks if ( ($in{'action'} eq 'set_manual_paths') || ($commandtype eq 'o') ) { $manual_DirToCheck = $DirToCheck; # save value &getinfo; # get all standard ENV info but this will overwrite $DirtoCheck $DirToCheck = $manual_DirToCheck; $DirToCheck =~ s/\\/\//g; # leaning toothpicks $DirToCheck =~ s/\s+$//sg; # rem leading and trailing spaces $DirToCheck =~ s/^\s+//sg; if ($DirToCheck =~ /(.*)/){ # untaint $DirToCheck = $1; } &CheckBadChars($DirToCheck); # no funny characters or commands &print_headers; &print_test_form; exit(0); } # end if } else { &getinfo; # decode $ENV variables $DirToCheck =~ s/\\/\//g; # leaning toothpicks &print_headers; &print_test_form; exit(0); } }# end if else { # this is POST of data from form &getinfo; # basic info from ENV &ReadParse(); # parse using same system as UBB $DirToCheck = $in{'absolutepath'}; # take input from form } # clean up and check path supplied $DirToCheck =~ s/\s+$//sg; # rem leading and trailing spaces $DirToCheck =~ s/^\s+//sg; if ($DirToCheck =~ /(.*)/){ # untaint $DirToCheck = $1; } &CheckBadChars($DirToCheck); # no funny characters or commands $ThisScriptDir = &getThisScriptDir();# get *this* CGI Script Directory path $OrigDirToCheck = $DirToCheck; # keep a copy of this global va &print_headers; &print_table_top; if($DirToCheck eq '') { # a missing path or PERLIS did not provide any path to check for $errortype = 'paths'; &parse_help('paths'); &print_result_row ('Path Missing!','There is no absolute path to check','Click back to enter an absolute path manually and submit again','paths','solution:'); &print_table_bottom; #print ""; #end code exit; } # or continue with selected tests # Always Test for Existence of Directory selected ($Existence_Check_Result,$anyerrormessage,$errortype,$errorlabel) = &checkDirExistence($DirToCheck); # does it exist? &print_result_row ('Path',$Existence_Check_Result,$anyerrormessage,$errortype,$errorlabel); # Option 1. Test for R/W/Append, Mkdir/Rmdir in the directory selected if ($in{'action'} eq 'dirwritetest') { # test read, write, append delete, mkdir, rmdir unless ($DirNotFound){ # $DirNotFound means the directory doesn't exist so don't bother with this test ($DirToCheck_ReadWrite,$anyerrormessage,$errortype,$errorlabel)= &checkdirReadWrite($DirToCheck); &print_result_row ('Directory Read/Write?',$DirToCheck_ReadWrite,$anyerrormessage,$errortype,$errorlabel); }# end unless }# end of option 1 directory write test # OPTION 2. Test for Required files *in the directory* selected if ($in{'action'} eq 'testrequired') { # check each library or config file for availability &isThisFreeware(); # change @filestocheck to match Freeware 'requires' foreach $variablefile(@filestocheck){ undef($anyerrormessage,$errortype,$errorlabel); ($variable_file_status,$anyerrormessage,$errortype,$errorlabel) = &checkRequired_Files($variablefile); &print_result_row ($variablefile,$variable_file_status,$anyerrormessage,$errortype,''); } } # end Option 2 # OPTION 3. Test for R/W, of 4 variable files *in the directory* selected if ($in{'action'} eq 'checkreadwrite') { foreach $filename(@variablesfiles){ undef($read_write_status,$anyerrormessage,$errortype,$errorlabel); ($read_write_status,$anyerrormessage,$errortype,$errorlabel) = &check_variable_file_readwrite($filename); &print_result_row ($filename,$read_write_status,$anyerrormessage,$errortype,$errorlabel); } } # end Option 3 # Option 4. Test Absolute paths in a UltBB.setup *if found*. if ($in{'action'} eq 'checkabsolutes') { # check absolute paths if defined in UltBB.setup ($variable_file_status,$anyerrormessage,$errorlabel) = &checkRequired_Files('UltBB.setup'); if ($anyerrormessage ne ''){ $anyerrormessage = "Are you sure you are looking in the directory where UltBB.setup is ?"; $errortype = "paths"; $errorlabel = "comment:"; &print_result_row ('UltBB.setup','not found in this directory',$anyerrormessage,'paths',$errorlabel); } else { # continue only if there's no problem with the 'require' UltBB.setup if (-e "$CGIPath/Ultimate.cgi"){ &print_result_row ('CGI Directory Path OK','There is a correct path in general settings',$errormessage,$errortype); } else { &print_result_row ('CGI Directory Path','has not been defined sucessfully in the control panel',$errormessage,'paths'); } if ($NonCGIPath ne '') { ($DirToCheck_ReadWrite,$anyerrormessage)= &checkdirReadWrite($NonCGIPath); &print_result_row ('NonCGI Directory Path OK',$DirToCheck_ReadWrite,$anyerrormessage,$errortype); } else { &print_result_row ('NonCGI Directory Path','has not been defined sucessfully in the control panel',$anyerrormessage,'paths'); } if ($MembersPath ne '') { ($DirToCheck_ReadWrite,$anyerrormessage)= &checkdirReadWrite($MembersPath); &print_result_row ('Members Directory Path OK',$DirToCheck_ReadWrite,$anyerrormessage,$errorlabel); } else { &print_result_row ('Members Directory Path','has not been defined sucessfully in the control panel',$anyerrormessage,'paths'); } if (-e "$VariablesPath/UltBB.setup"){ &print_result_row ('Variables Directory Path Found','There is a correct path in general settings',$anyerrormessage,$errortype); } else { &print_result_row ('Variables Directory Path','has not been defined sucessfully in the control panel',$errormessage,'paths'); } } # end else continue if ... } # end check absolute paths check &print_result_row ('Next Action:',"go back more tests with this path full reset",'','nohelp'); &print_table_bottom; # END exit(0); ############################################## # S U B R O U T I N E S #1 sub error { my $message = shift; print "
$message\n\n"; } sub print_test_form { print <<"EOF";