diff options
author | Andreas Gohr <andi@splitbrain.org> | 2007-02-12 20:02:16 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2007-02-12 20:02:16 +0100 |
commit | 7503035957fa441a0911bd9f96dc4f554875123a (patch) | |
tree | 7448d201bee2c2941eaedabcac1d5dc6d4198801 | |
parent | 8cb1eb011a72ab9d73730fff0851c6d1abcabad1 (diff) | |
download | rpg-7503035957fa441a0911bd9f96dc4f554875123a.tar.gz rpg-7503035957fa441a0911bd9f96dc4f554875123a.tar.bz2 |
send notify mails for uploaded files
darcs-hash:20070212190216-7ad00-7be9443a13ab0e885e569f4bdae166fcd00ab836.gz
-rw-r--r-- | inc/lang/en/lang.php | 7 | ||||
-rw-r--r-- | inc/lang/en/uploadmail.txt | 14 | ||||
-rw-r--r-- | inc/media.php | 32 |
3 files changed, 50 insertions, 3 deletions
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 20f6f43c7..aa0aad6e0 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -140,9 +140,10 @@ $lang['restored'] = 'old revision restored'; $lang['external_edit'] = 'external edit'; $lang['summary'] = 'Edit summary'; -$lang['mail_newpage'] = 'page added:'; -$lang['mail_changed'] = 'page changed:'; -$lang['mail_new_user'] = 'New user:'; +$lang['mail_newpage'] = 'page added:'; +$lang['mail_changed'] = 'page changed:'; +$lang['mail_new_user'] = 'new user:'; +$lang['mail_upload'] = 'file uploaded:'; $lang['nosmblinks'] = 'Linking to Windows shares only works in Microsoft Internet Explorer.\nYou still can copy and paste the link.'; diff --git a/inc/lang/en/uploadmail.txt b/inc/lang/en/uploadmail.txt new file mode 100644 index 000000000..b725cf827 --- /dev/null +++ b/inc/lang/en/uploadmail.txt @@ -0,0 +1,14 @@ +A file was uploaded to your DokuWiki. Here are the details: + +File : @MEDIA@ +Date : @DATE@ +Browser : @BROWSER@ +IP-Address : @IPADDRESS@ +Hostname : @HOSTNAME@ +Size : @SIZE@ +MIME Type : @MIME@ +User : @USER@ + +-- +This mail was generated by DokuWiki at +@DOKUWIKIURL@ diff --git a/inc/media.php b/inc/media.php index ed64e6388..052e9a54a 100644 --- a/inc/media.php +++ b/inc/media.php @@ -236,6 +236,7 @@ function media_upload($ns,$auth){ // (Should normally chmod to $conf['fperm'] only if $conf['fperm'] is set.) chmod($fn, $conf['fmode']); msg($lang['uploadsucc'],1); + media_notify($id,$fn,$imime); return $id; }else{ msg($lang['uploadfail'],-1); @@ -280,6 +281,37 @@ function media_contentcheck($file,$mime){ } /** + * Send a notify mail on uploads + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function media_notify($id,$file,$mime){ + global $lang; + global $conf; + if(empty($conf['notify'])) return; //notify enabled? + + $text = rawLocale('uploadmail'); + $text = str_replace('@DATE@',date($conf['dformat']),$text); + $text = str_replace('@BROWSER@',$_SERVER['HTTP_USER_AGENT'],$text); + $text = str_replace('@IPADDRESS@',$_SERVER['REMOTE_ADDR'],$text); + $text = str_replace('@HOSTNAME@',gethostbyaddr($_SERVER['REMOTE_ADDR']),$text); + $text = str_replace('@DOKUWIKIURL@',DOKU_URL,$text); + $text = str_replace('@USER@',$_SERVER['REMOTE_USER'],$text); + $text = str_replace('@MIME@',$mime,$text); + $text = str_replace('@MEDIA@',DOKU_URL.ml($id,'',true,'&'),$text); + $text = str_replace('@SIZE@',filesize_h(filesize($file)),$text); + + $from = $conf['mailfrom']; + $from = str_replace('@USER@',$_SERVER['REMOTE_USER'],$from); + $from = str_replace('@NAME@',$INFO['userinfo']['name'],$from); + $from = str_replace('@MAIL@',$INFO['userinfo']['mail'],$from); + + $subject = '['.$conf['title'].'] '.$lang['mail_upload'].' '.$id; + + mail_send($conf['notify'],$subject,$text,$from); +} + +/** * List all files in a given Media namespace */ function media_filelist($ns,$auth=null,$jump=''){ |