diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 20f6f43c7cfbe5ef55f10ffc33233dd7322262f9..aa0aad6e000b6e863a77fd5e6dc2be98bea36b89 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 0000000000000000000000000000000000000000..b725cf82770f145630ae7fec20f16645d47d4339 --- /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 ed64e6388b4cbd75825165df50d9e645f08b4648..052e9a54a978a2d1a7a98966e8c494a8ddaccb4c 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); @@ -279,6 +280,37 @@ function media_contentcheck($file,$mime){ return 0; } +/** + * 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 */