七行プログラミング (452レス)
七行プログラミング http://medaka.5ch.net/test/read.cgi/php/1036141603/
上
下
前
次
1-
新
通常表示
512バイト分割
レス栞
277: SevenLines の中の人 [sage] 04/03/14 15:52 ID:??? >>274-276 の三つ、問題無いようでしたらサイトに載せます。 7uploader と 7Hoo は仕様や出力を随分いぢってしまったので、 軌道修正もお願いします。(w >原作者殿 作業用のアップローダ用意しましたので、ファイルの受け渡しに ご利用下さい。 http://cm.xrea.cc/upload.cgi TODO: 7rwcntr > telnetd > Unit7 > Store7 > 7vote telnetd と accesslog.cgi は 202 さんと 266 さんに掲載許可を 頂け次第サイトに載せようと思ってますので、適用ライセンス等 ご連絡下されば幸いです。 http://medaka.5ch.net/test/read.cgi/php/1036141603/277
278: 266 [] 04/03/15 14:12 ID:jJ3gsLA0 #! /usr/bin/perl sub r{$r=$_[0]?"tab-separated-values\nContent-Disposition: attachment;filenam". "e=log.csv":"plain";print"Content-Type: text/$r\n\n"}if(($a,$f,$t,$k)=split/&/, $ENV{QUERY_STRING}){r $a;for($f...$t){/^\d{8}$/x&&open F,"$_.txt";($k?/\Q$k/:1) &&(print)while<F>}}else{r;s/^\d$/0$&/for($s,$n,$h,$d,$m,$y)=localtime;$y+=1900; $m++;$m=~s/^\d$/0$&/;open F,">>$y$m$d.txt";print F join("\t",$h,$n,$s,@ENV{ REQUEST_URI,REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER}),"\n"} >>266です。 >>268はアクセスログ記録モードで呼び出したときもCSVのダウンロードダイアログが出る という致命的なバグがありました。すみません。 バグ修正と、さらにパラメータで画面に表示/ダウンロードを選択できるようにしました。 また、REQUEST_URIも記録するようにしたので、サイト全体の解析にも使えるようになったと思います。 スクリプト名は他にあわせて、7accesslog.cgi と変更しようと思います。 こんなので掲載していただけるのであれば是非お願いします。 このスレのおかげで完成したと思っているので、私としては権利等の主張をする つもりはありませんのでGPLあたりの他のスクリプト同様のライセンスにしてください。 ■使用法 ・記録時はSSI等で呼び出します。>>271さんみたいにJavaScriptでも呼び出せそうな気はします。 ・表示およびダウンロード時はパラメータをつけて普通に呼び出します。 パラメータなし アクセスログを記録。 日付.txt に 時,分,秒,REQUEST_URI,REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER を記録します。 パラメータあり アクセスログを表示/ダウンロード 第1パラメータ ・・・ 0:表示 1:ダウンロード 第2パラメータ ・・・ ログの取得開始日(yyyymmdd) 第3パラメータ ・・・ ログの取得終了日(yyyymmdd) 第4パラメータ ・・・ ログ取得時の絞込みキーワード(省略すると全件取得) (例) http://hoge.com/7accesslog.cgi?1&20040301&20040331&MSIE この例では、2004年3月1日〜2004年3月31日までの「MSIE」を含むログがダウンロードされます。 http://medaka.5ch.net/test/read.cgi/php/1036141603/278
279: 7accesslog [sage] 04/03/16 15:40 ID:??? ($a,$f,$t,$k)=@ARGV;print"Content-Type: text/",!$a?plain:"tab-separated-values Content-Disposition: attachment;filename=log.csv","\n\n";$k=~s/%([\da-f]{2})/ pack"H2",$1/egi;$f?do{/^\d{8}$/&&(open(F,"$_.txt"),print grep$k?/\Q$k/o:1,<F>) for$f..$t||$f}:do{s/^\d$/0$&/for($s,$n,$h,$d,$m,$y)=localtime;$y+=1900;$m++;$m =~s/^\d$/0$&/;open F,">>$y$m$d.txt";print F join("\t",$h,$n,$s, @ENV{REQUEST_URI,REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER}),"\n"} ・検索ワードを URI-unescape ・第 3 引数を省略可能に ・パラメータをクエリ渡しから引数渡しへ (例) http://hoge.com/7accesslog.cgi?1+20040301+20040331+MSIE%205 http://hoge.com/7accesslog.cgi?1+20040301 http://medaka.5ch.net/test/read.cgi/php/1036141603/279
280: 266 [sage] 04/03/16 18:36 ID:??? >7accesslog for で $f..$t ってやると、月や年をまたいだ時、 無駄なファイルオープン(できないやつ)が多発するので そこをなんとかしたいです・・・。 ヘタレな私にはいい方法が思いつきませんが。 http://medaka.5ch.net/test/read.cgi/php/1036141603/280
281: nobodyさん [sage] 04/03/16 22:51 ID:??? >>280 ・効率的な生成アルゴリズムを Web や本から探す。 ・思いつくまま色々書いて試す。 ・文字数を食っている機能を捨てる。 ・緩めのルール (shebang 無し 7 行 & モジュール可) で挑戦する。 とにかく足掻いて形にするのが大事。 http://medaka.5ch.net/test/read.cgi/php/1036141603/281
282: nobodyさん [sage] 04/03/16 23:11 ID:??? >>277 202です。 ライセンスとかようわからないですが、telnetdとStore7はほかのと同じようにして置いていただければ結構です。 http://medaka.5ch.net/test/read.cgi/php/1036141603/282
283: 266 [sage] 04/03/17 10:18 ID:??? ($a,$f,$t,$k)=@ARGV;$k=~s/%([\da-f]{2})/pack"H2",$1/egi;$l=$f.($t?"-$t":"").($k ?"-$k":"");print"Content-Type: text/",$a?"tab-separated-values\nContent-Dispo". "sition: attachment;filename=log$l.csv":plain,"\n\n";$f?do{/^\d{4}(\d\d)(\d\d)$ /x&&$1*$2&&$1<13&&$2<32&&(open(F,"$_.txt"),print grep$k?/\Q$k/o:1,<F>)for$f..$t ||$f}:do{s/^\d$/0$&/for($s,$n,$h,$d,$m,$y)=localtime;$y+=1900;$m++;$m=~s/^\d$/0 $&/x;open F,">>$y$m$d.txt";print F join("\t",$y,$m,$d,$h,$n,$s,@ENV{REQUEST_URI ,REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER}),"\n"} ■記録時 ・ログファイルに日付も記録するよう変更。 (日付範囲を指定してログ表示した際に日付が無いとわけわからないため) ■閲覧時 ・ダウンロード時のファイル名に抽出条件を盛り込むよう変更。 ・1〜12月の1〜31日の間だけファイルオープンを試みるよう変更。 いろいろ増やしたらshebang無し七行になっちゃいました。 http://medaka.5ch.net/test/read.cgi/php/1036141603/283
284: nobodyさん [sage] 04/03/17 11:13 ID:??? トイレに行かせただけで動作未確認。 ($k=$ARGV[3])=~s/%([\da-f]{2})/pack"H2",$1/egi;/\D/&&die for($a,$f,$t)=@ARGV; print"Content-Type: text/",$a?"tab-separated-values\nContent-Disposition: atta" ."achment;filename=log$f".($t&&"-$t").($k&&"-$k").'.csv':plain,"\n\n";$f?do{/^. ...(..)(..)$/x&&$1*$2&&$1<13&&$2<32&&(open(F,"$_.txt"),print grep$k?/\Q$k/o:1, <F>)for$f..$t||$f}:do{($d,$m,$y)=(localtime)[3,4,5];open F,sprintf">>%d%02d%02" ."d.txt",$y+1900,$m+1,$d;print F join("\t",''.localtime,@ENV{REQUEST_URI, REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER}),"\n"} ログの日付を scalar localtime に変更。 http://medaka.5ch.net/test/read.cgi/php/1036141603/284
285: nobodyさん [sage] 04/03/17 14:13 ID:??? ($a,$f,$t,$k)=@ARGV;$k=~s/%([\da-f]{2})/pack"H2",$1/egi;print"Content-Type: ". "text/",$a?"tab-separated-values\nContent-Disposition: attachment;filename=l". "og$f".($t&&"-$t").($k&&"-$k").'.csv':plain,"\n\n";$f?do{/^....(..)(..)$/&&$1* $2&&$1<13&&$2<32&&(open(F,"$_.txt"),print grep$k?/\Q$k/o:1,<F>)for$f..$t||$f}: do{($d,$m,$y)=(localtime)[3,4,5];open F,sprintf">>%d%02d%02d.txt",$y+1900,$m+1 ,$d;print F join("\t",''.localtime,@ENV{REQUEST_URI,REMOTE_ADDR, HTTP_USER_AGENT,HTTP_REFERER}),"\n"} >>284 1行目ってなんで変えたの?>>283の1行目で動くようなので戻すことで若干縮め。 あとattachmentのつづり直した。もう少しでshebang含7行。 http://medaka.5ch.net/test/read.cgi/php/1036141603/285
286: nobodyさん [sage] 04/03/17 15:03 ID:??? >>285 コードそのまま。$a, $f, $t に数字以外の文字が 含まれない事を保障する為。 まぁここはチェック飛ばしても穴にはならんかな。 http://medaka.5ch.net/test/read.cgi/php/1036141603/286
287: nobodyさん [sage] 04/03/17 17:14 ID:??? >>285 78文字+改行になってるよw さらに強引に短くしてみた。 変更点 pack"H2"→pack H2 DLファイル名→$f-$t-$k.log $1*$2→$1のみ判定 [3,4,5]→[3..5] #! perl ($a,$f,$t,$k)=@ARGV;$k=~s/%([\da-f]{2})/pack H2,$1/egi;print"Content-Type: te". "xt/",$a?"tab-separated-values\nContent-Disposition: attachment;filename=$f".($ t&&"-$t").($k&&"-$k").'.log':plain,"\n\n";$f?do{/^....(..)(..)$/&&$1&&$1<13&&$2 <32&&(open(F,"$_.txt"),print grep$k?/\Q$k/o:1,<F>)for$f..$t||$f}:do{($d,$m,$y)= (localtime)[3..5];open F,sprintf">>%d%02d%02d.txt",$y+1900,$m+1,$d;print F join ("\t",''.localtime,@ENV{REQUEST_URI,REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER}), "\n"} あと5バイト http://medaka.5ch.net/test/read.cgi/php/1036141603/287
288: nobodyさん [sage] 04/03/17 17:15 ID:??? 汎用 TSV ヴューア #!/usr/local/bin/perl use CGI":all";charset$C='EUC-JP';*P=*param;($f=P(f))=~/[^\w*\-.?\[\\\]]/&¨$ w=P(w)||"\t";chomp(@l=map{open(_)?grep(/\Q$w/,<_>):()}grep/$f/o&&-f,<*>)if$f;%l =(f,"target file regex",w,"search word",o,"output file name");put(($o=P(o))?( "Content-Type: text/tab-separated-values\nContent-Disposition: attachment;file" ."name=$o\n\n",@l):(header,start_html(-title=>'7tsview',encoding,$C,lang,ja), table({border,1},Tr[map{td[split/\t/]}@l]),startform(0,url),p(map{$l{$_}, textfield($_,'',40).br}f,w,o),endform,end_html)) http://medaka.5ch.net/test/read.cgi/php/1036141603/288
289: nobodyさん [sage] 04/03/17 17:27 ID:??? use CGI":all";charset$C='EUC-JP';*P=*param;($f=P(f))=~/[^\w*\-.?\[\\\]]/&¨$ w=P(w)||"\t";chomp(@l=map{open(_)?grep(/\Q$w/,<_>):()}grep/$f/o&&-f,<*>)if$f;%l =(f,"target file regex",w,"search word",o,"output file name");put(($o=P(o))?( "Content-Type: text/tab-separated-values\nContent-Disposition: attachment;file" ."name=$o\n\n",@l):(header,start_html(-title=>'7tsview',encoding,$C,lang,ja), table({border,1},Tr[map{td[split/\t/]}@l]),startform(0,url),p(map{$l{$_}, textfield($_,'',40).br}f,w,o),submit(0,go),endform,end_html)) submitを追加 http://medaka.5ch.net/test/read.cgi/php/1036141603/289
290: nobodyさん [sage] 04/03/17 17:31 ID:??? 動作未確認。末尾に空フィールドができるけどゴメンして。 ($a,$f,$t,$k)=@ARGV;$k=~s/%([\da-f]{2})/pack H2,$1/egi;print"Content-Type: te". "xt/",$a?"tab-separated-values\nContent-Disposition: attachment;filename=$f".($ t&&"-$t").($k&&"-$k").'.log':plain,"\n\n";sub l{localtime}$f?do{/^....(..)(..)$ /x&$1<13&$2<32&&(open(F,"$_.txt"),print grep$k?/\Q$k/o:1,<F>)for$f..$t||$f}:do{ ($d,$m,$y)=(l)[3..5];open F,sprintf">>%d%02d%02d.txt",$y+1900,$m+1,$d;print F join"\t",''.l,@ENV{REQUEST_URI,REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER},"\n"} http://medaka.5ch.net/test/read.cgi/php/1036141603/290
291: 266 [] 04/03/18 14:52 ID:vM8w8oY1 #! /usr/bin/perl ($a,$f,$t,$k)=@ARGV;$k=~s/%([\da-f]{2})/pack H2,$1/egi;print"Content-Type: te". "xt/",$a?"tab-separated-values\nContent-Disposition: attachment;filename=$f".($ t&&"-$t").($k&&"-$k").'.log':plain,"\n\n";sub l{localtime}$f?do{/^....(..)(..)$ /x&$1*$2&$1<13&$2<32&&(open(F,"$_.txt"),print grep$k?/\Q$k/o:1,<F>)for$f..$t||$ f}:do{open F,sprintf">>%d%02d%02d.txt",(l)[5]+1900,(l)[4]+1,(l)[3];print F join ("\t",''.l,@ENV{REQUEST_URI,REMOTE_ADDR,HTTP_USER_AGENT,HTTP_REFERER}),"\n"} ・書き込み時のファイル名構築の際に関数lを使用するよう変更 ・0月も0日も除外するようあらためて変更 ・>>290さんの末尾の空フィールドができないよう変更 皆さんのおかげで再びshebang入り七行達成しました。 しかし、>>288-289のツールがあるなら、閲覧モードは不要だったりして・・・。 http://medaka.5ch.net/test/read.cgi/php/1036141603/291
292: SevenLines の中の人 [sage] 04/03/23 12:22 ID:??? 7wiki (>>274) 、7Hoo (>>276) 、7accesslog (>>291) を載せました。 README の変更等ありましたらココかアップローダにお願いします。 http://medaka.5ch.net/test/read.cgi/php/1036141603/292
293: nobodyさん [] 04/03/23 16:33 ID:C7ISjwar #! /usr/bin/perl use CGI":all";charset$c='EUC-JP';opendir(H,"./");$s='7editor';while($i=readdir H){$l.=li a {href,"$s.cgi?$i"},$i}if(request_method eq'POST'){$p=param(f);open( H,">$p");print H param(t);print"Location: $s.cgi?$p\n\n"}else{$q=$ARGV[0];if($q ){open H,$q;$f.=$_ while(<H>)}put header,start_html(-title=>$s,encoding,$c,lang ,ja),h1($s),ul($l),startform(post,"$s.cgi"),p(textfield f,$q),p(textarea t,$f,9 ,82),p(submit regist),endform,end_html} ●7editor.cgi サーバ上のファイルを直接編集できます。ファイル名欄を変えれば新規作成も可能です。 textareaのサイズは、一応七行プログラミングを組みやすいかと思われる82x9にしてみました。 ToDo: ・セキュリティ対策 ・ディレクトリ移動 ・ファイル削除くらいはできた方がいいかも とりあえずたたき台ってことで。 http://medaka.5ch.net/test/read.cgi/php/1036141603/293
294: nobodyさん [sage] 04/03/23 17:07 ID:??? 縮め&書き込み確認ダイアログ #! /usr/bin/perl use CGI":all";charset$c='EUC-JP';opendir H,"./";$s='7editor';while($i=readdir H ){$l.=li a{href,"$s.cgi?$i"},$i}if(request_method eq'POST'){$p=param(f);open H, ">$p";print H param(t);put"Location: $s.cgi?$p\n\n"}else{if(open H,$q=$ARGV[0]) {$f.=$_ while(<H>)}put header,start_html(-title=>$s,encoding,$c,lang,ja),h1($s) ,ul($l),startform(-onSubmit=>"return confirm('OK?')",post,"$s.cgi"),p(textfield f,$q),p(textarea t,$f,9,82),p(submit regist),endform,end_html} http://medaka.5ch.net/test/read.cgi/php/1036141603/294
295: nobodyさん [sage] 04/03/23 18:36 ID:??? #! /usr/bin/perl use CGI":all";charset$c='EUC-JP';*b=*param;opendir H,"./";while($i=readdir H){$ l.=li a{href,($s='7editor').".cgi?$i"},$i}if(request_method=~/POST/){open H,">" .($n=b F);$_=b T;s/[\r\n|\r[^\n]]/\n/g;print H;put redirect"$s.cgi?$n"}else{if( open H,$q=$ARGV[0]){$f.=$_ while<H>}put header,start_html(-title=>$s,encoding,$ c,lang,ja),h1($s),ul($l),startform(-onSubmit=>"return confirm('OK?')",,"$s.cgi" ),p(textfield F,$q),p(textarea T,$f,9,82),p(submit regist),endform,end_html} 環境によって改行コードが変わってしまうバグを修正。結構ギリギリ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/295
296: nobodyさん [] 04/03/24 11:46 ID:/Yo7kiNa #! perl use CGI":all";charset$c='EUC-JP';opendir H,".".($d=path_info);while($_=readdir H){if(!/^\.+$/){$l.=li a{href,script_name."$d".(-d".$d/$_"?"/":"?").$_},$_}}if( request_method=~/P/){open H,">.$d/".($n=param F);$_=param T;s/\r\n|\r[^\n]/\n/g ;print H}if(open H,".$d/".($q=$ARGV[0])){$f.=$_ while<H>}put header,start_html( -title=>"7editor",encoding,$c,lang,ja),h1($d||"/"),ul($l),startform(-onSubmit=> "return confirm('OK?')"),p(textfield(F,$q),br,textarea(T,$f,9,82),br,submit),endform,end_html ディレクトリを移動できるように 「.」「..」は非表示 h1要素は現在位置を表示 スクリプト名は自由(7editorじゃなくても可)に でも14文字ほどハミ出た。 http://medaka.5ch.net/test/read.cgi/php/1036141603/296
297: nobodyさん [sage] 04/03/24 14:15 ID:??? use CGI":all";charset$c='EUC-JP';($d=path_info)=~s|/*$|/|;if(request_method=~PO ){open H,">.$d".($n=param F);$_=param T;s/\x0D\x0A/\n/g;tr/\r/\n/;print H}$/=() ,$f=<H>if open H,".$d".($q=pop);opendir H,".$d";$l.=li a{href,url.$d.(-d".$d$_" ?$_:"?$_")},$_ for grep!/^\.+$/,readdir H;put header,start_html(-encoding=>$c, lang,ja,Title,"7editor"),h1($d),ul($l),startform(-onSubmit=>"return confirm( 'OK?')"),p(textfield(F,$q),br,textarea(T,$f,9,82),br,submit),endform,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/297
298: nobodyさん [sage] 04/03/24 15:33 ID:??? ・.で画面リロード、..で親DIRへ移動 ・ディレクトリはお尻に「/」 use CGI":all";charset$c='EUC-JP';($d=path_info)=~s|/*$|/|;if(request_method=~PO ){open H,">.$d".($n=param F);$_=param T;s/\x0D\x0A/\n/g;tr/\r/\n/;print H}$/=() ,$f=<H>if open H,".$d".($q=pop);opendir H,".$d";$l.=li a{href,url.$d.(($h=-d".$ d$_")?$_:"?$_")},($_.($h&&"/"))for readdir H;put header,start_html(-encoding=>$ c,lang,ja,Title,"7editor"),h1($d),ul($l),startform(-onSubmit=>"return confirm( 'OK?')"),p(textfield(F,$q),br,textarea(T,$f,9,82),br,submit),endform,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/298
299: nobodyさん [sage] 04/03/24 20:28 ID:??? #!/usr/bin/perl use IO::Socket;$S=new IO::Socket::INET(Listen,1,LocalPort,1029,Reuse,1);sub p{ print@_}sub g($){($_=getc$C)eq pop}$n="\x0D\x0A";sub o{$c=pop;g"\x01"?($e=$c&2) :/\x22/?($c&1or$e=0):($c=1);p pack(C2,255,250+(4,2,2,4,3,2,1,4)[$c&1?$c:$c+4]), $_}{binmode($C=$S->accept);select$C;$e=1;$b='';p$p='$ ';{g"\xFF"?g"\xF7"?chop$b :/\xF8/?($b=''):/\xFB/?o 0:/\xFC/?o 1:/\xFD/?o 2:/\xFE/?o 3:0:/\x00/?do{$b=~s/[ $n]+\z//x;"exit"eq$b&&last;s/\s+\z/$n/for@o=`$b`;p$n,@o,$p;$b=''}:(/\x08/?chop$ b:($b.=$_),/[$n]/||$e&&p$_);redo}close$C;redo} ttp://www5e.biglobe.ne.jp/~aji/3min/53.html を読みながら色々 実装してみるも、>>207 に負けてる telnetd 。;) 動作確認: TeraTermPro → Win98SE (command.com + KI-Shell) TeraTermPro → FreeBSD 4-STABLE (tcsh) telnet(1) (line mode) → Win98SE (command.com + KI-Shell) telnet(1) (line mode) → FreeBSD 4-STABLE (tcsh) TODO: cd http://medaka.5ch.net/test/read.cgi/php/1036141603/299
300: 7telnetd [sage] 04/03/25 10:13 ID:??? cd 実装。 #!/usr/bin/perl use IO::Socket;$S=new IO::Socket::INET(Listen,1,LocalPort,1029,Reuse,1);sub p{ print$C @_}sub g($){($_=getc$C)eq pop}$n="\x0D\x0A";{binmode($C=$S->accept);$e= 1;$b='';p$p='$ ';{g"\xFF"?g"\xF7"?chop$b:/\xF8/?($b=''):/[\xFB-\xFE]/?do{$c=ord ()-251;g"\x01"?($e=$c&2):/\x22/?($c&1or$e=0):($c=1);p pack(C2,255,250+(4,2,2,4, 3,2,1,4)[$c&1?$c:$c+4]),$_}:0:/\x00/?(($_,$b)=$b,s/[$n]+\z//,/^exit$/&&last,p$n ,(/^cd\s+/?chdir$':map{s/\s+\z/$n/;$_}`$_`),$p):(/\x08/?chop$b:($b.=$_),/[$n]/ ||$e&&p$_);redo}close$C;redo} http://medaka.5ch.net/test/read.cgi/php/1036141603/300
301: クダランけど [sage] 04/03/25 11:06 ID:??? ■ 7jump.cgi(ime.nuクローン) ttp://hoge.com/7jump.cgi/http://www.2ch.net/ スキーマ指定可能 ttp://hoge.com/7jump.cgi/www.2ch.net/ 省略時はhttp:// #! perl use CGI":all";charset$c='EUC-JP';$_=path_info;s|^/||;s/\"/"/g;s/\'/?/g ;s/</</g;s/>/>/g;s/&(?![\#0-9a-zA-Z]+;?)/&/g;$_="http://$_"if!/:/;($m ,$a)=<DATA>;put header,start_html(-title=>"7jump",encoding,$c,lang,ja),p(strong (a{href,$_},$_).br.$m),hr,address($a),end_html; __DATA__ 別のサイトにジャンプしようとしています。宜しければ上記のリンクをクリックしてください Powered by WebProg http://medaka.5ch.net/test/read.cgi/php/1036141603/301
302: 実体参照忘れてたスマソ [sage] 04/03/25 11:08 ID:??? #! perl use CGI":all";charset$c='EUC-JP';$_=path_info;s|^/||;s/\"/"/g;s/\'/'/g ;s/</</g;s/>/>/g;s/&(?![\#0-9a-zA-Z]+;?)/&/g;$_="http://$_"if!/:/;($m ,$a)=<DATA>;put header,start_html(-title=>"7jump",encoding,$c,lang,ja),p(strong (a{href,$_},$_).br.$m),hr,address($a),end_html; __DATA__ 別のサイトにジャンプしようとしています。宜しければ上記のリンクをクリックしてください Powered by WebProg http://medaka.5ch.net/test/read.cgi/php/1036141603/302
303: nobodyさん [sage] 04/03/25 11:55 ID:??? use CGI":all";charset$c='EUC-JP';$_=path_info;/:/?s|^/||:($_="http:/$_");put header,start_html(-Title,"7jump",encoding,$c,lang,ja),p(strong(a{href,$_}, escapeHTML$_).br.<DATA>),hr,address(<DATA>),end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/303
304: nobodyさん [sage] 04/03/29 10:25 ID:??? 巻き戻り分。 304 :7uploader :04/03/25 21:16 ID:??? use CGI":all";$CGI::POST_MAX=1<<20;$/=\4096;chdir D;sub v{open(F,pop)?binmode F :die}if(($f=upload f)=~/\.\w+$/){v">".time.$&;print F while<$f>;close F}++$i<51 ?push@f,$_:unlink for sort{$b<=>$a}<*>;($_=param d)?(v($_),put header(-type, 'application/octet-stream',Content_length,-s,attachment,$_),<F>):put(header, start_html,start_multipart_form,filefield(f),submit,endform,table({border,1},Tr [map{td[a({href,"?d=$_"},$_),''.localtime+(stat)[9],(-s>>10).KB]}@f]),end_html) ・ファイルサイズを KB で表示。 http://medaka.5ch.net/test/read.cgi/php/1036141603/304
305: Unit7.pm [sage] 04/03/29 10:31 ID:??? #!perl if(!caller){my$p=pop;eval"use $p;1"?new$p->run:die$@}package Unit7;sub p{print" @_\n"}sub new{bless{},shift}sub run{$N=$O=0;for(grep/^test/,keys%{ref($s=shift) ."::"}){$T=$n=$o=0;$N++;set_up$s;$s->$_();tear_down$s;$n-$o||$O++;$T||p"$N) $S" ;print"$o/$n ok\n"}p$N-$O?("Run: $N, Failures:",$N-$O):"OK ($N tests)"}*set_up= *tear_down=sub{};sub assert{($s,$f,$m)=@_;($S)=(caller 1)[3]=~/\w+$/g;$n++;$o++ ,return if$f;$T++||p"$N) $S";print"\t$m\n"}$VERSION=1.00 ・出力フォーマットの変更 ・簡易 TestRunner.pl を内包 (> perl ./Unit7.pm My::TestCase::Class) http://medaka.5ch.net/test/read.cgi/php/1036141603/305
306: Store7.pm [sage] 04/03/29 14:12 ID:??? package Store7;use Symbol;sub E{$_=pop;s/['\\]/\\$&/g;"'$_'"}sub D{local$_=ref( my$f=pop);/SCALAR/?E$$f:/ARRAY/?"[".join(',',map{D($_)}@$f)."]":/HASH/?"{".join (',',map{E($_),D($f->{$_})}keys%$f)."}":E$f}$O='{open($f=gensym,$m.pop)||die if $m="';$E='local$/;(eval<$f>';$P='print$f D pop;1';$F='eval{flock$f';$L='lock_'; use base Exporter;$C=',close$f';$G='{$f=pop;';$M='}sub ';@EXPORT=($S='store',$R ='retrieve');@EXPORT_OK=($S.'_fd',"fd_$R",$L.$S,$L.$R);eval qq/sub $R$O<";$E$C )[0]$M$L$R$O<";$F,1};$E$C)[0]$M\fd_$R$G$E)[0]$M$S$O>";$P$C$M$L$S$O>";$F,2};$P$C $M$S\_fd$G$P}/;$VERSION=1.00 ・store_fd 、lock_store 、fd_retrieve 、lock_retrieve 実装 >>260 s/['\\]/\\$&/g でマズい例ってどんなのでしょう? http://medaka.5ch.net/test/read.cgi/php/1036141603/306
308: SevenLines の中の人 [sage] 04/04/16 12:18 ID:??? ダメ出しが無いようなので 7telnetd (>>300) と Unit7 (>>305) を載せました。 (個人的な)TODO: 7ch と 7thread の転載体裁整え > Store7 > 7vote 128 氏もライセンス GPL にしちゃっていいんでしょか? ご自身のサイトをお持ちでそちらで公開されるなら、SevenLines から リンクさせてもらいますよと言ってみるテスト。 http://medaka.5ch.net/test/read.cgi/php/1036141603/308
309: Store7.pm [sage] 04/04/19 14:35 ID:??? 縮め。 package Store7;use base Exporter;use Symbol;sub E{$_=pop;s/['\\]/\\$&/g;"'$_'"} @EXPORT=($S=store,$R=retrieve);$L=lock_;@EXPORT_OK=($S.'_fd',"fd_$R",$L.$S,$L.$ R);sub D{local($_,$")=(ref(my$f=pop),',');/^S/?E$$f:/^A/?"[@{[map{D($_)}@$f]}]" :/^H/?"{@{[map{E($_),D($f->{$_})}keys%$f]}}":E$f}$M='}sub ';$P='print$f D pop;1 ';($E,$C,$F,$G)=qw|local$/;(eval<$f> ,close$f eval{flock$f {$f=pop;|;$O='{open( $f=gensym,$m.pop)||die if$m="';eval qq/sub $R$O<";$E$C)[0]$M$L$R$O<";$F,1};$E$C )[0]$M fd_$R$G$E)[0]$M$S$O>";$P$C$M$L$S$O>";$F,2};$P$C$M$S\_fd$G$P}/;$VERSION=1 http://medaka.5ch.net/test/read.cgi/php/1036141603/309
310: SevenLines の中の人 [sage] 04/04/21 09:33 ID:??? 7ch と 7thread を GPL でパッケージング & Store7 を載せました。 README の変更等ありましたら作業用 uploader の方へお願いします。 http://medaka.5ch.net/test/read.cgi/php/1036141603/310
311: おうら [] 04/05/12 22:12 ID:3q/C0Ti+ リファーを残さずにリダイレクト。JavaScript Off でも動作可能なコード #! /bin/ksh # リダイレクト if [ "$QUERY_STRING" ]; then echo "Pragma: no-cache Refresh: 0; URL=QUERY_STRING\n"; exit; fi # エラー出力 echo "Content-Type: text/html\nPragma: no-cache\n\n<html><head> </head><body>\nリンク先を指定して下さい\n</body></html>" リファーについて参考にしたページ ttp://www.teria.com/~koseki/memo/referrer/ http://medaka.5ch.net/test/read.cgi/php/1036141603/311
312: おうら [sage] 04/05/12 22:16 ID:??? うぐぅ。上のコード URL=QUERY_STIRNG に $ が抜けてました。 URL=$QUERY_STRING と見て下さい。 http://medaka.5ch.net/test/read.cgi/php/1036141603/312
313: 7vote [sage] 04/05/12 22:40 ID:??? 仕様変更無しでザッと縮め。 use CGI":all";*P=*param;charset$c='EUC-JP';chdir V;($F)=P(f)=~/^(\d+)$/;if(open F,"+<$F"){eval{flock F,2};$t=<F>;/\t/and$D{$`}=$'+0while<F>;($n=P(n))?$D{$n}||= 1:($v=P(v))&&$D{$v}++,seek(F,0,0),print F"$t\n",map"$_\t$D{$_}\n",keys%D if request_method=~PO}$L{$K[$i++]}=$_ for radio_group(v,[@K=sort{$D{$b}<=>$D{$a}} keys%D]);put header,start_html(-Title,$t,encoding,$c,lang,ja),h1($t),startform, table({},Tr[map{td["$L{$_}($D{$_})",hr{width,$D{$_}}]}@K]),hr,p(textfield(n), hidden(f,$F),submit),endform,end_html ・hr のグラフは微妙。 ・既に存在する選択肢への投票は、選択肢自体をクリックできた方がより直感的か? http://medaka.5ch.net/test/read.cgi/php/1036141603/313
314: nobodyさん [sage] 04/05/15 10:22 ID:??? open(IN, $ARGV[0].".txt");@lines = <IN>;close(IN); foreach $line (@lines) {if( $line =~ / [a-z0-9]{32}/ ){$hash .= $line;}} open(OUT, ">hash".$ARGV[0].".txt"); print OUT $hash;close(OUT); WinnyBBS の内容を全部コピペ。テキストファイルに保存。 ↓ その中からハッシュを摘出。テキストファイルに出力。 http://medaka.5ch.net/test/read.cgi/php/1036141603/314
315: nobodyさん [sage] 04/05/15 14:15 ID:??? >>314 perl -ne "/ [0-9a-z]{32}/ && print" in.txt > out.txt grep " [0-9a-z]\{32\}" in.txt > out.txt http://medaka.5ch.net/test/read.cgi/php/1036141603/315
316: nobodyさん [] 04/06/11 10:54 ID:iPrFu4uN # 最近、下がり気味なので保守ついでに package BEncode7;use base Exporter;@EXPORT=qw/bencode bdecode/;sub bencode($){ my$i=pop;ref$i eq'HASH'?"d@{[join('',map{bencode($_).bencode($i->{$_})}keys%$i) ]}e":ref$i eq'ARRAY'?"l@{[join('',map{bencode($_)}@$i)]}e":$i=~/^([+-]?\d+)$/? "i${i}e":length($i).":$i"}sub bdecode{local$_=pop;(/^d(.+)e$/s)?{bdecode($1)}:( /^l(.+)e$/s)?[bdecode("$1")]:(s/^i?([+-]?\d+)e//)?(int("$1"),bdecode($_)):( /^(\d+)/&&s/\d+\:(.{$1})//s)?("$1",bdecode($_)):undef}7 Convert::BEncodeの7行版。bittorrent等で使われているフォーマット。 http://medaka.5ch.net/test/read.cgi/php/1036141603/316
317: nobodyさん [sage] 04/06/13 17:48 ID:??? >>316 それだとテスト (001_basic.t) 通らないから、 オリジナルからザックリ縮め直してみたよ。 package Bencode7;use strict;use bytes;use base"Exporter";*bencode=*E=sub{no locale;my$i=pop;ref$i eq"HASH"?join("","d",map(E($_).E($i->{$_}),sort keys%$i), "e"):ref$i eq"ARRAY"?join("","l",map(E($_),@$i),"e"):$i=~/^\d+$/?"i${i}e": length($i).":$i"};sub D{my$c=pop;my$i=shift@{$c};$i=~/d/?do{my%h;while(($i= shift@{$c})ne"e"){unshift@{$c},$i;my$k=D($c);$h{$k}=D($c)}\%h}:$i=~/l/?do{my@l; while(($i=shift@{$c})ne"e"){unshift@{$c},$i;push@l,D($c)}\@l}:$i=~/i/?do{my$n; $n.=$i while($i=shift@{$c})ne"e";$n}:$i=~/\d/?do{my$n="";do{$n.=$i}while($i= shift@{$c})=~/\d/;my$l="";$l.=shift@{$c}for 1..$n;$l}:$c}sub bdecode{D[pop=~ /./gs]}our($VERSION,@EXPORT_OK)=qw(0.01 bencode bdecode) http://medaka.5ch.net/test/read.cgi/php/1036141603/317
318: nobodyさん [] 04/07/14 16:53 ID:I7yo4p0b お題。 ttp://www.webclap.com/ 6行くらいにはなると思う。 http://medaka.5ch.net/test/read.cgi/php/1036141603/318
319: nobodyさん [age] 04/07/14 23:00 ID:??? ム板より http://pc5.2ch.net/test/read.cgi/tech/1051703369/699-700 こういうのはperlとかのが得意そうだったので。 http://medaka.5ch.net/test/read.cgi/php/1036141603/319
320: nobodyさん [sage] 04/07/15 21:20 ID:??? while($act ne "ガッ"){ print "ぬるぽ\n"; $act = <STDIN>; chomp($act); } print "撃退\n"; sleep(1); http://medaka.5ch.net/test/read.cgi/php/1036141603/320
321: nobodyさん [sage] 04/07/24 18:39 ID:??? これってphpじゃだめなん? http://medaka.5ch.net/test/read.cgi/php/1036141603/321
322: nobodyさん [sage] 04/07/24 18:52 ID:??? >>321 個人的には WebPlog らしいお題なら言語は何でも いいと思うけど。てかこんなんはやった者勝ちかと。 http://medaka.5ch.net/test/read.cgi/php/1036141603/322
323: nobodyさん [sage] 04/07/24 20:08 ID:??? とりあえずPHP5+SQLiteな一行掲示板。フォーム部分は分離させた。 <form action=bbs.php method=post>名前:<input type=text name=n>一言:<input type=t ext name=t size=60><input type=submit value=送信></form> <? $d=sqlite_open('l');$n=$_POST['n'];if(!@sqlite_query($d,'SELECT * FROM b;')){ sqlite_query($d,'CREATE TABLE b(n,t,d);');}$t=$_POST['t'];$z=date("Y/m/d H:i:s") ;if($n!=''&&$t!=''){$s="INSERT INTO b(n,t,d) VALUES(\"$n\",\"$t\",\"$z\");";sqli te_query($d,$s);}print "<hr>";$r=sqlite_query($d,"SELECT * FROM b ORDER BY d DES C");$c=0;while(($a=sqlite_fetch_array($r))&&$c<50){print htmlspecialchars($a['n' ]).":".htmlspecialchars($a['t'])."[".$a['d']."]<br><hr>\n";$c++;}sqlite_close($ d); ?> DBファイルとテーブル勝手に作る方式。新着順、50件まで(ただしDBからは消してない)。 読みにくいけどSQLiteの使い方の勉強に…ならんか。 http://medaka.5ch.net/test/read.cgi/php/1036141603/323
324: nobodyさん [sage] 04/07/24 20:14 ID:??? >>318 ちなみにそれ、アクセス解析機能もつけるのか? http://medaka.5ch.net/test/read.cgi/php/1036141603/324
325: nobodyさん [sage] 04/07/25 13:12 ID:??? >>323 GJ! http://medaka.5ch.net/test/read.cgi/php/1036141603/325
326: nobodyさん [sage] 04/07/26 14:27 ID:??? 人ほとんどいないなここ(´・ω・`) Web拍手PHP版(記録側)。例によってフォームは分離。 <form method="post" action="webclap.php" target="clap"> <input type="hidden" name="m" value="c">ついでに一言。 <input type="text" name="t" size=40> <input type="submit" value="拍手を送る"></form> <? if($_POST['m']=='c'){$n=file("l");$d=date("Ymd");$h=date("H");$b=split(",",$n [0]);$a=file("t");echo $a[array_rand($a)];if($b[0]!=$d){$i=0;$x="$d,1,";while($i ++<24){if($i==$h+1)$x.="1,";else$x.="0,";}array_unshift($n,"$x\n");}else{$b[1]++ ;$b[$h+2]++;$x="";$i=-1;while($i++<count($b)-2)$x.="$b[$i],";$n[0]="$x\n";if(cou nt($n)>14)array_pop($n);}$f=fopen("l","w");while(count($n)>0)fputs($f,array_shif t($n));fclose($f);$t=$_POST['t'];if($t!=""){$m=file("m");$f=fopen("m","w");array _unshift($m,"$d,$t\n");if(count($m)>200)array_pop($m);while(count($m)>0)fputs($f ,array_shift($m));fclose($f);}} ?> ごめん、8行になってしまた。取得ログは14日分で1時間単位ごとの記録アリ、 一言メッセージは200件まで保存。動かす前にl,m,tとそれぞれ空ファイル作ってくだされ。 tには拍手ボタン押した後に表示するHTMLを一行で叩き込んで。 複数行にするとランダムでどの行か選んで表示します。一行の長さの制限はわからん。 だれか7行に縮めてくれ。俺はもうだめだ(´Д⊂ http://medaka.5ch.net/test/read.cgi/php/1036141603/326
327: nobodyさん [age] 04/07/26 20:37 ID:??? ためしにkaiseki.php作ったら12行になったΛ||Λダメポ 活気ないのでage http://medaka.5ch.net/test/read.cgi/php/1036141603/327
328: 7clap [sage] 04/07/26 23:10 ID:??? オリジナルから仕様を極力変えない方向で10行。 #!/usr/local/bin/perl use CGI":all";charset$c=Shift_JIS;param(k,$k=1+param k);($w=escapeHTML(param w) )=~s/\x0D\x0A|[\x0A\x0D]/br/eg;sub d{($h,$d,$m,$y)=(localtime(time-86400*pop))[ 2..5];$g=($y+1900).sprintf"%02d"x2,$m+1,$d}($C,$M,$L,$T,$I,$S,$E,@M)=<DATA>; open L,">$L";eval{flock L,2};open C;d>(@c=<C>)[-1]?(@c<14||shift@c,@l=((0)x25, "\n")):(($g,@l)=split/<>/,pop@c);$l[$h+1]++;$l[0]++;open C,">$C";print C@c,join "<>",$g,@l;d(14);open M;@m=grep$g<=$_,<M>;open M,">$M";print M@m,""ne$w&&d."<>$ h<>$w<>\n";put header,start_html(-Title,$T,lang,ja,encoding,$c),($k<10?(p($M[ rand@M]),startform,p(hidden(k),submit$S),p($I,br,textfield w,'',50,50),endform) :p$E),end_html;__END__ ./log.dat ./mes.dat ./lock.dat web拍手送信完了 ついでに一言あればどうぞ (拍手だけでも送れます) もっと送る 沢山の拍手を有り難うございました! 拍手が送信されました。ありがとうございました! 拍手が送信されました。ありがとうございますた! 拍手が送信されました。ありがとさ〜ん! http://medaka.5ch.net/test/read.cgi/php/1036141603/328
329: nobodyさん [sage] 04/07/29 22:33 ID:??? >>323 >>326 PHPって関数名の途中に空白文字入っても動くの? http://medaka.5ch.net/test/read.cgi/php/1036141603/329
330: nobodyさん [sage] 04/07/30 11:49 ID:??? >>329 行末改行は79文字で切ったものなんで、動かす場合は繋げて。 http://medaka.5ch.net/test/read.cgi/php/1036141603/330
331: nobodyさん [sage] 04/07/30 14:27 ID:??? あぁ、「そのまま動く」ってのが明文化されてないわけね…。 >>330 「560byte」プログラミングじゃなくて「7行」なので、79文字 一杯々々使いたかったら、コードの順番入れ替えたりして 調整してね。 http://medaka.5ch.net/test/read.cgi/php/1036141603/331
332: nobodyさん [sage] 04/07/30 23:12 ID:??? あと2chの仕様だが、コード中に半角スペースが2コ以上連続する時は 半角スペースを に置換する 行の最後に半角スペースが付くので、実行する時には注意する http://medaka.5ch.net/test/read.cgi/php/1036141603/332
333: nobodyさん [あ] 04/08/04 20:11 ID:??? age http://medaka.5ch.net/test/read.cgi/php/1036141603/333
334: 7clap [sage] 04/08/06 15:30 ID:??? あと一行半。 #!/usr/local/bin/perl use CGI":all";charset$c=Shift_JIS;param(k,$k=1+param k);($w=escapeHTML(param w) )=~tr/\x0A\x0D//d;($C,$M,$L,$E,@M)=<DATA>;open L;eval{flock L,2};@l=((0)x26," ");sub d{($s,$m,$h,$d,$m,$y)=localtime(time-pop);$l[0]=($y+1900).sprintf"%02d"x 2,$m+1,$d}open C;d>(@c=<C>)[-1]?@c<14||shift@c:(@l=split/<>/,pop@c);$l[$_]++for $h+2,1;open C,">$C";print C@c,join"<>",@l;d 1209600;open M;@m=grep$l[0]<=$_,<M> ;open M,">$M";print M@m,""ne$w&&d."<>$h<>$w<>\n";put header,start_html(lang,ja, encoding,$c),$k<10?(p($M[rand@M]),startform,p(hidden(k),submit Clap),p(Comment, textfield w),endform):p$E,end_html;__END__ ./log.dat ./mes.dat >./lock.dat 沢山の拍手を有り難うございました! 拍手が送信されました。ありがとうございました! 拍手が送信されました。ありがとうございますた! 拍手が送信されました。ありがとさ〜ん! http://medaka.5ch.net/test/read.cgi/php/1036141603/334
335: nobodyさん [sage] 04/08/07 07:38 ID:??? >319 全然要求満たしてないけど、叩き台に。 C/C++用、inputは余計なコード書いてないヘッダファイルのみ #!/usr/bin/perl -Pn /^namespace\s*(\w+)/ && ($ns=$1); /\#include\s*[<"](.+)[">]/ && push(@inc, $1); /^class\s+(\w+)\s*\:?/ && push(@cls, $1); /(([\w\s\*]+)(\w+)\s*\((.+)\))/ && push(@memf, $1); # メンバ関数 /(([\w\s\*]+)(\w+));/ && push(@memv, $1); # メンバ変数 END{ print join("\n", $., $ns, "@inc","@cls","@memf", "@memv"),"\n" } JAVAはリフレクションがあるし、classファイルのフォーマットも公開されてるので 別のアプローチでやってみると面白いかも知れない。(javapやClassBrowserが既にあるけど) http://medaka.5ch.net/test/read.cgi/php/1036141603/335
336: nobodyさん [あ] 04/08/11 09:29 ID:??? age http://medaka.5ch.net/test/read.cgi/php/1036141603/336
337: nobodyさん [] 04/09/18 22:44:55 ID:9YaH2aKo age http://medaka.5ch.net/test/read.cgi/php/1036141603/337
338: nobodyさん [sage] 04/09/18 22:53:04 ID:??? >>335 使い方がわからない。。。。 http://medaka.5ch.net/test/read.cgi/php/1036141603/338
339: nobodyさん [] 04/09/20 13:46:08 ID:k3h/6iWb スクリプト -> 335.pl /* C++のヘッダファイル foo.h */ #include <iostream> #include <stdlib.h> #include "common.h" using namespace std; namespace test{ class FooTest: public Test { int total; public: Test(); ~Test(); int foo(void); int bar(int n, int m); }; // End of class FooTest }; // End of namespace test 実行方法 $ perl -Pn 335.pl < foo.h または、 $ ./335.pl < foo.h 18 test iostream stdlib.h common.h FooTest int foo(void) int bar(int n, int m) using namespace std int total 行数, namespace, includeファイル, メンバ関数, 変数の順に出力 http://medaka.5ch.net/test/read.cgi/php/1036141603/339
340: nobodyさん [sage] 04/09/20 14:43:21 ID:??? 何故わざわざ WebProg 板で? と思いつつ縮め。 #!/usr/bin/perl -n $n=$1if/^namespace\s*(\w+)/;/#include\s*[<"](.+)[">]/&&push@i,$1;/^class\s+(\w+ )\s*\:?/x&&push@c,$1;/\s*([\w\s\*]+\w\s*\(.+\))/&&push@f,$1;/\s*([\w\s\*]+\w);/ &&push@v,$1;END{print join"\n",$.,$n,"@i","@c","@f","@v",''} http://medaka.5ch.net/test/read.cgi/php/1036141603/340
341: nobodyさん [sage] 04/09/21 17:50:57 ID:??? <html> <head> <title>あ</title> </head> <body> </body> </html> http://medaka.5ch.net/test/read.cgi/php/1036141603/341
342: nobodyさん [釣られてみるsage] 04/09/21 17:58:26 ID:??? それはマークアップ言語という(ry http://medaka.5ch.net/test/read.cgi/php/1036141603/342
343: nobodyさん [] 04/10/03 15:30:49 ID:qw0lrubh Store7の圧縮してない奴ないですか? > 作者 http://medaka.5ch.net/test/read.cgi/php/1036141603/343
344: nobodyさん [sage] 04/10/03 17:06:58 ID:??? >>343 自分で展開していかないと面白味が分からないと思うなぁ、コレ。 http://cm.xrea.cc/upload.cgi?d=1096790671.tgz http://medaka.5ch.net/test/read.cgi/php/1036141603/344
345: nobodyさん [sage] 04/10/03 20:29:26 ID:??? >>344 ありがとう いや,実は>>258なんだけど機能強化されてるのでこっちを使おうかと思ってね http://medaka.5ch.net/test/read.cgi/php/1036141603/345
346: nobodyさん [age] 04/12/12 03:10:20 ID:??? あげ http://medaka.5ch.net/test/read.cgi/php/1036141603/346
347: nobodyさん [sage] 04/12/16 18:47:01 ID:??? http://internet.watch.impress.co.jp/cda/news/2004/12/16/5820.html http://medaka.5ch.net/test/read.cgi/php/1036141603/347
348: nobodyさん [sage] 04/12/17 09:19:09 ID:??? >>347 Perlのmolester-minの方はライブラリ使わず9行。(詰めれば6,7行以内に収まりそう。 http://ansuz.sooke.bc.ca/software/molester/ http://medaka.5ch.net/test/read.cgi/php/1036141603/348
349: nobodyさん [sage] 04/12/17 14:50:07 ID:??? >>348 定数をハードコーディングして可搬性を激しく落としてでも Socket.pm を使わない選択は漢だなぁ。(w 80桁ギリギリまで詰めるよう整形したら既にシェバング無し 七行達成してるし、あと 40 byte ほど縮めたらいい感じかな。 $/=$_;$,=shift;$w=$a=shift;sub g{open(F,$4)&&t($2,$a,"e$4",<F>);close F}socket S,2,1,6;$k{+shift}=1;bind S,&a;sub e{open F,">$4";print F$';close F}sub h{t($2, $_,id)for keys%k}sub i{$k{$2}=1}sub f{t($_,$2,$4)for keys%k}sub a{$w=~/:/;pack 'CxnC4x8',2,$',split'\.',$`}sub t{socket X,2,1,6;$w=shift;$k{$w}=(connect X,&a) ?print X"$, $_[0] $_[1]/".pop:$/;close X}for(listen S,5;$SIG{ALRM}=sub{}; m!^(.*?) (.*?) ([e-i])([^/]*)/!s&&$,eq$1&&&$3){alarm 9;(accept(C,S),alarm 0)? read C,$_,1e6:($_="$, $a f".shift);close C} http://medaka.5ch.net/test/read.cgi/php/1036141603/349
350: nobodyさん [sage] 04/12/17 21:57:04 ID:??? >>349 正規表現による暗黙の代入とグローバル特殊変数を使った引数渡しは使えそうだ。 PythonのTinyP2PがXMLRPC等のライブラリを使っているので、 動機のひとつにライブラリなしバージョンを作ろう、ってのがあったみたい。 サイトを良く読むとblogとかにその辺の事情も書いてる様です。 他の言語では、Java(16行), Ruby(6行)版も投稿されてます。 ttp://developers.slashdot.org/comments.pl?sid=132907&cid=11103175 ttp://developers.slashdot.org/comments.pl?sid=132907&cid=11097812 http://medaka.5ch.net/test/read.cgi/php/1036141603/350
351: nobodyさん [sage] 04/12/24 21:39:51 ID:??? ほす http://medaka.5ch.net/test/read.cgi/php/1036141603/351
352: nobodyさん [] 05/01/30 23:39:07 ID:cEoW2dZ/ >>341-342 そういえば、昔、5kっていう5KBにHTMLページを収めるってなコンテストがあったなぁ。 http://www.the5k.org/ 5Kといい、7Lといい、こういうの好きなんだわ漏れ。 7行といえば560バイトでWebPage作るってのはどう? ちょっと擦違いスマソ http://medaka.5ch.net/test/read.cgi/php/1036141603/352
353: nobodyさん [sage] 05/01/31 00:37:15 ID:??? >>352 「どう?」じゃなくて、作って晒せば? こういうのはやったもん勝ち。 面白いと思わせる事ができれば挑戦者も出てくるんじゃない? ただスレのルール的に、「560 byte」でなく、1 行は 79 byte + 改行、 7 行以内でそのまま使える、って条件を満たしてないと個人的には 受け入れ難いなぁ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/353
354: nobodyさん [age] 05/01/31 14:38:02 ID:??? <? echo 'PHPもまぜてくれ'; ?> http://medaka.5ch.net/test/read.cgi/php/1036141603/354
355: nobodyさん [sage] 05/02/06 00:29:37 ID:??? じゃぁ、phpで7行wiki <? require("Text/Wiki.php");require("Cache/Lite.php");$c=&new Cache_Lite(); $s=$_SERVER[PHP_SELF];$g=$_GET;$b=&$_POST[b];$n=$g[n]?$g[n]:"FrontPage";$b&& $c->save($b,$n)&&header("Location: $s?n=$n");($b=$c->get($n))||$g[c]=e; $h="<h1>$n</h1>";if($g[c]==e)$h.="<form method=post action='?n=$n'>". "<textarea name=b rows=30 cols=80>$b</textarea><input type=submit>"; else{$w=&new Text_Wiki;$w->setRenderConf(xhtml,wikilink,new_url,"?n=%s"); $h.=$w->transform($b,xhtml)."<hr><a href='?c=e&n=$n'>e";}?><html><body><?=$h?> PEAR::Text_Wikiが必要。Cache_LiteはPEARにデフォルトで入ってる気がする。 あとshort_open_tag=Onでよろしく。 整形ルールは ttp://wiki.ciaweb.net/yawiki/index.php?area=Text_Wiki&page=SamplePage 日本語のwikinameは使えなかったりする。これはText_Wikiが対応していないせい。 http://medaka.5ch.net/test/read.cgi/php/1036141603/355
356: nobodyさん [] 2005/04/24(日) 00:09:53 ID:s2OIHVmv 保守あげ http://medaka.5ch.net/test/read.cgi/php/1036141603/356
357: nobodyさん [] 2005/04/26(火) 00:51:58 ID:UrRypboo >>355 ちょっとずるい気がする http://medaka.5ch.net/test/read.cgi/php/1036141603/357
358: nobodyさん [sage] 2005/04/26(火) 17:50:19 ID:??? どの辺が? タグを閉じていないあたり? http://medaka.5ch.net/test/read.cgi/php/1036141603/358
359: nobodyさん [sage] 2005/04/27(水) 02:12:54 ID:??? >>358 ライブラリ使い過ぎると面白さ半減ってことだろ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/359
360: nobodyさん [] 2005/04/27(水) 03:24:58 ID:0BxullHs モジュール/ライブラリに関して >>46, >>135 >>136, >>174 >>175 http://cm.xrea.cc/techinfo.cgi の 0.1. ライブラリ及びモジュールの利用 >>355 requireって () 省略できるはず。 http://medaka.5ch.net/test/read.cgi/php/1036141603/360
361: nobodyさん [sage] 2005/04/27(水) 07:43:42 ID:??? >>355 まぁでも、7行で基本機能を備えたwikiが使えるなら実世界でも結構有用じゃないか。 Text_Wikiの機能のデモにはなるでしょ。 むしろwiki技術関連スレ向きとは思うが。 向こうにも一応アンカー張ってあるね。 http://medaka.5ch.net/test/read.cgi/php/1036141603/361
362: nobodyさん [sage] 2005/04/28(木) 12:12:12 ID:??? 流れを無視して、7vote が 7 行に収まったのでパッケージング。 #!perl use CGI":all";charset$c='UTF-8';${$_}=param$_ for f,n,v;$f=~s/\W//g;open F,"+<$ f"if chdir V;eval{flock F,2};$t=<F>;/\t/and$D{$`}+=$' for<F>;seek F,0,0;$n?$D{$ n}||=1:$v&&$D{$v}++,print F$t,map"$_\t$D{$_}\n",keys%D if$n||$v;$L{$K[$i++]}=$_ for radio_group(v,[@K=sort{$D{$b}<=>$D{$a}}keys%D]);put header,start_html(-lang ,ja,encoding,$c,-Title,$t),h1($t),startform,table({},Tr[map{td["$L{$_}($D{$_})" ,hr{width,$D{$_}}]}@K]),hr,p(textfield(n),hidden(f,$F),submit),endform,end_html UTF-8 になったのがちょっと悔しい。 ファイル名は \w+ にしました。 http://medaka.5ch.net/test/read.cgi/php/1036141603/362
363: nobodyさん [hg] 2005/11/07(月) 20:21:27 ID:??? 半年ぶりフォーーーーーーーーーーーーーーーーーーーーーー http://medaka.5ch.net/test/read.cgi/php/1036141603/363
364: nobodyさん [] 2005/11/23(水) 11:59:34 ID:8dGTpf7c 良スレあげ http://medaka.5ch.net/test/read.cgi/php/1036141603/364
365: nobodyさん [sage] 2006/01/21(土) 13:50:12 ID:??? #!/usr/bin/perl my@d=([qw/? ? ? ? ? ? ? ? ? ? ? ? ? ?/],[qw/☆ △ ■/]); my$c='Shift_JIS';my$l='ja';use CGI':standard';my@r=(0)x@d; print header(-charset=>$c),start_html(-encoding=>$c,-lang=>$l),start_form, (map{my$i=$_;ul li[(map{$r[$i]+=param($_);$_.textfield -name=>$_}@{$d[$i]}), "計 $r[$i]"]}0..$#d),ul(li"$r[1]÷$r[0]=".eval{$r[1]/$r[0]}),submit,end_form, end_html; http://medaka.5ch.net/test/read.cgi/php/1036141603/365
366: nobodyさん [] 2006/01/21(土) 23:54:14 ID:e+ke+qvM なぜ丸付き数字と図形なのかわからんけど面白いですね。 どういうときに使えるだろう・・・。と考えてしまう http://medaka.5ch.net/test/read.cgi/php/1036141603/366
367: クロエ [sage] 2006/01/22(日) 02:56:50 ID:??? http://tool-6.net/?0001 イメージ的には、こんな感じなんですが…。【1】,「?〜?まで入力した数値を総計。」 【2】,「A+B+Cに入力した数値を総計。」 【3】,「【2】÷【1】×100」っていう演算プログラムなんですが…。 http://medaka.5ch.net/test/read.cgi/php/1036141603/367
368: 365 [sage] 2006/01/22(日) 10:02:46 ID:??? >>367 仕様変更は34,000円からになっておりますw 話の流れがわからない人はhttp://pc8.2ch.net/test/read.cgi/tech/1134327348/756- >>365はかなりゆとりがあったので7Excelにしてみた。 スタイルシートを別ファイルにしてもいいならまだまだいけそうだ。 #!/usr/bin/perl @x='A'..'G';@y=1..10;$c='Shift_JIS';use CGI':all';@r=(0)x(@x+1);print header( -charset=>$c),start_html(-encoding=>$c,-lang=>'ja',-head=>style({-type=> 'text/css'},'table{border-collapse:collapse}input,th{width:50px}td{text-align: right}td,th{border:1px solid gray}')),start_form,table(Tr(map th($_),'',@x,''), (map{$i=$_;$s=0;Tr td[$_,(map{$p=param"$i$x[$_]";$s+=$p;$r[$_]+=$p;textfield "$i$x[$_]"}0..$#x),($r[-1]+=$s,$s)[1]]}@y),Tr td['',@r]),submit,end_form,end_html http://medaka.5ch.net/test/read.cgi/php/1036141603/368
369: 365 [sage] 2006/01/22(日) 16:39:32 ID:??? use Storable;$f='file';$s=8;$c='Shift_JIS';%p=qw/-1 〇 0 _ 1 ●/;@m=map([map 0 ,0..$s+2],0..$s+2);($x,$y)=map param($_)%($s+1),qw/x y/;$r=1;use CGI':all';sub f2{my($w,$y,$x,$c)=@_;$u=1;if(0>$r*$m[$y][$x]){$c++;$m[$y][$x]*=$u=f2($w,$y+$w ->[0],$x+$w->[1],$c)}elsif(0<$c&&0<$r*$m[$y][$x]){$u*=-1}$u}sub r{if($y&&$x&&! $m[$y][$x]){for(0..7){$i=$_*atan2 1,1;$l=[map int(sprintf'%f',$_*sqrt 2),sin$i, cos$i];$z++if 0>f2$l,$y+$l->[0],$x+$l->[1]}if($z){$m[$y][$x]=$r;$r*=-1}}}$m[$s/ 2+(0<($_&2))][$s/2+(0<($_&1))]=$_%3?1:-1 for 0..3;($r,@m)=@{retrieve$f}if-s$f;r ;store[$r,@m],$f;print header(-charset=>$c),start_html(-encoding=>$c,-lang=> 'ja'),table(Tr[map{$i=$_;td[map a({-href=>"o.cgi?y=$i&x=$_"},$p{$m[$i][$_]}),1 ..$s]}1..$s]),$p{$r},end_html; 7オセロ? o.cgiで保存。 同じディレクトリに記録用ファイルの "file" を作成。 要 Storable.pm (Active Perl なら最初から入っているはず) リセットは手動で "file" を空にするw 7行に収まると思ったけど見込みが甘かった。 http://medaka.5ch.net/test/read.cgi/php/1036141603/369
370: クロエ [sage] 2006/01/23(月) 02:25:04 ID:??? >>365 本当にありがとうございます。設置の仕方が分かりませんorz orz orz 今日6時間くらい、CGIについて解説してあるサイトを隅から隅まで見ましたが、収穫なしですwww ばかん ばかん 俺のばかん テキストエディタ?を使うんですか? http://medaka.5ch.net/test/read.cgi/php/1036141603/370
371: nobodyさん [sage] 2006/01/23(月) 03:02:02 ID:??? >>370 CGI設置について質問 【Part2】 http://pc8.2ch.net/test/read.cgi/php/1104624784/ だがどのみち使いこなせないと見た http://medaka.5ch.net/test/read.cgi/php/1036141603/371
372: クロエ [sage] 2006/01/23(月) 16:06:04 ID:??? >>365氏 本当にありがとうございます。 2chでこんな優しい人初めてだ。 勉強してきますた。 鯖にアップロードして、パーミッションを755にするだけでおKですか? http://medaka.5ch.net/test/read.cgi/php/1036141603/372
373: nobodyさん [sage] 2006/01/23(月) 16:30:08 ID:??? >>372 やってから聞いてる? http://medaka.5ch.net/test/read.cgi/php/1036141603/373
374: クロエ [sage] 2006/01/23(月) 18:13:14 ID:??? 372であってますか? http://medaka.5ch.net/test/read.cgi/php/1036141603/374
375: nobodyさん [sage] 2006/01/23(月) 18:19:38 ID:??? >>374 鯖によるから合ってるとか間違ってるとか言えん。 とにかくやって、エラーが出たらまた聞いてくれよ。 何かやるたびに聞かれたんじゃ迷惑だし、そもそもスレ違い。 http://medaka.5ch.net/test/read.cgi/php/1036141603/375
376: nobodyさん [sage] 2006/01/23(月) 19:29:44 ID:??? ($f,$s,$r,@p)=qw/file 8 1 _ ● 〇/;use Storable;use CGI':all';sub f{$u=1;my($y ,$x,$c)=@_;if(0>($t=$r*$m[$y][$x])){$m[$y][$x]*=f($y+$p,$x+$n,1)}elsif($c&$t){ $u=-1;$z++}$u}$$_=param($_)%($s+1)for qw/x y/;@m=map[(0)x$s+1],0..$s+1;map$m[$s /2+$_/2][$s/2+$_%2]=$_%3?1:-1,0..3;($r,@m)=@{retrieve$f}if-s$f;$o=\$m[$y][$x]; if($y&&$x&&!$$o){for(0..7){($p,$n)=map sprintf('%.f',$_),sin($i=$_*0.78),cos$i; f$y+$p,$x+$n}$$o=$r,$r*=-1 if$z}store[$r,@m],$f;charset '';print header,$p[$r], table Tr[map{$i=$_;td[map a({href,"?y=$i&x=$_"},$p[$m[$i][$_]]),1..$s]}1..$s] 昨日の続きで7オセロ! モジュール詳しくないからやらないけどモジュール*だけ*で構成なんてのも面白そうだ。 http://medaka.5ch.net/test/read.cgi/php/1036141603/376
メモ帳
(0/65535文字)
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 76 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
アボンOFF
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.010s