⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chooser.cgi

📁 Unix下基于Web的管理工具
💻 CGI
字号:
#!/usr/local/bin/perl# chooser.cgi# Outputs HTML for a frame-based file chooser $icon_map = (	"c", "text.gif",		"txt", "text.gif",		"pl", "text.gif",		"cgi", "text.gif",		"html", "text.gif",		"htm", "text.gif",		"gif", "image.gif",		"jpg", "image.gif",		"tar", "binary.gif"		);require './web-lib.pl';&init_config();&ReadParse();if ($in{'file'} =~ /^(.*\/)([^\/]*)$/) { $dir = $1; $file = $2; }else { $dir = "/"; $file = ""; }if (!(-d $dir)) { $dir = "/"; $file = ""; }if ($in{'frame'} == 0) {	# base frame	&PrintHeader();	if ($in{'type'} == 0)		{ print "<title>$text{'chooser_title1'}</title>\n"; }	elsif ($in{'type'} == 1)		{ print "<title>$text{'chooser_title2'}</title>\n";}	print "<frameset rows='*,50'>\n";	print "<frame marginwidth=5 marginheight=5 name=topframe ",	     "src=\"chooser.cgi?frame=1&file=$in{'file'}&type=$in{'type'}\">\n";	print "<frame marginwidth=0 marginheight=0 name=bottomframe ",	      "src=\"chooser.cgi?frame=2&file=$in{'file'}&type=$in{'type'}\" ",	      "scrolling=no>\n";	print "</frameset>\n";	}elsif ($in{'frame'} == 1) {	# List of files in this directory	&header();		print <<EOF;<script>function fileclick(f, d){curr = top.frames[1].document.forms[0].elements[1].value;if (curr == f) {	// Double-click! Enter directory or select file	if (d) {		// Enter this directory		location = "chooser.cgi?frame=1&type=$in{'type'}&file="+f+"/";		}	else {		// Select this file and close the window		top.ifield.value = f;		top.close();		}	}else {	top.frames[1].document.forms[0].elements[1].value = f;	}}function parentdir(p){top.frames[1].document.forms[0].elements[1].value = p;location = "chooser.cgi?frame=1&type=$in{'type'}&file="+p;}</script>EOF	print "<b>",&text('chooser_dir', $dir),"</b>\n";	print "<table width=100%>\n";	opendir(DIR, $dir);	foreach $f (sort { $a cmp $b } readdir(DIR)) {		$path = "$dir$f";		if ($f eq ".") { next; }		if ($f eq ".." && $dir eq "/") { next; }		if (!(-d $path) && $in{'type'} == 1) { next; }		@st = stat($path);		print "<tr>\n";		$isdir = 0; undef($icon);		if (-d $path) { $icon = "dir.gif"; $isdir = 1; }		elsif ($path =~ /\.([^\.\/]+)$/) { $icon = $icon_map{$1}; }		if (!$icon) { $icon = "unknown.gif"; }		if ($f eq "..") {			$dir =~ /^(.*\/)[^\/]+\/$/;			$link = "<a href=\"\" onClick='parentdir(\"$1\"); return false'>";			}		else {			$link = "<a href=\"\" onClick='fileclick(\"$path\", $isdir); return false'>";			}		print "<td>$link<img border=0 src=/images/$icon></a></td>\n";		print "<td nowrap>$link$f</a></td>\n";		printf "<td nowrap>%s</td>\n",			$st[7] > 1000000 ? int($st[7]/1000000)." Mb" :			$st[7] > 1000 ? int($st[7]/1000)." Kb" :			$st[7];		@tm = localtime($st[9]);		printf "<td nowrap><tt>%.2d/%.2d/%.4d</tt></td>\n",			$tm[3], $tm[4]+1, $tm[5]+1900;		printf "<td nowrap><tt>%.2d:%.2d</tt></td>\n", $tm[1], $tm[2];		print "</tr>\n";		}	closedir(DIR);	print "</table>\n";	}elsif ($in{'frame'} == 2) {	# Current file and OK/cancel buttons	&header();	print <<EOF;<script>function filechosen(){top.ifield.value = document.forms[0].path.value;top.close();}</script>EOF	print "<table width=100%>\n";	print "<form onSubmit='filechosen(); return false'>\n";	print "<tr><td><input type=submit value=\"$text{'chooser_ok'}\"></td>\n";	print "<td align=right><input name=path size=45 value=\"$dir$file\"></td></tr>\n";	print "</form>\n";	print "</table>\n";	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -