#!/usr/bin/perl ########################################################################## # Blosedit.cgi # # Allows editing of Blosxom files while maintining posting file date. # # Using just one other file for user/password entry, one can root a # # user to a home directory. The use of user flags control visibility of # # subdirectories such as /.settings/ as used in Blosxom 3 and visibility # # of dot named files such as .htaccess. Old files can be edited while # # maintaining integrity of timestamps. New files can aslo be created. # # Edited files can be saved as draft and then later saved as completed # # Directories or files need to be writable by "www" (or "apache") # # work. # # # # Blosedit is free software. you may redistribute it and/or modify it # # under the terms of the GNU General Public License as published by the # # Free Software Foundation. # # pdr 10/15/04, v1.0.2 # ########################################################################## use CGI; use Time::Local; # # <<<<<<<<<<<<<< Edit below for Your setup >>>>>>>>>>>>>>>>> # as they say, "Location, Location, Location!" my $passfile = '/var/www/cgi-bin/pssw.txt'; # absolute path to user/password file # my $passfile = '/Library/WebServer/CGI-Executables/pssw.txt'; # absolute path to user/password file my $salt ='gh'; # salt for crypt function my $usesecure = 0; # set if you want to use SSL secured cookie my $Xpiration = '+1d'; # cookie expiration date my $MAX_SIZE = 50; # if flag is set, user is not allowed to upload flles larger then this in kilobytes my $draft = tmp; # draft file extension ig. mysummertrip.txt is saved as mysummertrip.txt.tmp # thus preventing blosxom from showing it until it has a valid 'flavour' name # also when re-loaded, comes up with non-draft name for normal save # for more personal style define your own header/footer # Note, user's header and footer files care not active until log in my $usr_headerfile =''; # path is relative to current user's root my $usr_footerfile =''; # path is relative to current user's root # If user's header/footer not defined or doesn't exist then try default (if defined and exists) my $default_headerfile=''; # must be aboslute path to header my $default_footerfile=''; # must be aboslute path to footer # <<<<<<<<<<<<<< Edit above for Your setup >>>>>>>>>>>>>>>>> ########################################################################## # Password File Format: # a tab delimited file with the following on each line # userid password flags rootdirectory # # example: # admin bratwurst 0 /var/www/html/data # betty boop 3 /var/www/html/toons_only # otto bismark 12 /var/www/html/prussia # # file flags are decimal summation of flag (bits) values that are set # if flag is clear then its value is not added (= zero) # File Invisibility value = 1 files with names starting with period are not shown # Directory Invisible value = 2 directories w/names starting w/period are not shown # Directory create value = 4 User cannot create new subdirectories in home folder # File upload value = 8 User limited to maximum set file size # example: betty can not see any dot name files or directories since flag = 3 =1 + 2 # and otto is not allowed to expand beyond his current boundaries by making new subdirectories # in his root folder named prussia and his upload size is limited 12 = 4 + 8 ########################################################################## #create a new CGI object $cgi = new CGI; my $script=$cgi->script_name; my $user; my $pass; my $root; my $mydir; #flags my $FileInvisible=1; my $DirInvisible=2; my $DirCreate=4; my $LimitUpload=8; #attempt to read the cookie from the clients cache $userdata = $cgi->cookie("login"); if ($userdata) { $userdata =~ / pw=/; $user = $`; $pass = $'; $user =~ / /; $mydir = $'; $user = $`; if (ValidateUser()) { # user has a valid cookie. GetAction(); } } else { # check if the user has filled in the form. verify their ID/password and issue a cookie $submitted = $cgi->param('choose'); if ($submitted eq 'Login') { $user = $cgi->param('user'); $pass = $cgi->param('pass'); chomp($user); chomp($pass); $pass = crypt($pass, $salt); if (ValidateUser()) { HTML_ShowFiles(); } else { # Let them know that they didn't pass my $badlogin =1; HTML_Login(); } } else { # user has no valid cookie. Allow them to log in HTML_Login(); } } ############## HTML Forms ############## sub HTML_Login { $Blosedit_title = 'Login'; HTML_Header (); print qq(
Username/Password invalid!<\p>\n) if $badlogin; print qq(