📄 show.cgi
字号:
#!/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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -