七行プログラミング (452レス)
七行プログラミング http://medaka.5ch.net/test/read.cgi/php/1036141603/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
69: nobodyさん [sage] 02/11/21 22:40 ID:??? 間違えた・・ s|\b([A-Z][a-z]+){2,}\b|a{href=>"7wiki.cgi?$1"},$1|ge; http://medaka.5ch.net/test/read.cgi/php/1036141603/69
70: nobodyさん [sage] 02/11/21 22:52 ID:??? 括弧わすれてた・・・ゴメン(再び修正 \b(([A-Z][a-z]+){2,})\b http://medaka.5ch.net/test/read.cgi/php/1036141603/70
71: nobodyさん [sage] 02/11/22 07:28 ID:??? use CGI':all';use SDBM_File;$i='7wiki.cgi';$j=$ENV{QUERY_STRING}||'FrontPage'; tie%D,'SDBM_File',$i,258,438or die;$_=$D{$j}=param('m')||$D{$j};untie%D;put header,startform('post',"$i?$j"),submit,b($j),br,textarea('m',$_,6,60),endform ,hr;$_=escapeHTML$_;s|\b(([A-Z][a-z]+){2,})\b|a{href=>"$i?$1"},$1|ge;put$_ http://medaka.5ch.net/test/read.cgi/php/1036141603/71
72: nobodyさん [sage] 02/11/22 14:36 ID:??? Good job. http://medaka.5ch.net/test/read.cgi/php/1036141603/72
73: nobodyさん [sage] 02/11/22 18:30 ID:??? 折角なので副産物も(ワンライナーだけど れぎゅれーしょん ちぇっか usage: ./7rc.pl < target_script.pl #! perl -nw chomp;length>79||$.>7?die:print"line $. OK\n" http://medaka.5ch.net/test/read.cgi/php/1036141603/73
74: nobodyさん [sage] 02/11/24 15:39 ID:??? >>71 use Fcntl; はいらないのか? http://medaka.5ch.net/test/read.cgi/php/1036141603/74
75: nobodyさん [sage] 02/11/24 17:47 ID:??? use Fcntl; O_CREAT|O_RDWR を纏めて 286(tie の引数 定数部分は環境依存するかも知れないので /usr/include/sys/fcntl.h を参照 http://medaka.5ch.net/test/read.cgi/php/1036141603/75
76: nobodyさん [sage] 02/11/25 00:58 ID:??? DB_File なら use した時点で O_CREAT も O_RDWR も使えるようになる罠。 use DB_File; print join '/', O_CREAT => O_CREAT, O_RDWR => O_RDWR; そして O_CREAT は実際 512 だったり 256 だったりする罠。 http://medaka.5ch.net/test/read.cgi/php/1036141603/76
77: nobodyさん [sage] 02/11/25 06:28 ID:??? 余った行で僅かばかり実用的にしてみる。 #!/usr/local/bin/perl -w use CGI qw(:all escapeHTML);use DB_File;$j=$ENV{QUERY_STRING}||'FrontPage';($f) =$0=~m|([^/]+)(\.cgi)$|;open(L,'+<&='.($d=tie%D,'DB_File',$f,O_CREAT|O_RDWR or die)->fd)||die;eval{flock L,2};$_=escapeHTML($m=$D{$j}=param('m')||$D{$j});$d-> sync;$d=untie%D;s/\b(([A-Z][a-z]+){2,})/a{href=>"$f.cgi?$1"},$1/ge;s/\x0d\x0a| \x0d|\x0a/<br>/gx;put header,title("$f - $j"),startform('post',"$f.cgi?$j"), submit,b($j),br,textarea('m',$m,6,60),endform,hr,$_ 陽に輸入してやらないと上のタイミングで escapeHTML 使えなかったよ。 (FreeBSD 4.7R, Perl 5.005_03, CGI.pm 2.89) http://medaka.5ch.net/test/read.cgi/php/1036141603/77
78: nobodyさん [sage] 02/11/25 23:38 ID:??? #! perl use CGI':all';$w='\b(([A-Z][a-z]+){2,})';($p)=($ENV{QUERY_STRING}||'FrontPage') =~/$w/;$f='7wiki.cgi';$o=-f$p?'<':'>';open F,"+$o$p"or die;eval{flock F,2};read F,$m,-s$p;$_=escapeHTML($m=param('m')||$m);seek F,0,0;print F $m;close F;$_.=hr .ul map{li"".localtime time-86400*-M," $_"}sort{-M$a<=>-M$b}grep{/^$w$/}glob"*" ;s/$w/a{href=>"$f?$1"},$1/ge;put header,start_html($p),h1($p),startform('post', "$f?$p"),textarea('m',$m,6,60),br,submit,endform,hr,pre($_),end_html 一覧を付けてみた・・・(残り:1行と10字 :all tag で全部輸入できなかった?:html2 とかでも無理かな? http://medaka.5ch.net/test/read.cgi/php/1036141603/78
79: nobodyさん [sage] 02/11/26 00:26 ID:??? < $_=escapeHTML($m=param('m')||$m);seek F,0,0;print F $m; > $_=escapeHTML $m=param('m')||$m;seek F,0,0;print F$m; http://medaka.5ch.net/test/read.cgi/php/1036141603/79
80: nobodyさん [sage] 02/11/26 00:30 ID:??? < .ul map{li"".localtime time-86400*-M," $_"}sort{-M$a<=>-M$b}grep{/^$w$/}glob"*" > .ul map{li"".localtime time-86400*-M,$_}sort{-M$a<=>-M$b}grep{/^$w$/}glob"*" http://medaka.5ch.net/test/read.cgi/php/1036141603/80
81: 74 [sage] 02/11/26 00:51 ID:??? >>75 勉強になりました。 http://medaka.5ch.net/test/read.cgi/php/1036141603/81
82: nobodyさん [sage] 02/11/26 01:21 ID:??? use CGI':all';$w='\b(([A-Z][a-z]+){2,})';($p)=($ENV{QUERY_STRING}||FrontPage)=~ /$w/;$f=script_name;open(F,'+'.(-f$p?'<':'>').$p)||die;eval{flock F,2};read F,$ m,-s$p;$_=escapeHTML$m=param(z)||$m;seek F,0,0;print F$m;close F;$_.=hr.ul map{ li"".localtime time-86400*-M,$_}sort{-M$a<=>-M$b}grep{/$w$/}glob'*';s/$w/a{href =>"$f?$1"},$1/ge;put header,start_html($p),h1($p),startform(0,"$f?$p"),textarea (z,$m,6,60),br,submit,endform,hr,pre($_),end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/82
83: nobodyさん [sage] 02/11/26 04:49 ID:??? >>78 ごめん、CGI.pm 2.89 置いたパスを use lib し忘れたままテストしてた。 5.005_03 同梱のは 2.46 で、この辺だと escapeHTML はどのタグにも 含まれてない。submit() を呼んだ時点で main に定義されるのかな。 #! perl use CGI':all';$f=script_name;$w='\b(([A-Z][a-z]+){2,})';($p)=($ENV{QUERY_STRING }||FrontPage)=~/$w/;open(F,-f$p?"+<$p":"+>$p")||die;eval{flock F,2};$/=();$_= escapeHTML$m=param(z)||<F>;truncate F,0;seek F,0,0;print F$m;close F;$_=join hr ,endform,pre($_),ul map{li localtime((stat$_)[9])." $_"}sort{-M$a<=>-M$b}grep /$w$/,<*>;s/$w/a{href=>"$f?$1"},$1/eg;put header,start_html($p),startform(0, "$f?$p"),h1($p),textarea(z,$m,6,60),br,submit,$_,end_html 1 byte 長くなった。むぅ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/83
84: nobodyさん [sage] 02/11/26 06:11 ID:??? 書き忘れたけど、78-82 はWin/ActivePerlで作ってました。 他の環境に移したら CGI.pm 2.56 で同様のエラーが出たので パッケージ名をつけてCGI::escapeHTMLで対応。 もしくは、モジュールを新しくする。でいいかな>対策 NOTE QUERY_STRING を PATH_INFO に変更して url の区切りを ? -> / に。 # 勿論、 s/// のスラッシュも他の記号に変更する。 (stat)[9] BUG ページ読むだけでも書き込みしてるので タイムスタンプが。。 http://medaka.5ch.net/test/read.cgi/php/1036141603/84
85: nobodyさん [sage] 02/11/26 22:06 ID:??? >>84 パッケージ名付けた方が優しいかな。> escapeHTML タイムスタンプのバグフィクス版。以下の環境で動作。 ・Perl 5.005_03, CGI.pm 2.46 ・Win98SE, AN-HTTPD 1.41g ・FreeBSD 4.7R, Apache/1.3.27 #!/usr/local/bin/perl use CGI':all';$w='\b(([A-Z][a-z]+){2,})';($p)=($ENV{PATH_INFO}||FrontPage)=~/$w /x;if(open F,($m=param z)?">$p":$p){eval{flock F,2};$/=();$_=CGI::escapeHTML($m ||=<F>);truncate F,0;seek F,0,0;print F$m;close F}opendir D,'./';$_=join hr, endform,pre($_),ul map{li localtime((stat)[9])." $_"}sort{-M$a<=>-M$b}grep/$w$/ ,readdir D;$f=script_name;s|$w|a{href=>"$f/$1"},$1|eg;put header,start_html($p) ,startform(0,"$f/$p"),h1($p),textarea(z,$m,6,60),br,submit,$_,end_html AN-HTTPD だとグロブ効かなかったので readdir に変更。 i-httpd だと PATH_INFO 使えなかったけど、まぁこれは 少数派という事で。あともしかしたら MacPerl が truncate で引っかかるやも。 http://medaka.5ch.net/test/read.cgi/php/1036141603/85
86: nobodyさん [sage] 02/11/27 00:19 ID:??? CGI.pm 2.752, perl 5.005_03 build for sun4-solaris Apache 1.3.27 #! perl -w use CGI':all';$w='\b(([A-Z][a-z]+){2,})';$f=script_name;$/=();($p)=(path_info|| FrontPage)=~/$w/;opendir D,'.';if(open F,($m=param z)?">$p":$p){eval{flock F,2} ;$_=CGI::escapeHTML$m||=<F>;eval{truncate F,0};seek F,0,0;print F$m;close F}$_. =hr.ul((map{li"".localtime((stat)[9]),$_}sort{-M$a<=>-M$b}grep/$w$/,readdir D)[ 0..9]);s|$w|a{href=>"$f/$1"},$1|eg;put header,start_html$p),h1($p),startform(0 ,"$f/$p"),textarea(z,$m,6,60),br,submit,endform,pre($_),end_html 一覧の表示数制限機能追加。 truncate は eval で対応できるかな?>MacPerl http://medaka.5ch.net/test/read.cgi/php/1036141603/86
87: nobodyさん [sage] 02/11/27 01:56 ID:??? #! perl -w use CGI':all';$w='\b(([A-Z][a-z]+){2,})';$/=();($p)=(path_info||FrontPage)=~/$w /x;$f=script_name."/";opendir D,'.';if(open F,($m=param z)?">$p":$p){eval{flock F,2};$_=CGI::escapeHTML$m||=<F>;eval{truncate F,0};seek F,0,0;print F$m;close F }$_.=hr.ul((map{li"".localtime((stat)[9]),$_}sort{-M$a<=>-M$b}grep/$w$/,readdir D)[0..14]);s|$w|a{href=>$f.$1},$1|eg;put header,start_html($p),h1($p),startform (0,$f.$p),textarea(z,$m,6,60),br,submit,endform,pre($_),end_html -1byte http://medaka.5ch.net/test/read.cgi/php/1036141603/87
88: nobodyさん [sage] 02/11/27 06:40 ID:??? #! perl -w use CGI':all';@c=qw/white eeeeff/;$d=0;$e=path_info();$f=script_name;*p=*param; $h=DELETE;$i=RENAME;$j=COPY;$k=FILES;opendir D,"./$e";if(p$h){unlink p$k}put header,start_html('7files'),startform(0,$t),table(Tr([th({bgcolor=>ddddff},['', qw/Name Size LastModified/]),(map{td({bgcolor=>$c[$d++%2]},[checkbox($k,0,$_,'' ),g($_)." ".a({href=>"$f/$_"},$_),-s,"".localtime((stat)[9])])}sort{$a cmp $b} grep/^[^.]/,readdir D)])),(map{submit$_}($i,$j,$h)),endform,end_html;sub g{$t= -d$_[0]?'folder':'text';img{src=>"/icons/$t.gif",alt=>$t}} ファイル削除 CgI あぱっち用 RENAME と COPY は未実装。もうちょっと痩せないとなぁ・・ WikiName のリンク処理(存在しないページのリンクは?に。 s|$w|(-f$1?'':$1).a{href=>$f.$1},-f$1?$1:'?'|eg; http://medaka.5ch.net/test/read.cgi/php/1036141603/88
89: nobodyさん [sage] 02/11/27 08:37 ID:??? 検索エンジン <? fopen("http://www.yahoo.co.jp");?> http://medaka.5ch.net/test/read.cgi/php/1036141603/89
90: nobodyさん [sage] 02/11/27 09:55 ID:??? >>89 Warning: fopen() expects at least 2 parameters, 1 given in ... http://medaka.5ch.net/test/read.cgi/php/1036141603/90
91: nobodyさん [sage] 02/11/27 20:42 ID:??? 7wiki.cgi 、一旦まとめ。(w #! perl use CGI':all';$w='\b(([A-Z][a-z]+){2,})';($p)=(path_info||FrontPage)=~/$w/;$/=( );$f=script_name."/";opendir D,".";if(open F,($m=param z)?">$p":$p){eval{flock F,2};$_=CGI::escapeHTML($m||=<F>);eval{truncate F,0};seek F,0,0;print F$m;close F}$_=pre($_).hr.ul map{li"".localtime((stat)[9]),$_}sort{-M$a<=>-M$b}grep/$w$/, readdir D;s|$w|(!-f$1&&$1).a{href,$f.$1},-f$1?$1:"?"|eg;put header,start_html( $p),h1($p),startform(0,$f.$p),textarea(z,$m,6,60),br,submit,endform,$_,end_html ・bare word が存在するので perl -w は不可。 ・古い CGI.pm は escapeHTML を輸出しないので括弧が必要。 http://medaka.5ch.net/test/read.cgi/php/1036141603/91
92: nobodyさん [sage] 02/11/28 03:13 ID:??? use CGI':all';$w='\b(([A-Z][a-z]+){2,})';$f=script_name."/";opendir D,".";$/=() ;($p)=(path_info||FrontPage)=~/$w/;if(open F,($m=param z)?">$p":$p){eval{flock F,2};$_=submit.endform.hr.pre CGI::escapeHTML($m||=<F>);eval{truncate F,0};seek F,0,0;print F$m;close F}$_=br.$_.hr.ul map{li"".localtime((stat)[9]),$_}sort{-M $a<=>-M$b}grep/$w$/,readdir D;s|$w|(!-f$1&&$1).a{href,$f.$1},-f$1?$1:"?"|eg;put header,start_html($p),h1($p),startform(0,$f.$p).textarea(z,$m,6,60),$_,end_html -w は >>86 の環境では付けないとCGIとして動かなかったんだけど・・ どうしてだろう?z maybe crash って warning 出すのはわかっていたけど ちゃんと動いていたような気がする。(エラーログ今度ちゃんと見て来よう。 TextRule に Pod::Htmlを使おうとしたが、 pod2html はファイルを対象としているため実装を断念。 残り一行じゃ TextRuleは辛いかな・・URLのリンクくらいなら追加出来そう・・? http://medaka.5ch.net/test/read.cgi/php/1036141603/92
93: nobodyさん [sage] 02/11/28 03:23 ID:??? あっ バグ・・・今気付いた。 open が失敗した時困るかな >>92 http://medaka.5ch.net/test/read.cgi/php/1036141603/93
94: nobodyさん [sage] 02/11/28 05:30 ID:??? >>88 アイコンと th 無くして、あと目に付いたトコだけザッと。 #! perl -w use CGI':all';*p=*param;$d=path_info;$t=opendir D,".$d";$F=F;($c=$f=script_name )=~s|/[^/]+$||;$R=REN;$C=CP;$D=DEL;p$D&&unlink p$F;put header,start_html(7files ),startform(0,$f),table(Tr[map{$i="$d/$_";($l,$s)=-d".$i"?($f.$i,'DIR'):($c.$i, -s _);td({bgcolor,(white,eeeeff)[$t++%2]},[checkbox($F,0,$_,''),a({href,$l},$_) ,$s,"".localtime((stat)[9])])}sort grep!/^\./,readdir D]),(map{submit$_}$R,$C, $D),endform,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/94
95: nobodyさん [sage] 02/11/28 05:55 ID:??? >>94 修正…。 use CGI':all';($c=$f=script_name)=~s|/[^/]+$||;$d=path_info;$t=opendir D,".$d"; $F=F;$M=MV;$C=CP;$R=RM;*p=*param;p$D&&unlink p$F;put header,start_html('7files' ),startform(0,$f),table(Tr[map{$i="$d/$_";($l,$s)=-d".$i"?($f.$i,'DIR'):($c.$i, -s _);td({bgcolor,(white,eeeeff)[$t++%2]},[checkbox($F,0,$_,''),a({href,$l},$_) ,$s,"".localtime((stat)[9])])}sort grep!/^\./,readdir D]),(map{submit$_}$M,$C, $R),endform,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/95
96: nobodyさん [sage] 02/11/28 06:10 ID:??? >>92 成る程、そういう環境もありますか。 warning 吐きまくるのはヤだなぁと思っただけなんで、 shebang line は適宜変更でいいですかのぅ。 つか valid な HTML にはあまりこだわってませんか。 URL リンクはこうかな…。 s|(http://[\w!#-;=?-@~]+)|a{href,$1},$1|eg; >>93 困りました。:) http://medaka.5ch.net/test/read.cgi/php/1036141603/96
97: nobodyさん [sage] 02/11/28 11:46 ID:??? >困りました。:) ごめん。パズルに夢中でperl -cしかチェックしてなかったw 書きこみ、 新規ページ作成 テスト、以後気を付けます。テスト書こうっと HTMLの構文チェックもしてません。出力はCGI.pm任せなので、 少なくともwelformedにはなってるはずだけど・・ 7wiki.cgi 6行76桁 use CGI':all';$w='\b(([A-Z][a-z]+){2,})';$/=();$f=script_name;($p)=(path_info|| FrontPage)=~/$w/;opendir D,".";if(open F,($m=param z)?">$p":$p){eval{flock F,2} ;eval{truncate F,0};seek F,0,0;print F$m||=<F>;close F}$_=pre CGI::escapeHTML($ m).hr.ul map{li"".localtime((stat)[9]),$_}sort{-M$a<=>-M$b}grep/$w$/,readdir D; s|$w|(!-f$1&&$1).a{href,"$f/$1"},-f$1?$1:"?"|eg;put header,start_html($p),h1($p ),startform(0,"$f/$p").textarea(z,$m,6,60),br,submit.endform.hr.$_,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/97
98: nobodyさん [sage] 02/11/29 06:36 ID:??? >>97 うん、well-formed ではあるけど、pre に hr や ul が入ってるから valid じゃないよね。 別にいちゃもん付けてるんじゃ無くて、七行に収まってる状態で更に 数 byte の為に valid な出力を諦めるか否かは好みの問題だから、 何としても縮める方針でやってるのかな、と。挙動が変更されたコード 見たら、何を意図してるか大体分かるでしょ。 で、俺は shebang 込みで七行派だから、7wiki.cgi に関しては >>97 か 下ので完成気分。shebang 無し七行で続けるなら、それはそれで参加 させてもらうけどね。 #! perl -w use CGI':all';$w='\b(([A-Z][a-z]+){2,})';$/=();$f=script_name;($p)=(path_info|| FrontPage)=~/$w/;opendir D,".";if(open F,($m=param z)?">$p":$p){eval{flock F,2} ;eval{truncate F,0};seek F,0,0;print F$m||=<F>;close F}$_=pre(CGI::escapeHTML($ m)).hr.ul map{li"".localtime((stat)[9]),$_}sort{-M$a<=>-M$b}grep/$w$/,readdir D ;s|$w|(!-f$1&&$1).a{href,"$f/$1"},-f$1?$1:"?"|eg;put header,start_html($p),h1($ p),startform(0,"$f/$p"),textarea(z,$m,6,60),br,submit,endform,hr,$_,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/98
99: nobodyさん [sage] 02/11/29 08:01 ID:??? 7files.cgi use CGI':all';*p=*param;($c=$f=script_name)=~s|/[^/]+$||;$d=path_info;opendir D ,$e=".$d/";sub cp{}$F=p(F);$N=$e.p(N);($_=p(S))=~/MV/?rename$F,$N:/CP/?cp$F,$N: /RM/?unlink$F:0;put header,start_html('7files'),startform(0,"$f$d"),table(Tr[ map{$i="$d/$_";($l,$s)=-d".$i"?($f.$i,DIR):($c.$i,-s _);td({bgcolor,(silver, white)[$t++%2]},[checkbox(F,0,".$i",''),a({href,$l},$_),$s,"".localtime((stat)[ 9])])}sort grep!/^\./,readdir D]),textfield(N),map(submit(S,$_),MV,CP,RM), endform,end_html rename 実装。copy が悩み処ですな。 http://medaka.5ch.net/test/read.cgi/php/1036141603/99
100: nobodyさん [sage] 02/11/29 08:04 ID:??? rename の仕方: 変更したいファイルにチェック、textfield に変更後の名前を入れて MV http://medaka.5ch.net/test/read.cgi/php/1036141603/100
101: nobodyさん [sage] 02/11/29 09:06 ID:??? >>98 お疲れ様 && ありがとう。色々と勉強になりました。 no strict で bare word 使い始めた当たりから 短くすることを優先させてました。use strictなしって時点で すでに気持ち悪かったwので「汚くても動けばいいや」って感じだった HTMLもチェックしていなかった位だから、当然拘っていませんでした (HTMLは、7行って時点で最初から諦めていたかもしれない ただ、valid な出力にするとなると、 CGI.pm の textarea が rows,colsの属性の値をクオートしない。 br, hr は、p,div,h[1-6] 等の親要素が必要 等々、新たな課題が出てくるんじゃないかな? http://medaka.5ch.net/test/read.cgi/php/1036141603/101
102: nobodyさん [sage] 02/11/29 09:30 ID:??? 動作チェックしてないけど。 use File::Copy; sub cp{ map{ -f$_&©($_,"copy_of_$_") }p(F) } http://medaka.5ch.net/test/read.cgi/php/1036141603/102
103: nobodyさん [sage] 02/11/29 11:06 ID:??? >>101 ありゃ。本当に全然拘ってなかったのね。w なら 3 文字加えてピッタリ 6x79 。 use CGI':all';$w='\b(([A-Z][a-z]+){2,})';$/=();$f=script_name;($p)=(path_info|| FrontPage)=~/$w/;opendir D,".";if(open F,($m=param z)?">$p":$p){eval{flock F,2} ;eval{truncate F,0};seek F,0,0;print F$m||=<F>;close F}$_=pre(CGI::escapeHTML($ m)).hr.ul map{li"".localtime((stat)[9]),$_}sort{-M$a<=>-M$b}grep/$w$/,readdir D ;s|$w|(!-f$1&&$1).a{href,"$f/$1"},-f$1?$1:"?"|eg;put header,start_html($p),h1($ p),startform(0,"$f/$p"),p(textarea(z,$m,6,60),br,submit),endform,hr,$_,end_html ・hr はブロック要素なので無問題。 ・form 内の各要素がインライン要素なので p で囲む。 ・textarea の属性値クォートは 7wiki.cgi 側でなく CGI.pm 側の 問題だし、最近の CGI.pm なら直ってるので考えない。w これでかなり valid. http://medaka.5ch.net/test/read.cgi/php/1036141603/103
104: nobodyさん [sage] 02/11/29 11:54 ID:??? >>102 そか…モジュールという手が…。(´Д`; use CGI':all';use File::Copy;$d=path_info;($c=$f=script_name)=~s|/[^/]+$||;*p=* param;opendir D,$e=".$d/";$F=p(F);$N=$e.p(N);$w=($_=p(S))=~/MV/?rename$F,$N:/CP /x?copy$F,$N:/RM/?unlink$F:1;put header,start_html('7files'),startform(0,"$f$d" ),table(Tr[map{$i="$d/$_";($l,$s)=-d".$i"?($f.$i,DIR):($c.$i,-s _);td({bgcolor, (silver,white)[$t++%2]},[checkbox(F,0,".$i",''),a({href,$l},$_),$s,"".localtime ((stat)[9])])}sort grep!/^\./,readdir D]),textfield(N),map(submit(S,$_),MV,CP, RM),endform,end_html copy の仕方も rename と一緒。 http://medaka.5ch.net/test/read.cgi/php/1036141603/104
105: nobodyさん [sage] 02/11/30 03:07 ID:??? > ありゃ。本当に全然拘ってなかったのね。w えぇ。行末の桁揃えに夢中だったので。。w use CGI':all';use File::Copy;$d=path_info;*p=*param;opendir D,$e=".$d/";$F=p(F) ;$N=$e.p(N);($_=p(S))=~/MV/?move$F,$N:/CP/?copy$F,$N:/RM/?unlink p(F):1;($c=$f= script_name)=~s|/[^/]+$||;put header,start_html('7files'),startform(0,$f.$d), table(Tr[map{$i="$d/$_";($l,$s)=-d".$i"?($f.$i,DIR):($c.$i,-s _);td({bgcolor,( white,silver)[$t^=1]},[checkbox(F,0,".$i",''),a({href,$l},$_),$s,"".localtime(( stat)[9])])}sort grep!/^\./,readdir D]),textfield(N),map(submit(S,$_),MV,CP,RM) ,endform,end_html - rename --> File::Copy#move に変更。 ファイルをチェックして、テキストにディレクトリ名を入れてMVで ファイルをディレクトリに移動します。 = TODO mkdir, rmdir http://medaka.5ch.net/test/read.cgi/php/1036141603/105
106: nobodyさん [sage] 02/12/01 01:22 ID:??? mkdir, rmdir 実装。特にヒネりもなく…。 use CGI':all';use File::Copy;$d=path_info;($c=$f=script_name)=~s|/[^/]+$||;*p=* param;opendir D,$e=".$d/";$F=p(F);$N=$e.p(N);$_=p(S);/MV/?move$F,$N:/CP/?copy$F ,$N:/RM/?unlink$F:/MD/?mkdir$N,511:/RD/?rmdir$F:1;put header,start_html('7files '),startform(0,$f.$d),table(Tr[map{$i="$d/$_";($l,$s)=-d".$i"?($f.$i,DIR):($c.$ i,-s _);td({bgcolor,(white,silver)[$t^=1]},[checkbox(F,0,".$i",''),a({href,$l}, $_),$s,"".localtime((stat)[9])])}sort grep!/^\./,readdir D]),textfield(N),map( submit(S,$_),MV,CP,RM,MD,RD),endform,end_html table を何とかせんと、劇的には縮まらな気。 http://medaka.5ch.net/test/read.cgi/php/1036141603/106
107: nobodyさん [sage] 02/12/01 05:42 ID:??? bgcolorを削って、chdirにしてみた・・ use CGI':all';use File::Copy;$d=path_info;*p=*param;chdir".$d";$N=p N;$F=p F;$_ =p S;/MV/?move$F,$N:/CP/?copy$F,$N:/RM/?unlink$F:/MD/?mkdir$N,511:/RD/?rmdir$F: 1;opendir D,".";($c=$f=script_name)=~s|/[^/]+$||;put header,start_html('7files' ),startform(0,$f.$d),table(Tr[map{td[checkbox(F,0,$_,''),a({href,-d$_?"$f$d/$_" :"$c$d/$_"},$_),-s||DIR,"".localtime((stat)[9])]}sort grep!/^\./,readdir D]), textfield(N),map(submit(S,$_),MV,CP,RM,MD,RD),endform,end_html p(F); を p F; って表記するのも環境/バージョンに依存するのかな? http://medaka.5ch.net/test/read.cgi/php/1036141603/107
108: nobodyさん [sage] 02/12/01 07:42 ID:??? give up 気味。(´Д`; use CGI':all';use File::Copy;$d=path_info;*b=*param;chdir".$d";$N=b N;$F=b F;%m =qw(MV move$F,$N CP copy$F,$N RM unlink$F MD mkdir$N,511 RD rmdir$F);eval$m{b S };opendir D,".";($c=$f=script_name)=~s|/[^/]+$||;put header,start_html('7files' ),startform(0,$f.$d),table(Tr[map{td[checkbox(F,0,$_,''),a({href,(-d$_?$f:$c). "$d/$_"},$_),-s||DIR,"".localtime((stat)[9])]}sort grep!/^\./,readdir D]), textfield(N),(map{submit S,$_}keys%m),endform,end_html param のエイリアスを b にしたのは、p 要素の p() を 使えるようにする為の布石。 > p(F); を p F; って表記 大丈夫っぽいです。 http://medaka.5ch.net/test/read.cgi/php/1036141603/108
109: nobodyさん [sage] 02/12/01 08:40 ID:??? ディレクトリは別にサイズ取れない訳じゃないので -s||DIR は駄目ですな…。 http://medaka.5ch.net/test/read.cgi/php/1036141603/109
110: nobodyさん [sage] 02/12/01 12:51 ID:??? >109 Win/ActivePerlだとディレクトリのサイズ0が返ってきていた これも環境に依存するのか。。 -d _?DIR:-s _ でok ? use CGI':all';use File::Copy;$_='$d=path_info;*b=*param;chz".$d";$N=b N;$F=b F; %m=qw(MV move$F,$N CP copy$F,$N RM unlink$F MD mkz$N,511 RD rmz$F);eval$m{b S} ;openz D,".";($c=$f=script_name)=~s|/[^/]+$||;put header,start_html("7files") ,startform(0,$f.$d),table(Tr[map{td[checkbox(F,0,$_,""),a({href,(-d$_?$f:$c) ."$d/$_"},$_),-d _?DIR:-s _,"".localtime((stat)[9])]}sort grep/^[^.]/,readz D]),textfield(N),(map{submit S,$_}keys%m),endform,end_html';s/z/dir/g;eval 置換してスクリプト長くなってるし。。。そろそろ give up >108 のファイルサイズを直して、完成かな http://medaka.5ch.net/test/read.cgi/php/1036141603/110
111: nobodyさん [sage] 02/12/01 14:28 ID:??? せっかくだから空ファイル作成 (MF) など付けてみる。 use CGI':all';use File::Copy;$d=path_info;*b=*param;chdir".$d";$N=b N;$F=b F;%m =(qw(MV move$F,$N CP copy$F,$N RM unlink$F MD mkdir$N,511 RD rmdir$F MF),'open F,">$N"');eval$m{b S};opendir D,".";($c=$f=script_name)=~s|/[^/]+$||;put header ,start_html("7files"),startform(0,$f.$d),table(Tr[map{td[checkbox(F,0,$_,""),a( {href,(-d$_?$f:$c)."$d/$_"},$_),-d$_?DIR:-s,"".localtime((stat)[9])]}sort grep! /^\./,readdir D]),p(textfield(N),map{submit S,$_}keys%m),endform,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/111
112: nobodyさん [sage] 02/12/02 07:11 ID:??? Rss出力と検索機能 4 7wiki.cgi ---- 7search.cgi use CGI':all';$f=script_name;$s=param S;opendir D,".";if($s){map{$t=$_;if(open F,$t){eval{flock F,2};while(<F>){chomp;if(/\Q$s\E/io){push(@r,li(a{href,$t},$t) ," - $_");last}}close F}}sort grep/^[^.]+$/,readdir D}put header,start_html( '7search'),startform(0,$f),p(textfield(S),submit),endform,hr,ul(@r),end_html ---- 7rss.cgi use CGI qw/:all channel item textinput link name/;($p)=script_name=~m|(.+)/[^/] +$|x;$s=server_name.$p;opendir D,".";$w='7wiki';put"Content-type:text/xml\n\n", qq|<?xml version="1.0"?>\n<rdf:RDF xmlns:rdf="http://www.w3c.org/1999/02/22-r|, q|df-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/">|,channel(title ($w),link"$s/$w.cgi"),(map{item(title($_),link"$s.$_")."\n"}sort grep/^[^.]+$/, readdir D),textinput(title($w),link("$s/7search.cgi"),name(S)),"\n</rdf:RDF>"; # CGI.pm v2.69 以降 or c2.67 wiz xhtml tag - link() の動作がちょっと不安。 http://medaka.5ch.net/test/read.cgi/php/1036141603/112
113: nobodyさん [sage] 02/12/02 07:39 ID:??? 7rss.cgi > item(title($_),link"$s.$_")." < item(title($_),link"$s.cgi/$_")." http://medaka.5ch.net/test/read.cgi/php/1036141603/113
114: nobodyさん [sage] 02/12/02 08:06 ID:??? #7search.cgi - v0.02 fixed some bugs use CGI':all';($c=$f=script_name)=~s|/[^/]+$||;$s=param S;if($s){opendir D,"."; map{$t=$_;if(open F,$t){eval{flock F,2};while(<F>){chomp;if(/\Q$s\E/io){push@r, li(a({href,"$c/7wiki.cgi/$t"},$t)," $_");last}}close F}}sort grep/^[^.]+$/, readdir D}put header,start_html('7search'),startform(0,$f),p(textfield(S), submit),endform,hr,ul(@r),end_html #7rss.cgi - v0.02 show latest 15 articles use CGI qw/:all channel item textinput link name/;($p)=script_name=~m|(.+)/[^/] +$|x;$s=server_name.$p;opendir D,".";$w='7wiki';put"Content-type:text/xml\n\n", qq|<?xml version="1.0"?>\n<rdf:RDF xmlns:rdf="http://www.w3c.org/1999/02/22-r|, q|df-syntax-ns#" xmlns="http://my.netscape.com/rdf/simple/0.9/">|,channel(title ($w),link"$s/$w.cgi"),(map{item title($_),link"$s.cgi/$_"}sort{-M$a<=>-M$b}grep /^[^.]+$/,readdir D)[0..14],textinput(title($w),link("$s/7search.cgi"),name S), "\n</rdf:RDF>"; http://medaka.5ch.net/test/read.cgi/php/1036141603/114
115: nobodyさん [sage] 02/12/02 17:31 ID:??? # 7rss.cgi v0.03 use CGI qw/:all channel item textinput link name/;opendir D,".";$w='7wiki';($p) =url=~m|^(.+)/[^/]+$|;put header('text/xml'),qq|<?xml version="1.0"?>\n<rdf:RD| ,'F xmlns:rdf="http://www.w3c.org/1999/02/22-rdf-syntax-ns#" xmlns="http://my.' ,'netscape.com/rdf/simple/0.9/">',channel(title($w),link"$p/$w.cgi"),(map{item title($_),link"$p/$w.cgi/$_"}sort{-M$a<=>-M$b}grep/^[^.]+$/,readdir D)[0..14], textinput(title($w),link("$p/7search.cgi"),name S),"\n</rdf:RDF>"; http://medaka.5ch.net/test/read.cgi/php/1036141603/115
116: nobodyさん [] 02/12/21 03:14 ID:RF/wn3c8 7threadキボンヌ http://medaka.5ch.net/test/read.cgi/php/1036141603/116
117: nobodyさん [sage] 02/12/30 09:38 ID:??? 拙作をまとめていた isweb のサイト、広告ウザいので引っ越し。 ついでに配布体裁整え。http://calorymate.s15.xrea.com/ 7wiki と 7files 、参加作という事でサイトに載っけていいですか? http://medaka.5ch.net/test/read.cgi/php/1036141603/117
118: 'a';$happy = new Year; [sage] 02/12/31 15:36 ID:??? >>117 Take It free. <一応、ベースとなるものを書いたモノです 自分が代表してレスしていいのかわかんないけど && このスレッド的にはどうなのか知らないけど・・・、 このまま過去ログに埋もれて日の目を見ないよりも、 公開して保守して貰えるのなら、そっちの方がいいよな て事でお願いします。 ついでに、7rss, 7search も載せてもらえるとうれしいな。 package Year;sub new{bless{},shift} http://medaka.5ch.net/test/read.cgi/php/1036141603/118
119: nobodyさん [sage] 03/01/15 02:35 ID:??? 忘れた頃に。(w --- 7search.cgi use CGI':all';put header,start_html('7search'),startform(0,$_=script_name),p( textfield(S),submit),endform,hr;if($s=param S){m|/[^/]+$|;$c=$`;opendir D,"."; for(sort grep/^\w+$/&-f,readdir D){if(open F,$t=$_){eval{flock F,2};/\Q$s\E/io &&push(@r,li(a({href,"$c/7wiki.cgi/$t"},$t)," $_"))&&next while<F>;}}@r&&put ul @r}put end_html --- 7rss.cgi use CGI qw/:all channel item textinput link name/;opendir D,".";$w='7wiki';url =~m|[^/]+$|;$p=$`;put header('text/xml'),join"\n",'<?xml version="1.0"?>', '<rdf:RDF xmlns:rdf="http://www.w3c.org/1999/02/22-rdf-syntax-ns#" xmlns="http' .'://my.netscape.com/rdf/simple/0.9/">',channel(title($w),link"$p$w.cgi"),(map{ item title($_),link"$p$w.cgi/$_"}sort{-M$a<=>-M$b}grep/^\w+$/&-f,readdir D)[0.. 14],textinput(title($w),link($p.'7search.cgi'),name S),'</rdf:RDF>' つー事で載せときました。 http://medaka.5ch.net/test/read.cgi/php/1036141603/119
120: 山崎渉 [(^^)sage] 03/01/15 13:41 ID:??? (^^) http://medaka.5ch.net/test/read.cgi/php/1036141603/120
121: nobodyさん [sage] 03/01/17 18:30 ID:??? 2ch の dat ファイル (かちゅ〜しゃのログ) を XHTML ファイルに変換。 http://cm.xrea.cc/kat2xhtml.shtml $s="kat2xhtml.tmpl";sub a{'<a href="'.pop().'</a>'}sub p{'<span class="'.pop(). '</span>'}while(<>){($n,$m,$d,$_,$t,$")=split/,/;$.-1||($T=$t)=~s/\s+$//;$n=$n =~m|^<b>([^<]*)</b>(?:([^<]*)<b></b>)?$|?p"n\">$1":'';$n.=p"m\">$2"if$2;$n=$m=~ /\@/?a"mailto:$m\">$n":$m=~/./?p qq|k" title="$m">$n|:$n;s/\x81\x97\x81\x4D/,/g ;s/\s+(?:target="_blank"|$)//g;s|\s*<br>|<br />|g;s/&(?![a-z]+;)/&/g;for(@r =split/(<a href="[^"]+">[^<]+<\/a>)/){(($u,$a)=m|^<a href="([^"]+)">([^<]+)</a> $|x)?($u=~s/~/%7E/g&&($_=a"$u\">$a"),$a=~/^>>(\d+)/&&($_=a"#R$1\">$a")): s/"/"/g}$A.="<dt>$. :<a id=\"R$.\">$n :$d</a></dt><dd>@r</dd>\n"}if(open T,$s){$/='';$_=<T>;s/\%(.)/${$1}/g;print} 機能減らさないと七行に収まらないかなぁ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/121
122: nobodyさん [] 03/03/10 02:24 ID:drTO4vMw 使い方わからなかったけど…(かちゅーしゃのログ持っていないので。 '<a href="'.pop().'</a> ↓ "a href=\"$_[0]</a>" http://medaka.5ch.net/test/read.cgi/php/1036141603/122
123: 山崎渉 [(^^)] 03/03/13 17:04 ID:??? (^^) http://medaka.5ch.net/test/read.cgi/php/1036141603/123
124: nobodyさん [sage] 03/03/13 18:58 ID:??? このスレの dat 上げといたんでテストする人はどぞ。 http://cm.xrea.cc/thread/1036141603.dat >>122 @_ でもいいですね。 $s="kat2xhtml.tmpl";sub a{"<a href=\"@_</a>"}sub p{"<span class=\"@_</span>"} while(<>){($n,$m,$d,$_,$t,$")=split/,/;$.-1||chomp($T=$t);$n=~m|<b>([^<]*)(?: </b>([^<]*))?|x;$n=($1&&p"n\">$1").($2&&p"m\">$2");$n=p qq|k" title="$m">$n|if $m.0;s/\x81\x97\x81\x4D/,/g;s/\s+(?:target="\w*"|$)//g;s|\s*<br>|<br />|g;s/& (?![a-z]+;)/&/gx;for(@r=split/(<a href="[^"]+">[^<]+<\/a>)/){(($u,$a)= /^<a href="([^"]+)">([^<]+)/)?($_=$u=~s/~/%7E/g?a"$u\">$a":$a=~/^(?:>){1,2} (\d+)/x?a"#R$1\">$a":$_):s/"/"/g}$A.="<dt>$. :<a id=\"R$.\">$n :$d</a>". "</dt><dd>@r</dd>\n"}if(open T,$s){$/='';$_=<T>;s/\%(.)/${$1}/g;print} mailto: やめてあと一行。 http://medaka.5ch.net/test/read.cgi/php/1036141603/124
125: 通りすがり [sage] 03/03/25 06:39 ID:??? このすれ見て ish思い出しますた http://medaka.5ch.net/test/read.cgi/php/1036141603/125
126: 山崎渉 [(^^)] 03/04/17 12:25 ID:??? (^^) http://medaka.5ch.net/test/read.cgi/php/1036141603/126
127: ◆PAmX3cjLtw [] 03/04/18 14:01 ID:yrVQyLZr こんなスレあったんだ。燃えてきた! http://medaka.5ch.net/test/read.cgi/php/1036141603/127
128: ◆PAmX3cjLtw [] 03/04/18 15:48 ID:yrVQyLZr 俺も作ってみた。 2chモドキの掲示板です。ログファイル F が必要。 URLと、発言番号への自動リンクがありますが、使い物になるかどうか・・・。 Win98のPWSとLinuxのApacheで動作を確認しました。。。 ------------ 7ch.cgi ----------------- #!/usr/bin/perl use CGI':all';*i=*param;$n=i N;$m=i M;$t=i T;open F,'+<F';eval{flock F,2};1 for <F>;$.++;if($t){$_=$t;s/</</g;$h='<a href=';s!(https?://.+?)$!$h$1>$1</a>!mg ;s!>>(\d+)!$h#$1>>>$1</a>!g;s/\n/br/eg;seek F,0,2;print F dt("$. :".b(a{href=> $m?"mailto:$m":undef,name=>$.},$n||='名無しさん'),':'.localtime),(dd $_.br.br) ."\n"}seek F,0,0;*x=*textfield;print header(-charset=>''),start_html(-style=>' body{background:#eee}b{color:green}').startform,dl(<F>),hr,submit('書き込む'),' 名前:',x(N),' E-mail:',x(M),br,textarea(T,'',5,70,1),endform.end_html; -------------------- 結構つかれた・・・。 http://medaka.5ch.net/test/read.cgi/php/1036141603/128
129: nobodyさん [sage] 03/04/18 16:33 ID:??? すげぇ… http://medaka.5ch.net/test/read.cgi/php/1036141603/129
130: nobodyさん [sage] 03/04/19 00:20 ID:??? >>128 日本語まともに表示できるようにしたら、URL リンク外してもはみだしちゃった。 #!/usr/bin/perl use CGI':all';open F,'+<F';eval{flock F,2};[<F>];$.++;*i=*param;if($_=i T){s/< /&lt;/gx;$h='<a href="';s!(&gt;&gt;\d+)!$h#R$1">$1</a>!g;s/\n/br/eg;$m=i M;seek F,0,2;print F dt("$. :".b(a{name=>"R$.",$m&&(href=>"mailto:$m")},i(N)|| '名無しさん'),':'.localtime),dd($_.br.br),"\n"}*x=*textfield;$c='Shift_JIS'; seek F,0,0;put header(-charset=>$c),start_html(-encoding=>$c,-lang=>'ja', -style=>'body{background:#eee}b{color:green}'),dl(<F>),hr,startform,p(submit( '書き込む'),' 名前:',x(N),' E-mail:',x(M),br,textarea(T,'',5,70,1)),endform, end_html CGI.pm は 2.91 と 2.46 で確認。&を戻して使って下され。 http://medaka.5ch.net/test/read.cgi/php/1036141603/130
131: nobodyさん [sage] 03/04/19 04:23 ID:??? 収まった。 #!/usr/bin/perl use CGI':all';open F,'+<F';[<F>];$.++;*i=*param;s!(&gt;&gt;)(\d+)!'<a href="#R' ."$2\">$1$2</a>"!eg,s/\n/br/eg,seek(F,0,2),eval{flock F,2},print F dt("$. :".b (a{name,"R$.",($m=i M)&&(href,"mailto:$m")},i(N)||'nobodyさん'),':'.localtime) ,dd($_.br.br),"\n"if$_=escapeHTML i T;*x=*textfield;$c='Shift_JIS';seek F,0,0; put header(-charset=>$c),start_html(-encoding=>$c,-lang=>'ja',-style=>'b{color: green}body{background:#eee}'),dl(<F>),hr,startform,p(submit('書き込む'),' 名前' .':',x(N),' E-mail:',x(M),br,textarea(T,'',5,70,1)),endform,end_html escapeHTML 使ったから、CGI.pm v2.46 だと不可。 http://medaka.5ch.net/test/read.cgi/php/1036141603/131
132: ◆PAmX3cjLtw [] 03/04/19 12:39 ID:S+81Ncm0 >>131 修正ありがとう!勉強になります。 httpへの自動リンクも入れてみたけど、p抜かしたりズルしてます。 【今後の課題】 ・キャップもどき追加(s/#.*/crypt$&,'◆'/e) ・全角小文字のkが文字化けするバグ use CGI':all';open F,'+<F';[<F>];$.++;*i=*param;s!>>(\d+)!a{href,"#R$1"}, $&!eg,s!https?://.+?$!a{href,$&},$&!emg,s/\n/br/eg,seek(F,0,2),eval{flock F,2}, print F dt("$. :".b(a{name,"R$.",($m=i M)&&(href,"mailto:$m")},i(N)||'nobody'. 'さん'),':'.localtime),dd($_.p),"\n"if$_=escapeHTML i T;*x=*textfield;seek F,0 ,0;put header(-charset=>$c='Shift_JIS'),start_html({lang,'ja',encoding,$c,Style ,'b{color:#080}body{background:#eee}'}),dl(<F>),hr,startform,submit('書き込む') ,' 名前:',x(N),' E-mail:',x(M),br,textarea(T,'',6,70,1),endform,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/132
133: 動画直リン [] 03/04/19 12:40 ID:PZJVQOkw http://www.agemasukudasai.com/movie/ http://medaka.5ch.net/test/read.cgi/php/1036141603/133
134: ◆PAmX3cjLtw [] 03/04/19 12:41 ID:S+81Ncm0 すまそ。&置換するの忘れました。 use CGI':all';open F,'+<F';[<F>];$.++;*i=*param;s!&gt;&gt;(\d+)!a{href,"#R$1"}, $&!eg,s!https?://.+?$!a{href,$&},$&!emg,s/\n/br/eg,seek(F,0,2),eval{flock F,2}, print F dt("$. :".b(a{name,"R$.",($m=i M)&&(href,"mailto:$m")},i(N)||'nobody'. 'さん'),':'.localtime),dd($_.p),"\n"if$_=escapeHTML i T;*x=*textfield;seek F,0 ,0;put header(-charset=>$c='Shift_JIS'),start_html({lang,'ja',encoding,$c,Style ,'b{color:#080}body{background:#eee}'}),dl(<F>),hr,startform,submit('書き込む') ,' 名前:',x(N),' E-mail:',x(M),br,textarea(T,'',6,70,1),endform,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/134
135: nobodyさん [sage] 03/04/19 12:54 ID:??? ライブラリをつかってよいのなら、主要な処理はライブラリに書けば数文字でかけますね。 http://medaka.5ch.net/test/read.cgi/php/1036141603/135
136: nobodyさん [sage] 03/04/19 21:11 ID:??? >>135 個人的にはモジュール不可派だけど、WebProg だし 標準モジュールだけ使用可にした方が面白いものが 出てきそうな気がするのでそういう縛りで考えてるよ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/136
137: ◆PAmX3cjLtw [sage] 03/04/20 02:19 ID:??? encoding をハズしてなんとかイけたよ。疲れた。 まとめ&使い方 ・番号自動リンク( >>100 とか入力する) ・URL自動リンク(http://... 行末までリンク) ・キャップ(名前欄の # 以降をcryptします) ・EUC-JP で保存する(じゃないと文字化けする) ・&を&に置換する ・カレントに空ファイル F を作ること ------------------------------- 7ch.cgi use CGI':all';open F,'+<F';[<F>];$.++;*i=*param;s!&gt;&gt;(\d+)!a{href,"#R$1"}, $&!eg,s!https?://.+?$!a{href,$&},$&!emg,s/\n/br/eg,seek(F,0,2),eval{flock F,2}, ($n=i(N)||'nobodyさん')=~s/#.*/crypt$&,'◆'/e,print F dt("$. :".b(a{name,"R$." ,i(M)&&(href,'mailto:'.i M)},font{color,'green'},$n),':'.localtime),dd($_.p)," "if$_=escapeHTML i T;seek F,0,0;*x=*textfield;put header(-charset=>'EUC-JP'), start_html({lang,'ja',bgcolor,'#efefef'}).dl(<F>),startform,p(submit('書き込む' ),' 名前:',x(N),' E-mail:',x(M),br,textarea(T,'',6,70,1)),endform,end_html; http://medaka.5ch.net/test/read.cgi/php/1036141603/137
138: nobodyさん [i] 03/04/20 04:52 ID:??? 縮めるならロックなんてしなくてもよいだろ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/138
139: nobodyさん [sage] 03/04/20 04:57 ID:??? >>137 ・改行しないとレス番が2以上に増えない。 ・Mozilla 1.3 だと font では色変わらんかったんで、CSS に戻し。 ・> 一個でリンク。 use CGI':all';open F,'+<F';[<F>];seek F,0,2;*i=*param;s!&gt;(\d+)!a{href,"#R$1" },$&!eg,s!https?://.+$!a{href,$&},$&!emg,s/\n/br/eg,eval{flock F,2},($n=i(N)|| 'nobodyさん')=~s/#.+/crypt$&,'◆'/e,print F dt(++$.,':'.b(a{name,"R$.",i(M)&&( href,'mailto:'.i M)},$n),':'.localtime),dd($_.p),"\n"if$_=escapeHTML i T;seek F,0,0;*x=*textfield;put header(-charset=>'EUC-JP'),start_html({lang,ja,Style, 'b{color:#080}body{background:#eee}'}),dl(<F>),hr,startform,p(submit('書き込む' ),' 名前:',x(N),' E-mail:',x(M),br,textarea(T,'',6,70,1)),endform,end_html >>130 での変更は HTML 的に正しくする為のものなんだけど (文字コードや言語を指定するから化けずに済む)、そーゆーの より「似せる」方を重視してるのかな? http://medaka.5ch.net/test/read.cgi/php/1036141603/139
140: 山崎渉 [(^^)sage] 03/04/20 05:57 ID:??? ∧_∧ ( ^^ )< ぬるぽ(^^) http://medaka.5ch.net/test/read.cgi/php/1036141603/140
141: nobodyさん [] 03/05/09 00:09 ID:seZLVSXV ∩(゚∀゚∩)age http://medaka.5ch.net/test/read.cgi/php/1036141603/141
142: nobodyさん [sage] 03/05/09 21:42 ID:??? えぇと、みんななんか面白そうなコトやってるね。 俺も参加しよう思ったけど…読めない所が多いや。 http://medaka.5ch.net/test/read.cgi/php/1036141603/142
143: nobodyさん [sage] 03/05/10 00:35 ID:??? >>142 過疎スレだから、分からんトコは*自分で調べた上で* 適宜質問してくれれば良いかと。 http://medaka.5ch.net/test/read.cgi/php/1036141603/143
144: 山崎渉 [(^^)] 03/05/22 02:04 ID:??? ━―━―━―━―━―━―━―━―━[JR山崎駅(^^)]━―━―━―━―━―━―━―━―━― http://medaka.5ch.net/test/read.cgi/php/1036141603/144
145: nobodyさん [] 03/05/28 05:53 ID:dphN6O/1 ポートスキャナー。 # portscan.pl use Socket;$h=$ARGV[0];$p=--$ARGV[1];$e=$ARGV[2];$i=inet_aton($h)||die;print"ho st $h\n\n";while($p++<$e){$f=1;for(1..2){$t=$f?"tcp":"udp";socket(S,PF_INET, SOCK_STREAM,getprotobyname($t));print"$p $t\n"if connect(S,pack_sockaddr_in($p, $i));close(S);$f=0}} usage >peal portscan.pl [host] [start_port] [end_port] ちなみに、エラーチェックもしてないし、socketらへんもかなり適当なので動かないかもしれますん。 そんときは自分で手を加えるなりして動くようにしてください。 http://medaka.5ch.net/test/read.cgi/php/1036141603/145
146: nobodyさん [] 03/05/28 06:12 ID:u3FXwnkV (´―`)y━~~タバコ代上がるのイヤー http://www.k-514.com/good/dxlive.html http://www.k-514.com/good/hgmo.html http://www.k-514.com/good/jgirlpa.html http://www.k-514.com/good/tokyonights.html http://www.k-514.com/good/tokyonights.html http://www.k-514.com/good/erox.html http://www.k-514.com/good/goa.html http://www.k-514.com/good/caribeancom.html http://www.k-514.com/good/1pondou.html http://www.k-514.com/good/osikko.html http://www.k-514.com/good/beikoku.html (´―`)y━~~タバコ代上がるのイヤー http://medaka.5ch.net/test/read.cgi/php/1036141603/146
147: 145 [] 03/05/28 19:26 ID:MVa2hSnY 縮まった。 # portscan.pl use Socket;$h=$ARGV[0];$p=--$ARGV[1];$i=inet_aton $h||die;print"host $h\n\n"; while(++$p<$ARGV[2]){$f=1;for(1..2){socket S,PF_INET,SOCK_STREAM,getprotobyname ($f?"tcp":"udp");print"$p $t\n"if connect S,pack_sockaddr_in($p,$i);close S;$f= 0}} >>145と同じ理由で動かないかもしれますん。 これ以上縮まらないヨカソ…。 http://medaka.5ch.net/test/read.cgi/php/1036141603/147
148: nobodyさん [] 03/05/28 20:05 ID:Edz5ugJ5 >>147 板違い http://medaka.5ch.net/test/read.cgi/php/1036141603/148
149: 145 [] 03/05/28 21:50 ID:RXOOGbeu 言ってるそばから縮まった。 # portscan.pl use Socket;@t=@ARGV;$p=--$t[1];$i=inet_aton $t[0]||die;print"host $t[0]\n\n"; while(++$p<$t[2]){$f=1;for(1..2){socket S,PF_INET,SOCK_STREAM,getprotobyname($f ?"tcp":"udp");print"$p $t\n"if connect S,pack_sockaddr_in($p,$i);close S;$f=0}} http://medaka.5ch.net/test/read.cgi/php/1036141603/149
150: nobodyさん [sage] 03/05/29 12:44 ID:??? use Socket;($h,$s,$e)=@ARGV;$i=inet_aton($h)||die;print"host $h\n\n";for$p($s.. $e){for('tcp','udp'){socket S,PF_INET,SOCK_STREAM,getprotobyname$_;print"$p $_ "if connect S,pack_sockaddr_in$p,$i;close S}} http://medaka.5ch.net/test/read.cgi/php/1036141603/150
151: nobodyさん [sage] 03/07/01 18:25 ID:??? #!/usr/local/bin/perl print "Hello World!"; print "Hello World!"; print "Hello World!"; print "Hello World!"; print "Hello World!"; print "Hello World!"; http://medaka.5ch.net/test/read.cgi/php/1036141603/151
152: nobodyさん [sage] 03/07/06 12:17 ID:??? お前ら!すごいですね http://medaka.5ch.net/test/read.cgi/php/1036141603/152
153: 山崎 渉 [(^^)] 03/07/15 11:13 ID:??? __∧_∧_ |( ^^ )| <寝るぽ(^^) |\⌒⌒⌒\ \ |⌒⌒⌒~| 山崎渉 ~ ̄ ̄ ̄ ̄ http://medaka.5ch.net/test/read.cgi/php/1036141603/153
154: nobodyさん [sage] 03/07/24 09:35 ID:??? おもしろそう・・・ http://medaka.5ch.net/test/read.cgi/php/1036141603/154
155: 山崎 渉 [(^^)sage] 03/08/02 02:38 ID:??? ∧_∧ ( ^^ )< ぬるぽ(^^) http://medaka.5ch.net/test/read.cgi/php/1036141603/155
156: ぼるじょあ ◆ySd1dMH5Gk [(^^)] 03/08/02 05:21 ID:??? ∧_∧ ∧_∧ ピュ.ー ( ・3・) ( ^^ ) <これからも僕たちを応援して下さいね(^^)。 =〔~∪ ̄ ̄ ̄∪ ̄ ̄〕 = ◎――――――◎ 山崎渉&ぼるじょあ http://medaka.5ch.net/test/read.cgi/php/1036141603/156
157: 山崎 渉 [(^^)] 03/08/15 22:57 ID:??? (⌒V⌒) │ ^ ^ │<これからも僕を応援して下さいね(^^)。 ⊂| |つ (_)(_) 山崎パン http://medaka.5ch.net/test/read.cgi/php/1036141603/157
158: nobodyさん [sage] 03/08/17 15:16 ID:??? 山崎ばかりなのもナニなので kat2xhtml 更新。あと 10 byte ほどなんだが…。 $l='<a href="';sub a{"$l@_\">$a</a>"}sub p{"<span class=\"@_</span>"}while(<>){ ($n,$m,$d,$_,$t,$")=split/[,\n]/;$.-1or$T=$t;$n=~m|<b>([^<]*)(</b>([^<]*))?|;$n =($1&&p"n\">$1").($3&&p"m\">$3");$n=p qq|k" title="$m">$n|if$m.0;s/\x81\x97\x81 M/,/gx;s/\s+(target="\w*"|$)//g;s|\s*<br>|<br />|g;s/&(?!\w+;|\#\d+;)/&/g;( ($u,$a)=/^$l([^"]+)">([^<]+)/)?($_=$u=~s/~/%7E/g?a$u:$a=~/^(>){1,2}(\d+)/?a "#R$2":$_):s/"/"/g for@r=split/($l[^"]+">[^<]+<\/a>)/;$A.="<dt>$. :<a id" ."=\"R$.\">$n :$d</a></dt><dd>@r</dd>\n"}open T,$/="$0.tmpl";$_=<T>;s/%(.)/${ $1}/g;print ・?xHHHH 形式の数値実体参照を諦め。 ・テンプレートのファイル名を "$0.tmpl" に。 ・説明やら入れたアーカイヴは http://cm.xrea.cc/ に。 http://medaka.5ch.net/test/read.cgi/php/1036141603/158
159: nobodyさん [sage] 03/08/17 15:19 ID:??? >>158 s/?xHHHH/&#xHHHH/; http://medaka.5ch.net/test/read.cgi/php/1036141603/159
160: nobodyさん [sage] 03/08/18 07:15 ID:??? ちょっと長くなったけど、初心者質問スレを荒らしている彼に捧げよう。(w #--- br.p --- package P;sub c{bless pop,pop}sub s{$_[0]->{s}}sub n{$_[0]->{n}}sub h{my($s,$c) =@_;$c||return$s->{h};($s->{h}+=$c)>0or$s->{h}=0}sub b{my($s,$e)=@_;my@w=keys%{ $s->{w}};my$w=$w[int rand@w];print$s->n,' は ',$w," で攻撃!\n";my($d,$a)=@{$s-> {w}{$w}}{d,a};$d=(my$n=int rand 101)>$a?0:$n>$a/2?int($d/2)-$e->s:$n>$a/20?$d- $e->s:$d;print$d<=0?"ミス!\n":($e->n,' に ',$d," ポイントのダメージ!\n");$e->h( -$d)||print$e->n," を倒した!\n"}package main;sub p{splice@p,int rand@p,1}@p=map P->c($_),@{do'./p.dat'};while(@p>1){my$o=p;my$d=p;print"\n",$o->n,':',$o->h,' ' ,$d->n,':',$d->h,"\n";$o->b($d);push@p,$o;$d->h>0&&push@p,$d}print(shift(@p)->n , " の 勝利!\n") #--- p.dat --- [{n=>'煽り',h=>400,s=>10,w=>{'キック'=>{d=>60,a=>60},'パンチ'=>{d=>20,a=>70},}} ,{n=>'荒らし',h=>300,s=>0,w=>{'キック'=>{d=>100,a=>60},'パンチ'=>{d=>40,a=>70}} },{n=>'夏厨',h=>200,s=>20,w=>{'キック'=>{d=>80,a=>90},'パンチ'=>{d=>10,a=>100}} }]; http://medaka.5ch.net/test/read.cgi/php/1036141603/160
161: nobodyさん [sage] 03/08/18 12:36 ID:??? >>160 ワロタ http://medaka.5ch.net/test/read.cgi/php/1036141603/161
162: nobodyさん [sage] 03/08/19 11:57 ID:??? 縮めて CGI プログラムにした。これで彼も満足だろう。 #--- br.cgi --- #!/usr/local/bin/perl use CGI':all';put header(-charset=>($c='EUC-JP')),start_html(-lang=>ja,-title=> 'B.R.',-encoding=>$c);@p=@{do'br.dat'};sub e{splice@p,int rand@p,1}while(@p>1){ *o=e;*d=e;put p"$o{N}:$o{H} $d{N}:$d{H}";@w=keys%{$o{W}};$w=$w[int rand@w];($p, $a)=@{$o{W}{$w}}{D,A};put p("$o{N}は$wで攻撃!",(($p=($n=int rand 101)>$a?0:$n> $a/2?int($p/2)-$d{S}:$n>$a/20?$p-$d{S}:$p)>0or$p=0)?"$d{N}に$pポイントのダメー" .'ジ!':'ミス!');($d{H}-=$p)>0or put p"$d{N}を倒した!";push@p,\%o;$d{H}>0&&push @p,\%d}put p(pop(@p)->{N}, 'の勝利!'),end_html #--- br.dat --- [ {N=>'煽り', H=>400,S=>10,W=>{'キック'=>{D=>60, A=>60},'パンチ'=>{D=>20,A=>70 }}}, {N=>'荒らし',H=>300,S=>0, W=>{'キック'=>{D=>100,A=>60},'パンチ'=>{D=>40,A=>70 }}}, {N=>'夏厨', H=>200,S=>20,W=>{'キック'=>{D=>80, A=>90},'パンチ'=>{D=>10,A=>100}}}, ]; http://medaka.5ch.net/test/read.cgi/php/1036141603/162
163: nobodyさん [sage] 03/08/20 07:02 ID:??? メッセージを削るという安直な方法で七行達成。 #!/usr/local/bin/perl use CGI':all';put header(-charset=>($c='EUC-JP')),start_html -lang=>ja,-title=> BR,-encoding=>$c;@p=@{do'br.dat'};while(@p>1){put p map"$_->{N}:$_->{H}",@p;*d= splice@p,int rand@p,1;*o=$p[int rand@p];@w=keys%{$o{W}};($p,$a)=@{$o{W}{$w=$w[ int rand@w]}}{D,A};put p"$o{N}は$d{N}に$wで攻撃!",(($p=($n=int rand 100)>$a?0: $n>$a/2?int($p/2)-$d{S}:$n>$a/20?$p-$d{S}:$p)>0or$p=0)?"$pダメージ!":'ミス!';( $d{H}-=$p)>0?push@p,\%d:put p b"$d{N}を倒した!"}put p"$p[0]{N}の勝利!",end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/163
164: nobodyさん [sage] 03/08/28 05:11 ID:??? 「素早さ」を実装したいけど、どうも巧くない。 #--- br.dat --- # 名前, 防御力, 体力, 素早さ(1〜99), [ [ 武器名, 攻撃力, 命中率(1〜99) ] ... ] [ [ '煽り', 10, 300, 99, [['キック',60,50], ['パンチ',30,70]] ], [ '荒らし', 0, 400, 50, [['キック',90,70], ['パンチ',40,80]] ], [ '夏厨', 20, 200, 25, [['キック',80,90], ['パンチ',20,90]] ], ]; #--- br.cgi (素早さ実装版) --- #!/usr/local/bin/perl use CGI':all';put header(-charset=>($C='EUC-JP')),start_html -encoding=>$C,lang ,ja,title=>BR;@p=@{do'br.dat'};while($#p){put p map"[$_->[0]:$_->[2]]",@p;$N=0; {for(0..$#p){int$c%(99/$p[$_][3])&&next;($N,*W)=@{*O=splice@p,$_,1}[0,4];($W,$D ,$A)=@{$W[rand@W]};last}$c=0if++$c>99;$N||redo}($n,$s)=@{*d=splice@p,rand@p,1}; put p"$Nは$nに$W!",(($D-=($i=rand 100)>$A?$D:$i>$A/2?int($D/2)+$s:$i>$A/20?$s:0 )>0or$D=0)?"$Dダメージ!":'ミス!';@p=sort{$b->[3]<=>$a->[3]}@p,\@O;($d[2]-=$D)>0 ?@p=(\@d,@p):put p b"$nを倒した!"}put p"$Nの勝利!",end_html #--- br.cgi (素早さ未実装版) --- #!/usr/local/bin/perl use CGI':all';put header(-charset=>($C='EUC-JP')),start_html -encoding=>$C,lang ,ja,title=>BR;@p=@{do'br.dat'};while($#p){put p map"[$_->[0]:$_->[2]]",@p;($N, *W)=@{$p[-1]}[0,4];($W,$D,$A)=@{$W[rand@W]};($n,$s)=@{*d=splice@p,rand$#p,1}; put p"$Nは$nに$W!",(($D-=($i=rand 100)>$A?$D:$i>$A/2?int($D/2)+$s:$i>$A/20?$s:0 )>0or$D=0)?"$Dダメージ!":'ミス!';($d[2]-=$D)>0?push@p,\@d:put p b"$nを倒した!"} put p"$Nの勝利!",end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/164
165: nobodyさん [sage] 03/08/28 12:01 ID:??? >>164 まだやってたのかよw がんがれ! http://medaka.5ch.net/test/read.cgi/php/1036141603/165
166: 保守 [sage] 03/10/04 05:54 ID:??? $$_=1for"@ARGV"=~/\w/g;for('0019'..9999){my%c;$n=$_;next if$h{"@{[sort@v=/./g]} "}++&&$o||$z&&/0/||$d&&(grep$c{$_}++,@v);O:for(map[@{[qw(+ - * /)]}[$_&3,$_>>2& 3,$_>>4&3]],0..63){@x=(@$_,@v);eval==10&&do{print"$n:$_\n";$c&&last O}for grep s/(\d)/$x[$1]/g,qw/(304)1(526) ((304)15)26 30(41(526)) 30((415)26) (30(415))26/ }} http://medaka.5ch.net/test/read.cgi/php/1036141603/166
167: nobodyさん [sage] 03/10/05 03:33 ID:??? 本家スレで出てた切符問題の CGI プログラム版。 選択された4つの数字のみを調べる。 #!/usr/local/bin/perl use CGI':all';@n=param n;for(map[@{[qw(+ - * /)]}[$_&3,$_>>2&3,$_>>4&3]],0..63) {@x=(@$_,@n);for$t(qw/(304)1(526) ((304)15)26 30(41(526)) 30((415)26)/,'(30(41' .'5))26'){$_=$t;s/(\d)/$x[$1]/g;eval==10&&push@e,$_.br}}put header,start_html( -title=>7410),startform(0,script_name),p(scrolling_list(qw(-name n -size 10), -values=>[0..9])x4,submit),endform,p(@e),end_html >>166 は 5.005_03 なら動いたけど 5.8.0 だと不可。 http://medaka.5ch.net/test/read.cgi/php/1036141603/167
168: nobodyさん [sage] 03/10/05 20:23 ID:??? コマンドライン・CGI 両対応版。 #--- 7410.cgi --- #!/usr/local/bin/perl use CGI':all';sub e{for(map[@{[qw(+ - * /)]}[$_&3,$_>>2&3,$_>>4&3]],0..63){@x=( @$_,@n);for$t(qw/(304)1(526) ((304)15)26 30(41(526)) 30((415)26) (30(415))26/){ $_=$t;s/(\d)/$x[$1]/g;eval==10&&do{$r?push@e,$_.br:print"$n:$_\n";$c&&return}}} @e}if($r=$ENV{'REMOTE_ADDR'}){@n=param n;put header,start_html(-title=>7410), startform(0,script_name),p(scrolling_list(qw(-name n -size 10 -values),[0..9])x 4,submit),endform,p(e),end_html}else{$$_=1for"@ARGV"=~/\w/g;$n=$_,$h{"@{[sort@n =/./g]}"}++&&$o||$z&&/0/||$d&&do{my%c;grep$c{$_}++,@n}or e for'0019'..9999} __END__ usage: ./7410.cgi [ -cdoz ] -c : 1組の数字に対し1つの計算式のみ出力 -d : 同じ数字を使わない -o : 1組の数字に対し1つの出現順序のみ出力 -z : 0を含めない http://medaka.5ch.net/test/read.cgi/php/1036141603/168
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 284 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.017s