#!/usr/local/bin/perl # freeport.cgi -- freeport server gateway CGI interface # # Written by Russell McOrmond of FLORA Community WEB # $Id: freeport_batch,v 1.1 1998/10/06 00:56:00 tygerwww Exp $ # See http://www.flora.ottawa.on.ca/flora/server/freeport/ # for more information # require "freeport.pl"; # Host where Email can be sent for Users who own files. $email_host = "flora.ottawa.on.ca"; # URL to point to for things that did not automatically translate $badfreeport = "http://www.flora.ottawa.on.ca/nccn/server/"; # What is the URL for the un-translated files (for 'p' references) $ip_dir = "/ip"; # What is the pathname of the IP (Freeport root) to read menu files from. $ip = "/home/servers/freeport/ip"; # What is the URL of translated files references. (for menus) $trans_name="/free"; # What is the pathname for the translated files (output) $output_path = "/home/servers/freeport/freeport"; # What is the URL for the 'pattern' CGI or gateway? $pattern_name="/ip"; # match externalally represented commands. $command_pattern = '^(nr|\S*lynx|s?gopher|b?btelnet)\s'; #$menu_attributes = "/freenet/rootdir/config/menu_attributes.dat"; $menu_attributes = "/home/servers/nccn-server/menu.dat"; umask 022; # We need to create files that are world readable... open(MENULIST,$menu_attributes) || die "Cannot open menu_attributes file: $!\n\n"; while () { s/^\s+|\s+$//g; # strip leading/trailing whitespace next if /^(\#|\s*$)/; # Don't copy comments or blank lines next if /^\+/; # Attributes start with a plus next if /^\$BASE/; $menufile = $_; $file="$ip/$menufile"; $outfile="$output_path/$menufile"; ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file); # print "$file: $mtime\n"; ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$outmtime,$ctime,$blksize,$outblocks) = stat($outfile); # print "$outfile: $outmtime $outblocks\n"; if ($blocks == 0) { print STDERR "Can't open $file\n"; } elsif (($outblocks+0 == 0) || ($mtime > $outmtime)) { print "$file updates $outfile\n"; &create_dirs($output_path,$menufile); if (!open(HTMLFILE,">$outfile")) { print STDERR "HTML: can't open $outfile : $!\n"; } else { $oldfh = select(HTMLFILE); &translate_freeport($file); select($oldfh); } } else { print "$outfile is up to date...\n" } } exit 0; # # We need to create the directories for output HTML files - this will only # create directories below the root for the translator. # sub create_dirs { local($dir,$filename) = @_; @dirs = split(/\//,$filename); pop(@dirs); while($thisdir = shift @dirs) { $dir .= "/$thisdir"; if(! -d "$dir") { mkdir($dir,0755) || print STDERR "Cannot Create directory $dir: $!\n\n"; } } } # Only error so far is the 'not found' error message...Otherwise, 'status' # needs to be checked. In the case of the file translator, we check this # condition before going in. sub error { local($status, $msg) = @_; print STDERR "Translation error - now what??\n"; } # Outputs Status. sub MIME_header { # We don't want not MIME header. };