LoginSignup
2
5

More than 5 years have passed since last update.

さくらのレンタルサーバのMLのカスタマイズ

Last updated at Posted at 2014-09-02

さくらのレンタルサーバに付属するメーリングリスト(fml)について、サーバコントロールパネル以外で行う設定のメモ。

HTML アーカイブをアクセス制限する

コントロールパネルの[メーリングリストの動作を設定する]>[詳細表示]にて[HTMLファイルの自動生成]を設定すると、~/www/ 直下に ml というディレクトリができて[*]、過去記事が HTML 形式で保存されるようになる。

(*:できていない場合は、[メーリングリスト管理]にて[過去記事を再生成する場合は、こちらをクリックして下さい。]を実行。)

この ml 直下に .htaccess をおいて Basic 認証をかける。

.htaccess
# アクセス制限

AuthUserFile /home/[user]/.htpasswd
AuthType Basic
AuthName "ML Archives"

Require valid-user

SSH して .htpasswd を作成。

$ htpasswd -c .htpasswd [username]
New password: 
Re-type new password: 
Adding password for user [username]

HTML アーカイブのインデックス・ページを月別にする

デフォルトでは日別(目次ページが1日ごとに分割して作られる)。
それほど投稿数が多くなければ月別などにしたい。

~/fml/spool/ml/[ml-name]/cf を編集する。

~/fml/spool/ml/[ml-name]/cf[before]
### Automatic Html Generation
AUTO_HTML_GEN               1
HTML_THREAD_REF_TYPE        prefer-in-reply-to
HTML_STYLESHEET_BASENAME

~/fml/spool/ml/[ml-name]/cf[after]
  ### Automatic Html Generation
  AUTO_HTML_GEN             1
  HTML_THREAD_REF_TYPE      prefer-in-reply-to
  HTML_STYLESHEET_BASENAME
+ HTML_INDEX_UNIT             month

*「+」の文字は不要。

取りうる値は [number] / day / week / month / infinite のいずれか。
参考:1 HTML形式の記事を作成する

上記編集後、以下のコマンドを実行して、cf(設定ファイルの原本) から config.ph(設定ファイルの実体)を生成する。
(なお、config.ph を直接編集してしまうと、さくらのコントロールパネルから ML の設定を変更したときに上書きされて編集内容が消えてしまう。)

# 初期状態では実行パーミションが無いので付与。2回目以降は不要。
$ chmod u+x ~/fml/sbin/makefml 
# config.ph を生成。
$ ~/fml/sbin/makefml update-config [ml-name]

   THIS HOST (wwwXXX.sakura.ne.jp) IS [amd64-unknown-freebsd9.1]

DO "update-config" for [ml-name] mailing list.
O.K. Try to re-create /home/[user]/fml/spool/ml/[ml-name]/config.ph !!!

   Create config.ph(/home/[user]/fml/spool/ml/[ml-name]/config.ph):
    /home/[user]/fml/spool/ml/[ml-name]/cf  ->  config.ph ... Done.
    (configuration is backuped in /home/[user]/fml/spool/ml/[ml-name]/config.ph.bak)
done.

参考:9 設定ファイルの編集について

HTML アーカイブのメールアドレスを伏せ字にする

~/fml/libsynchtml.pl を直接編集する。
(もっとスマートなやり方があるかもしれないが、とりあえず。)
(編集前と編集後のファイル、両方ともバックアップを取っておく。)

~/fml/libsynchtml.pl[before]
    $s =~ s/\r\n/\n/g; # too obstinate ;-) to cut off \r ?
    $s =~ s/\r//g;     # too obstinate ;-) to cut off \r ?
    $s =~ s/&/&/g;
    $s =~ s/</&lt;/g;
    $s =~ s/>/&gt;/g;
    $s =~ s/\"/&quot;/g;
    &jcode'convert(*s, 'jis'); #';
    ### special character convertion ends

~/fml/libsynchtml.pl[after]
     $s =~ s/\r\n/\n/g; # too obstinate ;-) to cut off \r ?
     $s =~ s/\r//g;     # too obstinate ;-) to cut off \r ?
     $s =~ s/&/&amp;/g;
     $s =~ s/</&lt;/g;
     $s =~ s/>/&gt;/g;
     $s =~ s/\"/&quot;/g;
+    $s =~ s/([a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+)@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*/$1@.../g; # Anti-spam
     &jcode'convert(*s, 'jis'); #';
     ### special character convertion ends

*「+」の文字は不要。
*正規表現でメールアドレスっぽいものを見つけて @ より後を ... に置換している。

編集後、さくらのコントロールパネルの[メーリングリスト管理]にて[過去記事を再生成する場合は、こちらをクリックして下さい。]で過去記事を再生成。

2
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5