WiLiKi/trackback

TrackBack


tb-standalone の修正

  • send_form 後、reload すると二重投稿になる問題の修正
  • trackbackされた件数を表示できるようにする(http://nais.to/~yto/clog/2003-09-25-4.html)
        - tb.cgi.orig Wed Feb 18 00:45:08 2004
+++ tb.cgi      Fri Jul  8 17:24:48 2005
@@ -26,6 +26,22 @@
 
 charset $Charset;
 
+my $i;
+if (open(FH, ">> /tmp/trackback.log")) {
+       print FH "trackback log\n";
+       foreach $i (sort keys %ENV) {
+               print FH "ENV:$i:",$ENV{$i},"\n";
+       }
+       print FH "----\n";
+       print FH "__mode:",param('__mode'),"\n";
+       print FH "title:",param('title'),"\n";
+       print FH "excerpt:",param('excerpt'),"\n";
+       print FH "url:",param('url'),"\n";
+       print FH "blog_name:",param('blog_name'),"\n";
+       print FH "----\n\n\n";
+       close FH;
+}
+
 my $mode = param('__mode');
 unless ($mode) {
     my $tb_id = munge_tb_id(get_tb_id());
@@ -44,6 +60,12 @@
     if ($NotifyEmail) {
        notify_email($NotifyEmail, $i, $tb_id);
     }
+# from here
+    if (open(FH, ">" . catfile($DataDir, $tb_id . '.js'))) {
+       print FH "document.write('(@{[scalar(grep {$_} @$data)]})');\n";
+       close FH; # 追加
+    }
+# to here
     respond_exit();
 } elsif ($mode eq 'list') {
     my $tb_id = munge_tb_id(get_tb_id());
@@ -120,7 +142,7 @@
     my($e, $msg) = $res->content =~ m!(\d+).*(.+?)!s;
     $e ? ping_form_exit("Error: $msg") : ping_form_exit("Ping successfuly sent"
);
 } elsif ($mode eq 'send_form') {
- ping_form_exit();
+    ping_form_exit2(param('message'));
 } elsif ($mode eq 'login') {
     print header(), login_form();
 } elsif ($mode eq 'do_login') {
@@ -232,15 +254,20 @@
 }
 
 sub ping_form_exit {
+    my $message = encode_url("@_");
+    print redirect(url() . "?__mode=send_form&message=$message");
+}
+
+sub ping_form_exit2 {
     print header(), from_file($Header);
- print "@_" if @_;
+    print escapeHTML("@_") if @_;
     print <Send a TrackBack ping
 
- +
TrackBack Ping URL:
 
Title:
Title:
Blog name:
Excerpt:
Permalink URL: