なかのでアドバイスを受けまして、 変更をメールで知らせるようにしてみようと思ってます。
現在update_execはfile_writeの中で呼ばれているようで、 一回の更新で2通のメールが来てしまいます。
サンプルのupdate_execはmknmzを呼んでいるようですが、 この場合も2回呼ぶ必要はないような気がします。
file_writeの中でupdate_execを実行していますが、 update_execの意味的には呼出元で実行した方がいいような気がしています。どうでしょうか?
ちなみにメールで更新内容そのものを送れるように以下の修正をしてみました。
こちらも考慮頂ければと思います。
$update_exec = 'mail mail_address@ドメイン < %update_file';
--- file.php.org 2002-07-27 18:06:58.000000000 +0900 +++ file.php 2002-07-27 18:06:40.000000000 +0900 @@ -49,7 +49,8 @@ if($update_exec) { - system($update_exec." > /dev/null &"); + $new_update_exec = str_replace("%update_file",$dir.encode($page).".txt",$update_exec); + system($new_update_exec." > /dev/null &"); } }
- if($update_exec) + if($update_exec and $dir == DATA_DIR)
Index: pukiwiki.ini.php =================================================================== RCS file: /cvsroot/pukiwiki/pukiwiki/pukiwiki.ini.php,v retrieving revision 1.34 diff -u -r1.34 pukiwiki.ini.php --- pukiwiki.ini.php 3 Apr 2003 01:42:02 -0000 1.34 +++ pukiwiki.ini.php 24 Apr 2003 13:19:32 -0000 @@ -131,6 +131,17 @@ // ページの更新時にバックグランドで実行されるコマンド(mknmzなど) $update_exec = ''; //$update_exec = '/usr/bin/mknmz --media-type=text/pukiwiki -O /var/lib/namazu/index/ -L ja -c -K /var/www/wiki/'; +//////////////////////////////////////////////// +// ページの更新時にメールを送信するか +$notify = 1; +// To:(宛先) +$notify_to = 'masao@ulis.ac.jp'; +// From:(送り主) +$notify_from = 'admin@nile.ulis.ac.jp'; +// Subject:(件名) +$notify_subject = '[pukiwiki] %page'; +// 追加ヘッダ +$notify_header = "From: ".$notify_from."\r\nX-Mailer: PukiWiki/".S_VERSION." PHP/".phpversion(); ///////////////////////////////////////////////// // 一覧・更新一覧に含めないページ名(正規表現で) Index: file.php =================================================================== RCS file: /cvsroot/pukiwiki/pukiwiki/file.php,v retrieving revision 1.17 diff -u -r1.17 file.php --- file.php 13 Apr 2003 06:10:37 -0000 1.17 +++ file.php 24 Apr 2003 13:19:32 -0000 @@ -76,6 +76,7 @@ function file_write($dir,$page,$str) { global $post,$update_exec; + global $notify,$notify_to,$notify_from,$notify_subject,$notify_header; global $_msg_invalidiwn; if (!is_pagename($page)) @@ -118,6 +119,12 @@ if ($update_exec and $dir == DATA_DIR) { system($update_exec.' > /dev/null &'); + } + + if ($notify and $dir == DIFF_DIR) { + $subject = str_replace('%page', $page, $notify_subject); + mb_language(LANG); + mb_send_mail($notify_to, $subject, $str, $notify_header); } }