2008/01/31


実は、ここのサーバのJcode.pmがちゃんと動いてなかった事に気づいた。

最近トラックバックスパムがやたらと文字化けを起こすなぁ...って思ってたんです。まぁ、相手のサーバの文字コードなんかお構い無しに放り投げてくるのがスパム!な訳ですから、化けてあたりまえ...
いや待てよ、blosxomのwritebackプラグインでJcode::convert変換してたはず。しかもutf8でだ。
で、ようやく重い腰をあげる。

調べてる内に、ここのサーバではJcode.pmがutf8で全滅している事に気づいた。
このサーバではXSは置けないのでJcode::Unicode::NoXSが動いているものとばかり思っていたのだが、いやいや...

うんちゃらかんちゃら、弄ってる内にメンドクサクなってきたので、ついいつもの適当ハック癖...。
Jcode/Unicode/NoXS.pm内のメソッドをJcode::XXXからJcode::_Classic::XXXに一括痴漢^H^H置換して、お茶を濁す。

--- Jcode/Unicode/NoXS.pm.orig  2007-06-26 00:31:47.000000000 +0900
+++ Jcode/Unicode/NoXS.pm   2007-06-26 03:23:49.000000000 +0900
@@ -53,7 +53,7 @@
 # instead of being 'use'd (No package export done) subs below
 # belong to Jcode, not Jcode::Unicode

-sub Jcode::ucs2_euc{
+sub Jcode::_Classic::ucs2_euc{
     my $thingy = shift;
     my $r_str = ref $thingy ? $thingy : \$thingy;
     _init_u2e();
@@ -68,7 +68,7 @@
     $$r_str;
 }

-sub Jcode::euc_ucs2{
+sub Jcode::_Classic::euc_ucs2{
     my $thingy = shift;
     my $r_str = ref $thingy ? $thingy : \$thingy;
     _init_e2u();
@@ -84,21 +84,21 @@
     $$r_str;
 }

-sub Jcode::euc_utf8{
+sub Jcode::_Classic::euc_utf8{
     my $thingy = shift;
     my $r_str = ref $thingy ? $thingy : \$thingy;
-    &Jcode::euc_ucs2($r_str);
-    &Jcode::ucs2_utf8($r_str);
+    &Jcode::_Classic::euc_ucs2($r_str);
+    &Jcode::_Classic::ucs2_utf8($r_str);
 }

-sub Jcode::utf8_euc{
+sub Jcode::_Classic::utf8_euc{
     my $thingy = shift;
     my $r_str = ref $thingy ? $thingy : \$thingy;
-    &Jcode::utf8_ucs2($r_str);
-    &Jcode::ucs2_euc($r_str);
+    &Jcode::_Classic::utf8_ucs2($r_str);
+    &Jcode::_Classic::ucs2_euc($r_str);
 }

-sub Jcode::ucs2_utf8{
+sub Jcode::_Classic::ucs2_utf8{
     my $thingy = shift;
     my $r_str = ref $thingy ? $thingy : \$thingy;
     my $result;
@@ -121,7 +121,7 @@
     $$r_str = $result;
 }

-sub Jcode::utf8_ucs2{
+sub Jcode::_Classic::utf8_ucs2{
     my $thingy = shift;
     my $r_str = ref $thingy ? $thingy : \$thingy;
     my $result;

とりあえず、動いてそげ。
Posted at by




blosxomでモブログをするには、2つの機能が必要となります。
  1. XMLRPCでのポスト
  2. メール受信でXMLRPCをキックするサーバ
前者については、「BXR: Blosxom XML-RPC Interface>」というスバラシイものがあるので、これを利用します。
ただ、後者については、サーバを用意出来ない方もいらっしゃると思います。そこで登場するのが「サイドバー.jp」です。このサービスでは、モブログ支援ということで、各アカウント毎に用意されたメールアドレスに対して記事を投稿すると、設定していたXMLRPCサーバをコールしてくれる機能を持っています。

続きを読む...

Posted at by




このサイトのfeedは、Feedburnerを使って焼いていません。いずれdel.icio.us等と一緒に配信させて頂くことになるやもしれませんが、なんとなくブログのフィード購読者数をカウントするCGI作ってみました。
例によって2〜3分で出来た代物なので(ブログ書いてる時間のほうが長いやろ)、中身のクオリティは適当です。
大体の著明なFeed-Fetcherは、ユーザエージェントに「XXX subscriber」という文字列を埋め込んできます。このXXXにそのフィードリーダのsubscriber数が格納されています。
blosxomのloggerプラグイン(もしくはココ)が出力したログファイルから、このsubscriber部を抜き取り著明なフィードリーダ毎購読者数をカウントします。

livedoor FeedFetcher/0.01 (http://reader.livedoor.com/; 23 subscribers) ...
#!/usr/bin/perl

use strict;
my $logfile = "/blosxom/logs/access.log";
#my $logfile = "access.log";
my %agents;
my %bot_ua = (
  'Hatena' => 'Hatena\x20RSS',
  'NewsAlloy' => 'NewsAlloy',
  'FreshReader' => 'FreshReader',
  'Feedpath' => 'Feedpath',
  'Google Reader' => 'Feedfetcher-Google',
  'Rojo' => 'Rojo',
  'Bloglines' => 'Bloglines',
  'Livedoor Reader' => 'livedoor\x20FeedFetcher',
);
open(FILE"<$logfile");
while(<FILE>) {
  my $line = $_;
  $line =~ s/^([^\t]+\t){2}([^\t]+)\t.*/\2/;
  if ((my $ua) = grep {$line =~ /$bot_ua{$_}/} keys(%bot_ua)) {
    $line =~ s/^.* ([0-9]+) subscriber.*\n$/\1/;
    $agents{$ua} = $line if ($agents{$ua} < $line);
  }
}
close(FILE);

print <<EOF
Content-Type: text/html;

<html>
<head><title>Your Feeds Subscriber</title><head>
<body>
<table border=\"1\">
EOF
;
my $sum = 0;
while(my ($key$value) = each(%agents)) {
  print "<tr><td>$key</td><td>$value</td></tr>\n";
  $sum += $value;
}
print <<EOF
<tr><td>total</td><td>$sum</td></tr>
</table>
</body>
</html>
EOF
;

いや、つまらない事しか書いてないのに、購読者がいらっしゃるとは...
※実際にはクライアントサイドで閲覧していらしゃるでしょうから、正しい値とは限りません。
Posted at by