📄 essence-explore.pl
字号:
#!/bin/perl -Tw
# The filename of this Perl script should be the same at Rednet.
#
# There are various configuration variables below which need changing for your site.
#
# Path to Perl needed at Essence ISP is /bin/perl -Tw. First line should be first line!
# Path to Perl needed at Essence local is /perl/bin/perl.exe -Tw.
#
# The following may not be needed now. There is little of the original code left (mainly
# some bits of sub search(), and attempts to contact the authors by email
# to ask permission to distribute have so far failed.
#
############################################################################
# #
# FileSeek Version 1.5 #
# Written by Craig Patchett craig@patchett.com #
# Created 7/25/96 Last Modified 3/14/97 #
# format_date() Version 1.5 #
# Written by Craig Patchett craig@patchett.com #
# Created 8/15/96 Last Modified 5/31/97 #
# #
# Copyright 1997 Craig Patchett & Matthew Wright. All Rights Reserved. #
# This program is part of The CGI/Perl Cookbook from John Wiley & Sons. #
# License to use this program or install it on a server (in original or #
# modified form) is granted only to those who have purchased a copy of The #
# CGI/Perl Cookbook. (This notice must remain as part of the source code.) #
# #
############################################################################
# Directories and URL's used by this script. These need changing for different environments.
# $ROOT_DIR is the full path to the root directory that FileSeek will look
# for files in. (Note that it should end with a directory delimiter.)
# $ROOT_DIR = '/wwwroot/essence/testexplore/'; # Path for Essence development
$ROOT_DIR = "/usr/ftp/incoming/storage/essence/testexplore/"; # Path for Essence ISP
# $ROOT_URL is the URL of the directory specified by $ROOT_DIR
# $ROOT_URL = 'http://127.0.0.1/testexplore/'; # Path for Essence development
$ROOT_URL = "http://www.essence.co.uk/essence/testexplore/"; # Path for Essence ISP
# $ICON_DIR and $FOLDER_DIR are relative path from your server's root directory, where the
# icons and foldertree script/applets will be kept. (Note that it should end
# with a forward slash.)
# $ICON_DIR = 'http://127.0.0.1/foldertree/'; # Path for Essence development
# $FOLDER_DIR = 'http://127.0.0.1/foldertree/'; # Path for Essence development
$ICON_DIR = 'http://www.essence.co.uk/essence/foldertree/'; # Path for Essence ISP
$FOLDER_DIR = 'http://www.essence.co.uk/essence/foldertree/'; # Path for Essence ISP
# $ROOT_NAME is the name of the root directory that will appear at the top of the tree.
# Can include some HTML formatting.
$ROOT_NAME = '<i><b>Exploring site</b></i>';
# %TYPES matches file types to the corresponding icon files. With the
# exception of 'directory' and 'binary' default file types, each file
# type corresponds to a filename extension.
%TYPES = ('parent', $ICON_DIR . 'parent.gif',
'directory', $ICON_DIR . 'ftfc.gif',
'binary', $ICON_DIR . 'binary.gif',
'txt', $ICON_DIR . 'text.gif',
'gif', $ICON_DIR . 'graphic.gif',
'jpg', $ICON_DIR . 'graphic.gif',
'jpeg', $ICON_DIR . 'graphic.gif',
'htm', $ICON_DIR . 'ftd.gif',
'html', $ICON_DIR . 'ftd.gif',
'pdf', $ICON_DIR . 'pdf.gif');
############################################################################
# Perform security and validity checks on directories and files #
############################################################################
# Set the directory delimiter based on $ROOT_DIR and make sure the
# different directory variables end or don't end with a delimiter as
# called for.
$DD = substr($ROOT_DIR, -1);
if ($DD !~ /[\/:]/) { die "\$ROOT_DIR must end with a directory delimiter. $!\n";}
# Change to root in case an invalid directory was specified
if (!$ROOT_DIR) { die "$ROOT_DIR has not been defined. $!\n" }
if (!(-d $ROOT_DIR)) { die "$ROOT_DIR is not a valid directory $!\n " }
if (!(-r $ROOT_DIR)) { die "$ROOT_DIR is not readable $!\n" }
#chdir($ROOT_DIR);
############################################################################
# Perform search or get directory listing #
############################################################################
# Generate the HTML header
print "Content-type: text/html\n\n";
# Insert the page header if specified
$ftstyle = $FOLDER_DIR . "ftstyle.css";
$ft = $FOLDER_DIR . "ft.js";
$ftoptions = $FOLDER_DIR . "ftoptions.js";
$ftbase = $FOLDER_DIR . "ftbase.htm";
$ftexplore = $FOLDER_DIR . "ftexplore.js";
$ftblank = $FOLDER_DIR . "ftblank.htm";
print <<END_HTML;
<html>
<head>
<link rel="stylesheet" href="$ftstyle">
<!-- Infrastructure code for the tree -->
<script language = "Javascript" src = "$ft"></script>
<script language = "Javascript" src = "$ftoptions"></script>
<script>
var styleSheetFile = "$ftstyle"
iconFolder = "$ICON_DIR"
ftFolder = "$FOLDER_DIR"
useTextLinks = 1
</script>
<script language = "Javascript" src = "$ftexplore"></script>
<script>
rootURL = "$ROOT_URL"
fT = gFld("$ROOT_NAME", "javascript:parent.drawTable(this.id)")
END_HTML
$directory = '';
&search("$ROOT_DIR", '', 0);
############################################################################
# Finish the HTML page #
############################################################################
print <<END_HTML;
</script>
</head>
<FRAMESET cols="200,*" onLoad="self.blank();">
<FRAME SRC = "$ftblank" name="menufrm" >
<FRAME SRC="$ftbase" name="basefrm">
</FRAMESET>
</HTML>
END_HTML
############################################################################
# Search subroutine #
############################################################################
sub search {
# Initialize
local($SEARCH_ROOT, $search_dir, $treelevel) = @_;
opendir LISTDIR, "$SEARCH_ROOT$search_dir" or die "Couldn't open dir: $SEARCH_ROOT$search_dir $!";
local (@filenames) = grep !/^\.\.?$/, readdir LISTDIR;
local($file);
# Scan directory & subdirectories
foreach $file (@filenames) {
$nextlevel = $treelevel + 1;
if (-d "$SEARCH_ROOT$search_dir$file" && -r "$SEARCH_ROOT$search_dir$file") {
if ($search_dir) {
$docobj = "aux$nextlevel";
print "aux$nextlevel = insFld(aux$treelevel, gFld('$file','javascript:parent.drawTable(this.id)'))\n";
$modify = $^T - int((-M "$SEARCH_ROOT$search_dir$file") * 24*60*60); # Modification date
print "$docobj.setUserDef('Modified','$modify')\n";
&search($SEARCH_ROOT, "$search_dir$file$DD", $treelevel + 1);
}
else {
$docobj = "aux1";
print "aux1 = insFld(fT, gFld('$file','javascript:parent.drawTable(this.id)'))\n";
$modify = $^T - int((-M "$SEARCH_ROOT$search_dir$file") * 24*60*60); # Modification date
print "$docobj.setUserDef('Modified','$modify')\n";
&search($SEARCH_ROOT, "$file$DD", $treelevel + 1) ;
}
}
elsif (-r "$SEARCH_ROOT$search_dir$file") {
if ($search_dir) {
$docobj = "aux$nextlevel";
print "aux$nextlevel = insDoc(aux$treelevel, gLnk('$file',''))\n";
}
else {
$docobj = "aux1";
print "aux1 = insDoc(fT, gLnk('$file',''))\n";
}
if ($treelevel eq 0) {print "$docobj.setUserDef('URL','$search_dir$file')\n";}
else {print "$docobj.setUserDef('URL','$search_dir$file')\n";}
$filesize = -s "$SEARCH_ROOT$search_dir$file" ;
print "$docobj.setUserDef('Size','$filesize')\n";
$modify = $^T - int((-M "$SEARCH_ROOT$search_dir$file") * 24*60*60); # Modification date
print "$docobj.setUserDef('Modified','$modify')\n";
$_ = $file;
tr/A-Z/a-z/;
if ((/\.([^.]+)$/) && $TYPES{$1}) { $filetype = $1}
elsif (-B "$SEARCH_ROOT$search_dir$file") { $filetype = 'binary' }
else { $filetype = 'txt'}
$filetypeo = $filetype . "o";
print "$docobj.setIcon('$filetype','$filetypeo')\n";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -