show.cgi
来自「Unix下基于Web的管理工具」· CGI 代码 · 共 54 行
CGI
54 行
#!/usr/local/bin/perl# show.cgi# Output some file for the browserrequire './file-lib.pl';&switch_acl_uid();use POSIX;$p = $ENV{'PATH_INFO'};if ($p =~ /\.([^\.\/]+)$/) { $ext = $1; &get_miniserv_config(\%miniserv); open(MIME, $miniserv{'mimetypes'}); while(<MIME>) { s/#.*//g; if (/(\S+)\s+(.*)/) { foreach $e (split(/\s+/, $2)) { if ($ext eq $e) { $type = $1; last; } } } } close(MIME); }if (!$type) { # No idea .. use the 'file' command if (`file "$p"` =~ /text|script/) { $type = "text/plain"; } else { $type = "application/octet-stream"; } }# Dump the fileif (!&can_access($p)) { print "Content-type: text/plain\n\n"; print &text('view_eaccess', $p),"\n"; }elsif (!open(FILE, $p)) { print "Content-type: text/plain\n\n"; print &text('view_eopen', $p, $!),"\n"; }else { @st = stat($p); print "Content-length: $st[7]\n"; print "Content-type: $type\n\n"; while(read(FILE, $buf, 1024)) { print $buf; } close(FILE); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?