[w3m-dev 03634] smb.cgi
* Bonus/smb.cgi: added * Bonus/README: update From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
This commit is contained in:
16
Bonus/README
16
Bonus/README
@@ -1,3 +1,19 @@
|
||||
smb.cgi
|
||||
|
||||
[w3m-dev 03634] smb.cgi
|
||||
SMB <20>˥<EFBFBD><CBA5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> local CGI <20>Ǥ<EFBFBD><C7A4><EFBFBD>
|
||||
nmblookup,smbclient <20><><EFBFBD>Ȥ<EFBFBD><C8A4>Τ<EFBFBD> sabma <20><><EFBFBD><EFBFBD><EFBFBD>ȡ<F3A5B9A5><C8A1>뤵<EFBFBD><EBA4B5><EFBFBD>Ƥ<EFBFBD><C6A4><EFBFBD>
|
||||
ɬ<>פ<EFBFBD><D7A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>
|
||||
<20>ѥ<EFBFBD><D1A5><EFBFBD>ɤϡ<C9A4>smbclient <20><> -A <20><><EFBFBD>ץ<EFBFBD><D7A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD><C8A4><EFBFBD><EFBFBD>ʤ顢
|
||||
smbclient -A ~/.w3m/smb <20>Ȥ<EFBFBD><C8A4>ơ<EFBFBD><C6A1>Ȥ<EFBFBD><C8A4>ʤ<EFBFBD><CAA4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ~/.w3m/smb <20><>
|
||||
<20>ɤ<EFBFBD><C9A4>ǴĶ<C7B4><C4B6>ѿ<EFBFBD> PASSWD <20><><EFBFBD>Ϥ<EFBFBD><CFA4>ޤ<EFBFBD><DEA4><EFBFBD>
|
||||
<20>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD>ˤ<EFBFBD><CBA4>衢<EFBFBD><E8A1A2><EFBFBD>ޤ<EFBFBD><DEA4>ɤ<EFBFBD><C9A4><EFBFBD><EFBFBD>ǤϤʤ<CFA4><CAA4>Τ<EFBFBD> SMB(CIFS)<29>ץ<EFBFBD><D7A5>ȥ<EFBFBD><C8A5><EFBFBD><EFBFBD><EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>˾<EFBFBD><CBBE>
|
||||
|
||||
google.cgi
|
||||
|
||||
[w3m-dev 03625] keymap key SEARCH string
|
||||
|
||||
html2latex
|
||||
|
||||
HTML<4D><4C>ʸ<EFBFBD><CAB8><EFBFBD><EFBFBD>LaTeX <20><><EFBFBD>Ѵ<EFBFBD><D1B4><EFBFBD><EFBFBD>ޤ<EFBFBD><DEA4><EFBFBD>Ruby<62><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ץȤǤ<C8A4><C7A4><EFBFBD><EFBFBD>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD>Ǥ<EFBFBD><C7A4><EFBFBD>
|
||||
|
397
Bonus/smb.cgi
Executable file
397
Bonus/smb.cgi
Executable file
@@ -0,0 +1,397 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Workgroup list: file:/$LIB/smb.cgi
|
||||
# Server list: file:/$LIB/smb.cgi?workgroup
|
||||
# Sahre list: file:/$LIB/smb.cgi?//server
|
||||
# Directory: file:/$LIB/smb.cgi?//server/share
|
||||
# file:/$LIB/smb.cgi?//server/share/dir...
|
||||
# Get file: file:/$LIB/smb.cgi?//server/share/dir.../file
|
||||
#
|
||||
# ----- ~/.w3m/smb -----
|
||||
# workgroup = <workgroup>
|
||||
# username = <username>
|
||||
# password = <password>
|
||||
# ----------------------
|
||||
|
||||
$DEBUG = 1;
|
||||
|
||||
$MIME_TYPE = "~/.mime.types";
|
||||
$AUTH_FILE = "~/.w3m/smb";
|
||||
$MIME_TYPE =~ s@^~/@$ENV{"HOME"}/@;
|
||||
$AUTH_FILE =~ s@^~/@$ENV{"HOME"}/@;
|
||||
$WORKGROUP = "-";
|
||||
$USER = $ENV{"USER"};
|
||||
$PASSWD = $ENV{"PASSWD"};
|
||||
&load_auth_file($AUTH_FILE);
|
||||
|
||||
$NMBLOOKUP = "nmblookup";
|
||||
$SMBCLIENT = "smbclient";
|
||||
@NMBLOOKUP_OPT = ("-T");
|
||||
@SMBCLIENT_OPT = ("-N");
|
||||
$USE_OPT_A = &check_opt_a();
|
||||
if ($USE_OPT_A) {
|
||||
undef $USER;
|
||||
undef $PASSWD;
|
||||
push(@SMBCLIENT_OPT, "-A", $AUTH_FILE);
|
||||
}
|
||||
$PAGER = "cat";
|
||||
$FILE = "F000";
|
||||
|
||||
$CGI = "file://" . &file_encode($ENV{"SCRIPT_NAME"} || $0);
|
||||
$QUERY = $ENV{"QUERY_STRING"};
|
||||
|
||||
$_ = &file_decode($QUERY);
|
||||
$DEBUG && print "DEBUG: QUERY_STRING=\"$_\"\n";
|
||||
if (s@^//([^/]+)@@) {
|
||||
$server = $1;
|
||||
if (s@^/([^/]+)@@) {
|
||||
&file_list("//$server/$1", &cleanup($_));
|
||||
} else {
|
||||
&share_list($server);
|
||||
}
|
||||
} elsif (m@^[^/]@) {
|
||||
&server_list($_);
|
||||
} else {
|
||||
&group_list();
|
||||
}
|
||||
|
||||
sub file_list {
|
||||
local($service, $file) = @_;
|
||||
local(@files) = ();
|
||||
local($dir, $qservice, $qfile);
|
||||
local($_, $c);
|
||||
|
||||
$DEBUG && print "DEBUG: service=\"$service\" file=\"$file\"\n";
|
||||
if ($file eq "/") {
|
||||
goto get_list;
|
||||
}
|
||||
$_ = $file;
|
||||
s@/@\\@g;
|
||||
@cmd = ($SMBCLIENT, $service, @SMBCLIENT_OPT, "-c", "ls \"$_\"");
|
||||
$F = &open_pipe(1, @cmd);
|
||||
while (<$F>) {
|
||||
$DEBUG && print "DEBUG: $_";
|
||||
/^\s/ && last;
|
||||
}
|
||||
close($F);
|
||||
if (s/\s+([A-Z]*) {1,8}\d+ (\w{3} ){2}[ \d]\d \d\d:\d\d:\d\d \d{4}\s*$//
|
||||
&& $1 !~ /D/) {
|
||||
&get_file($service, $file);
|
||||
exit;
|
||||
}
|
||||
|
||||
get_list:
|
||||
$_ = "$file/*";
|
||||
s@/+@\\@g;
|
||||
@cmd = ($SMBCLIENT, $service, @SMBCLIENT_OPT, "-c", "ls \"$_\"");
|
||||
$F = &open_pipe(1, @cmd);
|
||||
while (<$F>) {
|
||||
/^\s*$/ && last;
|
||||
$DEBUG && print "DEBUG: $_";
|
||||
/^cd\s+/ && last;
|
||||
/^\S/ && next;
|
||||
s/\r?\n//;
|
||||
push(@files, $_);
|
||||
}
|
||||
close($F);
|
||||
|
||||
$qservice = &html_quote($service);
|
||||
$service = &file_encode($service);
|
||||
$qfile = &html_quote($file);
|
||||
$file = &file_encode($file);
|
||||
|
||||
print "Content-Type: text/html\n\n";
|
||||
print "<title>$qservice$qfile</title>\n";
|
||||
print "<b>$qservice$qfile</b>\n";
|
||||
print "<pre>\n";
|
||||
for (sort @files) {
|
||||
s/\s+([A-Z]*) {1,8}\d+ (\w{3} ){2}[ \d]\d \d\d:\d\d:\d\d \d{4}\s*$// || next;
|
||||
$c = $&;
|
||||
s/^ //;
|
||||
$_ eq "." && next;
|
||||
print "<a href=\"$CGI?$service"
|
||||
. &cleanup("$file/" . &file_encode($_)) . "\">"
|
||||
. &html_quote($_) . "</a>"
|
||||
. &html_quote($c) . "\n";
|
||||
}
|
||||
print "</pre>\n";
|
||||
}
|
||||
|
||||
sub get_file {
|
||||
local($service, $file) = @_;
|
||||
local($encoding, $type);
|
||||
local($_, @cmd);
|
||||
|
||||
$_ = $file;
|
||||
s@/@\\@g;
|
||||
@cmd = ($SMBCLIENT, $service, @SMBCLIENT_OPT, "-E", "-c", "more \"$_\"");
|
||||
$DEBUG && print "DEBUG: @cmd\n";
|
||||
|
||||
($encoding, $type) = &guess_type($file);
|
||||
$file =~ s@^.*/@@;
|
||||
$| = 1;
|
||||
print "Content-Encoding: $encoding\n" if $encoding;
|
||||
print "Content-Type: $type; name=\"$file\"\n\n";
|
||||
|
||||
$ENV{"PAGER"} = $PAGER if $PAGER;
|
||||
&exec_cmd(1, @cmd);
|
||||
}
|
||||
|
||||
sub share_list {
|
||||
local($server) = @_;
|
||||
local(@share);
|
||||
local($qserver, $_, $d, @c);
|
||||
|
||||
@share = &get_list(1, $server, "Share");
|
||||
|
||||
$qserver = &html_quote($server);
|
||||
$server = &file_encode($server);
|
||||
|
||||
print "Content-Type: text/html\n\n";
|
||||
print "<title>Share list: $qserver</title>\n";
|
||||
print "<table>\n";
|
||||
print "<tr><td colspan=3><b>$qserver</b>";
|
||||
for (sort @share) {
|
||||
($_, $d, @c) = split(" ");
|
||||
if ($d eq 'Disk') {
|
||||
print "<tr><td>+ <a href=\"$CGI?//$server/"
|
||||
. &file_encode($_) . "\">"
|
||||
. &html_quote($_) . "</a>";
|
||||
} else {
|
||||
print "<tr><td>+ "
|
||||
. &html_quote($_);
|
||||
}
|
||||
print "<td><td>"
|
||||
. &html_quote($d) . "<td><td>"
|
||||
. &html_quote("@c") . "\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
sub server_list {
|
||||
local($group) = @_;
|
||||
local($master, @server);
|
||||
local($_, @c);
|
||||
|
||||
$master = &get_master($group);
|
||||
@server = &get_list(0, $master, "Server");
|
||||
|
||||
$group = &html_quote($group);
|
||||
|
||||
print "Content-Type: text/html\n\n";
|
||||
print "<title>Server list: $group</title>\n";
|
||||
print "<table>\n";
|
||||
print "<tr><td colspan=3><b>$group</b>\n";
|
||||
for (sort @server) {
|
||||
($_, @c) = split(" ");
|
||||
print "<tr><td>+ <a href=\"$CGI?//"
|
||||
. &file_encode($_) . "\">"
|
||||
. &html_quote($_) . "</a><td><td>"
|
||||
. &html_quote("@c") . "\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
sub group_list {
|
||||
local($master, @group);
|
||||
local($_, @c);
|
||||
|
||||
$master = &get_master($WORKGROUP || "-");
|
||||
@group = &get_list(0, $master, "Workgroup");
|
||||
|
||||
print "Content-Type: text/html\n\n";
|
||||
print "<title>Workgroup list</title>\n";
|
||||
print "<table>\n";
|
||||
for (sort @group) {
|
||||
($_, @c) = split(" ");
|
||||
print "<tr><td><a href=\"$CGI?"
|
||||
. &file_encode($_) . "\">"
|
||||
. &html_quote($_) . "</a><td><td>"
|
||||
. &html_quote("@c") . "\n";
|
||||
}
|
||||
print "</table>\n";
|
||||
}
|
||||
|
||||
sub check_opt_a {
|
||||
local($_, $F, @cmd);
|
||||
|
||||
@cmd = ($SMBCLIENT, "-h");
|
||||
$F = &open_pipe(0, @cmd);
|
||||
while (<$F>) {
|
||||
if (/^\s*-A\s/) {
|
||||
$DEBUG && print "DEBUG: $_";
|
||||
close($F);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
close($F);
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub get_master {
|
||||
local($group) = @_;
|
||||
local($_, $F, @cmd);
|
||||
|
||||
@cmd = ($NMBLOOKUP, "-M", @NMBLOOKUP_OPT, $group);
|
||||
$F = &open_pipe(0, @cmd);
|
||||
$_ = <$F>;
|
||||
$_ = <$F>;
|
||||
close($F);
|
||||
($_) = split(/[,\s]/);
|
||||
s/\.*$//;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub get_list {
|
||||
local($passwd, $server, $header) = @_;
|
||||
local(@list) = ();
|
||||
local($_, @cmd, $F);
|
||||
|
||||
@cmd = ($SMBCLIENT, @SMBCLIENT_OPT, "-L", $server);
|
||||
$F = &open_pipe($passwd, @cmd);
|
||||
while (<$F>) {
|
||||
/^\s*$header/ && last;
|
||||
}
|
||||
$DEBUG && print "DEBUG: $_";
|
||||
while (<$F>) {
|
||||
/^\s*$/ && last;
|
||||
$DEBUG && print "DEBUG: $_";
|
||||
/^\S/ && last;
|
||||
/^\s*-/ && next;
|
||||
push(@list, $_);
|
||||
}
|
||||
close($F);
|
||||
return @list;
|
||||
}
|
||||
|
||||
sub open_pipe {
|
||||
local($passwd, @cmd) = @_;
|
||||
local($F) = $FILE++;
|
||||
|
||||
$DEBUG && print "DEBUG: @cmd\n";
|
||||
open($F, "-|") || &exec_cmd($passwd, @cmd);
|
||||
return $F;
|
||||
}
|
||||
|
||||
sub exec_cmd {
|
||||
local($passwd, @cmd) = @_;
|
||||
|
||||
$ENV{"LC_ALL"} = "C";
|
||||
if (!$USE_OPT_A && $passwd) {
|
||||
$ENV{"USER"} = $USER if $USER;
|
||||
$ENV{"PASSWD"} = $PASSWD if $PASSWD;
|
||||
}
|
||||
open(STDERR, ">/dev/null");
|
||||
exec @cmd;
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub print_form {
|
||||
print <<EOF;
|
||||
<form action="$CGI" method=POST>
|
||||
<table>
|
||||
<tr><td>Workgroup <td>User <td>Password
|
||||
<tr><td><input type=text size=8 name=group value="$WORKGROUP">
|
||||
<td><input type=text size=8 name=user value="$USER">
|
||||
<td><input type=password size=8 name=passwd value="$PASSWD">
|
||||
<td><input type=submit name=OK value=OK>
|
||||
</table>
|
||||
</form>
|
||||
EOF
|
||||
}
|
||||
|
||||
sub load_auth_file {
|
||||
local($_) = @_;
|
||||
|
||||
if ($USER =~ s/%(.*)$//) {
|
||||
$PASSWD = $1 unless $PASSWD;
|
||||
}
|
||||
open(F, $_) || return;
|
||||
while (<F>) {
|
||||
s/\s+$//;
|
||||
if (s/^workgroup\s*=\s*//i) {
|
||||
$WORKGROUP = $_;
|
||||
} elsif (s/^user(name)?\s*=\s*//i) {
|
||||
$USER = $_;
|
||||
} elsif (s/^passw(or)?d\s*=\s*//i) {
|
||||
$PASSWD = $_;
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
}
|
||||
|
||||
sub load_mime_type {
|
||||
local($_) = @_;
|
||||
local(%mime) = ();
|
||||
local($type, @suffix);
|
||||
|
||||
open(F, $_) || return ();
|
||||
while(<F>) {
|
||||
/^#/ && next;
|
||||
chop;
|
||||
(($type, @suffix) = split(" ")) >= 2 || next;
|
||||
for (@suffix) {
|
||||
$mime{$_} = $type;
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
return %mime;
|
||||
}
|
||||
|
||||
sub guess_type {
|
||||
local($_) = @_;
|
||||
local(%mime) = &load_mime_type($MIME_TYPE);
|
||||
local($encoding) = undef;
|
||||
|
||||
if (s/\.gz$//i) {
|
||||
$encoding = "gzip";
|
||||
} elsif (s/\.Z$//i) {
|
||||
$encoding = "compress";
|
||||
} elsif (s/\.bz2?$//i) {
|
||||
$encoding = "bzip2";
|
||||
}
|
||||
/\.(\w+)$/;
|
||||
$_ = $1;
|
||||
tr/A-Z/a-z/;
|
||||
return ($encoding, $mime{$_} || "text/plain");
|
||||
}
|
||||
|
||||
sub cleanup {
|
||||
local($_) = @_;
|
||||
|
||||
$_ .= "/";
|
||||
s@//+@/@g;
|
||||
s@/\./@/@g;
|
||||
while(m@/\.\./@) {
|
||||
s@^/(\.\./)+@/@;
|
||||
s@/[^/]+/\.\./@/@;
|
||||
}
|
||||
s@(.)/$@$1@;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub file_encode {
|
||||
local($_) = @_;
|
||||
s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub file_decode {
|
||||
local($_) = @_;
|
||||
s/\+/ /g;
|
||||
s/%([\da-f][\da-f])/pack('C', hex($1))/egi;
|
||||
s@[\r\n\0\\"]@@g;
|
||||
return $_;
|
||||
}
|
||||
|
||||
sub html_quote {
|
||||
local($_) = @_;
|
||||
local(%QUOTE) = (
|
||||
'<', '<',
|
||||
'>', '>',
|
||||
'&', '&',
|
||||
'"', '"',
|
||||
);
|
||||
s/[<>&"]/$QUOTE{$&}/g;
|
||||
return $_;
|
||||
}
|
@@ -1,3 +1,9 @@
|
||||
2003-01-12 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
|
||||
|
||||
* [w3m-dev 03634] smb.cgi
|
||||
* Bonus/smb.cgi: added
|
||||
* Bonus/README: update
|
||||
|
||||
2003-01-12 Fumitoshi UKAI <ukai@debian.or.jp>
|
||||
|
||||
* ftp.c (ftp_pasv): ftp_command response
|
||||
@@ -6378,4 +6384,4 @@ a * [w3m-dev 03276] compile error on EWS4800
|
||||
* release-0-2-1
|
||||
* import w3m-0.2.1
|
||||
|
||||
$Id: ChangeLog,v 1.674 2003/01/11 16:00:55 ukai Exp $
|
||||
$Id: ChangeLog,v 1.675 2003/01/11 16:05:17 ukai Exp $
|
||||
|
Reference in New Issue
Block a user