#!/usr/local/bin/perl -T ########################################################### # WEB_STORE_CHECK_SETUP.CGI # # Date Created: 11-15-96 # Date Last Modified: 11-27-96 # # Copyright: # # You may use this code according to the terms specified in # the "Artistic License" included with this distribution. The license # can be found in the "Documentation" subdirectory as a file named # README.LICENSE. If for some reason the license is not included, you # may also find it at www.extropia.com. # # Though you are not obligated to do so, please let us know if you # have successfully installed this application. Not only do we # appreciate seeing the wonderful things you've done with it, but we # will then be able to contact you in the case of bug reports or # security announcements. To register yourself, simply send an # email to register@extropia.com. # # Finally, if you have done some cool modifications to the scripts, # please consider submitting your code back to the public domain and # getting some community recognition by submitting your modifications # to the Extropia Cool Hacks page. To do so, send email to # hacks@extropia.com # # Purpose: this CGI script can be run to check the setup # file to see if all the directories and files that will # be required exist and have the correct permissions # # Special Note: if you change the setup file you are using, # then you need to change the $sc_setup_file variable # that appears below. # # Output: # An HTML page which contains information about your # setup and whether your environment is configured correctly. # ############################################################ # Added some global scalers to handle repeated strings. # Christian Smith # September 14, 1999 $sc_chris_good = "This is good."; $sc_chris_bad = "This is bad. YOU NEED TO CORRECT THIS."; $sc_setup_file = "./Library/web_store.setup.db"; # Turn off buffering since this is an # error checking script and we do not # want anything to not be output if the # program crashes. $| = 1; # Print the HEADER print "Content-type: text/html\n\n"; # Added CSS info to customize error reporting. # Christian Smith # September 14, 1999 print qq! <\!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> Check HTML

Checking Web Store Setup


!; # Check the current version of # PERL and print it out print "

\nYou are using version $] of Perl.\n

"; # Depending on the version of PERL # you use, you will need to # either "use" the Cwd package or # "require" the getcwd library in # order to get the current working # directory in a platform independent # way # # This working directory will be printed out if ($] >= 5) { print "

\nWe are about to \"use\" the Cwd package to obtain the current working directory\n

"; use Cwd; $cwd = getcwd(); } else { print "

\nWe are about to \"require\" getcwd.pl library to obtain the current working directory\n

"; require "getcwd.pl"; $cwd = getcwd(); } print "

\nThe current working directory is: $cwd\n

"; # Now we load the setup file into # memory. print qq!

Checking: $sc_setup_file

!; # Check the location of the setup file # and call the Check_path subroutine to # check that (A) The file exists and (B) # that the file is readable # # When $dieflag is on, if there is an error # the program will exit immediately # $dieflag = "on"; &Check_path($sc_setup_file, "sc_setup_file", "exists,read"); $dieflag = "off"; # If the check was passed, we require the # setup file print "

\nNow, we will load the setup file.\n

"; require "$sc_setup_file"; print "Setup File Loaded.
"; # # Check all the paths and files # that were defined in the setup file # &Check_path($sc_cgi_lib_path, "sc_cgi_lib_path", "exists,read"); &Check_path($sc_mail_lib_path, "sc_mail_lib_path", "exists,read"); &Check_path($sc_html_search_routines_library_path, "sc_html_search_routines_library_path", "exists,read"); &Check_path($sc_db_lib_path, "sc_db_lib_path", "exists,read"); &Check_path($sc_order_lib_path, "sc_order_lib_path","exists,read"); &Check_path($sc_pgp_lib_path, "sc_pgp_lib_path", "exists,read"); &Check_path($sc_html_setup_file_path, "sc_html_setup_file_path", "exists,read"); &Check_path($sc_user_carts_directory_path, "sc_user_carts_directory_path", "exists,read,execute,write"); &Check_path($sc_data_file_path, "sc_data_file_path", "exists,read"); $data_path = &get_path_from_full_filename( $sc_data_file_path); &Check_path($data_path, "path from sc_data_file_path", "exists,read,execute"); &Check_path($sc_options_directory_path, "sc_options_directory_path", "exists,read,execute"); &Check_path($sc_html_product_directory_path, "sc_html_product_directory_path", "exists,read,execute"); &Check_path($sc_html_order_form_path, "sc_html_order_form_path", "exists,read"); &Check_path($sc_store_front_path, "sc_store_front_path", "exists, read"); &Check_path($sc_counter_file_path, "sc_counter_file_path", "exists,read,write"); $data_path = &get_path_from_full_filename( $sc_counter_file_path); &Check_path($data_path, "path from sc_counter_file_path", "exists,read,execute,write"); &Check_path($sc_error_log_path, "sc_error_log_path", "exists,read,write"); $data_path = &get_path_from_full_filename( $sc_error_log_path); &Check_path($data_path, "path from sc_error_log_path", "exists,read,execute,write"); &Check_path($sc_access_log_path, "sc_access_log_path", "exists,read,write"); $data_path = &get_path_from_full_filename( $sc_access_log_path); &Check_path($data_path, "path from sc_access_log_path", "exists,read,execute,write"); if ($sc_send_order_to_log =~ /yes/i) { &Check_path($sc_order_log_file, "sc_order_log_file","exists,read,write"); $data_path = &get_path_from_full_filename( $sc_order_log_file); &Check_path($data_path, "path from sc_order_log_file", "exists,read,execute,write"); } # If PGP is on, then we will check the # pgp related variables if ($sc_use_pgp =~ /yes/i) { &Check_path($sc_pgp_temp_file_path, "sc_pgp_temp_file_path", "exists,read,execute,write"); } &Check_path($sc_root_web_path, "sc_root_web_path", "exists,read,execute"); # Print the footer print qq! !; # The Check_path subroutine # provides a quick and easy method # of checking for the existence, readability, # writability, and executability of files. # sub Check_path { local($path, $varname, $rights) = @_; if ($rights =~ /exist/i) { if (!(-e $path)) { &HTMLDie("

\n$sc_chris_bad - Web server thinks $path specified in $varname does not exist.\n

"); } else { &HTMLMsg("

\n$sc_chris_good - $path specified in $varname exists.
\n

"); } } if ($rights =~ /read/i) { if (!(-r $path)) { &HTMLDie("

\n$sc_chris_bad - Web server cannot read from $path specified in $varname.\n

"); } else { &HTMLMsg("

\n$sc_chris_good - The web server can read from $path specified in $varname.\n

"); } } if ($rights =~ /write/i) { if (!(-w $path)) { &HTMLDie("

\n$sc_chris_bad - Web server cannot write to $path specified in $varname.\n

"); } else { &HTMLMsg("

\n$sc_chris_good - The web server can write to $path specified in $varname.\n

"); } } if ($rights =~ /execute/i) { if (!(-x $path)) { &HTMLDie("

\n$sc_chris_bad - Web server cannot execute $path specified in $varname.
\n

"); } else { &HTMLMsg("

\n$sc_chris_good - The web server can execute $path specified in $varname.\n

"); } } print "\n
\n"; } # End of Check_path # HTMLMsg outputs an HTMLized message sub HTMLMsg { local($msg) = @_; print "\n$msg\n"; } # End of HTMLMsg # HTMLDie is just like HTMLMsg except that it # also kills the program if the $dieflag is on. # sub HTMLDie { local($msg) = @_; print "\n$msg\n"; if ($dieflag =~ /on/i) { exit; } } # End of HTMLDie # get_path_from_full_filename takes a # variable pointing to a filename and # obtains the path to that filename. # sub get_path_from_full_filename { local($file) = @_; if (rindex($file, "/") > 0) { $file = substr($file,0,rindex($file, "/") + 1); } return($file); } # end of get_path_from_full_filenam