diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-01-11 16:12:44 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2003-01-11 16:12:44 +0000 |
commit | bc0a1c71364fe141c6190d30fca321fb6ed115f5 (patch) | |
tree | d85947ee2bed5dd834c8704d008a8ce227c173e8 | |
parent | Bonus/README.eng: sync with Bonus/README (diff) | |
download | w3m-bc0a1c71364fe141c6190d30fca321fb6ed115f5.tar.gz w3m-bc0a1c71364fe141c6190d30fca321fb6ed115f5.zip |
[w3m-dev 03635] 2ch.cgi
* Bonus/2ch.cgi: added
* Bonus/README: update
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rwxr-xr-x | Bonus/2ch.cgi | 134 | ||||
-rw-r--r-- | Bonus/README | 11 | ||||
-rw-r--r-- | ChangeLog | 8 |
3 files changed, 152 insertions, 1 deletions
diff --git a/Bonus/2ch.cgi b/Bonus/2ch.cgi new file mode 100755 index 0000000..392fb22 --- /dev/null +++ b/Bonus/2ch.cgi @@ -0,0 +1,134 @@ +#!/usr/bin/perl + +$WGET = "wget"; +$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0; +$CGI = "file://$SCRIPT_NAME"; +$_ = $QUERY_STRING = $ENV{"QUERY_STRING"}; + +if (/subback.html$/) { + &subback(); + exit; +} + +s@(/\d+)(/([^/]*))?$@$1@ || exit; +$label = $3; +$cgi = "$CGI?$_"; +s@^http://([^/]+)/test/read.cgi/([^/]+)/@$1/$2/dat/@ || exit; +$subback = "$CGI?http://$1/$2/subback.html"; +$_ .= ".dat"; +$dat = "http://$_"; +$tmp = $ENV{"HOME"} . "/.w3m2ch/$_"; +$dat =~ s/([^\w\/.\:\-])/\\$1/g; +$tmp =~ s/([^\w\/.\:\-])/\\$1/g; +($dir = $tmp) =~ s@/[^/]+$@@; +$cmd = "mkdir -p $dir; $WGET -c -O $tmp $dat >/dev/null 2>&1"; +system $cmd; +$lines = (split(" ", `wc $tmp`))[0]; +$lines || exit; + +@ARGV = ($tmp); +if ($label =~ /^l(\d+)/) { + $start = $lines - $1 + 1; + if ($start < 1) { + $start = 1; + } + $end = $lines; +} elsif ($label =~ /^(\d+)-(\d+)/) { + $start = $1; + $end = $2; +} elsif ($label =~ /^(\d+)-/) { + $start = $1; + $end = $start + 100 - 1; +} elsif ($label =~ /^(\d+)/) { + $start = $1; + $end = $1; +} else { + $start = 1; + $end = $lines; +} +$head = "<a href=\"$subback\">■掲示板に戻る■</a>\n"; +$head .= "<a href=\"$cgi/\">全部</a>\n"; +for (0 .. ($lines - 1) / 100) { + $n = $_ * 100 + 1; + $head .= "<a href=\"$cgi/$n-\">$n-</a>\n"; +} +$head .= "<a href=\"$cgi/l50\">最新50</a>\n"; +print <<EOF; +Content-Type: text/html + +EOF +$i = 1; +while (<>) { + s/\r?\n$//; + ($name, $mail, $date, $_, $title) = split(/\<\>/); + if ($i == 1) { + if (!$title) { + print <<EOF; +このスレッドは過去ログ倉庫に格納されています。 +<p> +<a href="$QUERY_STRING">$QUERY_STRING</a> +EOF + unlink($tmp); + exit + } + print <<EOF; +<title>$title</title> +$head +<p>$title</p> +<dl> +EOF + } + if ($mail) { + $name = "<a href=\"mailto:$mail\">$name</a>"; + } + s@http://ime.nu/@http://@g; + s@(h?ttp:)([#-~]+)@"<a href=\"" . &link("http:$2") . "\">$1$2</a>"@ge; + s@(ftp:[#-~]+)@<a href="$1">$1</a>@g; + s@<a href="../test/read.cgi/\w+/\d+/@<a href="$cgi/@g; + if ($i == 1 || ($i >= $start && $i <= $end)) { + print <<EOF; +<dt><a name="$i">$i</a> :$name:$date +<dd> +$_ +<p> +EOF + } + $i++; +} +print <<EOF; +</dl> +<hr> +EOF + +sub link { + local($_) = @_; + if (m@/test/read.cgi/@) { + return "$CGI?$_"; + } + return $_; +} + +sub subback { + $dat = $_; + s@http://@@ || exit; + $tmp = $ENV{"HOME"} . "/.w3m2ch/$_"; + $dat =~ s/([^\w\/.\:\-])/\\$1/g; + $tmp =~ s/([^\w\/.\:\-])/\\$1/g; + ($dir = $tmp) =~ s@/[^/]+$@@; + $cmd = "mkdir -p $dir; $WGET -O $tmp $dat >/dev/null 2>&1"; + system $cmd; +print <<EOF; +Content-Type: text/html + +EOF + @ARGV = ($tmp); + while (<>) { + if (/<base href="([^"]+)"/) { + $base = $1; + } elsif ($base) { + s@^<a href="@<a href="$CGI?$base@; + } + print; + } + unlink($tmp); +} diff --git a/Bonus/README b/Bonus/README index 2b2b829..31615e7 100644 --- a/Bonus/README +++ b/Bonus/README @@ -1,3 +1,14 @@ +2ch.cgi + + [w3m-dev 03635] 2ch.cgi + 2ch 、ホ dat 、トセニノ、゚、ケ、 local CGI 、ヌ、ケ。」 + + w3m file:/cgi-bin/2ch.cgi?http://pc.2ch.net/test/read.cgi/unix/1035755937/ + + wget 、ホコケハャナセチ(-c)、サネ、、、゙、ケ。」 + ニノ、、タ dat 、マ ~/.w3m2ch/ ーハイシ、ヒハンツク、キ、゙、ケ。」 + ス、ュケ、゚、マ、ヌ、ュ、゙、サ、。」 + smb.cgi [w3m-dev 03634] smb.cgi @@ -1,3 +1,9 @@ +2003-01-12 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03635] 2ch.cgi + * Bonus/2ch.cgi: added + * Bonus/README: update + 2003-01-12 Fumitoshi UKAI <ukai@debian.or.jp> * Bonus/README.eng: sync with Bonus/README @@ -6388,4 +6394,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.676 2003/01/11 16:10:11 ukai Exp $ +$Id: ChangeLog,v 1.677 2003/01/11 16:12:44 ukai Exp $ |