OSDN Git Service

自動リンク機能がある程度安定しているようなので、現時点でのブランチorigin/autolinkをmasterにmerge。
[kenranchat/yadchat.git] / yadchatlib.pl
1 ###
2 ### Yet Anather Dice Chat: Library
3 ### $Id: yadchatlib.pl,v 1.6 2007/06/07 12:20:57 jyugoya Exp $
4 ### YADChat / 2007 © \8c\8b\8fé\97R\97\85\81\97\90¢\8aE\94E\8eÒ\8d\91 / BSD Lisence
5 ###
6
7 ### \95Û\97¯\92\86\95Ï\90\94 ###
8 $rep_color = "000000";
9
10 #####  \8aÖ\90\94\81F\83G\83\89\81[\95\\8e¦ (\8b¤\92Ê) #####
11 sub error {
12     local($errmsg) = $_[0];
13     local($lockfile) = $CONF{'lockdir'}.'/'.$IN{'room'}.'.lock';
14     local($memlock) = $CONF{'lockdir'}.'/'.$IN{'room'}.'.memlock';
15     local($rplock) = $CONF{'lockdir'}.'/'.$IN{'room'}.'.rplock';
16
17     # \83\8d\83b\83N\83t\83@\83C\83\8b\82Ì\89ð\8f\9c
18     if ($CONF{'lockmode'}) {
19         &unlock($lockfile);
20         &unlock($memlock);
21         &unlock($rplock);
22     }
23
24     &printHeader();
25     print << "EOM";
26 <body>
27 <center><h3>ERROR !</h3>
28 <font color='red'>$errmsg</font></center>
29 </body></html>
30 EOM
31     exit(0);
32 }
33
34 ##### \8aÖ\90\94\81F\83G\83\89\81[\95\\8e¦ (&error()\82Æ\8fd\95¡) #####
35 sub printError {
36     &printHeader();
37
38     print $query->h1($CONF{'title'});
39     print $query->p("ERORR: " . $_[0]);
40
41     if ($DEBUG) {
42         foreach $key (keys %IN) {
43             print $query->p($key . ": " . $IN{$key});
44         }
45     }
46     print $query->p("<a href=\"$CONF{'indexcgi'}\" target=\"_top\">[ \88ê\97\97\82Ö\96ß\82é ]</a>");
47
48     # \95\\8e¦\8fI\97¹
49     print $query->end_html;
50     exit(0);
51 }
52
53 ##### \8aÖ\90\94\81F\83f\83o\83b\83O\95\\8e¦ #####
54 sub printDebug {
55     print $query->h2("\83f\83o\83b\83O\8fî\95ñ");
56     print "<div class=\"main\">";
57     print $query->p($errmsg);
58     print "Input: ";
59     foreach $key (keys %IN) {
60         print $key . " = " . $IN{$key} . ", ";
61     }
62     print "<br/>Config: ";
63     foreach $key (keys %CONF) {
64         print $key . " = " . $CONF{$key} . ", ";
65     }
66     print "</div>";
67 }
68
69 ##### \8aÖ\90\94\81F\92\8d\88Ó\8e\96\8d\80\95\\8e¦ #####
70 sub printNotice {
71     print $query->h2("\92\8d\88Ó\8e\96\8d\80");
72     print<<EOM;
73 <ul class="sub">
74 <li>\83`\83\83\83b\83g\83\8b\81[\83\80\8dì\90¬\83v\83\8d\83O\83\89\83\80\82Å\82·\81B</li>
75 <li>\83`\83\83\83b\83g\83\8b\81[\83\80\82Ì\8dì\90¬\82Í\92N\82Å\82à\82Å\82«\82Ü\82·\81B</li>
76 <li>\83`\83\83\83b\83g\83\8b\81[\83\80\82Ì\8fI\97¹\82Í\8dì\90¬\8eÒ\82Æ\8aÇ\97\9d\8eÒ\82µ\82©\82Å\82«\82Ü\82¹\82ñ\81B</li>
77 <li>\83`\83\83\83b\83g\83\8b\81[\83\80\82Ì\8dí\8f\9c\82Í\8aÇ\97\9d\8eÒ\82µ\82©\82Å\82«\82Ü\82¹\82ñ\81B</li>
78 <li>\82½\82­\82³\82ñ\82Ì\83`\83\83\83b\83g\83\8b\81[\83\80\82ð\93¯\8e\9e\97\98\97p\82·\82é\82Æ\95\89\89×\82ª\82©\82©\82è\82Ü\82·\82Ì\82Å\97Ç\8e¯\82Ì\94Í\88Í\82Å\82²\97\98\97p\82­\82¾\82³\82¢\81B</li>
79 <li>mihana\82³\82ñ\82Ì\83v\83\8d\83O\83\89\83\80\82ð\83\82\83f\83\8b\82É\83X\83N\83\89\83b\83`\82µ\81ABSD\83\89\83C\83Z\83\93\83X\89»\82µ\82Ä\82Ü\82·\81B</li>
80 <li>\83`\83\83\83b\83g\83\8b\81[\83\80\82Í\8d\8b\89Ø\88ºà£\83`\83\83\83b\83g\81icomchat\8cÝ\8a·\95i\81j\82ð\95Ï\8dX\82µ\82½\82à\82Ì\82Å\82·\81B\92·\95\83\82\81[\83h\82Í\82 \82è\82Ü\82¹\82ñ\81B\83_\83C\83X\82Í2d6\82Ì\82æ\82¤\82É\93ü\97Í\82·\82é\82Æ\92u\82«\8a·\82í\82è\82Ü\82·\81B</li>
81 </ul>
82 EOM
83 }
84
85 ##### \8aÖ\90\94\81F\95\94\89®\88ê\97\97\95\\8e¦ #####
86 sub printRoomList {
87     print<<HEADER;
88 <H2>\83`\83\83\83b\83g\83\8b\81[\83\80\88ê\97\97</H2>
89
90 <table class="sub">
91 <tr>
92 <th align="center">\83\8b\81[\83\80\96¼</TD>
93 <th align="center">\8ae\8eí\89{\97\97</TD>
94 <th align="center">\83R\83\81\83\93\83g</TD>
95 </tr>
96 HEADER
97
98     # \88ê\97\97\95\\8e¦
99     local(@index) = &readIndex();
100     foreach $room (@index){
101         local($idx, $name, $comment, $state, $pass) = split(/<>/, $room, 5);
102         if ($state){
103             local($loglink) = &genLogLinkString($idx);
104             print <<ROW;
105 <tr>
106 <td align="left"><a href="$CONF{'chatcgi'}?room=$idx">$idx $name</a></td>
107 <td align="left">
108 [<a href="$CONF{'chatcgi'}?room=$idx&weight=light">\8cg\91Ñ\93ü\8cû</a>]
109 $loglink
110 </td><td align="left">$comment</td>
111 </tr>
112 ROW
113         }
114     }
115
116     print $query->end_table;
117
118     # \83\81\83j\83\85\81[\95\\8e¦
119     print<<MENU;
120 <p class="sub">
121 <a href="$CONF{'indexcgi'}?mode=make">\90V\8bK\83`\83\83\83b\83g\83\8b\81[\83\80\8dì\90¬</a>
122  | <a href="$CONF{'indexcgi'}?mode=log">\83\8d\83O\83t\83@\83C\83\8b\88ê\97\97</a>
123  | <a href="$CONF{'indexcgi'}?mode=admin">\8aÇ\97\9d\83\81\83j\83\85\81[</a>
124 </p>
125 MENU
126 }
127
128 ##### \8aÖ\90\94\81F\95\94\89®\8dì\90¬\89æ\96Ê\95\\8e¦ #####
129 sub printMakeRoom {
130     print $query->h2("\83`\83\83\83b\83g\83\8b\81[\83\80\8dì\90¬");
131     print<<EOM;
132 <div class="main">
133 <form action="$CONF{'indexcgi'}" method="post" class="main">
134 <table>
135 <tr><td>\83\8b\81[\83\80\96¼</td><td><input type="text" name="name" size="40"></td></tr>
136 <tr><td>\83R\83\81\83\93\83g</td><td><input type="text" name="comment" size="40"></td></tr>
137 <tr><td>\83p\83X\83\8f\81[\83h</td><td><input type="password" name="pass" size="8"></td></tr>
138 <tr><td></td><td><input type="submit" name="make" value="\83`\83\83\83b\83g\83\8b\81[\83\80\82ð\8dì\90¬\82·\82é"></td></tr>
139 </table>
140 </form>
141 </div>
142 EOM
143 }
144
145 ##### \8aÖ\90\94\81F\83\8d\83O\83t\83@\83C\83\8b\88ê\97\97\95\\8e¦ #####
146 sub printLogList {
147     print $query->h2("\83\8d\83O\83t\83@\83C\83\8b\88ê\97\97");
148     print<<HEAD;
149 <table class="sub">
150 <tr>
151 <th align="center">\83\8b\81[\83\80\96¼</TD>
152 <th align="center">\83R\83\81\83\93\83g</TD>
153 </TR>
154 HEAD
155     # \88ê\97\97\95\\8e¦
156     local(@index) = &readIndex();
157     shift(@index);
158     foreach $room (@index){
159         local($idx, $name, $comment, $state, $pass) = split(/<>/, $room, 5);
160         if (!$state){
161             print<<ROW;
162 <tr>
163 <td align="left"><a href="$CONF{'logdir'}/$idx.html">$idx $name</a></td>
164 <td align="left">$comment</td>
165 </tr>
166 ROW
167         }
168     }
169     print $query->end_table;
170 }
171
172 ##### \8aÖ\90\94\81F\8aÇ\97\9d\83\81\83j\83\85\81[\95\\8e¦ #####
173 sub printAdminMenu {
174     &printClose();
175     &printDelete();
176 }
177
178 ##### \8aÖ\90\94\81F\8fI\97¹\83\81\83j\83\85\81[\95\\8e¦ #####
179 sub printClose {
180     print $query->h2("\83`\83\83\83b\83g\83\8b\81[\83\80\82Ì\8fI\97¹");
181     print<<HEAD;
182 <div class="main">
183 <form action="$CONF{'indexcgi'}" method="post" class="main">
184 <table>
185 <tr>
186 <td>\83`\83\83\83b\83g\83\8b\81[\83\80\91I\91ð</td>
187 <td><select name="close">
188 HEAD
189     # \83\8a\83X\83g\95\\8e¦
190     local(@index) = &readIndex();
191     shift(@index);
192     foreach $room (@index){
193         local($idx, $name, $comment, $state, $pass) = split(/<>/, $room, 5);
194         if ($state){
195             print <<OPTION;
196 <option value="$idx">$idx $name</option>
197 OPTION
198         }
199     }
200     print <<FOOT;
201 </select></td>
202 </tr>
203 <tr>
204 <td>\83p\83X\83\8f\81[\83h</td>
205 <td><input type="password" name="pass" size="15"></td>
206 </tr>
207 <tr><td></td><td><input type="submit" name="admin" value="\8fI\97¹"></td></tr>
208 </table>
209 </form>
210 </div>
211 FOOT
212 }
213
214 ##### \8aÖ\90\94\81F\8dí\8f\9c\83\81\83j\83\85\81[\95\\8e¦ #####
215 sub printDelete {
216     print $query->h2("\83`\83\83\83b\83g\83\8b\81[\83\80\82Ì\8dí\8f\9c");
217     print <<HEAD;
218 <div class="main">
219 <form action="$CONF{'indexcgi'}" method="post" class="main">
220 <table>
221 <tr>
222 <td>\83Q\81[\83\80\91I\91ð</td>
223 <td><select name="del">
224 HEAD
225
226     # \88ê\97\97\8dì\90¬
227     local(@index) = &readIndex();
228     shift(@index);
229     foreach $room (@index){
230         local($idx, $name, $comment, $state, $pass) = split(/<>/, $room, 5);
231         print <<ROW;
232 <option value="$idx">$idx $name</option>
233 ROW
234     }
235
236 print <<FOOT;
237 </select>
238 </td></tr>
239 <tr><td>\83p\83X\83\8f\81[\83h</td>
240 <td><input type="password" name="pass" size="15"></td>
241 </tr><tr><td></td><td><input type="submit" name="admin" value="\8dí\8f\9c"></td></tr>
242 </table>
243 </form>
244 </div>
245 FOOT
246 }
247
248 ##### \8aÖ\90\94\81F\92\98\8dì\8c \95\8e\9a\97ñ\90\90¬ #####
249 sub genCopyright() {
250     local($copyRight)=<<EOM;
251 <p class="footer">
252 YADChat / 2007 &copy; \8c\8b\8fé\97R\97\85\81\97\90¢\8aE\94E\8eÒ\8d\91 / BSD Lisence
253 </p>
254 EOM
255     return $copyRight;
256 }
257
258 ##### \8aÖ\90\94\81F\83\8d\83b\83N\8f\88\97\9d #####
259 sub lock {
260     local($lockfile) = $_[0]; # \83\8d\83b\83N\83t\83@\83C\83\8b\82Í\88ø\90\94\82Å\8ew\92è
261     local($lockmode) = $CONF{'lockmode'};
262     local($retry) = $CONF{'retry'};
263     local($timeout) = $CONF{'timeout'};
264     local($errmsg) = "Lock ($lockfile) is busy";
265
266     # \88ê\92è\8e\9e\8aÔ\88È\8fã\8cÃ\82¢\83\8d\83b\83N\82Í\8dí\8f\9c\82·\82é
267     if (-e $lockfile) {
268         ($mtime) = (stat($lockfile))[9];
269         if ($mtime < time - $timeout) { &unlock($lockfile); }
270     }
271     # symlink\8aÖ\90\94\8e®\83\8d\83b\83N
272     if ($lockmode == 1) {
273         while (!symlink(".", $lockfile)) {
274             if (--$retry <= 0) { &error($errmsg); }
275             sleep(1);
276         }
277     # mkdir\8aÖ\90\94\8e®\83\8d\83b\83N
278     } elsif ($lockmode == 2) {
279         while (!mkdir($lockfile, 0755)) {
280             if (--$retry <= 0) { &error($errmsg); }
281             sleep(1);
282         }
283     }
284 }
285
286 ##### \8aÖ\90\94\81F\83\8d\83b\83N\89ð\8f\9c #####
287 sub unlock {
288     local($lockfile) = $_[0]; # \83\8d\83b\83N\83t\83@\83C\83\8b\82Í\88ø\90\94\82Å\8ew\92è
289     local($lockmode) = $CONF{'lockmode'};
290
291     # symlink\8c`\8e®
292     if ($lockmode == 1) {
293         unlink($lockfile);
294     }
295
296     # mkdir\95û\8e®
297     elsif ($lockmode == 2) {
298         rmdir($lockfile);
299     }
300
301     # flock\95û\8e®\81F\96¢\8eÀ\91\95
302     elsif ($lockmode == 3) {
303     }
304 }
305
306 ##### \8aÖ\90\94\81F\83C\83\93\83f\83b\83N\83X\88ê\97\97\8eæ\93¾ #####
307 sub readIndex {
308     open(INDEX, "<$CONF{'indexdat'}") || die "Can't open $CONF{'indexdat'}: $!";
309     flock(INDEX, LOCK_SH);
310     local (@list) = <INDEX>;
311     flock(INDEX, LOCK_NB);
312     close(INDEX);
313     @list;
314 }
315
316 ##### \8aÖ\90\94\81F\83C\83\93\83f\83b\83N\83X\83t\83@\83C\83\8b\8dX\90V #####
317 sub updateIndex {
318     local(@index) = @_;
319
320     open(INDEX, ">$CONF{'indexdat'}") || die "Can't open $CONF{'indexdat'}: $!";
321     flock(INDEX, LOCK_EX);
322     print INDEX @index;
323     flock(INDEX, LOCK_NB);
324     close(INDEX);
325 }
326
327 ##### \8aÖ\90\94\81F\90V\8bK\95\94\89®\8dì\90¬ #####
328 sub createNewRoom {
329     local($name, $comment) = @_;
330     local(@index) = &readIndex();
331
332     # \8dÅ\8fI\95\94\89®\94Ô\8d\86\82Ì\8eæ\93¾
333     local($roomidx) = shift(@index);
334     $roomidx++;
335
336     # \95\94\89®\83t\83@\83C\83\8b\82Ì\8dì\90¬
337     local($roomfile) = "$CONF{'datdir'}/$roomidx.dat";
338     open(NEW, ">$roomfile")  || die "Can't open $roomfile: $!";
339     close(NEW);
340     chmod (0640, $roomfile);
341
342     # \83\81\83\93\83o\83t\83@\83C\83\8b\82Ì\8dì\90¬
343     local($memfile) = "$CONF{'memdir'}/$roomidx.dat";
344     open(NEW, ">$memfile")  || die "Can't open $memfile: $!";
345     close(NEW);
346     chmod (0640, $memfile);
347
348     # \90V\8bK\95\94\89®\82Ì\83C\83\93\83f\83b\83N\83X\83t\83@\83C\83\8b\82Ö\82Ì\92Ç\89Á
349     $line = "$roomidx<>$name<>$comment<>1<>$IN{'pass'}\n";
350     unshift(@index, $line);
351
352     $roomidx .= "\n";
353     unshift(@index, $roomidx);
354
355     updateIndex(@index);
356 }
357
358 ##### \8aÖ\90\94\81F\95\94\89®\8dí\8f\9c #####
359 sub deleteRoom {
360     local($delidx) = @_;
361     local(@index) = &readIndex();
362
363     local($roomfile) = "$CONF{'datdir'}/$roomidx.dat";
364     local($memfile) = "$CONF{'memdir'}/$roomidx.dat";
365     local($logfile) = "$CONF{'logdir'}/$roomidx.html";
366
367     # \8dí\8f\9c
368     unlink($roomfile) if (-e $roomfile);
369     unlink($memfile) if (-e $memfile);
370     unlink($logfile) if (-e $logfile);
371
372     @index = grep(!/$delidx<>/, @index);
373     &updateIndex(@index);
374 }
375
376 ##### \8aÖ\90\94\81F\95\94\89®\82ð\95Â\82\82é #####
377 sub closeRoom {
378     local($pass, $close) = @_;
379     local(@index) = &readIndex();
380
381     foreach $line (@index){
382         if ($pass eq $CONF{'pass'}) {
383             # \8aÇ\97\9d\8eÒ\8c \8cÀ\82Å\82Ì\83N\83\8d\81[\83Y
384             if ($line =~ s/$close<>([^<>]+)<>([^<>]+)<>1<>(\S+)/$close<>$1<>$2<>0<>$3/) {
385                 if ($DEBUG) {
386                     print "using admin pass...\n";
387                 }
388                 &genLogfile($close, &getRoomTitle($close, $1));
389                 &updateIndex(@index);
390             }
391         } else {
392             # \8dì\90¬\8eÒ\8c \8cÀ\82Å\82Ì\83N\83\8d\81[\83Y
393             if ($line =~ s/$close<>([^<>]+)<>([^<>]+)<>1<>$pass/$close<>$1<>$2<>0<>$pass/) {
394                 if ($DEBUG) {
395                     print "using creater's pass...\n";
396                 }
397                 &genLogfile($close, &getRoomTitle($close, $1));
398                 &updateIndex(@index);
399             }
400         }
401     }
402 }
403
404 ##### \8aÖ\90\94\81F\95\94\89®\83^\83C\83g\83\8b\82Ì\8eæ\93¾ #####
405 sub getRoomTitle {
406     local($roomidx, $roomname) = @_;
407     if ($roomname eq "") {
408         local(@index) = &readIndex();
409         foreach $line (@index) {
410             if ($line =~ /$roomidx<>([^<>]+)<>([^<>]+)<>\d<>(\S+)/) {
411                 $roomname = $1;
412             }
413         }
414     }
415     return "$CONF{'title'}\81F$roomidx $roomname";
416 }
417
418 ##### \8aÖ\90\94\81F\83\8d\83O\89{\97\97\83\8a\83\93\83N\95\8e\9a\97ñ #####
419 sub genLogLinkString {
420     local($room) = $_[0];
421     local($str) = "";
422     $str .= "[<a href=\"";
423     $str .= $CONF{'chatcgi'}."?room=$room&mode=view&retime=0&line=200";
424     $str .= "\" target=_blank>200\8ds\83\8d\83O</a>]";
425     $str .= " [<a href=\"";
426     $str .= $CONF{'chatcgi'}."?room=$room&mode=view&retime=0&line=500";
427     $str .= "\" target=_blank>500\8ds\83\8d\83O</a>]";
428     $str .= " [<a href=\"";
429     $str .= $CONF{'chatcgi'}."?room=$room&mode=view&retime=0&line=1000";
430     $str .= "\" target=_blank>1000\8ds\83\8d\83O</a>]";
431     if ($CONF{'rplog'}) {
432         $str .= " [<a href=\"";
433         $str .= "rp/$room.txt";
434         $str .= "\" target=_blank>RP\83\8d\83O</a>]";
435     }
436     return $str;
437 }
438
439 ##### \8aÖ\90\94\81F\83f\81[\83^\82ð\8f\91\8e®\89» #####
440 sub formatDat {
441     local($datfile) = $_[0];
442     local($lnum) = $_[1];
443     local($weight) = $_[2];
444     local($reverse) = $_[3];
445
446     # \83f\81[\83^\8eæ\93¾
447     open(DAT,"<$datfile")
448         || &printError("Open Error : datfile : $datfile: $!");
449     flock(DAT, LOCK_SH);
450     local(@lines) = <DAT>;
451     flock(DAT, LOCK_NB);
452     close(DAT);
453
454     # \94½\93]\82·\82é\8fê\8d\87\82Í\94½\93]
455     if ($reverse) {
456         @lines = reverse(@lines);
457     }
458
459     local($i, $ret) = (0, "");
460     foreach $line (@lines) {
461         #print "$i: $line\n";
462         $i++;
463         if ($lnum ne 'max' && $i > $lnum) { last; }
464         local($date,$name,$email,$comment,$color) = split(/<>/, $line);
465         # \8e©\93®\83\8a\83\93\83NON\82È\82ç\82ÎURL\95\8e\9a\97ñ\92u\82«\8a·\82¦$
466         if ( $CONF{'autolink'} ) {
467             # URL Auto Link
468             $comment =~ s/(s?https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/<a href="\1" target="_blank">\1<\/a>/g;
469         }
470         $ret .= $query->hr;
471         if ($weight eq 'light') {
472             $ret .= "$name \81\84 $comment ";
473             $ret .= "($date)";
474         } else {
475             $ret .= "<font color=\"#$color\">$name \81\84 $comment</font> ";
476             $ret .= "<font color=\"#$rep_color\">($date)</font>";
477         }
478         $ret .= $query->br;
479         $ret .= "\n";
480     }
481
482     return $ret;
483 }
484
485 ##### \8aÖ\90\94\81F\83\8d\83O\83t\83@\83C\83\8b\90\90¬ #####
486 sub genLogfile {
487     local($close, $title) = @_;
488     local($datfile) = "$CONF{'datdir'}/$close.dat";
489     local($memfile) = "$CONF{'memdir'}/$close.dat";
490     local($logfile) = "$CONF{'logdir'}/$close.html";
491
492     if ($DEBUG) {
493         print "$datfile, $memfile, $logfile...\n";
494     }
495     # \83f\81[\83^\83t\83@\83C\83\8b\82ª\82È\82¢\8fê\8d\87\82Í\89½\82à\82¹\82¸\82É\96ß\82é
496     if (! -e $datfile) {
497         &printError("No such dat: $datfile");
498         return;
499     }
500
501     # \83\8d\83O\83t\83@\83C\83\8b\82É\8f\91\82«\8d\9e\82Ý\8aJ\8en
502     open(LOG, ">$logfile")
503         || &error("Can't open : logfile : $logfile: $!");
504     flock(LOG, LOCK_EX);
505
506     if ($DEBUG) {
507         print "writing $logfile...\n";
508     }
509     # \83w\83b\83_\95\94
510     print LOG $query->start_html(-lang => $CONF{'lang'},
511                  -encoding => $CONF{'charset'},
512                  -head => meta({-http_equiv => 'Content-Type',
513                                 -content    => 'text/html; charset=' . $CONF{'charset'}}),
514                  -title=>$title,
515                  -style=>{-src=>"../$CONF{'chatstyle'}"});
516
517     # \83^\83C\83g\83\8b
518     print LOG $query->h1($title);
519
520     if ($DEBUG) {
521         print "writing data...\n";
522     }
523     # \83f\81[\83^\95\94
524     print LOG &formatDat($datfile, 'max', 'normal', 'reverse');
525     if ($DEBUG) {
526         print "done...\n";
527     }
528
529     print LOG $query->hr ."\n";
530
531     # \83R\83s\81[\83\89\83C\83g\95\94
532     print LOG &genCopyright();
533
534     # HTML\8fI\82í\82è
535     print LOG $query->end_html;
536
537     if ($DEBUG) {
538         print "done...\n";
539     }
540     flock(LOG, LOCK_NB);
541     close (LOG);
542
543     if ($DEBUG) {
544         print "$delete files...\n";
545     }
546     # \83f\81[\83^\81\95\83\81\83\93\83o\83t\83@\83C\83\8b\8dí\8f\9c
547     unlink($datfile) if (-e $datfile);
548     unlink($memfile) if (-e $memfile);
549 }
550
551 ### End of yadchatlib
552 1;