OSDN Git Service

BugTrack/111:ページ更新時にメールを送信する [[masao]]さんのコードを追加
authorarino <arino>
Tue, 10 Jun 2003 14:22:51 +0000 (23:22 +0900)
committerarino <arino>
Tue, 10 Jun 2003 14:22:51 +0000 (23:22 +0900)
file.php
pukiwiki.ini.php

index 146cfe8..62d0230 100644 (file)
--- a/file.php
+++ b/file.php
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: file.php,v 1.22 2003/06/10 13:59:02 arino Exp $
+// $Id: file.php,v 1.23 2003/06/10 14:22:51 arino Exp $
 //
 
 // ¥½¡¼¥¹¤ò¼èÆÀ
@@ -89,6 +89,7 @@ function file_write($dir,$page,$str,$notimestamp=FALSE)
 {
        global $post,$update_exec;
        global $_msg_invalidiwn;
+       global $notify,$notify_to,$notify_from,$notify_subject,$notify_header;
        
        if (!is_pagename($page))
        {
@@ -102,14 +103,17 @@ function file_write($dir,$page,$str,$notimestamp=FALSE)
        $timestamp = FALSE;
        $file = $dir.encode($page).'.txt';
        
-       if ($dir == DATA_DIR and $str == '' and file_exists($file)) {
+       if ($dir == DATA_DIR and $str == '' and file_exists($file))
+       {
                unlink($file);
        }
-       if ($str != '') {
+       if ($str != '')
+       {
                $str = preg_replace("/\r/",'',$str);
                $str = rtrim($str)."\n";
                
-               if ($notimestamp and file_exists($file)) {
+               if ($notimestamp and file_exists($file))
+               {
                        $timestamp = filemtime($file) - LOCALZONE;
                }
                
@@ -119,18 +123,28 @@ function file_write($dir,$page,$str,$notimestamp=FALSE)
                fputs($fp,$str);
                flock($fp,LOCK_UN);
                fclose($fp);
-               if ($timestamp) {
+               if ($timestamp)
+               {
                        touch($file,$timestamp + LOCALZONE);
                }
        }
        
-       if (!$timestamp) {
+       if (!$timestamp)
+       {
                put_lastmodified();
        }
        
-       if ($update_exec and $dir == DATA_DIR) {
+       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);
+       }
 }
 
 // ºÇ½ª¹¹¿·¥Ú¡¼¥¸¤Î¹¹¿·
index f3a7ded..86f0076 100644 (file)
@@ -2,7 +2,7 @@
 /////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
 //
-// $Id: pukiwiki.ini.php,v 1.37 2003/06/05 06:20:48 arino Exp $
+// $Id: pukiwiki.ini.php,v 1.38 2003/06/10 14:22:51 arino Exp $
 //
 // PukiWiki setting file
 
@@ -136,6 +136,18 @@ $splitter = ">>>>>>>>>>";
 $update_exec = '';
 //$update_exec = '/usr/bin/mknmz --media-type=text/pukiwiki -O /var/lib/namazu/index/ -L ja -c -K /var/www/wiki/';
 
+////////////////////////////////////////////////
+// ¥Ú¡¼¥¸¤Î¹¹¿·»þ¤Ë¥á¡¼¥ë¤òÁ÷¿®¤¹¤ë
+$notify = 0;
+// To:¡Ê°¸Àè¡Ë
+$notify_to = 'xxx@yyy.zz';
+// From:¡ÊÁ÷¤ê¼ç¡Ë
+$notify_from = 'xxx@yyy.zz';
+// Subject:¡Ê·ï̾¡Ë $page¤Ë¥Ú¡¼¥¸Ì¾¤¬Æþ¤ë
+$notify_subject = '[pukiwiki] $page';
+// ÄɲåإåÀ
+$notify_header = "From: $notify_from\r\nX-Mailer: PukiWiki/".S_VERSION." PHP/".phpversion();
+
 /////////////////////////////////////////////////
 // °ìÍ÷¡¦¹¹¿·°ìÍ÷¤Ë´Þ¤á¤Ê¤¤¥Ú¡¼¥¸Ì¾(Àµµ¬É½¸½¤Ç)
 $non_list = '^\:';