/[suikacvs]/okuchuu/blue-oceans/board-t/board.cgi
Suika

Contents of /okuchuu/blue-oceans/board-t/board.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Sun Feb 10 00:48:06 2002 UTC (22 years, 9 months ago) by wakaba
Branch: MAIN
Changes since 1.1: +16 -14 lines
*** empty log message ***

1 wakaba 1.1 #!/usr/bin/perl
2     ## This file is euc-jisx0213 encoding.
3    
4     use Suika::CGI;
5     $myvesion = '1.00 (2001-08-22)';
6    
7     $about_perl = <<"EOH";
8     <address class="version" style="font-size: 50%">
9     FlasH BBS Pro v1.41 [©¦<a href="http://www7.big.or.jp/~jawa/">Shigeto Nakazawa</a>] ¤ò¥Ù¡¼¥¹¤Ë<a href="http://www.ne.jp/asahi/minazuki/bakera/">¿å̵·î¤Ð¤±¤é</a>¤¬²þ¤
10     + <a href="mailto:wakaba\@suika.fam.cx">¼ãÍÕ</a>¤Î quick hack $myversion
11     </address>
12     EOH
13    
14     ## h12-05-06 ¿å̵·î¤Ð¤±¤é <bakera@star.email.ne.jp>
15     ## h09-01-17 ¤¸¤ã¤ï@Ãæß·½Å¿Í <jawa@big.or.jp>
16     ## FlasH BBS Pro 1.41 <http://www7.big.or.jp/~jawa/>
17    
18     #°ìÈÌÀßÄê
19     $max_size = 512 * 1024;
20     $max_msg = 2000;
21     $admin_email = 'blue-oceans@suika.fam.cx';
22     $this_name = 'board';
23     $gif_allnews = '';
24     $gif_news = '';
25     $gif_new_news = '';
26     $gif_width = 20;
27     $gif_height = 14;
28     $default_title = 'Âê̾¤òÆþ¤ì¤Æ²¼¤µ¤¤';
29     $default_name = '¤ªÌ¾Á°¤ò¤É¤¦¤¾';
30     $default_email = 'ÅŻҥᥤ¥ë¥¢¥É¥ì¥¹¤ò¤É¤¦¤¾¡£(¾Êά²Äǽ)';
31     $default_comment = 'ËÜʸ¤ò¤É¤¦¤¾';
32     $arc_dir = './log/';
33     $log_dir = './log/';
34     $base_url = "http://suika.fam.cx/~okuchuu/blue-oceans/";
35     $rfc_base_uri = 'http://dnsbalance.ring.gr.jp/pub/doc/RFC';
36     $logfile = $log_dir.'bo.log';
37    
38     #¥í¥Ã¥¯¥Õ¥¡¥¤¥ë¸¡½Ð»þ¤Î¥ê¥È¥é¥¤²ó¿ô
39     $retry = 3;
40    
41     #ʸ»ú¥³¡¼¥É
42     $mojicode = "euc";
43    
44     #NN2 ¤Ç charset=EUC-JP ¤òÁ÷¤ë¤È²½¤±¤ë¤é¤·¤¤¡£
45     if( $ENV{'HTTP_USER_AGENT'} =~ /compatible/ ){
46     $charset = ';charset=EUC-JP';
47     }elsif( $ENV{'HTTP_USER_AGENT'} =~ /Mozilla\/2.0/ ){
48     $charset = '';
49     }else{
50     $charset = ';charset=EUC-JP';
51     }
52    
53     &read_form;
54    
55     #¥Ñ¥é¥á¡¼¥¿¤Î½èÍý
56     #¥Ç¥Õ¥©¥ë¥È
57     $uri_mode = 'all';
58     $tree = 0;
59     $new_kiji = 10;
60     $max_tree = 10;
61     $nazo = '';
62     $indent = 'ul';
63     $max_depth = 40;
64     $margin = 3;
65    
66     $ID = $OPT{'id'};
67     $uri_query = "id=$ID";
68     $form_query = "<input type=\"hidden\" name=\"id\" value=\"$ID\">";
69     if($OPT{'link'}){
70     $uri_mode = $OPT{'link'};
71     &add_query('link', $uri_mode);
72     }
73     if($OPT{'tree'}){
74     $tree = $OPT{'tree'};
75     &add_query('tree', $tree);
76     }
77     if($OPT{'new_kiji'}){
78     $new_kiji = $OPT{'new_kiji'};
79     &add_query('new_kiji', $new_kiji);
80     }
81     if($OPT{'tmp_new_kiji'}){
82     $new_kiji = $OPT{'tmp_new_kiji'};
83     #¤³¤Î¥Ñ¥é¥á¡¼¥¿¤Ï¥¯¥¨¥ê¡¼¤ËÈ¿±Ç¤·¤Ê¤¤¡£
84     }
85     if($OPT{'max_tree'}){
86     $max_tree = $OPT{'max_tree'};
87     &add_query('max_tree',$max_tree);
88     }
89     if($OPT{'nazo'}){
90     $nazo = $OPT{'nazo'};
91     &add_query('nazo', $nazo) if ( $nazo ne 'only' );
92     }
93     if($OPT{'indent'}){
94     $indent = $OPT{'indent'};
95     &add_query('indent', $indent);
96     }
97     if($OPT{'max_depth'}){
98     $max_depth = $OPT{'max_depth'};
99     &add_query('max_depth', $max_depth);
100     }
101     if($OPT{'margin'}){
102     $margin = $OPT{'margin'};
103     &add_query('margin', $margin);
104     }
105    
106     $cookie_name = 'board';
107     $title = '¥Ö¥ë¡¼¥ª¡¼¥·¥ã¥ó¥º·Ç¼¨ÈÄ';
108     $backurl = '../top';
109     $back_name = 'Ìܼ¡';
110     $html_info = '';
111     $link_element = '';
112     ## Administrator
113     $address_element = "<address><a href=\"mailto:blue-oceans\@suika.fam.cx\">¥Ö¥ë¡¼¥ª¡¼¥·¥ã¥ó¥º</a></address>";
114    
115    
116     $defhead = <<"EOH";
117    
118 wakaba 1.2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
119 wakaba 1.1 <html lang="ja">
120     <head>
121     <title>$title</title>
122 wakaba 1.2 <link rel="stylesheet" href="/s/simpledoc">
123     <link rel="stylesheet" href="../bo-style">
124 wakaba 1.1 <link rel="index" href="../top" />
125     </head>
126     <body>
127     <h1>$title</h1>
128     EOH
129     $def_header_http = <<EOH;
130     Content-Type: text/html; charset=euc-jisx0213
131     Content-Language: ja
132     Content-Style-Type: text/css
133     Content-Script-Type: text/javascript
134    
135     EOH
136    
137     $deffoot = <<"EOH";
138     $address_element
139     $about_perl
140     </body></html>
141     EOH
142    
143     $navi_usage = '<div class="navi"><p>[';
144     $navi_ichiran = "<a href=\"$this_name?$uri_query\">°ìÍ÷ɽ¼¨</a>";
145     $navi_num = " / <a href=\"$this_name?$uri_query;md=num\">ºÇ¿·µ­»ö</a>";
146     $navi_new = " / <a href=\"$this_name?$uri_query;md=new\">¿·µ¬Åê¹Æ</a>";
147     $navi_back = " / <a href=\"$backurl\">$back_name</a> ]</p></div>";
148     $html_navi = "<p class=\"navi\">$navi_usage$navi_ichiran$navi_num$navi_new$navi_back</p>";
149    
150    
151     ##
152    
153     &get_cookie;
154     if ($nazo eq 'only') {&nazo_only; }
155     elsif ($OPT{'md'} eq 'reg') {&regist; }
156     elsif ($OPT{'md'} eq 'del') {&delete; }
157     elsif ($OPT{'md'} eq 'viw') {&view; }
158     elsif ($OPT{'md'} eq 'new') {
159     $html_navi = "<p class=\"navi\">$navi_usage$navi_ichiran$navi_num$navi_back";
160     &html_form('root');
161     }
162     elsif ($OPT{'md'} eq 'set') { &set; }
163     elsif ($OPT{'md'} eq 'num') {
164     $html_navi = "<p class=\"navi\">$navi_usage$navi_ichiran$navi_new$navi_back";
165     &number;
166     }
167     else {
168     $html_navi = "<p class=\"navi\">$navi_usage$navi_num$navi_new$navi_back";
169     &ichiran;
170     }
171     &html_footer;
172     exit 0;
173    
174     # [ ¥Ø¥Ã¥À¡¼Éôʬɽ¼¨ ]
175     #
176    
177     sub html_header {
178     my($sub_title) = @_;
179     my $s;
180     if ($sub_title) {
181     $s = <<"_EOF_";
182     Content-Type: text/html; charset=euc-jisx0213
183     Content-Language: ja
184     Content-Style-Type: text/css
185     Content-Script-Type: text/javascript
186    
187 wakaba 1.2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
188 wakaba 1.1 <html lang="ja">
189     <head>
190 wakaba 1.2 <link rel="stylesheet" href="/s/simpledoc">
191     <link rel="stylesheet" href="../bo-style">
192 wakaba 1.1 $link_element
193     <title>$title ($sub_title)</title>
194     _EOF_
195    
196     if($indent eq 'css'){
197     my($i, $tmp_margin);
198 wakaba 1.2 $s .= '<style type="text/css">';
199 wakaba 1.1 for( $i = 1; $i <= $max_depth; $i++ ){
200     $tmp_margin = $margin * $i;
201     print ".lv$i\{margin-left:$tmp_margin\%\}";
202     }
203 wakaba 1.2 $s .= '</style>';
204 wakaba 1.1 }
205     $s .= <<"_EOF_";
206     </head>
207     <body>
208     <h1><a name="top">$title</a></h1>
209     $html_navi
210     <h2>$sub_title</h2>
211     _EOF_
212     return $s;
213     }
214     print $s;
215     }
216    
217     sub html_footer {
218     print<<"_EOF_";
219     $deffoot
220     _EOF_
221     }
222    
223     # [ °ìÍ÷ɽ¼¨ ]
224     #
225    
226     sub ichiran {
227     &set_cookie;
228 wakaba 1.2 local($s) = &html_header('µ­»ö°ìÍ÷');
229 wakaba 1.1
230     #¥í¥°Æɤ߽Ф·
231     open(LOG, $logfile) or &Suika::CGI::Error::die('open', file => $logfile);
232     print $s;
233     my($count, $last_nj);
234     $count = <LOG>;chop($count);
235     $last_nj = <LOG>;chop($last_nj);
236    
237     if( $indent eq 'css' || $indent eq 'ul' ){
238     $prt_elm = 'ul';
239     $cld_elm = 'li';
240     }else{
241     $prt_elm = 'div';
242     $cld_elm = 'p';
243     }
244    
245     print $html_info;
246 wakaba 1.2 print '<div class="set">';
247 wakaba 1.1 print "<p><em class=\"note\">([Á´]¤òÁªÂò¤¹¤ë¤È´ØÏ¢µ­»ö¤â´Þ¤á¤Æ°ì³çɽ¼¨¤Ç¤­¤Þ¤¹¡£)</em></p>\n";
248     $tree = int($tree/$max_tree) * $max_tree;
249     $end_tree = $tree + $max_tree;
250     my($tree_count) = 0;
251     while (<LOG>) {
252     my($last_lx) = -1;
253     $tree_count++;
254     next if $tree_count <= $tree;
255     next if $tree_count > $end_tree;
256     print "\n<hr>\n<$prt_elm class=\"tree\">";
257     @datas = &divide_log($_);
258     foreach (@datas) {
259     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act) = &divide_data($_);
260     if ( $indent eq 'ul' && $last_lx > -1 ){
261     my($l_diff) = $last_lx - $lx;
262     if( $l_diff < 0 ){
263     print "<$prt_elm>";
264     }elsif( $l_diff > 0){
265     my($i);
266     print "</$cld_elm>";
267     for($i = 1; $i <= $l_diff; $i++){
268     print "</$prt_elm></$cld_elm>";
269     }
270     }else{
271     print "</$cld_elm>";
272     }
273     }
274     if($indent eq 'css'){
275     print "<$cld_elm class=\"lv$lx\">";
276     }else{
277     print "<$cld_elm>";
278     }
279     if ($res eq 'root') {
280     print "[<a href=\"$this_name?$uri_query;md=set;tn=$tn\">Á´</a>]";
281     } elsif ($indent eq 'space') {
282     my($space_width) = $lx * 2 + 2;
283 wakaba 1.2 print '&nbsp;' x $space_width;
284 wakaba 1.1 }
285     print "<a href=\"$this_name?$uri_query;md=viw;no=$no;tn=$tn\">";
286     if ($no > $count - $new_kiji) {
287     print "[¿·]";
288     } else {
289     print "[¡¦]";
290     }
291     print " $title</a> : ";
292     if ($COOKIE{'name'} eq $name) {
293     print "<strong>$name</strong>"; #¼«Ê¬¤Îµ­»ö¤ò¶¯Ä´É½¼¨
294     } else {
295     print $name;
296     }
297     print " <span class=\"date\">($date)</span>";
298     $last_lx = $lx;
299     }
300     if ( $indent eq 'ul' ){
301     # print "<!--$last_lx-->";
302     my($i);
303     for($i = 1; $i <= $last_lx; $i++){
304     print "</$cld_elm></$prt_elm>";
305     }
306     }
307     print "</$cld_elm></$prt_elm>";
308     }
309     close(LOG);
310     print"</div>\n";
311    
312     &navi_form($tree_count);
313     }
314    
315     # [ ¸ÄÊ̤ǵ­»ö¤ÎÆâÍƤòɽ¼¨¤¹¤ë ]
316     #
317    
318     sub view {
319     local($s) = $def_header_http.$defhead.$html_navi."<h2>µ­»ö$OPT{'no'}</h2>";
320     my(@kiji_datas) = &divide_log(&search_tree);
321     my($kiji_data) = &search_data(@kiji_datas);
322    
323     $s .= &kiji_view($kiji_data);
324     $s .= "<div class=\"comment-navi\">";
325     my($no,$rq_res,$lx,$tn,$title,$name,$email,$date,$rq_act,$file_pwd,$rhost,$ipad,$comment) = &divide_data($kiji_data);
326     foreach (@kiji_datas) {
327     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act,$pwd,$rhost,$ipad,$comment) = &divide_data($_);
328     if ($rq_res == $no) {
329     $parent = "¤³¤Îµ­»ö¤Ï¡Ö<a href=\"$this_name?$uri_query;md=viw;no=$no;tn=$OPT{'tn'}\">$title</a>¡×¤Ø¤Î¥³¥á¥ó¥È¤Ç¤¹¡£";
330     }
331     if (($res == $OPT{'no'}) && ($res ne 'root')) {
332     $children .= "<li>¡Ö<a href=\"$this_name?$uri_query;md=viw;no=$no;tn=$OPT{'tn'}\">$title</a>¡×$name<span class=\"date\">($date)</span></li>";
333     }
334     }
335     if ($rq_res eq 'root') { $parent = '¥ë¡¼¥Èµ­»ö¤Ç¤¹¡£'; }
336     elsif (!$parent) { $parent = '¸µ¤Ë¤Ê¤Ã¤¿µ­»ö¤Ï¤ß¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿¡£'; }
337     if (!$children) { $children = '¥³¥á¥ó¥È¤ÏÅê¹Æ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£</p>'; }
338     else{$children = "°Ê²¼¤Î¥³¥á¥ó¥È¤¬Åê¹Æ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£</p>\n<ul class=\"comment\">$children</ul>";}
339     $s .= <<"_EOF_";
340 wakaba 1.2 <hr>
341 wakaba 1.1 <p>$parent
342     $children
343     <hr></div>
344     _EOF_
345     if ($rq_act > 6) {
346     $s .= '<p>¤³¤Îµ­»ö¤ËÂФ·¤Æ¥³¥á¥ó¥È¤òÅê¹Æ¤¹¤ë¤³¤È¤Ï½ÐÍè¤Þ¤»¤ó¡£</p>';
347     return 0;
348     }elsif( $nazo eq 'no' ){
349     $s .= '<!--Æ楹¥±¥ë¥Á¥â¡¼¥É¤Ç¤Ï¥³¥á¥ó¥È¤ÎÅê¹Æ¤Ï½ÐÍè¤Þ¤»¤ó¡£-->';
350     return 0;
351     }
352     if ($title =~ /^[Rr][Ee]\^\d+\:(.*)/) {$title = "Re: $1";}
353     elsif ($title =~ /^[Rr][Ee]\[\d+\]\:(.*)/) {$title = "Re: $1";}
354     elsif ($title =~ /^[Rr][Ee]\:(.*)/) {$title = "Re: $1";}
355     else {$title = "Re: $title"; }
356     $comment = "<br>$comment";
357     $comment =~ s/<br>((&gt;)+)/\n$1&gt;/ig;
358     $comment =~ s/<br>/\n&gt; /ig;
359     $comment =~ s/\n//;
360     $s .= '<p>¤³¤Îµ­»ö¤Ë´Ø¤¹¤ë¥³¥á¥ó¥È¤òÅê¹Æ¤¹¤ë¾ì¹ç¤Ï°Ê²¼¤ÎÅê¹ÆÍó¤Ë½ñ¤­¹þ¤ó¤Ç²¼¤µ¤¤¡£</p>';
361     $s .= &html_form($OPT{'no'},$title,$comment,$OPT{'tn'},$lx,1);
362    
363     #Åê¹Æ¼Ôºï½ü
364     if (crypt($COOKIE{'pwd'},$file_pwd) eq $file_pwd) {
365     $s .= <<"_EOF_";
366     <hr>
367     <form action="./$this_name" method="post">
368     <p>
369     $form_query
370     <input type="hidden" name="md" value="del">
371     <input type="hidden" name="code" value="$OPT{'code'}">
372     <input type="hidden" name="tn" value="$OPT{'tn'}">
373     <input type="hidden" name="no" value="$OPT{'no'}">
374     <input type="hidden" name="pwd" value="$COOKIE{'bbs_pwd'}">
375     <input type="submit" value="¤³¤Îµ­»ö¤ÎÆâÍƤòºï½ü¤¹¤ë">
376     <em class="note">(´°Á´¤Ëºï½ü½ÐÍè¤Ê¤¤¾ì¹ç¤â¤¢¤ê¤Þ¤¹¡£)</em></p>
377     </form>
378     _EOF_
379     }
380    
381     print ($s.$deffoot);
382     exit;
383     }
384    
385     # [ ¥»¥Ã¥Èɽ¼¨ ]
386     #
387    
388     sub set {
389     my($last_lx) = -1;
390     print &html_header('¥»¥Ã¥Èɽ¼¨');
391    
392     if( $indent eq 'css' || $indent eq 'ul' ){
393     $prt_elm = 'ul';
394     $cld_elm = 'li';
395     }else{
396     $prt_elm = 'div';
397     $cld_elm = 'p';
398     }
399    
400     print<<"_EOF_";
401     <div class=\"set\">
402     <h3><a name="list">µ­»ö°ìÍ÷</a></h3>
403     <$prt_elm class="tree">
404     _EOF_
405     @kiji_datas = &divide_log(&search_tree);
406     foreach (@kiji_datas) {
407     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act) = &divide_data($_);
408     my($num_no) = int($no);
409     $reply[$res] .= "$num_no-";
410     if ( $indent eq 'ul' && $last_lx > -1 ){
411     my($l_diff) = $last_lx - $lx;
412     if( $l_diff < 0 ){
413     print "<$prt_elm>";
414     }elsif( $l_diff > 0){
415     my($i);
416     print "</$cld_elm>";
417     for($i = 1; $i <= $l_diff; $i++){
418     print "</$prt_elm></$cld_elm>";
419     }
420     }else{
421     print "</$cld_elm>";
422     }
423     }
424     if($indent eq 'css'){
425     print "<$cld_elm class=\"lv$lx\">";
426     }else{
427     print "<$cld_elm>";
428     }
429     $last_lx = $lx;
430     if ($res ne 'root' && $indent eq 'space') {
431     my($space_width) = $lx * 2 + 2;
432     print '¡¡' x $space_width;
433     }
434     print "<a href=\"#c$num_no\">¡¦ $title</a> : $name <span class=\"date\">($date)</span>";
435     print "</$cld_elm>\n" unless ($indent eq 'ul');
436     }
437     if ( $indent eq 'ul' ){
438     # print "<!--$last_lx-->";
439     my($i);
440     for($i = 1; $i <= $last_lx; $i++){
441     print "</$cld_elm></$prt_elm>";
442     }
443     }else{
444     print "</$prt_elm>";
445     }
446    
447     print"</$cld_elm></$prt_elm></div>\n";
448    
449     foreach $data (@kiji_datas) {
450     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act,$pwd,$rhost,$ipad,$comment) = &divide_data($data);
451     my($num_no) = int($no);
452    
453     print "<p>No.<a name=\"c$num_no\">$num_no</a>";
454     if ($res eq 'root') {
455     print '<em class="note">(¿Æµ­»ö)</em>';
456     } else {
457     $res = int($res);
458     print "<a href=\"#c$res\">¢¥<em>[$res]</em></a>";
459     }
460     if (!$reply[$no]) {
461     print ' / <em class="note">(Ãí¼á¤Ê¤·)</em>';
462     } else {
463     chop($reply[$no]);
464     my(@replys) = split(/-/,$reply[$no]);
465     foreach (@replys) {
466     print " / <a href=\"#c$_\">¢§<em>[$_]</em></a>";
467     }
468     }
469     print "</p>\n";
470    
471     print &kiji_view($data);
472     if( $nazo eq 'no' ){
473     print '<!--Æ楹¥±¥ë¥Á¥â¡¼¥É¤Ç¤Ï¥³¥á¥ó¥È¤ÎÅê¹Æ¤Ï½ÐÍè¤Þ¤»¤ó¡£-->';
474     }else{
475     print "<p><a href=\"$this_name?$uri_query;md=viw;no=$no;tn=$OPT{'tn'}\">¥³¥á¥ó¥È¤òÅê¹Æ</a> / ";
476     }
477     print "<a href=\"#list\">µ­»ö°ìÍ÷</a></p><hr>";
478     }
479     }
480    
481     # [ ºÇ¿·µ­»ö°ì³çµ¡Ç½ ]
482    
483     sub number {
484     print &html_header("ºÇ¿·µ­»ö");
485     print "<p>ºÇ¶á¤Îµ­»ö $new_kiji ·ï¤òɽ¼¨¤·¤Æ¤¤¤Þ¤¹¡£</p>";
486     print '<p>[';
487     my($i,$j,$tmp);
488     for ( $i = 1; $i <= 10; $i++ ){
489     $j = $i * 10;
490     unless ($new_kiji == $j){
491     if($tmp){
492     print ' / ' ;
493     }else{
494     $tmp = 1;
495     }
496     print "<a href=\"$this_name?$uri_query;md=num;tmp_new_kiji=$j\">$j ·ï</a>";
497     }
498     }
499     print ' ]</p>';
500     open(LOG,$logfile) or &error('Æɤ߹þ¤ß¥¨¥é¡¼','¥í¥°¤ÎÆɤ߹þ¤ß¤¬½ÐÍè¤Þ¤»¤ó¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
501     my($count, $last_nj);
502     $count = <LOG>;chop($count);
503     $last_nj = <LOG>;chop($last_nj);
504     while (<LOG>) {
505     @datas = &divide_log($_);
506     foreach $data (@datas) {
507     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act) = &divide_data($data);
508     if ($no > $count - $new_kiji) {
509     push(@nums,$data);
510     }
511     }
512     last if @nums >= $new_kiji;
513     }
514     close(LOG);
515    
516     @nums = reverse(sort(@nums));
517     print '<ul class="new">';
518     my($list_order);
519     foreach $data (@nums) {
520     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act,$pwd,$rhost,$ipad,$comment) = &divide_data($data);
521     $list_order++;
522     print "<li><p>$list_order: µ­»öNo.$no</p>\n";
523     print &kiji_view($data);
524     print<<"_EOF_";
525     <p><a href="$this_name?$uri_query;md=viw;no=$no;tn=$tn">¥³¥á¥ó¥È¤òÅê¹Æ</a> / <a href="$this_name?$uri_query;md=set;tn=$tn">¥»¥Ã¥È¤Çɽ¼¨</a></p><hr></li>
526     _EOF_
527     }
528     print '</ul>';
529     }
530    
531     # [ Åê¹Æ¥Õ¥©¡¼¥à¤òɽ¼¨ ]
532     #
533    
534     sub html_form {
535     my($no,$title,$comment,$tn,$lx,$c) = (@_);
536     local($s); $s = $def_header_http.$defhead if $c != 1;
537     $s .= '<h2>µ­»ö¤ÎÅê¹Æ</h2>';
538    
539     if ($no eq '') { $no = 'root'; }
540     $title = "($default_title)" unless $title;
541     $comment = "($default_comment)" unless $comment;
542     if($COOKIE{'name'}){
543     $my_name = $COOKIE{'name'};
544     }else{
545     $my_name = "($default_name)";
546     }
547     if($COOKIE{'email'}){
548     $my_email = $COOKIE{'email'};
549     }else{
550     $my_email = "($default_email)";
551     }
552    
553     $nj = time() . '-' . &random_string(8);
554    
555     $s .= <<"_EOF_";
556     <script type="text/javascript" defer="defer"><!--
557     function check(myform){
558     if(!myform.name.value ){
559     alert("Åê¹Æ¼Ô̾¤òµ­Æþ¤·¤Æ¤¯¤À¤µ¤¤¡£");
560     myform.name.focus();
561     return false;
562     } else if(!myform.title.value ){
563     alert("Âê̾¤òµ­Æþ¤·¤Æ¤¯¤À¤µ¤¤¡£");
564     myform.title.focus();
565     return false;
566     } else if(!myform.comment.value ){
567     alert("ËÜʸ¤òµ­Æþ¤·¤Æ¤¯¤À¤µ¤¤¡£");
568     myform.comment.focus();
569     return false;
570     } else {
571     return true;
572     }
573     }
574     //--></script>
575     <form action="./$this_name" method="post" onsubmit="return check(this);">
576     <p><label accesskey="S" for="title">Âê̾(<span class="key">S</span>):</label>
577     <input type="text" name="title" id="title" size="40" maxlength="80" value="$title"></p>
578     <p><label accesskey="N" for="name">̾Á°(<span class="key">N</span>):</label>
579     <input type="text" name="name" id="name" size="40" maxlength="42" value="$my_name"></p>
580     <p><label accesskey="E" for="email">¥á¥¤¥ë(<span class="key">M</span>):</label>
581     <input type="text" name="email" id="email" size="60" maxlength="120" value="$my_email"></p>
582     <p><label accesskey="B" for="comment">ËÜʸ(<span class="key">B</span>):</label>
583     <br><textarea name="comment" id="comment" rows="10" cols="70">$comment</textarea></label></p>
584     <p><input type="submit" value="Á÷¿®">
585     $form_query
586     <input type="hidden" name="md" value="reg"><input type="hidden" name="no" value="$no"><input type="hidden" name="tn" value="$tn"><input type="hidden" name="lx" value="$lx"><input type="hidden" name="pwd" value="$COOKIE{'pwd'}"><input type="hidden" name="nj" value="$nj"><input type="hidden" name="code" value="$OPT{'code'}"></p>
587     </form>
588     _EOF_
589     if ($c == 1) {
590     $s;
591     } else {
592     print ($s);
593     }
594     }
595    
596     # [ µ­»öÆâÍƤòɽ¼¨ ]
597    
598     sub kiji_view {
599     my($data) = @_;
600     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act,$tm_pwd,$rhost,$ipad,$comment) = &divide_data($data);
601     # &jcode'convert(*comment,'euc');
602     $comment = &squelch($comment) if $nazo;
603     $comment =~ s/(<br>|\s|¡¡)+$//g;
604     $comment =~ s/^(>|&gt;)([^<]*)/<q class=\"responce\">&gt;$2<\/q>/g;
605     $comment =~ s/<br>(>|&gt;)([^<]*)/<br><q class=\"responce\">&gt;$2<\/q>/g;
606    
607     #URL ¤Ë¥¢¥ó¥«¡¼¤òÀßÄꤹ¤ë
608     if( $uri_mode eq 'uri' || $uri_mode eq 'all' ){
609     $comment =~ s/(https?|ftp|gopher|telnet|nntp|news)\:([\w|\:\!\#\$\%\=\&\-\^\`\\\|\@\~\[\{\]\}\;\+\*\,\.\?\/]+)/<a href=\"$1\:$2\">$1\:$2<\/a>/ig;
610     }
611     if( $uri_mode eq 'rfc' || $uri_mode eq 'all' ){
612     $comment =~ s/(\W)([Rr][Ff][Cc]\s?)([1-9]\d*)(\W)/$1<a href=\"$rfc_base_uri\/rfc$3.txt\">$2$3<\/a>$4/g;
613     }
614     # &jcode'convert(*comment,$mojicode);
615     if ($email) { $name = "<a href=\"mailto:$email\">$name</a>"; }
616     local($s) = <<"_EOF_";
617     <!-- message start -->
618     <div class="message"><h3 class="subject">$title</h3>
619     <div class="message-header"><p><cite class="from">$name</cite>
620     <span class="date">($date)</span><!--$rhost($ipad)--></p></div>
621     <div class="message-body">
622     <p>$comment</p></div></div>
623     <!-- message end -->
624     _EOF_
625     $s;
626     }
627    
628     # [ µ­»öÅÐÏ¿½èÍý ]
629    
630     sub regist {
631     my($title,$name,$email,$comment,$lx,$tn,$pwd,$ref_url) = ($OPT{'title'},$OPT{'name'},$OPT{'email'},$OPT{'comment'},$OPT{'lx'},$OPT{'tn'},$OPT{'pwd'},$ENV{'HTTP_REFERER'});
632     $title =~ s/^\($default_title\)//;
633     $title =~ s/\r\n//g;
634     $title =~ s/[\r\n]//g;
635     $name =~ s/^\($default_name\)//;
636     $name =~ s/\r\n//g;
637     $name =~ s/[\r\n]//g;
638     $email =~ s/^\($default_email\)//;
639     $email =~ s/\r\n//g;
640     $email =~ s/[\r\n]//g;
641     $comment =~ s/^\($default_comment\)//;
642     $comment =~ s/^\s+//g;
643     $comment =~ s/(\s|¡¡)+$//g;
644     $comment =~ s/\r\n/<br>/g;
645     $comment =~ s/[\r\n]/<br>/g;
646     $lx++;
647     $pwd =~ s/\r\n//g;
648     $pwd =~ s/\r|\n//g;
649     $ref_url =~ s/\?(.|\n)*//g;
650     s/\%7E/\~/g;
651    
652     #Åê¹Æ¥Á¥§¥Ã¥¯
653     if($ENV{'REQUEST_METHOD'} ne "POST"){
654     &method_error();
655     # }elsif($base_url && ($ref_url !~ $base_url)){
656     # &error('ÉÔÀµÅê¹Æ','¥¢¥¯¥»¥¹¤Ï¼õ¤±Æþ¤ì¤é¤ì¤Þ¤»¤ó¤Ç¤·¤¿¡£³°Éô¤«¤é¤ÎÉÔÀµ¤ÊÅê¹Æ¤¬¹Ô¤ï¤ì¤¿²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£Àµ¤·¤¤Åê¹Æ¤Ç¤â¤³¤Î¥¨¥é¡¼¤¬½Ð¤ë¾ì¹ç¤Ï¡¢¥Ö¥é¥¦¥¶¤¬ Referer ¤òÁ÷½Ð¤¹¤ëÀßÄê¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤«³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£');
657     }elsif (length($title) > 80) {
658     $_ = length($title) - 80;
659     &error('Âê̾ÆþÎÏ¥¨¥é¡¼',"Âê̾¤¬Ä¹¤¹¤®¤Þ¤¹¡£$_ ¥Ð¥¤¥Èºï¸º¤·¤Æ¤¯¤À¤µ¤¤¡£");
660     }elsif (!$title) {
661     &error('Âê̾ÆþÎÏ¥¨¥é¡¼','Âê̾¤¬ÆþÎϤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£');
662     }elsif (!$name) {
663     &error('Åê¹Æ¼Ô̾ÆþÎÏ¥¨¥é¡¼','Åê¹Æ¼Ô̾¤¬ÆþÎϤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£');
664     }elsif (length($name) > 42) {
665     $_ = length($name) - 42;
666     &error('Åê¹Æ¼Ô̾ÆþÎÏ¥¨¥é¡¼',"Åê¹Æ¼Ô̾¤¬Ä¹¤¹¤®¤Þ¤¹¡£$_ ¥Ð¥¤¥Èºï¸º¤·¤Æ¤¯¤À¤µ¤¤¡£");
667     }elsif ($email && $email !~ /\w[\w\.\-]*\@\w[\w\.\-]*\.\w+/){
668     &error('¥á¡¼¥ë¥¢¥É¥ì¥¹ÆþÎÏ¥¨¥é¡¼','¥á¡¼¥ë¥¢¥É¥ì¥¹¤Î½ñ¼°¤¬ÉÔÀµ¤Ç¤¹¡£Á´³Ñʸ»ú¤ò»È¤Ã¤Æ¤¤¤Ê¤¤¤«¡¢¶õÇò¤ò´Þ¤á¤Æ¤¤¤Ê¤¤¤«³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£');
669     }elsif (length($email) > 120) {
670     $_ = length($email) - 120;
671     &error('¥á¡¼¥ë¥¢¥É¥ì¥¹ÆþÎÏ¥¨¥é¡¼',"¥á¡¼¥ë¥¢¥É¥ì¥¹¤¬Ä¹¤¹¤®¤Þ¤¹¡£$_ ¥Ð¥¤¥Èºï¸º¤·¤Æ¤¯¤À¤µ¤¤¡£");
672     }elsif (!$comment) {
673     &error('ËÜʸÆþÎÏ¥¨¥é¡¼','ËÜʸ¤¬ÆþÎϤµ¤ì¤Æ¤¤¤Þ¤»¤ó¡£¶õÇò¤Î¤ß¤ÎÅê¹Æ¤Ï½ÐÍè¤Þ¤»¤ó¡£');
674     }elsif (length($comment) > $max_msg) {
675     $_ = length($comment) - $max_msg;
676     &error('ËÜʸÆþÎÏ¥¨¥é¡¼',"ËÜʸ¤¬Ä¹¤¹¤®¤Þ¤¹¡£$_ ¥Ð¥¤¥Èºï¸º¤·¤Æ¤¯¤À¤µ¤¤¡£");
677     }elsif ((!$pwd) || (length($pwd) > 8)) { $pwd = &random_string(8); }
678     my($salt) = &random_string(2);
679     $file_pwd = crypt($pwd,$salt);
680     &get_date;
681    
682     open(LOG,$logfile) or &error('Æɤ߹þ¤ß¥¨¥é¡¼','¥í¥°¤ÎÆɤ߹þ¤ß¤¬½ÐÍè¤Þ¤»¤ó¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
683     my($count, $last_nj);
684     $count = <LOG>;chop($count);
685     $last_nj = <LOG>;chop($last_nj);
686     my(@all_log) = <LOG>;
687     close(LOG);
688    
689     $this_nj = $OPT{'nj'};
690    
691     if (++$count > 9999) {
692     &error('µ­»ö¥«¥¦¥ó¥¿¤Î¥ª¡¼¥Ð¡¼¥Õ¥í¡¼','ÅÐÏ¿µ­»ö¿ô¤¬ 10,000 ¤Ë㤷¤¿¤¿¤á¡¢Åê¹Æ¤ò¼õ¤±ÉÕ¤±¤ë¤³¤È¤¬½ÐÍè¤Þ¤»¤ó¡£Åê¹Æ¤ò¼õ¤±ÉÕ¤±¤ë¤Ë¤Ï¡¢´û¸¤Îµ­»ö¤òºÆÊÔÀ®¤·¤Æ·Ç¼¨ÈĤκÇŬ²½¤ò¹Ô¤¦É¬Íפ¬¤¢¤ê¤Þ¤¹¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
693     # }elsif ($this_nj eq $last_nj){
694     # &error('Æó½ÅÅê¹Æ','Æó½ÅÅê¹Æ¤Ç¤¹¡£Åê¹Æ¥Ü¥¿¥ó¤¬Ï¢ÂǤµ¤ì¤Æ¤·¤Þ¤Ã¤¿²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£°ìÍ÷ɽ¼¨¤ò¥ê¥í¡¼¥É¤·¤Æµ­»ö¤¬Åê¹Æ¤µ¤ì¤¿¤«³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£ºÆÅê¹Æ¤ÎºÝ¤Ï¡¢Åê¹Æ¥Õ¥©¡¼¥à¤ò¥ê¥í¡¼¥É¤·¤ÆÅê¹Æ¤ò¤ä¤êľ¤·¤Æ¤¯¤À¤µ¤¤¡£');
695     }
696    
697     my($kiji_no) = substr("0000",length($count)).$count;
698    
699     $rhost = $ENV{'REMOTE_HOST'};
700     $ipad = $ENV{'REMOTE_ADDR'};
701    
702     if ($OPT{'no'} eq 'root') {
703     $kiji_data = "$kiji_no<>root<>0<>$kiji_no<>$title<>$name<>$email<>$date_now<>0<>$file_pwd<>$rhost<>$ipad<>$comment\n";
704     unshift(@all_log,$kiji_data);
705     } else {
706     foreach $tree (@all_log) {
707     if ($tn == (split(/<>/,$tree))[0]) {
708     @datas = &divide_log($tree);
709     $flag1 = 0; $flag2 = 0;
710     $kiji_data = "$kiji_no<>$OPT{'no'}<>$lx<>$tn<>$title<>$name<>$email<>$date_now<>0<>$file_pwd<>$rhost<>$ipad<>$comment";
711     foreach $data (@datas) {
712     if (($flag2 == 1) && ($temp_lx >= (split(/<>/,$data))[2])){
713     $tree_data = "$tree_data<#>$kiji_data";
714     $flag2 = 2;
715     }
716     if ($flag1) { $tree_data = "$tree_data<#>$data"; }
717     else { $tree_data = $data; $flag1 = 1; }
718     if (($OPT{'no'} == (split(/<>/,$data))[0]) && (!$flag2)) {
719     $flag2 = 1; $temp_lx = (split(/<>/,$data))[2];
720     }
721     }
722     if ($flag2 == 1){ $tree_data = "$tree_data<#>$kiji_data"; }
723     unshift (@new,"$tree_data\n");
724     }
725     else { push (@new,$tree); }
726     }
727     @all_log = @new;
728     }
729    
730     #ÍÆÎÌ¥ª¡¼¥Ð¡¼¤·¤¿µ­»ö¤òºï½ü
731     if ($max_size < 1500) { $max_size = 1500; }
732     $size = -s $logfile;
733     while ($size > $max_size){
734     my($delete) = pop(@all_log);
735     $size -= length($delete);
736     &delete_log($delete);
737     }
738     &write_file($count, $this_nj, @all_log);
739    
740     $COOKIE{'name'} = $name;
741     $COOKIE{'email'} = $email;
742     $COOKIE{'pwd'} = $pwd;
743     &set_cookie;
744     local($s) = $def_header_http.$defhead.$html_navi.'<h2>Åê¹Æ¤Î¼õÍý</h2>';
745     $s .= <<"_EOF_";
746     <p>¸æÅê¹ÆÍ­Æñ¤¦¤´¤¶¤¤¤Þ¤¹¡£°Ê²¼¤ÎÆâÍƤò¼õÍý¤·¤Þ¤·¤¿¡£</p>
747     _EOF_
748     $s .= &kiji_view($kiji_data);
749     print ($s.$deffoot);
750     exit;
751     }
752    
753     # [ Åê¹Æ¼Ôºï½ü½èÍý ]
754    
755     sub delete {
756     my(@kiji_datas) = &divide_log(&search_tree);
757     my($kiji_data) = &search_data(@kiji_datas);
758     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act,$file_pwd,$rhost,$ipad,$comment) = &divide_data($kiji_data);
759     if (crypt($COOKIE{'pwd'},$file_pwd) ne $file_pwd) {
760     &error('ºï½ü¥¨¥é¡¼','»ØÄꤷ¤¿µ­»ö¤Îºï½ü¤Ï¤Ç¤­¤Þ¤»¤ó¡£´û¤Ëºï½ü¤µ¤ì¤Æ¤¤¤Ê¤¤¤«³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£¤É¤¦¤·¤Æ¤âºï½ü¤·¤¿¤¤¾ì¹ç¤Ï´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
761     }
762     &get_date;
763    
764     #¾Úµò¤ò»Ä¤·¤Æ¤ª¤¯¡£
765     &delete_log($kiji_data);
766    
767     open(LOG,$logfile) or &error('Æɤ߹þ¤ß¥¨¥é¡¼','¥í¥°¤ÎÆɤ߹þ¤ß¤¬½ÐÍè¤Þ¤»¤ó¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
768     my($count, $last_nj);
769     $count = <LOG>;chop($count);
770     $last_nj = <LOG>;chop($last_nj);
771     my($delete_notice);
772     if (@kiji_datas == 1) {
773     while (<LOG>) {
774     unless (/^$OPT{'no'}/) { push(@new,$_); }
775     }
776     $delete_notice = '<p>µ­»ö¤Ï¥Ä¥ê¡¼¤ò¹½À®¤·¤Æ¤¤¤Ê¤«¤Ã¤¿¤¿¤á¡¢´°Á´¤Ë¾ÃÌǤ·¤Æ¤¤¤Þ¤¹¡£</p>';
777     } else {
778     my($kiji_data) = "$no<>$res<>$lx<>$tn<><del datetime=\"$datetime\">$title</del><em>(Åê¹Æ¼Ôºï½ü)</em><>$name<><>$date<>8<>Null<>$rhost<>$ipad<>Åê¹Æ¼Ô¤Ë¤è¤Ã¤Æºï½ü¤µ¤ì¤Þ¤·¤¿¡£(ºï½ü: $date_now)";
779     my($flag) = 0;
780     my($tree_data);
781     foreach (@kiji_datas) {
782     if ($flag) { $tree_data .= "<#>"; } else { $flag = 1; }
783     if (/^$OPT{'no'}/) { $tree_data .= $kiji_data; }
784     else { $tree_data .= $_; }
785     }
786     $tree_data =~ s/\n//;
787     while (<LOG>) {
788     if (!/^$OPT{'tn'}/) { push(@new,$_); }
789     else { push(@new,"$tree_data\n"); }
790     }
791     $delete_notice = '<p>µ­»ö¤Ï¥Ä¥ê¡¼¤Î°ìÉô¤ò¹½À®¤·¤Æ¤¤¤¿¤¿¤á¡¢(Åê¹Æ¼Ôºï½ü) ¤È¤¤¤¦µ­»ö¤Ëº¹¤·Âؤ¨¤é¤ì¤Æ¤¤¤Þ¤¹¡£</p>';
792     }
793     close(LOG);
794     &write_file($count, $this_nj, @new);
795     print &html_header("Åê¹Æ¼Ôºï½ü");
796     print<<"_EOF_";
797     <hr>
798     <p>µ­»ö No.$OPT{'tn'}¡Ö$title¡×¤òºï½ü¤·¤Þ¤·¤¿¡£</p>
799     $delete_notice
800     <p><a href="$this_name?$uri_query">°ìÍ÷ɽ¼¨</a>¤ò¥ê¥í¡¼¥É¤·¤Æ¡¢µ­»ö¤¬ºï½ü¤µ¤ì¤¿¤³¤È¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£</p>
801     <hr>
802     _EOF_
803     }
804    
805     # [ ¥Ç¡¼¥¿½èÍý´ØÏ¢ÈÆÍÑ¥µ¥Ö ]
806    
807     sub divide_log {
808     my($data) = @_;
809     chop($data);
810     return split(/<#>/,$data);
811     }
812     sub divide_data {
813     my $data = @_;
814     return split(/<>/,$_[0]);
815     }
816    
817     sub search_data {
818     my(@kiji_datas) = @_;
819     my($search_data_no) = $OPT{'no'};
820     my($hit_data);
821     foreach(@kiji_datas){
822     if ( /^$search_data_no/ ) {
823     $hit_data = $_;
824     last;
825     }
826     }
827     return $hit_data;
828     }
829    
830     sub search_tree {
831     my($search_tree_no) = $OPT{'tn'};
832     my($hit_data);
833     open(LOG,$logfile) or &error('Æɤ߹þ¤ß¥¨¥é¡¼','¥í¥°¤ÎÆɤ߹þ¤ß¤¬½ÐÍè¤Þ¤»¤ó¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
834     my($count, $last_nj);
835     $count = <LOG>;chop($count);
836     $last_nj = <LOG>;chop($last_nj);
837     while (<LOG>) {
838     if ( /^$search_tree_no/ ){
839     $hit_data = $_;
840     last;
841     }
842     }
843     close(LOG);
844     return $hit_data;
845     }
846    
847     # [ ¥Õ¥©¡¼¥à¤«¤é¥Ç¡¼¥¿¼èÆÀ ]
848    
849     sub read_form {
850     %OPT = %Suika::CGI::param;
851     return;
852     my($pair,$buffer);
853     if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
854     } else { $buffer = $ENV{'QUERY_STRING'}; }
855     my(@pairs) = split(/[&;]/,$buffer); #¥Ñ¥é¥á¡¼¥¿¶èÀÚ¤ê¤Ë ; ¤ò»È¤¨¤ë¤è¤¦¤Ë²þ¤¡£
856     foreach $pair (@pairs) {
857     my($name,$value) = split(/=/,$pair);
858     $value =~ tr/+/ /;
859     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
860     $OPT{$name} = &change_code($value);
861     }
862     }
863    
864     # [ ¥¯¥Ã¥­¡¼½èÍý ]
865    
866     sub get_cookie {
867     my($pair,%DUMMY);
868     my($cookies) = $ENV{'HTTP_COOKIE'};
869     my(@pairs) = split(/;/,$cookies);
870     foreach $pair (@pairs) {
871     my($name,$value) = split(/=/,$pair);
872     $name =~ s/ //g;
873     $value =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack("C", hex($1))/eg;
874     $DUMMY{$name} = $value;
875     }
876     @pairs = split(/,/,$DUMMY{$cookie_name});
877     foreach $pair (@pairs) {
878     my($name,$value) = split(/:/,$pair);
879     $COOKIE{$name} = &change_code($value);
880     }
881     }
882     sub set_cookie {
883     my($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime(time + 30*24*60*60);
884     $year += 100 if $year < 99;
885     $year += 1900;
886     $sec = "0$sec" if $sec < 10;
887     $min = "0$min" if $min < 10;
888     $hour = "0$hour" if $hour < 10;
889     $mday = "0$mday" if $mday < 10;
890     $mon = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mon];
891     $youbi = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday')[$wday];
892     $date_gmt = "$youbi, $mday\-$mon\-$year $hour:$min:$sec GMT";
893     my($cook);
894     foreach $valname ('name','email','pwd'){
895     my($tmp) = $COOKIE{$valname};
896     $tmp =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;
897     $cook .= "$valname:$tmp,";
898     }
899     print "Set-Cookie: $cookie_name=$cook; expires=$date_gmt\n";
900     }
901    
902     # [ ʸ»ú¥³¡¼¥É´ØÏ¢ ]
903    
904     sub change_code {
905     my($text)=$_[0];
906     &jcode'convert(*text,$mojicode);
907     $text =~ s/&/&amp;/g;
908     $text =~ s/</&lt;/g;
909     $text =~ s/>/&gt;/g;
910     return $text;
911     }
912    
913     # [ ÆüÉÕ¼èÆÀ ]
914    
915     sub get_date {
916     $ENV{'TZ'} = "JST-9"; # TimeZone (ÆüËÜ»þ´Ö = ¹ñºÝɸ½à»þ(JST) - 9»þ´Ö)
917     my($sec,$min,$hour,$day,$mon,$year) = localtime();
918     if ($year < 99) { $year += 100; }
919     $year += 1900;
920     $mon++;
921     $sec = "0$sec" if $sec < 10;
922     $min = "0$min" if $min < 10;
923     $hour = "0$hour" if $hour < 10;
924     $mon = "0$mon" if $mon < 10;
925     $day = "0$day" if $day < 10;
926     $date_now = "$year/$mon/$day $hour:$min:$sec";
927     $datetime = "$year-$mon-${day}T$hour:$min:$sec+09:00";
928     }
929    
930     # [ µ­Ï¿¥Õ¥¡¥¤¥ë¤Î½èÍý ]
931    
932     sub write_file {
933     my($count,$this_nj,@lines) = @_;
934    
935     #¥×¥í¥»¥¹ID ¤«¤é¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë̾¤òÀ¸À®
936     $pros = $$;
937     $pros = time unless $pros;
938     $tmp_file = "$ID$pros.tmp";
939    
940     #¾¤Î¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤ò¸¡º÷
941     opendir(DIR,$log_dir) or &error('¥·¥¹¥Æ¥à¥¨¥é¡¼','ºî¶È¥Ç¥£¥ì¥¯¥È¥ê¤Î¥ª¡¼¥×¥ó¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£´ÉÍý¼Ô¤¬²¿¤«¤ò˺¤ì¤Æ¤¤¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£');
942     @list = readdir(DIR);
943     closedir(DIR);
944     unless (@list) { &error('¥·¥¹¥Æ¥à¥¨¥é¡¼','ºî¶È¥Ç¥£¥ì¥¯¥È¥ê¤¬´°Á´¤Ë¶õ¤Ç¤¹¡£'); }
945     @lists = grep(/$ID.*\.tmp/,@list);
946    
947     #¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤¬¤¢¤ë¾ì¹ç
948     my($retry_counter) = $retry;
949     while (@lists) {
950     if (--$retry_counter <= 0) {
951     #¤·¤Ó¤ì¤òÀڤ餷¤¿
952     foreach (@lists) {
953     #¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤òËõ»¦
954     unlink("$log_dir$_") if (-e "$log_dir$_");
955     }
956     &error('¥Ó¥¸¡¼','¤¿¤Àº£º®»¨¤·¤Æ¤¤¤Þ¤¹¡£»þ´Ö¤ò¤ª¤¤¤ÆºÆÅټ¹Ԥ·¤Æ¤¯¤À¤µ¤¤¡£');
957     }
958     sleep(1);
959     opendir(DIR,"$log_dir");
960     @list = readdir(DIR);
961     closedir(DIR);
962     @lists = grep(/$ID.*\.tmp/,@list);
963     }
964    
965     #¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤Ë½ñ¤­¹þ¤à
966     open(WRITE,">$log_dir$tmp_file") or &error('½ñ¤­¹þ¤ß¥¨¥é¡¼','µ­Ï¿¥Õ¥¡¥¤¥ë¤Î½ñ¤­¹þ¤ß¤¬½ÐÍè¤Þ¤»¤ó¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
967     print WRITE "$count\n";
968     print WRITE "$this_nj\n";
969     print WRITE @lines;
970     close(WRITE);
971    
972     #¤â¤¦°ìÅÙ¾¤Î¥Æ¥ó¥Ý¥é¥ê¥Õ¥¡¥¤¥ë¤ò¸¡º÷
973     opendir(DIR,$log_dir);
974     @list = readdir(DIR);
975     closedir(DIR);
976     @lists = grep(/$ID.*\.tmp/,@list);
977     @lists = grep(!/$tmp_file/,@lists);#¼«Ê¬¼«¿È¤Ï½ü³°
978     if (@lists) {#¾¤Ç½ñ¤­¹þ¤ßÃæ¤Ç¤¢¤ì¤Ð½ñ¤­¹þ¤ß¤òÃæ»ß¤·¤Æ½ªÎ»
979     unlink("$log_dir$tmp_file") if (-e "$log_dir$tmp_file");
980     &error('½ñ¤­¹þ¤ß¤Î¶¥¹ç','Ê̤νñ¤­¹þ¤ß¤Î½èÍýÃæ¤Ç¤¹¡£¤¹¤³¤·»þ´Ö¤ò¤ª¤¤¤Æ¤«¤é¡¢ºÆÅÙ¤´ÍøÍѲ¼¤µ¤¤¡£');
981     }
982     rename("$log_dir$tmp_file",$logfile) or &error('½ñ¤­¹þ¤ß¤Î¶¥¹ç','½ñ¤­¹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£ºÆÅټ¹Ԥ·¤Æ¤¯¤À¤µ¤¤¡£');
983     chmod 0666, $logfile;
984     }
985    
986     sub delete_log{
987     my($delete) = @_;
988     open(WRITE,">> $arc_dir${ID}.txt") or &error('¥¨¥é¡¼','ºï½ü¥í¥°¤Î¥·¥¹¥Æ¥à¥¨¥é¡¼¤Ç¤¹¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
989     @datas = &divide_log($delete);
990     @datas = sort(@datas);
991     foreach $data (@datas) {
992     my($no,$res,$lx,$tn,$title,$name,$email,$date,$act,$pwd,$rhost,$ipad,$comment) = &divide_data($data);
993     print WRITE "No:$no $title\n";
994     print WRITE "$date";
995     print WRITE "$res ¤Ø¤Î¥³¥á¥ó¥È" unless ($res eq 'root');
996     print WRITE "\n";
997     $comment =~ s/<br>/\n/g;
998     $comment =~ s/&gt;/>/g;
999     $comment =~ s/&lt;/</g;
1000     $comment =~ s/&amp;/&/g;
1001     print WRITE "$comment\n\n";
1002     }
1003     close(WRITE);
1004     }
1005    
1006     sub random_string{
1007     my($str_length) = @_;
1008     my($str,$i);
1009     srand();
1010     for ($i=0; $i<$str_length; $i++){
1011     $str .= substr('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./', int(rand(64)),1);
1012     }
1013     return $str;
1014     }
1015    
1016     # [ ¥¨¥é¡¼½èÍý ]
1017    
1018     sub error {
1019     my($err_msg,$err_description) = @_;
1020     print<<"_EOF_";
1021     Content-type: text/html; $charset_code
1022     Content-Language: ja
1023    
1024     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
1025     "http://www.w3.org/TR/html4/strict.dtd">
1026     <html lang="ja">
1027     <head>
1028     $link_element
1029 wakaba 1.2 <link rel="stylesheet" href="/s/simpledoc">
1030     <link rel="stylesheet" href="../bo-style">
1031 wakaba 1.1 <title>(¥¨¥é¡¼Êó¹ð)</title>
1032     </head>
1033     <body>
1034     <h1><a name="top">¥¨¥é¡¼</a></h1>
1035     <h2>$err_msg</h2>
1036     <p>$err_description</p>
1037     _EOF_
1038     &html_footer;
1039     exit;
1040     }
1041    
1042     sub method_error{
1043     print<<"_EOF_";
1044     Status: 405 Method Not Allowed
1045     Allow: POST
1046     Content-type: text/html; $charset_code
1047     Content-Language: ja
1048    
1049     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
1050     "http://www.w3.org/TR/html4/strict.dtd">
1051     <html lang="ja">
1052     <head>
1053 wakaba 1.2 <link rel="stylesheet" href="/s/simpledoc">
1054     <link rel="stylesheet" href="../bo-style">
1055 wakaba 1.1 <title>(¥¨¥é¡¼Êó¹ð)</title>
1056     </head>
1057     <body>
1058     <h1><a name="top">¥¨¥é¡¼</a></h1>
1059     <h2>ÉÔÀµÅê¹Æ</h2>
1060     <p>¥¢¥¯¥»¥¹¤Ï¼õ¤±Æþ¤ì¤é¤ì¤Þ¤»¤ó¤Ç¤·¤¿¡£³°Éô¤«¤é¤ÎÉÔÀµ¤ÊÅê¹Æ¤¬¹Ô¤ï¤ì¤¿²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¡£</p>
1061     _EOF_
1062     &html_footer;
1063     exit;
1064     }
1065    
1066     sub navi_form{
1067     my($tree_count) = @_;
1068     my($this_page,$page_navi);
1069     my($tmp_query) = $uri_query;
1070     $tmp_query =~ s/;tree=\d+//;
1071     if($tree_count){
1072     for ($i = 0; $i < $tree_count; $i += $max_tree) {
1073     $j = $i / $max_tree + 1;
1074     if ($tree == $i) {
1075     $this_page = $j;
1076     } else {
1077     $page_navi .= "/ <a href=\"$this_name?$tmp_query;tree=$i\">$j¥Ú¡¼¥¸</a>\n"
1078     }
1079     }
1080     }
1081     $page_navi .= "( $this_page / $j ¥Ú¡¼¥¸ )" if $j > 1;
1082     print<<"_EOF_";
1083     <div class="pagenavi"><hr>
1084     <p><a href="$this_name?$uri_query;md=new">¿·µ¬Åê¹Æ</a>
1085     $page_navi</p>
1086     <hr></div>
1087     _EOF_
1088     }
1089    
1090     sub nazo_only{
1091     my(%nazo);
1092     my(@env);
1093     my($name, $value);
1094     open(LOG, $logfile) or &error('Æɤ߹þ¤ß¥¨¥é¡¼','¥í¥°¤ÎÆɤ߹þ¤ß¤¬½ÐÍè¤Þ¤»¤ó¡£´ÉÍý¼Ô¤ËÏ¢Íí¤·¤Æ¤¯¤À¤µ¤¤¡£');
1095     while(<LOG>){
1096     while( m|(¡Ú.+?¡Û)|g ){
1097     $nazo{"$1"} ++;
1098     }
1099     }
1100     close(LOG);
1101     print &html_header("ÆæÅý·×¾ðÊó");
1102     if(%nazo){
1103     print '<ul>';
1104     while (($name, $value) = each(%nazo)){
1105     push(@env, "$name = $value");
1106     }
1107     foreach (sort(@env)){
1108     print "<li><p>$_</p></li>";
1109     }
1110     print '</ul>';
1111     }else{
1112     print '<p>Not Found.</p>';
1113     }
1114     &html_footer;
1115     exit;
1116     }
1117    
1118     sub location{
1119     my($location) = @_;
1120     print <<"_EndOfText_";
1121     Status: 302 Found
1122     Location: $location
1123     Content-Type: text/html; charset=EUC-JP
1124     Content-Language: ja
1125    
1126     _EndOfText_
1127     print &html_header("$location");
1128     print "<p><a href=\"$location\">$location</a> ¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£</p>";
1129     &html_footer;
1130     exit;
1131     }
1132    
1133     sub add_query{
1134     my($name, $value) = @_;
1135     $uri_query .= ";$name=$value";
1136     $form_query .= "<input type=\"hidden\" name=\"$name\" value=\"$value\">";
1137     }
1138    
1139     sub squelch{
1140     my($data) = @_;
1141     #Ææ¤ò¥¹¥±¥ë¥Á¤¹¤ë
1142     if( $nazo eq 'no' ){
1143     $data =~ s/(¡Ú[^<]+?¡Û)/<del class="nazo">$1<\/del>/g;
1144     }
1145     return $data;
1146     }

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24