/[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.3 - (show annotations) (download)
Sun Aug 17 05:35:26 2003 UTC (21 years, 3 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +5 -4 lines
Error occurred while calculating annotation data.
Don't use obsoleted module of Suika::CGI

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24