summaryrefslogtreecommitdiff
path: root/inc/media.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/media.php')
-rw-r--r--inc/media.php32
1 files changed, 32 insertions, 0 deletions
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=''){